";
$counterAnswer = 1;
$s .= $isVertical ? '' : '
';
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
@@ -1378,7 +1386,7 @@ HTML;
} elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
global $exerciseId, $exe_id;
// Question is a HOT_SPOT
- //checking document/images visibility
+ // Checking document/images visibility
if (api_is_platform_admin() || api_is_course_admin()) {
$doc_id = $objQuestionTmp->getPictureId();
if (is_numeric($doc_id)) {
@@ -1672,12 +1680,12 @@ HOTSPOT;
}
return true;
- } else {
- return false;
}
- } else {
- return true;
+
+ return false;
}
+
+ return true;
}
/**
@@ -1782,18 +1790,18 @@ HOTSPOT;
}
/**
- * @param string $in_hotpot_path
+ * @param string $path
*
* @return int
*/
- public static function get_count_exam_hotpotatoes_results($in_hotpot_path)
+ public static function get_count_exam_hotpotatoes_results($path)
{
return self::get_exam_results_hotpotatoes_data(
0,
0,
'',
'',
- $in_hotpot_path,
+ $path,
true,
''
);
@@ -1828,16 +1836,20 @@ HOTSPOT;
$in_direction = Database::escape_string($in_direction);
$in_column = Database::escape_string($in_column);
$in_number_of_items = intval($in_number_of_items);
- $in_from = intval($in_from);
+ $in_from = (int) $in_from;
$TBL_TRACK_HOTPOTATOES = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_HOTPOTATOES
);
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
- $sql = "SELECT *, thp.id AS thp_id FROM $TBL_TRACK_HOTPOTATOES thp
- JOIN $TBL_USER u ON thp.exe_user_id = u.user_id
- WHERE thp.c_id = $courseId AND exe_name LIKE '$in_hotpot_path%'";
+ $sql = "SELECT *, thp.id AS thp_id
+ FROM $TBL_TRACK_HOTPOTATOES thp
+ JOIN $TBL_USER u
+ ON thp.exe_user_id = u.user_id
+ WHERE
+ thp.c_id = $courseId AND
+ exe_name LIKE '$in_hotpot_path%'";
// just count how many answers
if ($in_get_count) {
@@ -1872,7 +1884,7 @@ HOTSPOT;
'lastname' => $data['lastname'],
'username' => $data['username'],
'group_name' => implode(
- "
",
+ '
',
GroupManager::get_user_group_name($data['user_id'])
),
'exe_date' => $data['exe_date'],
@@ -1898,11 +1910,10 @@ HOTSPOT;
$courseId,
$sessionId
) {
- $table = Database::get_main_table(
- TABLE_STATISTIC_TRACK_E_HOTPOTATOES
- );
+ $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$exercisePath = Database::escape_string($exercisePath);
$userId = (int) $userId;
+ $courseId = (int) $courseId;
$sql = "SELECT * FROM $table
WHERE
@@ -1967,6 +1978,9 @@ HOTSPOT;
}
$course_id = $courseInfo['real_id'];
+ $sessionId = api_get_session_id();
+ $exercise_id = (int) $exercise_id;
+
$is_allowedToEdit =
api_is_allowed_to_edit(null, true) ||
api_is_allowed_to_edit(true) ||
@@ -1980,14 +1994,14 @@ HOTSPOT;
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
- $sessionId = api_get_session_id();
+
$session_id_and = '';
$sessionCondition = '';
if (!$showSessionField) {
$session_id_and = " AND te.session_id = $sessionId ";
$sessionCondition = " AND ttte.session_id = $sessionId";
}
- $exercise_id = (int) $exercise_id;
+
$exercise_where = '';
if (!empty($exercise_id)) {
$exercise_where .= ' AND te.exe_exo_id = '.$exercise_id.' ';
@@ -2160,9 +2174,9 @@ HOTSPOT;
// sql for hotpotatoes tests for teacher / tutor view
if ($get_count) {
- $hpsql_select = "SELECT count(username)";
+ $hpsql_select = ' SELECT count(username) ';
} else {
- $hpsql_select = "SELECT
+ $hpsql_select = " SELECT
$first_and_last_name ,
username,
official_code,
@@ -2761,8 +2775,6 @@ HOTSPOT;
*/
public static function convertScoreToPlatformSetting($score, $weight)
{
- $result = ['score' => $score, 'weight' => $weight];
-
$maxNote = api_get_setting('exercise_max_score');
$minNote = api_get_setting('exercise_min_score');
@@ -2981,7 +2993,7 @@ HOTSPOT;
* @return bool
*/
public static function addScoreModelInput(
- FormValidator &$form,
+ FormValidator $form,
$name,
$weight,
$selected
@@ -3134,35 +3146,6 @@ EOT;
return $return;
}
- /**
- * Converts a score/weight values to the platform scale.
- *
- * @param float $score
- * @param float $weight
- *
- * @deprecated seem not to be used
- *
- * @return float the score rounded converted to the new range
- */
- public static function convert_score($score, $weight)
- {
- $maxNote = api_get_setting('exercise_max_score');
- $minNote = api_get_setting('exercise_min_score');
-
- if ($score != '' && $weight != '') {
- if ($maxNote != '' && $minNote != '') {
- if (!empty($weight)) {
- $score = $minNote + ($maxNote - $minNote) * $score / $weight;
- } else {
- $score = $minNote;
- }
- }
- }
- $score_rounded = float_format($score, 1);
-
- return $score_rounded;
- }
-
/**
* Getting all active exercises from a course from a session
* (if a session_id is provided we will show all the exercises in the course +
@@ -3693,9 +3676,10 @@ EOT;
/**
* Get average score by score (NO Exercises in LPs ).
*
- * @param int exercise id
+ * @param int $exercise_id
* @param int $courseId
- * @param int session id
+ * @param int $session_id
+ * @param int $user_count
*
* @return float Best average score
*/
@@ -3718,7 +3702,7 @@ EOT;
$avg_score += $score;
}
}
- //We asumme that all exe_weighting
+ // We asumme that all exe_weighting
if (!empty($user_count)) {
$avg_score = float_format($avg_score / $user_count, 1) * 100;
} else {
@@ -3732,9 +3716,9 @@ EOT;
/**
* Get average score by score (NO Exercises in LPs ).
*
- * @param int exercise id
+ * @param int $exercise_id
* @param int $courseId
- * @param int session id
+ * @param int $session_id
*
* @return float Best average score
*/
@@ -4084,7 +4068,7 @@ EOT;
switch ($question_type) {
case FILL_IN_BLANKS:
$answer_condition = '';
- $select_condition = " e.exe_id, answer ";
+ $select_condition = ' e.exe_id, answer ';
break;
case MATCHING:
case MATCHING_DRAGGABLE:
@@ -4538,7 +4522,7 @@ EOT;
}
// Display text when test is finished #4074 and for LP #4227
- $endOfMessage = $objExercise->selectTextWhenFinished();
+ $endOfMessage = $objExercise->getTextWhenFinished();
if (!empty($endOfMessage)) {
echo Display::return_message($endOfMessage, 'normal', false);
echo "
";
diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php
index e8d6449c6f..e74864c7e6 100755
--- a/main/install/configuration.dist.php
+++ b/main/install/configuration.dist.php
@@ -1231,6 +1231,9 @@ $_configuration['required_extra_fields_in_profile'] = [
// ALTER TABLE c_quiz ADD page_result_configuration LONGTEXT DEFAULT NULL COMMENT '(DC2Type:array)';
//$_configuration['allow_quiz_results_page_config'] = false;
+// ALTER TABLE c_quiz MODIFY COLUMN save_correct_answers INT NULL DEFAULT NULL;
+//$_configuration['allow_quiz_save_correct_options'] = false;
+
// KEEP THIS AT THE END
// -------- Custom DB changes
// Add user activation by confirmation email