You are here

function opigno_quiz_app_course_results in Opigno Quiz App 7

Page callback: view all user results for a specific course.

Parameters

stdClass $node:

Return value

string

1 string reference to 'opigno_quiz_app_course_results'
opigno_quiz_app_menu in ./opigno_quiz_app.module
Implements hook_menu().

File

includes/opigno_quiz_app.pages.inc, line 73
Defines all page callbacks.

Code

function opigno_quiz_app_course_results($node) {
  if (empty($node->nid)) {
    drupal_set_message(t("Could not find the course."), 'error');
    drupal_not_found();
  }
  $state = isset($_SESSION['opigno_quiz_app']['state_filter'][request_path()]) ? $_SESSION['opigno_quiz_app']['state_filter'][request_path()] : OG_STATE_ACTIVE;
  $scores = array();
  foreach (opigno_get_users_in_group($node->nid, $state) as $uid => $account) {
    if (!og_user_access('node', $node->nid, 'skip display of results', $account, FALSE, TRUE) && ($data = opigno_quiz_app_get_course_data_result($uid, $node->nid, TRUE))) {
      $scores[$uid] = $data;
      $scores[$uid]['user'] = $account;
    }
  }
  $path = drupal_get_path('module', 'opigno_quiz_app');
  drupal_add_js($path . '/js/opigno_quiz_app.js');
  drupal_add_css($path . '/css/opigno_quiz_app.css');
  $form = render(drupal_get_form('opigno_quiz_app_filter_by_status_form'));
  return $form . theme('opigno_quiz_app_course_results', array(
    'course' => $node,
    'results' => $scores,
  ));
}