@ -114,7 +114,6 @@ class ExerciseLib
if (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
if ($answerType == DRAGGABLE) {
$isVertical = $objQuestionTmp->extra == 'v';
$s .= '
< div class = "col-md-12 ui-widget ui-helper-clearfix" >
< div class = "clearfix" >
@ -148,7 +147,6 @@ class ExerciseLib
}
$i = 1;
$select_items[0]['id'] = 0;
$select_items[0]['letter'] = '--';
$select_items[0]['answer'] = '';
@ -239,7 +237,6 @@ class ExerciseLib
} else {
$header .= Display::tag('th', $item);
}
}
if ($show_comment) {
$header .= Display::tag('th', get_lang('Feedback'));
@ -253,19 +250,17 @@ class ExerciseLib
}
if ($show_comment) {
if (
in_array(
$answerType,
array(
MULTIPLE_ANSWER,
MULTIPLE_ANSWER_COMBINATION,
UNIQUE_ANSWER,
UNIQUE_ANSWER_IMAGE,
UNIQUE_ANSWER_NO_OPTION,
GLOBAL_MULTIPLE_ANSWER
)
if (in_array(
$answerType,
array(
MULTIPLE_ANSWER,
MULTIPLE_ANSWER_COMBINATION,
UNIQUE_ANSWER,
UNIQUE_ANSWER_IMAGE,
UNIQUE_ANSWER_NO_OPTION,
GLOBAL_MULTIPLE_ANSWER,
)
) {
)) {
$header = Display::tag('th', get_lang('Options'));
if ($exercise_feedback == EXERCISE_FEEDBACK_TYPE_END) {
$header .= Display::tag('th', get_lang('Feedback'));
@ -302,7 +297,6 @@ class ExerciseLib
}
for ($answerId = 1; $answerId < = $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
@ -908,7 +902,6 @@ class ExerciseLib
if ($value == $selectedValue) {
break;
}
$selectedIndex++;
}
@ -994,7 +987,6 @@ HTML;
if ($answerCorrect != $chosen['answer']) {
continue;
}
$selectedValue = $chosen['answer'];
}
}
@ -1007,7 +999,6 @@ HTML;
if ($value == $selectedValue) {
break;
}
$selectedIndex++;
}
@ -1107,7 +1098,6 @@ HTML;
$s .= "< / ul > ";
$s .= "< / div > "; //clearfix
$counterAnswer = 1;
$s .= $isVertical ? '' : '< div class = "row" > ';
for ($answerId = 1; $answerId < = $nbrAnswers; $answerId++) {
@ -1313,7 +1303,6 @@ HOTSPOT;
if (!$only_questions) {
if ($show_title) {
TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
echo $objQuestionTmp->getTitleToDisplay($current_item);
}
echo '
@ -1397,6 +1386,10 @@ HOTSPOT;
/**
* Validates the time control key
* @param int $exercise_id
* @param int $lp_id
* @param int $lp_item_id
* @return bool
*/
public static function exercise_time_control_is_valid(
$exercise_id,
@ -1437,6 +1430,10 @@ HOTSPOT;
/**
* Deletes the time control token
*
* @param int $exercise_id
* @param int $lp_id
* @param int $lp_item_id
*/
public static function exercise_time_control_delete(
$exercise_id,
@ -1454,8 +1451,11 @@ HOTSPOT;
/**
* Generates the time control key
*/
public static function get_time_control_key($exercise_id, $lp_id = 0, $lp_item_id = 0)
{
public static function get_time_control_key(
$exercise_id,
$lp_id = 0,
$lp_item_id = 0
) {
$exercise_id = intval($exercise_id);
$lp_id = intval($lp_id);
$lp_item_id = intval($lp_item_id);
@ -2066,7 +2066,6 @@ HOTSPOT;
}
}
$revisedLabel = '';
switch ($revised) {
case 0:
$actions .= "< a href = 'exercise_show.php?".api_get_cidreq()."&action=qualify&id=$id' > ".
@ -2234,10 +2233,8 @@ HOTSPOT;
null,
date_default_timezone_get()
);
$hp_result = round(
($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1)) * 100,
2
).'% ('.$hpresults[$i][4].' / '.$hpresults[$i][5].')';
$hp_result = round(($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1)) * 100, 2)
.'% ('.$hpresults[$i][4].' / '.$hpresults[$i][5].')';
if ($is_allowedToEdit) {
$list_info[] = array(
$hpresults[$i][0],
@ -2329,7 +2326,7 @@ HOTSPOT;
* @param string $pass_percentage
* @return bool
*/
public static function is_success_exercise_r esult($score, $weight, $pass_percentage)
public static function isSuccessExerciseR esult($score, $weight, $pass_percentage)
{
$percentage = float_format(
($score / ($weight != 0 ? $weight : 1)) * 100,
@ -2349,17 +2346,17 @@ HOTSPOT;
* @param string $pass_percentage
* @return string
*/
public static function show_success_m essage($score, $weight, $pass_percentage)
public static function showSuccessM essage($score, $weight, $pass_percentage)
{
$res = '';
if (self::isPassPercentageEnabled($pass_percentage)) {
$is_success = self::is_success_exercise_r esult(
$isSuccess = self::isSuccessExerciseR esult(
$score,
$weight,
$pass_percentage
);
if ($is_s uccess) {
if ($isS uccess) {
$html = get_lang('CongratulationsYouPassedTheTest');
$icon = Display::return_icon(
'completed.png',
@ -2463,8 +2460,7 @@ HOTSPOT;
$search = '',
$search_all_sessions = false,
$active = 2
)
{
) {
$course_id = api_get_course_int_id();
if (!empty($course_info) & & !empty($course_info['real_id'])) {
@ -2549,9 +2545,9 @@ HOTSPOT;
* @param int $courseId The course ID (necessary as c_quiz.id is not unique)
* @return array Exercise info
*/
public static function get_exercise_by_id($exerciseId = 0, $courseId = null )
public static function get_exercise_by_id($exerciseId = 0, $courseId = 0 )
{
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$table = Database::get_course_table(TABLE_QUIZ_TEST);
if (empty($courseId)) {
$courseId = api_get_course_int_id();
} else {
@ -2564,7 +2560,7 @@ HOTSPOT;
)
);
return Database::select('*', $TBL_EXERCICES , $conditions);
return Database::select('*', $table , $conditions);
}
/**
@ -3758,7 +3754,6 @@ HOTSPOT;
$question_list_answers = array();
$media_list = array();
$category_list = array();
$loadChoiceFromSession = false;
$fromDatabase = true;
$exerciseResult = null;
@ -3773,6 +3768,7 @@ HOTSPOT;
$delineationResults = isset($delineationResults[$objExercise->id]) ? $delineationResults[$objExercise->id] : null;
}
$countPendingQuestions = 0;
// Loop over all question to show results for each of them, one by one
if (!empty($question_list)) {
foreach ($question_list as $questionId) {
@ -3865,7 +3861,7 @@ HOTSPOT;
$comnt = Event::get_comments($exe_id, $questionId);
if (!empty($comnt)) {
echo '< b > '.get_lang('Feedback').'< / b > ';
echo '< div id = "question_feedback" > '.$comnt.'< / div > ' ;
echo ExerciseLib::getFeedbackText($comnt) ;
}
}
@ -3886,6 +3882,13 @@ HOTSPOT;
$score = array();
}
if (in_array($objQuestionTmp->type, [FREE_ANSWER, ORAL_EXPRESSION])) {
$check = $objQuestionTmp->isQuestionWaitingReview($score);
if ($check === false) {
$countPendingQuestions++;
}
}
$contents = ob_get_clean();
$question_content = '';
if ($show_results) {
@ -3910,11 +3913,12 @@ HOTSPOT;
$total_score_text = null;
if ($show_results || $show_only_score) {
$total_score_text .= '< div class = "question_row_score" > ';
$total_score_text .= self::get_question_r ibbon(
$total_score_text .= self::getTotalScoreR ibbon(
$objExercise,
$total_score,
$total_weight,
true
true,
$countPendingQuestions
);
$total_score_text .= '< / div > ';
}
@ -3995,39 +3999,57 @@ HOTSPOT;
}
}
/**
* @param string $class
* @param string $scoreLabel
* @param string $result
*
* @return string
*/
public static function getQuestionRibbon($class, $scoreLabel, $result)
{
return '< div class = "ribbon" >
< div class = "rib rib-'.$class.'" >
< h3 > '.$scoreLabel.'< / h3 >
< / div >
< h4 > '.get_lang('Score').': '.$result.'< / h4 >
< / div > '
;
}
/**
* @param Exercise $objExercise
* @param float $score
* @param float $weight
* @param bool $check_pass_percentage
* @param bool $checkPassPercentage
* @param int $countPendingQuestions
* @return string
*/
public static function get_question_ribbon(
public static function getTotalScoreR ibbon(
$objExercise,
$score,
$weight,
$check_pass_percentage = false
$checkPassPercentage = false,
$countPendingQuestions = 0
) {
$passPercentage = $objExercise->selectPassPercentage();
$ribbon = '< div class = "title-score" > ';
if ($check_pass_percentage) {
$is_success = self::is_success_exercise_result(
if ($checkPassP ercentage) {
$isSuccess = self::isSuccessExerciseR esult(
$score,
$weight,
$objExercise->selectPassPercentage()
$passPercentage
);
// Color the final test score if pass_percentage activated
$ribbon_total_success_or_error = '';
if (self::isPassPercentageEnabled(
$objExercise->selectPassPercentage()
)
) {
if ($is_success) {
$ribbon_total_success_or_error = ' ribbon-total-success';
$class = '';
if (self::isPassPercentageEnabled($passPercentage)) {
if ($isSuccess) {
$class = ' ribbon-total-success';
} else {
$ribbon_total_success_or_error = ' ribbon-total-error';
$class = ' ribbon-total-error';
}
}
$ribbon .= '< div class = "total '.$ribbon_total_success_or_error .'" > ';
$ribbon .= '< div class = "total '.$class .'" > ';
} else {
$ribbon .= '< div class = "total" > ';
}
@ -4035,15 +4057,26 @@ HOTSPOT;
$ribbon .= self::show_score($score, $weight, false, true);
$ribbon .= '< / h3 > ';
$ribbon .= '< / div > ';
if ($check_pass_p ercentage) {
$ribbon .= self::show_success_m essage(
if ($checkPassP ercentage) {
$ribbon .= self::showSuccessM essage(
$score,
$weight,
$objExercise->selectPassPercentage()
$passPercentage
);
}
$ribbon .= '< / div > ';
if (!empty($countPendingQuestions)) {
$ribbon .= '< br / > ';
$ribbon .= Display::return_message(
sprintf(
get_lang('TempScoreXQuestionsNotCorrectedYet'),
$countPendingQuestions
),
'warning'
);
}
return $ribbon;
}
@ -4101,4 +4134,23 @@ HOTSPOT;
return $message;
}
/**
* @return string
*/
public static function getNotCorrectedYetText()
{
return Display::return_message(get_lang('notCorrectedYet'), 'warning');
}
/**
* @param string $message
* @return string
*/
public static function getFeedbackText($message)
{
// Old style
//return '< div id = "question_feedback" > '.$message.'< / div > ';
return Display::return_message($message, 'warning', false);
}
}