Move activity SQL query into a dedicated function
Move activity SQL query into a dedicated function

The SQL query based on the UNION predicate is now into a function which takes as
parameters the number of record we want to have in the result. This function
will be used for the activity dashboard and also for the new global activity
page using the datatable plugin.

The subqueries have been also updated in order to exclude some records which
shouldn't be fetched :
  - For the homework don't fetch records without an homework date
  - For the mark, don't fetch record without a mark

ptitoliv/cineapp,ptitoliv/cineapp,ptitoliv/cineapp