function opigno_quiz_app_user_passed in Opigno Quiz App 7
Helper function to check if the user passed all required quizzes inside the course.
Parameters
int $nid:
int $uid:
Return value
bool
1 call to opigno_quiz_app_user_passed()
- opigno_quiz_app_course_class_passed in ./
opigno_quiz_app.module - Helper function to check if a user passed the course or class given in parameter.
File
- ./
opigno_quiz_app.module, line 909 - Module file. Defines module hooks.
Code
function opigno_quiz_app_user_passed($nid, $uid) {
$cache =& drupal_static(__FUNCTION__);
if (!isset($cache["{$nid}:{$uid}"])) {
// Always false for none-courses.
$cache["{$nid}:{$uid}"] = FALSE;
$node = node_load($nid);
if ($node->type == OPIGNO_COURSE_BUNDLE) {
// Default to true (if no quizzes).
$cache["{$nid}:{$uid}"] = TRUE;
$quizzes = opigno_quiz_app_get_all_required_quizzes($node);
$all_scores = quiz_get_score_data(array_keys($quizzes), $uid);
foreach ($all_scores as $score) {
if ($score->percent_pass > $score->percent_score) {
$cache["{$nid}:{$uid}"] = FALSE;
break;
}
}
if (module_exists('opigno_in_house_training_app')) {
$iht = opigno_in_house_get_all_required_iht($node);
foreach ($iht as $index => $rest) {
$value = opigno_in_house_training_score_form_get_default_value($index, $uid);
if ($value['status'] != 1) {
$cache["{$nid}:{$uid}"] = FALSE;
break;
}
}
}
if (module_exists('opigno_webex_app')) {
$webx = opigno_webex_app_get_all_required_quizzes($node);
foreach ($webx as $index => $rest) {
$value = opigno_webex_attendance_form_get_default_value($index, $uid);
if ($value['status'] != 1) {
$cache["{$nid}:{$uid}"] = FALSE;
break;
}
}
}
if (module_exists('opigno_live_meetings')) {
$meetings = opigno_live_meetings_get_all_required_meetings($node);
foreach ($meetings as $index => $rest) {
$value = opigno_live_meetings_score_get_db_values($index, $uid);
if ($value['status'] != 1) {
$cache["{$nid}:{$uid}"] = FALSE;
break;
}
}
}
}
}
// Invoke all the hook if the user passed the course and if the user is not already in the table of passed users
if ($cache["{$nid}:{$uid}"]) {
if (module_exists('opigno_statistics_app')) {
$results = opigno_statistics_app_query_status_from_course_and_user($nid, $uid);
if (empty($results)) {
// In these invoke, the user will be saved in the table of passed users (statistics app)
module_invoke_all('opigno_course_passed', $nid, $uid);
}
}
else {
module_invoke_all('opigno_course_passed', $nid, $uid);
}
}
return $cache["{$nid}:{$uid}"];
}