';
@@ -444,7 +437,7 @@ if ($newQuestion || $editQuestion) {
// Question preview if teacher clicked the "switch to student"
if ($studentViewActive && $is_allowedToEdit) {
echo '
';
- echo Display::div($objQuestion->selectTitle(), array('class' => 'question_title'));
+ echo Display::div($objQuestion->selectTitle(), ['class' => 'question_title']);
ExerciseLib::showQuestion(
$objExercise,
$editQuestion,
diff --git a/main/exercise/showinframes.php b/main/exercise/showinframes.php
index 2bb9954791..dad1aa472c 100755
--- a/main/exercise/showinframes.php
+++ b/main/exercise/showinframes.php
@@ -12,7 +12,7 @@ require_once api_get_path(SYS_CODE_PATH).'exercise/hotpotatoes.lib.php';
$_course = api_get_course_info();
$time = time();
-$doc_url = str_replace(array('../', '\\', '\\0', '..'), array('', '', '', ''), urldecode($_GET['file']));
+$doc_url = str_replace(['../', '\\', '\\0', '..'], ['', '', '', ''], urldecode($_GET['file']));
$cid = api_get_course_id();
$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$document_web_path = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document';
@@ -66,15 +66,13 @@ $doc_url = GetFolderPath($doc_url).urlencode(basename($doc_url));
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
$my_file = Security::remove_XSS($_GET['file']);
-$my_file = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), urldecode($my_file));
+$my_file = str_replace(['../', '\\..', '\\0', '..\\'], ['', '', '', ''], urldecode($my_file));
$title = GetQuizName($my_file, $documentPath);
if ($title == '') {
$title = basename($my_file);
}
$nameTools = $title;
-$noPHP_SELF = true;
-
$htmlHeadXtra[] = /** @lang HTML */<<
$(document).on('ready', function () {
@@ -87,7 +85,7 @@ $htmlHeadXtra[] = /** @lang HTML */<<
HTML;
-$interbreadcrumb[] = array("url"=>"./exercise.php", "name"=> get_lang('Exercises'));
+$interbreadcrumb[] = ["url"=>"./exercise.php", "name"=> get_lang('Exercises')];
if ($origin == 'learnpath') {
Display::display_reduced_header($nameTools, "Exercise");
} else {
diff --git a/main/exercise/stats.php b/main/exercise/stats.php
index 98a4c4862a..2189db2564 100755
--- a/main/exercise/stats.php
+++ b/main/exercise/stats.php
@@ -5,9 +5,23 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
-$exercise_id = isset($_GET['exerciseId']) && !empty($_GET['exerciseId']) ? intval($_GET['exerciseId']) : 0;
+api_protect_course_script(true, false, true);
+
+$showPage = false;
+
+if (api_is_platform_admin() || api_is_course_admin() ||
+ api_is_course_tutor() || api_is_session_general_coach() || api_is_allowed_to_edit(null, true)
+) {
+ $showPage = true;
+}
+
+if (!$showPage) {
+ api_not_allowed(true);
+}
+
+$exerciseId = isset($_GET['exerciseId']) && !empty($_GET['exerciseId']) ? (int) $_GET['exerciseId'] : 0;
$objExercise = new Exercise();
-$result = $objExercise->read($exercise_id);
+$result = $objExercise->read($exerciseId);
if (!$result) {
api_not_allowed(true);
@@ -31,9 +45,9 @@ if (empty($sessionId)) {
$count_students = count($students);
$question_list = $objExercise->get_validated_question_list();
-$data = array();
+$data = [];
// Question title # of students who tool it Lowest score Average Highest score Maximum score
-$headers = array(
+$headers = [
get_lang('Question'),
get_lang('QuestionType'),
get_lang('NumberStudentWhoSelectedIt'),
@@ -41,48 +55,48 @@ $headers = array(
get_lang('AverageScore'),
get_lang('HighestScore'),
get_lang('Weighting'),
-);
+];
if (!empty($question_list)) {
foreach ($question_list as $question_id) {
- $question_obj = Question::read($question_id);
+ $questionObj = Question::read($question_id);
$exercise_stats = ExerciseLib::get_student_stats_by_question(
$question_id,
- $exercise_id,
+ $exerciseId,
$courseCode,
$sessionId
);
$count_users = ExerciseLib::get_number_students_question_with_answer_count(
$question_id,
- $exercise_id,
+ $exerciseId,
$courseCode,
$sessionId,
- $question_obj->type
+ $questionObj->type
);
- $data[$question_id]['name'] = cut($question_obj->question, 100);
- $data[$question_id]['type'] = $question_obj->get_question_type_name();
- $percentange = 0;
+ $data[$question_id]['name'] = cut($questionObj->question, 100);
+ $data[$question_id]['type'] = $questionObj->get_question_type_name();
+ $percentage = 0;
if ($count_students) {
- $percentange = $count_users / $count_students * 100;
+ $percentage = $count_users / $count_students * 100;
}
$data[$question_id]['students_who_try_exercise'] = Display::bar_progress(
- $percentange,
+ $percentage,
false,
$count_users.' / '.$count_students
);
$data[$question_id]['lowest_score'] = round($exercise_stats['min'], 2);
$data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
$data[$question_id]['highest_score'] = round($exercise_stats['max'], 2);
- $data[$question_id]['max_score'] = round($question_obj->weighting, 2);
+ $data[$question_id]['max_score'] = round($questionObj->weighting, 2);
}
}
// Format A table
-$table = new HTML_Table(array('class' => 'data_table'));
+$table = new HTML_Table(['class' => 'data_table']);
$row = 0;
$column = 0;
foreach ($headers as $header) {
@@ -103,23 +117,22 @@ foreach ($data as $row_table) {
$content = $table->toHtml();
// Format B
-
-$headers = array(
+$headers = [
get_lang('Question'),
get_lang('Answer'),
get_lang('Correct'),
get_lang('NumberStudentWhoSelectedIt')
-);
+];
-$data = array();
+$data = [];
if (!empty($question_list)) {
$id = 0;
foreach ($question_list as $question_id) {
- $question_obj = Question::read($question_id);
+ $questionObj = Question::read($question_id);
$exercise_stats = ExerciseLib::get_student_stats_by_question(
$question_id,
- $exercise_id,
+ $exerciseId,
$courseCode,
$sessionId
);
@@ -134,7 +147,7 @@ if (!empty($question_list)) {
$real_answer_id = $answer->selectAutoId($answer_id);
// Overwriting values depending of the question
- switch ($question_obj->type) {
+ switch ($questionObj->type) {
case FILL_IN_BLANKS:
$answer_info_db = $answer_info;
$answer_info = substr($answer_info, 0, strpos($answer_info, '::'));
@@ -143,7 +156,7 @@ if (!empty($question_list)) {
$counter = 0;
foreach ($answers as $answer_item) {
if ($counter == 0) {
- $data[$id]['name'] = cut($question_obj->question, 100);
+ $data[$id]['name'] = cut($questionObj->question, 100);
} else {
$data[$id]['name'] = '-';
}
@@ -155,7 +168,7 @@ if (!empty($question_list)) {
$data[$id]['answer'] = $answer_item;
$data[$id]['correct'] = '-';
- $count = ExerciseLib::getNumberStudentsFillBlanksAnswerCount($question_id, $exercise_id);
+ $count = ExerciseLib::getNumberStudentsFillBlanksAnswerCount($question_id, $exerciseId);
$count = isset($count[$counter]) ? $count[$counter] : 0;
$percentage = 0;
@@ -176,7 +189,7 @@ if (!empty($question_list)) {
case MATCHING_DRAGGABLE:
if ($is_correct == 0) {
if ($answer_id == 1) {
- $data[$id]['name'] = cut($question_obj->question, 100);
+ $data[$id]['name'] = cut($questionObj->question, 100);
} else {
$data[$id]['name'] = '-';
}
@@ -194,7 +207,7 @@ if (!empty($question_list)) {
$count = ExerciseLib::get_number_students_answer_count(
$answer_id,
$question_id,
- $exercise_id,
+ $exerciseId,
$courseCode,
$sessionId,
MATCHING
@@ -212,7 +225,7 @@ if (!empty($question_list)) {
break;
case HOT_SPOT:
if ($answer_id == 1) {
- $data[$id]['name'] = cut($question_obj->question, 100);
+ $data[$id]['name'] = cut($questionObj->question, 100);
} else {
$data[$id]['name'] = '-';
}
@@ -222,7 +235,7 @@ if (!empty($question_list)) {
$count = ExerciseLib::get_number_students_answer_hotspot_count(
$answer_id,
$question_id,
- $exercise_id,
+ $exerciseId,
$courseCode,
$sessionId
);
@@ -238,7 +251,7 @@ if (!empty($question_list)) {
break;
default:
if ($answer_id == 1) {
- $data[$id]['name'] = cut($question_obj->question, 100);
+ $data[$id]['name'] = cut($questionObj->question, 100);
} else {
$data[$id]['name'] = '-';
}
@@ -248,7 +261,7 @@ if (!empty($question_list)) {
$count = ExerciseLib::get_number_students_answer_count(
$real_answer_id,
$question_id,
- $exercise_id,
+ $exerciseId,
$courseCode,
$sessionId
);
@@ -268,7 +281,7 @@ if (!empty($question_list)) {
}
// Format A table
-$table = new HTML_Table(array('class' => 'data_table'));
+$table = new HTML_Table(['class' => 'data_table']);
$row = 0;
$column = 0;
foreach ($headers as $header) {
@@ -288,17 +301,17 @@ foreach ($data as $row_table) {
}
$content .= $table->toHtml();
-$interbreadcrumb[] = array(
+$interbreadcrumb[] = [
"url" => "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises'),
-);
-$interbreadcrumb[] = array(
- "url" => "admin.php?exerciseId=$exercise_id&".api_get_cidreq(),
+];
+$interbreadcrumb[] = [
+ "url" => "admin.php?exerciseId=$exerciseId&".api_get_cidreq(),
"name" => $objExercise->selectTitle(true),
-);
+];
$tpl = new Template(get_lang('ReportByQuestion'));
-$actions = '
'.
+$actions = ''.
Display:: return_icon(
'back.png',
get_lang('GoBackToQuestionList'),
@@ -306,7 +319,7 @@ $actions = ' "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises'),
-);
+];
$action = isset($_GET['action']) ? $_GET['action'] : '';
$content = '';
@@ -125,18 +125,18 @@ function edit_category_form($action)
// Setting the form elements
$form->addElement('header', get_lang('EditCategory'));
$form->addElement('hidden', 'category_id');
- $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
+ $form->addElement('text', 'category_name', get_lang('CategoryName'), ['size' => '95']);
$form->addHtmlEditor(
'category_description',
get_lang('CategoryDescription'),
false,
false,
- array('ToolbarSet' => 'test_category', 'Height' => '200')
+ ['ToolbarSet' => 'test_category', 'Height' => '200']
);
$form->addButtonSave(get_lang('ModifyCategory'), 'SubmitNote');
// setting the defaults
- $defaults = array();
+ $defaults = [];
$defaults["category_id"] = $objcat->id;
$defaults["category_name"] = $objcat->name;
$defaults["category_description"] = $objcat->description;
@@ -166,7 +166,7 @@ function edit_category_form($action)
} else {
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
- $form->setConstants(array('sec_token' => $token));
+ $form->setConstants(['sec_token' => $token]);
return $form->returnForm();
}
@@ -204,13 +204,13 @@ function add_category_form($action)
$form = new FormValidator('note', 'post', api_get_self().'?action='.$action.'&'.api_get_cidreq());
// Setting the form elements
$form->addElement('header', get_lang('AddACategory'));
- $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
+ $form->addElement('text', 'category_name', get_lang('CategoryName'), ['size' => '95']);
$form->addHtmlEditor(
'category_description',
get_lang('CategoryDescription'),
false,
false,
- array('ToolbarSet' => 'test_category', 'Height' => '200')
+ ['ToolbarSet' => 'test_category', 'Height' => '200']
);
$form->addButtonCreate(get_lang('AddTestCategory'), 'SubmitNote');
// setting the rules
@@ -233,7 +233,7 @@ function add_category_form($action)
} else {
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
- $form->setConstants(array('sec_token' => $token));
+ $form->setConstants(['sec_token' => $token]);
return $form->returnForm();
}