function opigno_quiz_app_get_score_data in Opigno Quiz App 7
Helper function to fetch score data for quizzes. The difference with the core quiz function is that this function gets all results (not just the best one) and also returns the start and end time.
Parameters
array $nids:
int $uid:
Return value
array
3 calls to opigno_quiz_app_get_score_data()
- opigno_quiz_app_course_lessons_progress_and_time in ./
opigno_quiz_app.module - opigno_quiz_app_get_course_data_result in ./
opigno_quiz_app.module - Helper function to get all results for a given course and user.
- opigno_quiz_get_score_data in ./
opigno_quiz_app.module - DEPRECATED. A typo in the function name omitted the 'app' word. This is now an alias to opigno_quiz_app_get_score_data(), which should be used instead.
File
- ./
opigno_quiz_app.module, line 1157 - Module file. Defines module hooks.
Code
function opigno_quiz_app_get_score_data($nids, $uid) {
$scores = array();
$query = db_select('quiz_node_results', 'r');
$query
->leftJoin('quiz_node_properties', 'p', 'r.vid = p.vid');
$query
->addField('r', 'score', 'percent_score');
$query
->addField('p', 'pass_rate', 'percent_pass');
$result = $query
->fields('r', array(
'result_id',
'nid',
'time_start',
'time_end',
))
->condition('r.uid', $uid)
->condition('r.time_end', 0, '>')
->condition('r.nid', $nids, 'IN')
->execute();
while ($score = $result
->fetchObject()) {
$scores[$score->nid][$score->result_id] = $score;
}
return $scores;
}