' . $comnt . '
';
}
}
if ($show_results) {
$score = array(
'result' => get_lang('Score') . " : " . self::show_score(
$my_total_score,
$my_total_weight,
false,
true
),
'pass' => $my_total_score >= $my_total_weight ? true : false,
'score' => $my_total_score,
'weight' => $my_total_weight,
'comments' => $comnt,
);
} else {
$score = array();
}
$contents = ob_get_clean();
$question_content = '';
if ($show_results) {
$show_media = false;
/*if ($objQuestionTmp->parent_id != 0 && !in_array($objQuestionTmp->parent_id, $media_list)) {
$show_media = true;
$media_list[] = $objQuestionTmp->parent_id;
}*/
//Shows question title an description
$question_content .= $objQuestionTmp->return_header(
null,
$counter,
$score
);
}
$counter++;
$question_content .= $contents;
$question_content .= '
';
$exercise_content .= $question_content;
} // end foreach() block that loops over all questions
}
$total_score_text = null;
if ($origin != 'learnpath') {
if ($show_results || $show_only_score) {
$total_score_text .= '';
$total_score_text .= get_question_ribbon(
$objExercise,
$total_score,
$total_weight,
true
);
$total_score_text .= '
';
}
}
if (!empty($category_list) && ($show_results || $show_only_score)) {
//Adding total
$category_list['total'] = array(
'score' => $total_score,
'total' => $total_weight
);
echo Testcategory::get_stats_table_by_attempt(
$objExercise->id,
$category_list
);
}
if ($show_all_but_expected_answer) {
$exercise_content .= "" . get_lang(
"ExerciseWithFeedbackWithoutCorrectionComment"
) . "
";
}
// Remove audio auto play from questions on results page - refs BT#7939
$exercise_content = preg_replace(
'/autoplay[\=\".+\"]+/',
'',
$exercise_content
);
echo $total_score_text;
echo $exercise_content;
if (!$show_only_score) {
echo $total_score_text;
}
if ($save_user_result) {
// Tracking of results
$learnpath_id = $exercise_stat_info['orig_lp_id'];
$learnpath_item_id = $exercise_stat_info['orig_lp_item_id'];
$learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
if (api_is_allowed_to_session_edit()) {
Event::update_event_exercice(
$exercise_stat_info['exe_id'],
$objExercise->selectId(),
$total_score,
$total_weight,
api_get_session_id(),
$learnpath_id,
$learnpath_item_id,
$learnpath_item_view_id,
$exercise_stat_info['exe_duration'],
$question_list,
'',
array()
);
}
// Send notification ..
if (!api_is_allowed_to_edit(null, true) && !apiIsExcludedUserType()
) {
if (api_get_course_setting(
'email_alert_manager_on_new_quiz'
) == 1
) {
$objExercise->send_mail_notification_for_exam(
$question_list_answers,
$origin,
$exe_id
);
}
$objExercise->send_notification_for_open_questions(
$question_list_answers,
$origin,
$exe_id
);
$objExercise->send_notification_for_oral_questions(
$question_list_answers,
$origin,
$exe_id
);
}
}
}
/**
* @param Exercise $objExercise
* @param float $score
* @param float $weight
* @param bool $check_pass_percentage
* @return string
*/
public static function get_question_ribbon(
$objExercise,
$score,
$weight,
$check_pass_percentage = false
) {
$ribbon = '';
if ($check_pass_percentage) {
$is_success = self::is_success_exercise_result(
$score,
$weight,
$objExercise->selectPassPercentage()
);
// Color the final test score if pass_percentage activated
$ribbon_total_success_or_error = "";
if (self::is_pass_pourcentage_enabled(
$objExercise->selectPassPercentage()
)) {
if ($is_success) {
$ribbon_total_success_or_error = ' ribbon-total-success';
} else {
$ribbon_total_success_or_error = ' ribbon-total-error';
}
}
$ribbon .= '
';
} else {
$ribbon .= '
';
}
$ribbon .= '
' . get_lang('YourTotalScore') . ": ";
$ribbon .= self::show_score($score, $weight, false, true);
$ribbon .= '
';
$ribbon .= '';
if ($check_pass_percentage) {
$ribbon .= self::show_success_message(
$score,
$weight,
$objExercise->selectPassPercentage()
);
}
$ribbon .= '
';
return $ribbon;
}
/**
* @param int $countLetter
* @return mixed
*/
public static function detectInputAppropriateClass($countLetter)
{
$limits = array(
0 => 'input-mini',
10 => 'input-mini',
15 => 'input-medium',
20 => 'input-xlarge',
40 => 'input-xlarge',
60 => 'input-xxlarge',
100 => 'input-xxlarge',
200 => 'input-xxlarge',
);
foreach ($limits as $size => $item) {
if ($countLetter <= $size) {
return $item;
}
}
return $limits[0];
}
}