You are here

function opigno_quiz_app_course_lessons in Opigno Quiz App 7

6 calls to opigno_quiz_app_course_lessons()
opigno_quiz_app_course_is_started in ./opigno_quiz_app.module
Helper function to know if a course is started or not by a user.
opigno_quiz_app_course_lessons_progress_and_time in ./opigno_quiz_app.module
opigno_quiz_app_course_resume_get_path in ./opigno_quiz_app.module
opigno_quiz_app_get_first_lesson_from_group in ./opigno_quiz_app.module
Helper function that returns the first lesson's ID of a group (course or class)
opigno_quiz_app_get_next_lesson_from_course in ./opigno_quiz_app.module
Returns the next lesson NID for a course.

... See full list

File

./opigno_quiz_app.module, line 1716
Module file. Defines module hooks.

Code

function opigno_quiz_app_course_lessons($course_nid) {
  global $user;
  $lessons = array();
  $query = db_select('node', 'n')
    ->fields('n', array(
    'nid',
    'title',
    'vid',
  ))
    ->condition('n.status', 1, '=')
    ->condition('n.type', 'quiz', '=');
  $query
    ->join('og_membership', 'og_m', 'og_m.etid = n.nid');

  //JOIN node with users
  $query
    ->fields('og_m', array(
    'gid',
  ))
    ->condition('og_m.gid', $course_nid, '=')
    ->condition('og_m.field_name', 'og_group_ref', '=')
    ->condition('og_m.state', 1, '=')
    ->condition('og_m.entity_type', 'node', '=');
  $result = $query
    ->execute();
  if (opigno_quiz_app_course_has_been_sorted($result, $course_nid)) {
    $query
      ->join('opigno_quiz_app_quiz_sort', 'oqs', 'oqs.quiz_nid = n.nid');

    //JOIN node with users
    $query
      ->fields('oqs', array(
      'weight',
    ))
      ->condition('oqs.gid', $course_nid, '=')
      ->orderBy('oqs.weight', 'ASC');
  }
  $result = $query
    ->execute();
  while ($record = $result
    ->fetchAssoc()) {
    if ($router_item = menu_get_item('node/' . $record['nid'])) {
      if ($router_item['access']) {
        $lessons[$course_nid][$record['nid']]['vid'] = $record['vid'];
      }
    }
  }
  return $lessons;
}