diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php
index 96f59419b0..4293ad4b08 100755
--- a/main/announcements/announcements.php
+++ b/main/announcements/announcements.php
@@ -14,7 +14,7 @@
$use_anonymous = true;
require_once __DIR__.'/../inc/global.inc.php';
-
+$current_course_tool = TOOL_ANNOUNCEMENT;
api_protect_course_script(true);
api_protect_course_group(GroupManager::GROUP_TOOL_ANNOUNCEMENT);
diff --git a/main/exercise/TestCategory.php b/main/exercise/TestCategory.php
index b18fa46b92..32b1fad6fa 100644
--- a/main/exercise/TestCategory.php
+++ b/main/exercise/TestCategory.php
@@ -762,7 +762,6 @@ class TestCategory
return null;
}
$categoryNameList = self::getListOfCategoriesNameForTest($exerciseId);
-
$table = new HTML_Table(
[
'class' => 'table table-hover table-striped table-bordered',
@@ -818,64 +817,7 @@ class TestCategory
// Radar requires more than 3 categories.
if ($countCategories > 2 && RESULT_DISABLE_RADAR === (int) $exercise->results_disabled) {
- $categoryNameToJson = json_encode(array_column($categoryNameList, 'title'));
- $resultsToJson = json_encode($resultsArray);
- $radar = "
-
-
- ";
+ $radar = $exercise->getRadar(array_column($categoryNameList, 'title'), [$resultsArray]);
}
if (!empty($none_category)) {
diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php
index 939f32bde6..01cdc73a54 100755
--- a/main/exercise/exercise.class.php
+++ b/main/exercise/exercise.class.php
@@ -8666,7 +8666,7 @@ class Exercise
* @param int $courseId
* @param int $sessionId
* @param bool $returnData
- * @param int $minCategories
+ * @param int $minCategoriesInExercise
* @param int $filterByResultDisabled
* @param int $filterByAttempt
*
@@ -8679,11 +8679,13 @@ class Exercise
$courseId = 0,
$sessionId = 0,
$returnData = false,
- $minCategories = 0,
+ $minCategoriesInExercise = 0,
$filterByResultDisabled = 0,
- $filterByAttempt = 0
+ $filterByAttempt = 0,
+ $myActions = null,
+ $returnTable = false
) {
- $allowDelete = Exercise::allowAction('delete');
+ //$allowDelete = Exercise::allowAction('delete');
$allowClean = self::allowAction('clean_results');
$TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
@@ -8754,17 +8756,15 @@ class Exercise
}
$filterByResultDisabledCondition = '';
- /*$filterByResultDisabled = (int) $filterByResultDisabled;
+ $filterByResultDisabled = (int) $filterByResultDisabled;
if (!empty($filterByResultDisabled)) {
$filterByResultDisabledCondition = ' AND e.results_disabled = '.$filterByResultDisabled;
- }*/
+ }
$filterByAttemptCondition = '';
- /*$filterByAttempt = (int) $filterByAttempt;
+ $filterByAttempt = (int) $filterByAttempt;
if (!empty($filterByAttempt)) {
- $filterByResultDisabledCondition = ' AND e.result_disabled = '.$filterByResultDisabled;
- }*/
- /*$minCategories = 0,
- $filterByAttempt = 0*/
+ $filterByAttemptCondition = ' AND e.max_attempt = '.$filterByAttempt;
+ }
// Only for administrators
if ($is_allowedToEdit) {
@@ -8777,6 +8777,7 @@ class Exercise
$categoryCondition
$keywordCondition
$filterByResultDisabledCondition
+ $filterByAttemptCondition
";
$sql = "SELECT * FROM $TBL_EXERCISES e
WHERE
@@ -8786,6 +8787,7 @@ class Exercise
$categoryCondition
$keywordCondition
$filterByResultDisabledCondition
+ $filterByAttemptCondition
ORDER BY title
LIMIT $from , $limit";
} else {
@@ -9078,10 +9080,17 @@ class Exercise
$results_text = $count_exercise_not_validated == 1 ? get_lang('ResultNotRevised') : get_lang('ResultsNotRevised');
$title .= ''.$count_exercise_not_validated.' '.$results_text.' ';
}*/
-
- $url = $move.'
+ $overviewUrl = api_get_path(WEB_CODE_PATH).'exercise/overview.php';
+ $url = $move.
+ '
'.Display::return_icon('quiz.png', $row['title']).'
- '.$title.' '.PHP_EOL;
+ '.$title.'
+ '.PHP_EOL;
if (ExerciseLib::isQuizEmbeddable($row)) {
$embeddableIcon = Display::return_icon('om_integration.png', get_lang('ThisQuizCanBeEmbeddable'));
@@ -9198,6 +9207,7 @@ class Exercise
}
$actions .= $clean;
+
// Visible / invisible
// Check if this exercise was added in a LP
if ($exercise->exercise_was_added_in_lp == true) {
@@ -9342,6 +9352,13 @@ class Exercise
$delete = '';
}
+ if (!empty($minCategoriesInExercise)) {
+ $cats = TestCategory::getListOfCategoriesForTest($exercise);
+ if (!(count($cats) >= $minCategoriesInExercise)) {
+ continue;
+ }
+ }
+
$actions .= $delete;
// Number of questions
@@ -9529,6 +9546,11 @@ class Exercise
$actions .= $additionalActions.PHP_EOL;
}
+ // Replace with custom actions.
+ if (!empty($myActions) && is_callable($myActions)) {
+ $actions = $myActions($row);
+ }
+
$currentRow = [
$row['id'],
$currentRow['title'],
@@ -9778,6 +9800,10 @@ class Exercise
}
}
+ if ($returnTable) {
+ return $table;
+ }
+
$content .= $table->return_table();
}
@@ -10908,4 +10934,136 @@ class Exercise
get_lang('ShowResultsToStudents')
);
}
+
+ public function getRadarsFromUsers($userList, $exercises, $courseId, $sessionId)
+ {
+ $dataSet = [];
+ $labels = [];
+ /** @var Exercise $exercise */
+ foreach ($exercises as $exercise) {
+ if (empty($labels)) {
+ $categoryNameList = TestCategory::getListOfCategoriesNameForTest($exercise->iId);
+ $labels = array_column($categoryNameList, 'title');
+ }
+
+ foreach ($userList as $userId) {
+ $results = Event::getExerciseResultsByUser(
+ $userId,
+ $exercise->iId,
+ $courseId,
+ $sessionId
+ );
+
+ if ($results) {
+ $firstAttempt = current($results);
+ $exeId = $firstAttempt['exe_id'];
+
+ ob_start();
+ $stats = ExerciseLib::displayQuestionListByAttempt(
+ $exercise,
+ $exeId,
+ false
+ );
+ ob_end_clean();
+
+ $categoryList = $stats['category_list'];
+ $resultsArray = [];
+ foreach ($categoryList as $category_id => $category_item) {
+ $resultsArray[] = round($category_item['score'] / $category_item['total'] * 10);
+ }
+ $dataSet[] = $resultsArray;
+ }
+ }
+ }
+
+ return $this->getRadar($labels, $dataSet);
+ }
+
+ public function getRadar($labels, $dataSet)
+ {
+ if (empty($labels) || empty($dataSet)) {
+ return '';
+ }
+
+ $labels = json_encode($labels);
+
+ // Default preset, after that colors are generated randomly. @todo improve colors. Use a js lib?
+ $colorList = [
+ 'rgb(255, 99, 132, 1.0)',
+ 'rgb(0,0,200,1.0)', // red
+ 'rgb(255, 159, 64, 1.0)', // orange
+ 'rgb(255, 205, 86, 1.0)', //yellow
+ 'rgb(75, 192, 192, 1.0)', // green
+ 'rgb(54, 162, 235, 1.0)', // blue
+ 'rgb(153, 102, 255, 1.0)', // purple
+ //'rgb(201, 203, 207)' grey
+ ];
+
+ $dataSetToJson = [];
+ $counter = 0;
+ foreach ($dataSet as $resultsArray) {
+ $color = isset($colorList[$counter]) ? $colorList[$counter] : 'rgb('.rand(0,255).', '.rand(0,255).', '.rand(0,255).', 1.0)';
+
+ $background = str_replace('1.0', '0.2', $color);
+ $dataSetToJson[] = [
+ 'fill' => true,
+ //'label' => '".get_lang('Categories')."',
+ 'backgroundColor' => $background,
+ 'borderColor' => $color,
+ 'pointBackgroundColor' => $color,
+ 'pointBorderColor' => '#fff',
+ 'pointHoverBackgroundColor' => '#fff',
+ 'pointHoverBorderColor' => $color,
+ 'pointRadius' => 6,
+ 'pointBorderWidth' => 3,
+ 'pointHoverRadius' => 10,
+ 'data' => $resultsArray,
+ ];
+ $counter++;
+ }
+ $resultsToJson = json_encode($dataSetToJson);
+
+ return "
+
+
+ ";
+ }
}
diff --git a/main/exercise/exercise_question_reminder.php b/main/exercise/exercise_question_reminder.php
index c14dead549..e24e90a729 100644
--- a/main/exercise/exercise_question_reminder.php
+++ b/main/exercise/exercise_question_reminder.php
@@ -5,6 +5,7 @@
use ChamiloSession as Session;
require_once __DIR__.'/../inc/global.inc.php';
+$current_course_tool = TOOL_QUIZ;
if (false === api_get_configuration_value('block_category_questions')) {
api_not_allowed(true);
diff --git a/main/exercise/exercise_reminder.php b/main/exercise/exercise_reminder.php
index 9c7b04c6cb..e560f26bb3 100755
--- a/main/exercise/exercise_reminder.php
+++ b/main/exercise/exercise_reminder.php
@@ -11,6 +11,7 @@ use ChamiloSession as Session;
* @author Julio Montoya switchable fill in blank option added
*/
require_once __DIR__.'/../inc/global.inc.php';
+$current_course_tool = TOOL_QUIZ;
$this_section = SECTION_COURSES;
diff --git a/main/exercise/exercise_result.php b/main/exercise/exercise_result.php
index 980ac4c266..a0fed32783 100755
--- a/main/exercise/exercise_result.php
+++ b/main/exercise/exercise_result.php
@@ -19,7 +19,7 @@ use ChamiloSession as Session;
*/
$debug = false;
require_once __DIR__.'/../inc/global.inc.php';
-
+$current_course_tool = TOOL_QUIZ;
$this_section = SECTION_COURSES;
api_protect_course_script(true);
@@ -60,6 +60,9 @@ $interbreadcrumb[] = [
'url' => 'exercise.php?'.api_get_cidreq(),
'name' => get_lang('Exercises'),
];
+if (RESULT_DISABLE_RADAR === (int) $objExercise->results_disabled) {
+ $htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js');
+}
$htmlHeadXtra[] = '';
$htmlHeadXtra[] = '';
diff --git a/main/exercise/exercise_show.php b/main/exercise/exercise_show.php
index a5d85d387e..78a6d62549 100755
--- a/main/exercise/exercise_show.php
+++ b/main/exercise/exercise_show.php
@@ -15,7 +15,7 @@ use ChamiloSession as Session;
* @todo small letters for table variables
*/
require_once __DIR__.'/../inc/global.inc.php';
-
+$current_course_tool = TOOL_QUIZ;
$origin = api_get_origin();
$currentUserId = api_get_user_id();
$printHeaders = 'learnpath' === $origin;
diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php
index b8bf6630db..3188b52081 100755
--- a/main/exercise/exercise_submit.php
+++ b/main/exercise/exercise_submit.php
@@ -35,6 +35,7 @@ $debug = false;
// Notice for unauthorized people.
api_protect_course_script(true);
+
$origin = api_get_origin();
$is_allowedToEdit = api_is_allowed_to_edit(null, true);
$courseId = api_get_course_int_id();
@@ -188,10 +189,17 @@ $exerciseInSession = Session::read('objExercise');
// 3. $objExercise is not set, then return to the exercise list.
if (!is_object($objExercise)) {
- header('Location: exercise.php');
+ header('Location: exercise.php?'.api_get_cidreq());
exit;
}
+if ('true' === api_get_plugin_setting('positioning', 'tool_enable')) {
+ $plugin = Positioning::create();
+ if ($plugin->blockFinalExercise(api_get_user_id(), $objExercise->iId, api_get_course_int_id(), $sessionId)) {
+ api_not_allowed(true);
+ }
+}
+
// if the user has submitted the form.
$exercise_title = $objExercise->selectTitle();
$exercise_sound = $objExercise->selectSound();
diff --git a/main/exercise/exercise_submit_modal.php b/main/exercise/exercise_submit_modal.php
index 114cd0b940..18264cc182 100755
--- a/main/exercise/exercise_submit_modal.php
+++ b/main/exercise/exercise_submit_modal.php
@@ -8,6 +8,7 @@ use ChamiloSession as Session;
* @author Julio Montoya
*/
require_once __DIR__.'/../inc/global.inc.php';
+$current_course_tool = TOOL_QUIZ;
api_protect_course_script();
diff --git a/main/exercise/overview.php b/main/exercise/overview.php
index 441d01b6db..9af4a3a642 100755
--- a/main/exercise/overview.php
+++ b/main/exercise/overview.php
@@ -8,11 +8,8 @@
* @author Julio Montoya
*/
require_once __DIR__.'/../inc/global.inc.php';
-
$current_course_tool = TOOL_QUIZ;
-
Exercise::cleanSessionVariables();
-
$this_section = SECTION_COURSES;
$js = '';
@@ -31,6 +28,13 @@ if (!$result) {
api_not_allowed(true);
}
+if ('true' === api_get_plugin_setting('positioning', 'tool_enable')) {
+ $plugin = Positioning::create();
+ if ($plugin->blockFinalExercise(api_get_user_id(), $exercise_id, api_get_course_int_id(), $sessionId)) {
+ api_not_allowed(true);
+ }
+}
+
$learnpath_id = isset($_REQUEST['learnpath_id']) ? (int) $_REQUEST['learnpath_id'] : null;
$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? (int) $_REQUEST['learnpath_item_id'] : null;
$learnpathItemViewId = isset($_REQUEST['learnpath_item_view_id']) ? (int) $_REQUEST['learnpath_item_view_id'] : null;
diff --git a/main/exercise/result.php b/main/exercise/result.php
index ac38761de6..2a7e0abe1b 100755
--- a/main/exercise/result.php
+++ b/main/exercise/result.php
@@ -10,6 +10,7 @@ use ChamiloSession as Session;
* @author Julio Montoya - Simple exercise result page
*/
require_once __DIR__.'/../inc/global.inc.php';
+$current_course_tool = TOOL_QUIZ;
$id = isset($_REQUEST['id']) ? (int) $_GET['id'] : 0; // exe id
$show_headers = isset($_REQUEST['show_headers']) ? (int) $_REQUEST['show_headers'] : null;
diff --git a/main/forum/index.php b/main/forum/index.php
index aa099811c2..3181026f5d 100755
--- a/main/forum/index.php
+++ b/main/forum/index.php
@@ -24,10 +24,9 @@ use ChamiloSession as Session;
* @copyright Patrick Cool
*/
require_once __DIR__.'/../inc/global.inc.php';
-
+$current_course_tool = TOOL_FORUM;
api_protect_course_script(true);
-$current_course_tool = TOOL_FORUM;
$htmlHeadXtra[] = '