Minor - format code

pull/3063/head
jmontoyaa 8 years ago
parent 351d10c929
commit 75ee00776c
  1. 14
      main/exercise/Annotation.php
  2. 4
      main/exercise/Draggable.php
  3. 4
      main/exercise/Hpdownload.php
  4. 15
      main/exercise/MatchingDraggable.php
  5. 6
      main/exercise/ReadingComprehension.php
  6. 24
      main/exercise/UniqueAnswerImage.php
  7. 8
      main/exercise/adminhp.php
  8. 4
      main/exercise/aiken.php
  9. 14
      main/exercise/exercise_admin.php
  10. 14
      main/exercise/exercise_history.php
  11. 28
      main/exercise/exercise_reminder.php
  12. 10
      main/exercise/exercise_result.class.php
  13. 64
      main/exercise/exercise_submit_modal.php
  14. 2
      main/exercise/export/aiken/aiken_classes.php
  15. 13
      main/exercise/export/aiken/aiken_import.inc.php
  16. 73
      main/exercise/export/exercise_import.inc.php
  17. 10
      main/exercise/export/qti2/qti2_classes.php
  18. 2
      main/exercise/export/qti2/qti2_export.php
  19. 52
      main/exercise/export/scorm/scorm_classes.php
  20. 6
      main/exercise/freeanswer.class.php
  21. 18
      main/exercise/global_multiple_answer.class.php
  22. 22
      main/exercise/hotpotatoes.lib.php
  23. 12
      main/exercise/hotpotatoes.php
  24. 74
      main/exercise/hotpotatoes_exercise_report.php
  25. 20
      main/exercise/hotpotatoes_exercise_result.class.php
  26. 10
      main/exercise/hotspot.class.php
  27. 12
      main/exercise/hotspot.inc.php
  28. 403
      main/exercise/hotspot_admin.inc.php
  29. 2
      main/exercise/hotspot_lang_conversion.php
  30. 40
      main/exercise/live_stats.php
  31. 14
      main/exercise/matching.class.php
  32. 16
      main/exercise/multiple_answer.class.php
  33. 18
      main/exercise/multiple_answer_combination.class.php
  34. 4
      main/exercise/multiple_answer_combination_true_false.class.php
  35. 30
      main/exercise/multiple_answer_true_false.class.php
  36. 8
      main/exercise/oral_expression.class.php
  37. 34
      main/exercise/overview.php
  38. 19
      main/exercise/qti2.php
  39. 8
      main/exercise/question_create.php
  40. 45
      main/exercise/unique_answer.class.php
  41. 22
      main/exercise/unique_answer_no_option.class.php
  42. 14
      main/exercise/upload_exercise.php
  43. 4
      main/inc/lib/browser/Browser.php
  44. 10
      main/inc/lib/elfinder/connectorAction.php
  45. 4
      main/inc/lib/elfinder/templates.php
  46. 4
      main/inc/lib/formvalidator/Element/SelectTheme.php
  47. 2
      main/inc/lib/hook/HookEvent.php

@ -41,15 +41,16 @@ class Annotation extends Question
); );
if (!empty($this->id)) { if (!empty($this->id)) {
$form->setDefaults(array('weighting' => float_format($this->weighting, 1))); $form->setDefaults(['weighting' => float_format($this->weighting, 1)]);
} else { } else {
if ($this->isContent == 1) { if ($this->isContent == 1) {
$form->setDefaults(array('weighting' => '10')); $form->setDefaults(['weighting' => '10']);
} }
} }
global $text;
if (isset($_GET['editQuestion'])) { if (isset($_GET['editQuestion'])) {
$form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion'); $form->addButtonUpdate($text, 'submitQuestion');
return; return;
} }
@ -57,7 +58,7 @@ class Annotation extends Question
$form->addElement( $form->addElement(
'file', 'file',
'imageUpload', 'imageUpload',
array( [
Display::img( Display::img(
Display::return_icon( Display::return_icon(
'annotation.png', 'annotation.png',
@ -69,7 +70,7 @@ class Annotation extends Question
) )
), ),
get_lang('UploadJpgPicture'), get_lang('UploadJpgPicture'),
) ]
); );
$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
@ -77,7 +78,7 @@ class Annotation extends Question
'imageUpload', 'imageUpload',
get_lang('OnlyImagesAllowed'), get_lang('OnlyImagesAllowed'),
'filetype', 'filetype',
array('jpg', 'jpeg', 'png', 'gif') ['jpg', 'jpeg', 'png', 'gif']
); );
$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
} }
@ -108,7 +109,6 @@ class Annotation extends Question
*/ */
public function createAnswersForm($form) public function createAnswersForm($form)
{ {
// nothing
} }
/** /**

@ -26,9 +26,9 @@ class Draggable extends Question
*/ */
public function createAnswersForm($form) public function createAnswersForm($form)
{ {
$defaults = array(); $defaults = [];
$nb_matches = $nb_options = 2; $nb_matches = $nb_options = 2;
$matches = array(); $matches = [];
$answer = null; $answer = null;
if ($form->isSubmitted()) { if ($form->isSubmitted()) {
$nb_matches = $form->getSubmitValue('nb_matches'); $nb_matches = $form->getSubmitValue('nb_matches');

@ -13,7 +13,7 @@ $this_section = SECTION_COURSES;
$tbl_document = Database::get_course_table(TABLE_DOCUMENT); $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
$doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), urldecode($_GET['doc_url'])); $doc_url = str_replace(['../', '\\..', '\\0', '..\\'], ['', '', '', ''], urldecode($_GET['doc_url']));
$filename = basename($doc_url); $filename = basename($doc_url);
// launch event // launch event
@ -87,7 +87,7 @@ header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + 10).' GMT');
if ($content_type == 'text/html') { if ($content_type == 'text/html') {
$directory_name = dirname($full_file_name); $directory_name = dirname($full_file_name);
$coursePath = api_get_path(SYS_COURSE_PATH); $coursePath = api_get_path(SYS_COURSE_PATH);
$dir = str_replace(array('\\', $coursePath.$_course['path'].'/document'), array('/', ''), $directory_name); $dir = str_replace(['\\', $coursePath.$_course['path'].'/document'], ['/', ''], $directory_name);
if ($dir[strlen($dir) - 1] != '/') { if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/'; $dir .= '/';

@ -26,9 +26,9 @@ class MatchingDraggable extends Question
*/ */
public function createAnswersForm($form) public function createAnswersForm($form)
{ {
$defaults = array(); $defaults = [];
$nb_matches = $nb_options = 2; $nb_matches = $nb_options = 2;
$matches = array(); $matches = [];
$answer = null; $answer = null;
$counter = 1; $counter = 1;
if (isset($this->id)) { if (isset($this->id)) {
@ -115,15 +115,14 @@ class MatchingDraggable extends Question
echo Display::return_message(get_lang('YouHaveToCreateAtLeastOneAnswer'), 'normal'); echo Display::return_message(get_lang('YouHaveToCreateAtLeastOneAnswer'), 'normal');
} }
$editorConfig = array( $editorConfig = [
'ToolbarSet' => 'TestMatching', 'ToolbarSet' => 'TestMatching',
'Width' => '100%', 'Width' => '100%',
'Height' => '125' 'Height' => '125'
); ];
for ($i = 1; $i <= $nb_matches; ++$i) { for ($i = 1; $i <= $nb_matches; ++$i) {
$renderer = &$form->defaultRenderer(); $renderer = &$form->defaultRenderer();
$renderer->setElementTemplate( $renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>',
"answer[$i]" "answer[$i]"
@ -198,7 +197,7 @@ class MatchingDraggable extends Question
$form->addHtml('</table>'); $form->addHtml('</table>');
global $text; global $text;
$group = array(); $group = [];
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
$group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true); $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true);
$group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true); $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true);
@ -214,10 +213,10 @@ class MatchingDraggable extends Question
} }
$form->setConstants( $form->setConstants(
array( [
'nb_matches' => $nb_matches, 'nb_matches' => $nb_matches,
'nb_options' => $nb_options 'nb_options' => $nb_options
) ]
); );
} }

@ -169,7 +169,7 @@ class ReadingComprehension extends UniqueAnswer
$isContent = isset($_REQUEST['isContent']) ? intval($_REQUEST['isContent']) : null; $isContent = isset($_REQUEST['isContent']) ? intval($_REQUEST['isContent']) : null;
// default values // default values
$defaults = array(); $defaults = [];
$defaults['questionName'] = $this->question; $defaults['questionName'] = $this->question;
$defaults['questionDescription'] = $this->description; $defaults['questionDescription'] = $this->description;
$defaults['questionLevel'] = $this->level; $defaults['questionLevel'] = $this->level;
@ -194,13 +194,13 @@ class ReadingComprehension extends UniqueAnswer
*/ */
public static function get_default_levels() public static function get_default_levels()
{ {
$select_level = array( $select_level = [
1 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[1]), 1 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[1]),
2 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[2]), 2 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[2]),
3 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[3]), 3 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[3]),
4 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[4]), 4 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[4]),
5 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[5]) 5 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[5])
); ];
return $select_level; return $select_level;
} }
} }

@ -68,7 +68,7 @@ class UniqueAnswerImage extends UniqueAnswer
$form->addHeader(get_lang('Answers')); $form->addHeader(get_lang('Answers'));
$form->addHtml($html); $form->addHtml($html);
$defaults = array(); $defaults = [];
$correct = 0; $correct = 0;
if (!empty($this->id)) { if (!empty($this->id)) {
@ -84,7 +84,7 @@ class UniqueAnswerImage extends UniqueAnswer
//Feedback SELECT //Feedback SELECT
$questionList = $objExercise->selectQuestionList(); $questionList = $objExercise->selectQuestionList();
$selectQuestion = array(); $selectQuestion = [];
$selectQuestion[0] = get_lang('SelectTargetQuestion'); $selectQuestion[0] = get_lang('SelectTargetQuestion');
if (is_array($questionList)) { if (is_array($questionList)) {
@ -106,14 +106,14 @@ class UniqueAnswerImage extends UniqueAnswer
$list = new LearnpathList(api_get_user_id()); $list = new LearnpathList(api_get_user_id());
$flatList = $list->get_flat_list(); $flatList = $list->get_flat_list();
$selectLpId = array(); $selectLpId = [];
$selectLpId[0] = get_lang('SelectTargetLP'); $selectLpId[0] = get_lang('SelectTargetLP');
foreach ($flatList as $id => $details) { foreach ($flatList as $id => $details) {
$selectLpId[$id] = cut($details['lp_name'], 20); $selectLpId[$id] = cut($details['lp_name'], 20);
} }
$tempScenario = array(); $tempScenario = [];
if ($numberAnswers < 1) { if ($numberAnswers < 1) {
$numberAnswers = 1; $numberAnswers = 1;
@ -161,8 +161,8 @@ class UniqueAnswerImage extends UniqueAnswer
$defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2'); $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
$defaults['weighting[2]'] = 0; $defaults['weighting[2]'] = 0;
$tempScenario['destination'.$i] = array('0'); $tempScenario['destination'.$i] = ['0'];
$tempScenario['lp'.$i] = array('0'); $tempScenario['lp'.$i] = ['0'];
} }
$defaults['scenario'] = $tempScenario; $defaults['scenario'] = $tempScenario;
@ -206,7 +206,7 @@ class UniqueAnswerImage extends UniqueAnswer
); );
// Direct feedback // Direct feedback
// Adding extra feedback fields // Adding extra feedback fields
$group = array(); $group = [];
$group['try'.$i] = $form->createElement('checkbox', 'try'.$i, null, get_lang('TryAgain')); $group['try'.$i] = $form->createElement('checkbox', 'try'.$i, null, get_lang('TryAgain'));
$group['lp'.$i] = $form->createElement( $group['lp'.$i] = $form->createElement(
'select', 'select',
@ -224,10 +224,10 @@ class UniqueAnswerImage extends UniqueAnswer
'text', 'text',
'url'.$i, 'url'.$i,
get_lang('Other').': ', get_lang('Other').': ',
array( [
'class' => 'col-md-2', 'class' => 'col-md-2',
'placeholder' => get_lang('Other') 'placeholder' => get_lang('Other')
) ]
); );
$form->addGroup($group, 'scenario'); $form->addGroup($group, 'scenario');
@ -238,7 +238,7 @@ class UniqueAnswerImage extends UniqueAnswer
} else { } else {
$form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig); $form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig);
} }
$form->addText('weighting['.$i.']', null, null, array('class' => "col-md-1", 'value' => '0')); $form->addText('weighting['.$i.']', null, null, ['class' => "col-md-1", 'value' => '0']);
$form->addHtml('</tr>'); $form->addHtml('</tr>');
} }
@ -269,11 +269,11 @@ class UniqueAnswerImage extends UniqueAnswer
// Default sample content. // Default sample content.
$form->setDefaults($defaults); $form->setDefaults($defaults);
} else { } else {
$form->setDefaults(array('correct' => 1)); $form->setDefaults(['correct' => 1]);
} }
} }
$form->setConstants(array('nb_answers' => $numberAnswers)); $form->setConstants(['nb_answers' => $numberAnswers]);
} }
/** /**

@ -38,16 +38,16 @@ if (!$is_allowedToEdit) {
} }
if (api_is_in_gradebook()) { if (api_is_in_gradebook()) {
$interbreadcrumb[] = array( $interbreadcrumb[] = [
'url' => Category::getUrl(), 'url' => Category::getUrl(),
'name' => get_lang('ToolGradebook'), 'name' => get_lang('ToolGradebook'),
); ];
} }
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => "exercise.php", "url" => "exercise.php",
"name" => get_lang('Exercises') "name" => get_lang('Exercises')
); ];
$nameTools = get_lang('adminHP'); $nameTools = get_lang('adminHP');
Display::display_header($nameTools, "Exercise"); Display::display_header($nameTools, "Exercise");

@ -25,10 +25,10 @@ if (!api_is_allowed_to_edit(null, true)) {
} }
// the breadcrumbs // the breadcrumbs
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => 'exercise.php?'.api_get_cidreq(), "url" => 'exercise.php?'.api_get_cidreq(),
"name" => get_lang('Exercises'), "name" => get_lang('Exercises'),
); ];
$is_allowedToEdit = api_is_allowed_to_edit(null, true); $is_allowedToEdit = api_is_allowed_to_edit(null, true);
// import file // import file
if ((api_is_allowed_to_edit(null, true))) { if ((api_is_allowed_to_edit(null, true))) {

@ -164,20 +164,20 @@ if ($form->validate()) {
exit; exit;
} else { } else {
if (api_is_in_gradebook()) { if (api_is_in_gradebook()) {
$interbreadcrumb[] = array( $interbreadcrumb[] = [
'url' => Category::getUrl(), 'url' => Category::getUrl(),
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); ];
} }
$nameTools = get_lang('ExerciseManagement'); $nameTools = get_lang('ExerciseManagement');
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => 'exercise.php?'.api_get_cidreq(), "url" => 'exercise.php?'.api_get_cidreq(),
'name' => get_lang('Exercises'), 'name' => get_lang('Exercises'),
); ];
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => 'admin.php?exerciseId='.$objExercise->id.'&'.api_get_cidreq(), "url" => 'admin.php?exerciseId='.$objExercise->id.'&'.api_get_cidreq(),
"name" => $objExercise->selectTitle(true), "name" => $objExercise->selectTitle(true),
); ];
Display::display_header($nameTools, get_lang('Exercise')); Display::display_header($nameTools, get_lang('Exercise'));
@ -190,7 +190,7 @@ if ($form->validate()) {
if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])) { if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])) {
if (!empty($_POST['lp_id'])) { if (!empty($_POST['lp_id'])) {
$lp_id = intval($_POST['lp_id']); $lp_id = intval($_POST['lp_id']);
//TODO:this remains to be implemented after press the first post //TODO:this remains to be implemented after press the first post
} else { } else {
$lp_id = intval($_GET['lp_id']); $lp_id = intval($_GET['lp_id']);
} }

@ -24,18 +24,18 @@ if (!$is_allowedToEdit) {
exit; exit;
} }
$interbreadcrumb[] = array( $interbreadcrumb[] = [
'url' => 'exercise_report.php?'.api_get_cidreq(), 'url' => 'exercise_report.php?'.api_get_cidreq(),
'name' => get_lang('Exercises'), 'name' => get_lang('Exercises'),
); ];
$interbreadcrumb[] = array( $interbreadcrumb[] = [
'url' => 'exercise_report.php?filter=2&'.api_get_cidreq(), 'url' => 'exercise_report.php?filter=2&'.api_get_cidreq(),
'name' => get_lang('StudentScore'), 'name' => get_lang('StudentScore'),
); ];
$interbreadcrumb[] = array( $interbreadcrumb[] = [
'url' => 'exercise_history.php?exe_id='.intval($_GET['exe_id']).'&'.api_get_cidreq(), 'url' => 'exercise_history.php?exe_id='.intval($_GET['exe_id']).'&'.api_get_cidreq(),
'name' => get_lang('Details'), 'name' => get_lang('Details'),
); ];
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
@ -44,7 +44,7 @@ $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_
Display::display_header($nameTools, get_lang('Exercise')); Display::display_header($nameTools, get_lang('Exercise'));
if (isset($_GET['message'])) { if (isset($_GET['message'])) {
if (in_array($_GET['message'], array('ExerciseEdited'))) { if (in_array($_GET['message'], ['ExerciseEdited'])) {
$my_message_history = Security::remove_XSS($_GET['message']); $my_message_history = Security::remove_XSS($_GET['message']);
echo Display::return_message(get_lang($my_message_history), 'confirm'); echo Display::return_message(get_lang($my_message_history), 'confirm');
} }

@ -104,7 +104,7 @@ if (empty($exercise_stat_info) || empty($question_list)) {
} }
$nameTools = get_lang('Exercises'); $nameTools = get_lang('Exercises');
$interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises')); $interbreadcrumb[] = ["url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises')];
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
//so we are not in learnpath tool //so we are not in learnpath tool
@ -119,9 +119,9 @@ if ($origin != 'learnpath') {
if (api_is_course_admin() && $origin != 'learnpath') { if (api_is_course_admin() && $origin != 'learnpath') {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'. echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.
Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 32).'</a>'; Display::return_icon('back.png', get_lang('GoBackToQuestionList'), [], 32).'</a>';
echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'. echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).'</a>'; Display::return_icon('edit.png', get_lang('ModifyExercise'), [], 32).'</a>';
echo '</div>'; echo '</div>';
} }
echo Display::page_header(get_lang('QuestionsToReview')); echo Display::page_header(get_lang('QuestionsToReview'));
@ -130,7 +130,7 @@ if ($time_control) {
echo $objExercise->return_time_left_div(); echo $objExercise->return_time_left_div();
} }
echo Display::div('', array('id'=>'message')); echo Display::div('', ['id'=>'message']);
echo '<script> echo '<script>
var lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'}); var lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'});
@ -174,7 +174,7 @@ echo '<script>
$attempt_list = Event::getAllExerciseEventByExeId($exe_id); $attempt_list = Event::getAllExerciseEventByExeId($exe_id);
$remind_list = $exercise_stat_info['questions_to_check']; $remind_list = $exercise_stat_info['questions_to_check'];
$remind_list = explode(',', $remind_list); $remind_list = explode(',', $remind_list);
$exercise_result = array(); $exercise_result = [];
foreach ($attempt_list as $question_id => $options) { foreach ($attempt_list as $question_id => $options) {
foreach ($options as $item) { foreach ($options as $item) {
@ -207,17 +207,17 @@ foreach ($question_list as $questionId) {
$objQuestionTmp = Question:: read($questionId); $objQuestionTmp = Question:: read($questionId);
$quesId = $objQuestionTmp->selectId(); $quesId = $objQuestionTmp->selectId();
$check_id = 'remind_list['.$questionId.']'; $check_id = 'remind_list['.$questionId.']';
$attributes = array('id' => $check_id, 'onclick' => "save_remind_item(this, '$questionId');"); $attributes = ['id' => $check_id, 'onclick' => "save_remind_item(this, '$questionId');"];
if (in_array($questionId, $remind_list)) { if (in_array($questionId, $remind_list)) {
$attributes['checked'] = 1; $attributes['checked'] = 1;
} }
$label_attributes = array(); $label_attributes = [];
$label_attributes['class'] = 'checkbox'; $label_attributes['class'] = 'checkbox';
$label_attributes['for'] = $check_id; $label_attributes['for'] = $check_id;
$label_attributes['class'] = "checkbox"; $label_attributes['class'] = "checkbox";
$checkbox = Display::input('checkbox', 'remind_list['.$questionId.']', '', $attributes); $checkbox = Display::input('checkbox', 'remind_list['.$questionId.']', '', $attributes);
$url = 'exercise_submit.php?exerciseId='.$objExercise->id.'&num='.$counter.'&reminder=1'; $url = 'exercise_submit.php?exerciseId='.$objExercise->id.'&num='.$counter.'&reminder=1&'.api_get_cidreq();
$counter++; $counter++;
if ($objExercise->type == ONE_PER_PAGE) { if ($objExercise->type == ONE_PER_PAGE) {
@ -234,25 +234,25 @@ foreach ($question_list as $questionId) {
$question_title = Display::label($question_title, 'warning'); $question_title = Display::label($question_title, 'warning');
} }
$question_title = Display::tag('label', $checkbox.$question_title, $label_attributes); $question_title = Display::tag('label', $checkbox.$question_title, $label_attributes);
$table .= Display::div($question_title, array('class'=>'exercise_reminder_item')); $table .= Display::div($question_title, ['class'=>'exercise_reminder_item']);
} // end foreach() block that loops over all questions } // end foreach() block that loops over all questions
echo Display::div($table, array('class'=>'question-check-test')); echo Display::div($table, ['class'=>'question-check-test']);
$exerciseActions = Display::url( $exerciseActions = Display::url(
get_lang('ReviewQuestions'), get_lang('ReviewQuestions'),
'javascript://', 'javascript://',
array('onclick'=>'review_questions();', 'class'=>'btn btn-success') ['onclick'=>'review_questions();', 'class'=>'btn btn-success']
); );
$exerciseActions .= '&nbsp;'.Display::url( $exerciseActions .= '&nbsp;'.Display::url(
get_lang('EndTest'), get_lang('EndTest'),
'javascript://', 'javascript://',
array('onclick' => 'final_submit();', 'class' => 'btn btn-warning') ['onclick' => 'final_submit();', 'class' => 'btn btn-warning']
); );
echo Display::div('', array('class'=>'clear')); echo Display::div('', ['class'=>'clear']);
echo Display::div($exerciseActions, array('class'=>'form-actions')); echo Display::div($exerciseActions, ['class'=>'form-actions']);
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
// We are not in learnpath tool // We are not in learnpath tool

@ -45,7 +45,7 @@ class ExerciseResult
$filter = 0, $filter = 0,
$exercise_id = 0 $exercise_id = 0
) { ) {
$return = array(); $return = [];
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN); $TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
@ -124,9 +124,9 @@ class ExerciseResult
ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC"; ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC";
} }
$results = array(); $results = [];
$resx = Database::query($sql); $resx = Database::query($sql);
$bestAttemptPerUser = array(); $bestAttemptPerUser = [];
while ($rowx = Database::fetch_array($resx, 'ASSOC')) { while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
if ($this->onlyBestAttempts) { if ($this->onlyBestAttempts) {
if (!isset($bestAttemptPerUser[$rowx['excruid']])) { if (!isset($bestAttemptPerUser[$rowx['excruid']])) {
@ -172,7 +172,7 @@ class ExerciseResult
$studentsUserIdList = array_keys($students); $studentsUserIdList = array_keys($students);
// Print the results of tests // Print the results of tests
$userWithResults = array(); $userWithResults = [];
if (is_array($results)) { if (is_array($results)) {
$i = 0; $i = 0;
foreach ($results as $result) { foreach ($results as $result) {
@ -198,7 +198,7 @@ class ExerciseResult
continue; continue;
} }
$return[$i] = array(); $return[$i] = [];
if (empty($user_id)) { if (empty($user_id)) {
$return[$i]['official_code'] = $result['official_code']; $return[$i]['official_code'] = $result['official_code'];
if (api_is_western_name_order()) { if (api_is_western_name_order()) {

@ -42,7 +42,7 @@ if (isset($_REQUEST['learnpath_item_id'])) {
$learnpath_item_id = intval($_REQUEST['learnpath_item_id']); $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
} }
$_SESSION['hotspot_coord'] = array(); $_SESSION['hotspot_coord'] = [];
$newquestionList = Session::read('newquestionList', []); $newquestionList = Session::read('newquestionList', []);
$questionList = Session::read('questionList'); $questionList = Session::read('questionList');
$exerciseId = intval($_GET['exerciseId']); $exerciseId = intval($_GET['exerciseId']);
@ -110,20 +110,20 @@ if (empty($choice_value)) {
// IMPORTANT // IMPORTANT
//this is the real redirect function //this is the real redirect function
//echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";'; //echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";';
echo ' url = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";'; echo ' url = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&'.api_get_cidreq().'&gradebook='.$gradebook.'";';
echo "$('#global-modal .modal-body').load(url);"; echo "$('#global-modal .modal-body').load(url);";
echo '</script>'; echo '</script>';
exit; exit;
} }
$choice = array(); $choice = [];
$questionid = $questionList[$questionNum]; $questionid = $questionList[$questionNum];
// $choice_value => value of the user selection // $choice_value => value of the user selection
$choice[$questionid] = isset($choice_value) ? $choice_value : null; $choice[$questionid] = isset($choice_value) ? $choice_value : null;
// initializing // initializing
if (!is_array($exerciseResult)) { if (!is_array($exerciseResult)) {
$exerciseResult = array(); $exerciseResult = [];
} }
// if the user has answered at least one question // if the user has answered at least one question
@ -170,11 +170,11 @@ if (in_array($questionid, $questionList)) {
$objAnswerTmp = new Answer($questionid); $objAnswerTmp = new Answer($questionid);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers(); $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
$choice = $exerciseResult[$questionid]; $choice = $exerciseResult[$questionid];
$destination = array(); $destination = [];
$comment = ''; $comment = '';
$next = 1; $next = 1;
$_SESSION['hotspot_coord'] = array(); $_SESSION['hotspot_coord'] = [];
$_SESSION['hotspot_dest'] = array(); $_SESSION['hotspot_dest'] = [];
$overlap_color = $missing_color = $excess_color = false; $overlap_color = $missing_color = $excess_color = false;
$organs_at_risk_hit = 0; $organs_at_risk_hit = 0;
$wrong_results = false; $wrong_results = false;
@ -195,7 +195,9 @@ if (!empty($choice_value)) {
//delineation //delineation
$delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1); $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
$answer_delineation_destination = $objAnswerTmp->selectDestination(1); $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
if ($dbg_local > 0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination, 0); } if ($dbg_local > 0) {
error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination, 0);
}
switch ($answerType) { switch ($answerType) {
// for unique answer // for unique answer
@ -230,7 +232,9 @@ if (!empty($choice_value)) {
} }
} elseif ($answerType == HOT_SPOT_DELINEATION) { } elseif ($answerType == HOT_SPOT_DELINEATION) {
if ($next) { if ($next) {
if ($dbg_local > 0) { error_log(__LINE__.' - next', 0); } if ($dbg_local > 0) {
error_log(__LINE__.' - next', 0);
}
$hot_spot_load = true; //apparently the script is called twice $hot_spot_load = true; //apparently the script is called twice
$user_answer = $user_array; $user_answer = $user_array;
$_SESSION['exerciseResultCoordinates'][$questionid] = $user_answer; //needed for exercise_result.php $_SESSION['exerciseResultCoordinates'][$questionid] = $user_answer; //needed for exercise_result.php
@ -265,7 +269,9 @@ if (!empty($choice_value)) {
} }
//$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
if ($dbg_local > 0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); } if ($dbg_local > 0) {
error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
}
if ($overlap < 1) { if ($overlap < 1) {
//shortcut to avoid complicated calculations //shortcut to avoid complicated calculations
$final_overlap = 0; $final_overlap = 0;
@ -274,13 +280,19 @@ if (!empty($choice_value)) {
} else { } else {
// the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
$final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
if ($dbg_local > 1) { error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); } if ($dbg_local > 1) {
error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
}
// the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
$final_missing = 100 - $final_overlap; $final_missing = 100 - $final_overlap;
if ($dbg_local > 1) { error_log(__LINE__.' - Final missing is '.$final_missing, 0); } if ($dbg_local > 1) {
error_log(__LINE__.' - Final missing is '.$final_missing, 0);
}
// the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
$final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
if ($dbg_local > 1) { error_log(__LINE__.' - Final excess is '.$final_excess, 0); } if ($dbg_local > 1) {
error_log(__LINE__.' - Final excess is '.$final_excess, 0);
}
} }
$destination_items = explode('@@', $answerDestination); $destination_items = explode('@@', $answerDestination);
@ -324,12 +336,16 @@ if (!empty($choice_value)) {
} }
} elseif ($answerId > 1) { } elseif ($answerId > 1) {
if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
if ($dbg_local > 0) { error_log(__LINE__.' - answerId is of type noerror', 0); } if ($dbg_local > 0) {
error_log(__LINE__.' - answerId is of type noerror', 0);
}
//type no error shouldn't be treated //type no error shouldn't be treated
$next = 1; $next = 1;
continue; continue;
} }
if ($dbg_local > 0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); } if ($dbg_local > 0) {
error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
}
//check the intersection between the oar and the user //check the intersection between the oar and the user
//echo 'user'; print_r($x_user_list); print_r($y_user_list); //echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list); //echo 'official';print_r($x_list);print_r($y_list);
@ -395,7 +411,9 @@ if (!empty($choice_value)) {
} }
} else { } else {
// the first delineation feedback // the first delineation feedback
if ($dbg_local > 0) { error_log(__LINE__.' first', 0); } if ($dbg_local > 0) {
error_log(__LINE__.' first', 0);
}
} }
} }
} }
@ -504,7 +522,7 @@ if (isset($try) && $try == 1) {
$links .= Display:: return_icon( $links .= Display:: return_icon(
'reload.gif', 'reload.gif',
'', '',
array('style' => 'padding-left:0px;padding-right:5px;') ['style' => 'padding-left:0px;padding-right:5px;']
).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />'; ).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
} }
@ -516,7 +534,7 @@ if (!empty($lp)) {
$links .= Display:: return_icon( $links .= Display:: return_icon(
'theory.gif', 'theory.gif',
'', '',
array('style' => 'padding-left:0px;padding-right:5px;') ['style' => 'padding-left:0px;padding-right:5px;']
).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />'; ).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
} }
$links .= '<br />'; $links .= '<br />';
@ -526,7 +544,7 @@ if (!empty($url)) {
$links .= Display:: return_icon( $links .= Display:: return_icon(
'link.gif', 'link.gif',
'', '',
array('style' => 'padding-left:0px;padding-right:5px;') ['style' => 'padding-left:0px;padding-right:5px;']
).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />'; ).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
} }
@ -535,7 +553,7 @@ if ($destinationid == -1) {
$links .= Display:: return_icon( $links .= Display:: return_icon(
'finish.gif', 'finish.gif',
'', '',
array('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;') ['style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;']
).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />'; ).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
} else { } else {
// the link to other question // the link to other question
@ -546,7 +564,7 @@ if ($destinationid == -1) {
$links .= Display:: return_icon( $links .= Display:: return_icon(
'quiz.png', 'quiz.png',
'', '',
array('style' => 'padding-left:0px;padding-right:5px;') ['style' => 'padding-left:0px;padding-right:5px;']
).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />'; ).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
} }
} }
@ -588,7 +606,7 @@ if ($links != '') {
echo '</div>'; echo '</div>';
Session::write('hot_spot_result', $message); Session::write('hot_spot_result', $message);
$_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]); $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = [$message, $exerciseResult[$questionid]];
//reseting the exerciseResult variable //reseting the exerciseResult variable
Session::write('exerciseResult', $exerciseResult); Session::write('exerciseResult', $exerciseResult);
@ -599,7 +617,7 @@ if ($links != '') {
} else { } else {
$questionNum++; $questionNum++;
echo '<script> echo '<script>
self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'"; self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&'.api_get_cidreq().'";
//self.parent.tb_remove(); //self.parent.tb_remove();
</script>'; </script>';
} }

@ -16,7 +16,7 @@ class Aiken2Question extends Question
/** /**
* Include the correct answer class and create answer * Include the correct answer class and create answer
*/ */
function setAnswer() public function setAnswer()
{ {
switch ($this->type) { switch ($this->type) {
case MCUA: case MCUA:

@ -29,7 +29,7 @@ function aiken_display_form()
'post', 'post',
api_get_self()."?".api_get_cidreq(), api_get_self()."?".api_get_cidreq(),
null, null,
array('enctype' => 'multipart/form-data') ['enctype' => 'multipart/form-data']
); );
$form_validator->addElement('header', $name_tools); $form_validator->addElement('header', $name_tools);
$form_validator->addElement('text', 'total_weight', get_lang('TotalWeight')); $form_validator->addElement('text', 'total_weight', get_lang('TotalWeight'));
@ -115,9 +115,9 @@ function aiken_import_exercise($file)
$uploadPath = 'aiken_'.api_get_unique_id().'/'; $uploadPath = 'aiken_'.api_get_unique_id().'/';
// set some default values for the new exercise // set some default values for the new exercise
$exercise_info = array(); $exercise_info = [];
$exercise_info['name'] = preg_replace('/.(zip|txt)$/i', '', $file); $exercise_info['name'] = preg_replace('/.(zip|txt)$/i', '', $file);
$exercise_info['question'] = array(); $exercise_info['question'] = [];
// if file is not a .zip, then we cancel all // if file is not a .zip, then we cancel all
if (!preg_match('/.(zip|txt)$/i', $file)) { if (!preg_match('/.(zip|txt)$/i', $file)) {
@ -252,7 +252,7 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
$question_index = 0; $question_index = 0;
$correct_answer = ''; $correct_answer = '';
$answers_array = array(); $answers_array = [];
$new_question = true; $new_question = true;
foreach ($data as $line => $info) { foreach ($data as $line => $info) {
if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/', $info)) { if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/', $info)) {
@ -288,7 +288,7 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
$correct_answer_index = array_search($matches[1], $answers_array); $correct_answer_index = array_search($matches[1], $answers_array);
$exercise_info['question'][$question_index]['title'] = $matches[1]; $exercise_info['question'][$question_index]['title'] = $matches[1];
} elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) {
//TAGS for chamilo >= 1.10 //TAGS for chamilo >= 1.10
$exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]);
} elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) {
//TAGS for chamilo >= 1.10 (Spanish e-ducativa format) //TAGS for chamilo >= 1.10 (Spanish e-ducativa format)
@ -305,7 +305,7 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
} }
$question_index++; $question_index++;
//emptying answers array when moving to next question //emptying answers array when moving to next question
$answers_array = array(); $answers_array = [];
$new_question = true; $new_question = true;
} else { } else {
if (empty($exercise_info['question'][$question_index]['title'])) { if (empty($exercise_info['question'][$question_index]['title'])) {
@ -349,7 +349,6 @@ function aiken_import_file($array_file)
Display::addFlash(Display::return_message(get_lang('Uploaded'))); Display::addFlash(Display::return_message(get_lang('Uploaded')));
return $imported; return $imported;
} else { } else {
Display::addFlash(Display::return_message(get_lang($imported), 'error')); Display::addFlash(Display::return_message(get_lang($imported), 'error'));

@ -66,7 +66,6 @@ function import_exercise($file)
global $resourcesLinks; global $resourcesLinks;
$baseWorkDir = api_get_path(SYS_ARCHIVE_PATH).'qti2/'; $baseWorkDir = api_get_path(SYS_ARCHIVE_PATH).'qti2/';
if (!is_dir($baseWorkDir)) { if (!is_dir($baseWorkDir)) {
mkdir($baseWorkDir, api_get_permissions_for_new_directories(), true); mkdir($baseWorkDir, api_get_permissions_for_new_directories(), true);
} }
@ -78,12 +77,12 @@ function import_exercise($file)
} }
// set some default values for the new exercise // set some default values for the new exercise
$exercise_info = array(); $exercise_info = [];
$exercise_info['name'] = preg_replace('/.zip$/i', '', $file); $exercise_info['name'] = preg_replace('/.zip$/i', '', $file);
$exercise_info['question'] = array(); $exercise_info['question'] = [];
$element_pile = array(); $element_pile = [];
// create parser and array to retrieve info from manifest // create parser and array to retrieve info from manifest
$element_pile = array(); //pile to known the depth in which we are $element_pile = []; //pile to known the depth in which we are
// if file is not a .zip, then we cancel all // if file is not a .zip, then we cancel all
if (!preg_match('/.zip$/i', $file)) { if (!preg_match('/.zip$/i', $file)) {
@ -102,7 +101,7 @@ function import_exercise($file)
$file_found = false; $file_found = false;
$result = false; $result = false;
$filePath = null; $filePath = null;
$resourcesLinks = array(); $resourcesLinks = [];
// parse every subdirectory to search xml question files and other assets to be imported // parse every subdirectory to search xml question files and other assets to be imported
// The assets-related code is a bit fragile as it has to deal with files renamed by Chamilo and it only works if // The assets-related code is a bit fragile as it has to deal with files renamed by Chamilo and it only works if
@ -139,7 +138,6 @@ function import_exercise($file)
$resourcesLinks = qtiProcessManifest($baseWorkDir.'/'.$file); $resourcesLinks = qtiProcessManifest($baseWorkDir.'/'.$file);
} }
} }
} }
} }
@ -212,6 +210,7 @@ function import_exercise($file)
if (!empty($question_array['description'])) { if (!empty($question_array['description'])) {
$description .= $question_array['description']; $description .= $question_array['description'];
} }
$question->updateDescription($description); $question->updateDescription($description);
$question->save($exercise); $question->save($exercise);
@ -222,7 +221,7 @@ function import_exercise($file)
$answer->new_nbrAnswers = count($answerList); $answer->new_nbrAnswers = count($answerList);
$totalCorrectWeight = 0; $totalCorrectWeight = 0;
$j = 1; $j = 1;
$matchAnswerIds = array(); $matchAnswerIds = [];
if (!empty($answerList)) { if (!empty($answerList)) {
foreach ($answerList as $key => $answers) { foreach ($answerList as $key => $answers) {
if (preg_match('/_/', $key)) { if (preg_match('/_/', $key)) {
@ -265,7 +264,6 @@ function import_exercise($file)
$question->save($exercise); $question->save($exercise);
$answer->save(); $answer->save();
} }
// delete the temp dir where the exercise was unzipped // delete the temp dir where the exercise was unzipped
my_delete($baseWorkDir.$uploadPath); my_delete($baseWorkDir.$uploadPath);
@ -309,18 +307,17 @@ function qti_parse_file($exercisePath, $file, $questionFile)
//parse XML question file //parse XML question file
//$data = str_replace(array('<p>', '</p>', '<front>', '</front>'), '', $data); //$data = str_replace(array('<p>', '</p>', '<front>', '</front>'), '', $data);
$data = ChamiloApi::stripGivenTags($data, array('p', 'front')); $data = ChamiloApi::stripGivenTags($data, ['p', 'front']);
$qtiVersion = array(); $qtiVersion = [];
$match = preg_match('/ims_qtiasiv(\d)p(\d)/', $data, $qtiVersion); $match = preg_match('/ims_qtiasiv(\d)p(\d)/', $data, $qtiVersion);
$qtiMainVersion = 2; //by default, assume QTI version 2 $qtiMainVersion = 2; //by default, assume QTI version 2
if ($match) { if ($match) {
$qtiMainVersion = $qtiVersion[1]; $qtiMainVersion = $qtiVersion[1];
} }
//used global variable start values declaration : //used global variable start values declaration:
$record_item_body = false; $record_item_body = false;
$non_HTML_tag_to_avoid = array( $non_HTML_tag_to_avoid = [
"SIMPLECHOICE", "SIMPLECHOICE",
"CHOICEINTERACTION", "CHOICEINTERACTION",
"INLINECHOICEINTERACTION", "INLINECHOICEINTERACTION",
@ -334,11 +331,12 @@ function qti_parse_file($exercisePath, $file, $questionFile)
"ITEMBODY", "ITEMBODY",
"BR", "BR",
"IMG" "IMG"
); ];
$question_format_supported = true; $question_format_supported = true;
$xml_parser = xml_parser_create(); $xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, false); xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, false);
if ($qtiMainVersion == 1) { if ($qtiMainVersion == 1) {
xml_set_element_handler( xml_set_element_handler(
$xml_parser, $xml_parser,
@ -354,6 +352,7 @@ function qti_parse_file($exercisePath, $file, $questionFile)
); );
xml_set_character_data_handler($xml_parser, 'elementDataQti2'); xml_set_character_data_handler($xml_parser, 'elementDataQti2');
} }
if (!xml_parse($xml_parser, $data, feof($fp))) { if (!xml_parse($xml_parser, $data, feof($fp))) {
// if reading of the xml file in not successful : // if reading of the xml file in not successful :
// set errorFound, set error msg, break while statement // set errorFound, set error msg, break while statement
@ -379,9 +378,9 @@ function qti_parse_file($exercisePath, $file, $questionFile)
Display::return_message( Display::return_message(
get_lang( get_lang(
'Unknown question format in file %file', 'Unknown question format in file %file',
array( [
'%file' => $questionFile, '%file' => $questionFile,
) ]
), ),
'error' 'error'
) )
@ -449,7 +448,6 @@ function startElementQti2($parser, $name, $attributes)
if ($current_element == 'TEXTENTRYINTERACTION') { if ($current_element == 'TEXTENTRYINTERACTION') {
$correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
$current_question_item_body .= "[".$correct_answer_value."]"; $current_question_item_body .= "[".$correct_answer_value."]";
} }
if ($current_element == 'BR') { if ($current_element == 'BR') {
$current_question_item_body .= "<br />"; $current_question_item_body .= "<br />";
@ -506,6 +504,7 @@ function startElementQti2($parser, $name, $attributes)
break; break;
case 'EXTENDEDTEXTINTERACTION': case 'EXTENDEDTEXTINTERACTION':
$exercise_info['question'][$current_question_ident]['type'] = FREE_ANSWER; $exercise_info['question'][$current_question_ident]['type'] = FREE_ANSWER;
$exercise_info['question'][$current_question_ident]['description'] = '';
break; break;
case 'SIMPLEMATCHSET': case 'SIMPLEMATCHSET':
if (!isset($current_match_set)) { if (!isset($current_match_set)) {
@ -513,7 +512,7 @@ function startElementQti2($parser, $name, $attributes)
} else { } else {
$current_match_set++; $current_match_set++;
} }
$exercise_info['question'][$current_question_ident]['answer'][$current_match_set] = array(); $exercise_info['question'][$current_question_ident]['answer'][$current_match_set] = [];
break; break;
case 'SIMPLEASSOCIABLECHOICE': case 'SIMPLEASSOCIABLECHOICE':
$currentAssociableChoice = $attributes['IDENTIFIER']; $currentAssociableChoice = $attributes['IDENTIFIER'];
@ -522,14 +521,14 @@ function startElementQti2($parser, $name, $attributes)
case 'SIMPLECHOICE': case 'SIMPLECHOICE':
$current_answer_id = $attributes['IDENTIFIER']; $current_answer_id = $attributes['IDENTIFIER'];
if (!isset($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id])) { if (!isset($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id])) {
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id] = array(); $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id] = [];
} }
break; break;
case 'MAPENTRY': case 'MAPENTRY':
if ($parent_element == 'MAPPING' || $parent_element == 'MAPENTRY') { if ($parent_element == 'MAPPING' || $parent_element == 'MAPENTRY') {
$answer_id = $attributes['MAPKEY']; $answer_id = $attributes['MAPKEY'];
if (!isset($exercise_info['question'][$current_question_ident]['weighting'])) { if (!isset($exercise_info['question'][$current_question_ident]['weighting'])) {
$exercise_info['question'][$current_question_ident]['weighting'] = array(); $exercise_info['question'][$current_question_ident]['weighting'] = [];
} }
$exercise_info['question'][$current_question_ident]['weighting'][$answer_id] = $attributes['MAPPEDVALUE']; $exercise_info['question'][$current_question_ident]['weighting'][$answer_id] = $attributes['MAPPEDVALUE'];
} }
@ -599,7 +598,14 @@ function endElementQti2($parser, $name)
if ($exercise_info['question'][$current_question_ident]['type'] == FIB) { if ($exercise_info['question'][$current_question_ident]['type'] == FIB) {
$exercise_info['question'][$current_question_ident]['response_text'] = $current_question_item_body; $exercise_info['question'][$current_question_ident]['response_text'] = $current_question_item_body;
} else { } else {
$exercise_info['question'][$current_question_ident]['statement'] = $current_question_item_body; if ($exercise_info['question'][$current_question_ident]['type'] == FREE_ANSWER) {
$current_question_item_body = trim($current_question_item_body);
if (!empty($current_question_item_body)) {
$exercise_info['question'][$current_question_ident]['description'] = $current_question_item_body;
}
} else {
$exercise_info['question'][$current_question_ident]['statement'] = $current_question_item_body;
}
} }
break; break;
} }
@ -643,11 +649,15 @@ function elementDataQti2($parser, $data)
} }
//treat the record of the full content of itembody tag (needed for question statment and/or FIB text: //treat the record of the full content of itembody tag (needed for question statment and/or FIB text:
if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) { if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
$current_question_item_body .= $data; $current_question_item_body .= $data;
} }
switch ($current_element) { switch ($current_element) {
case 'EXTENDEDTEXTINTERACTION':
$exercise_info['question'][$current_question_ident]['description'] .= $data;
break;
case 'SIMPLECHOICE': case 'SIMPLECHOICE':
if (!isset($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) { if (!isset($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) {
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data); $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data);
@ -703,7 +713,7 @@ function elementDataQti2($parser, $data)
); );
} else { } else {
if (!isset($exercise_info['question'][$current_question_ident]['wrong_answers'])) { if (!isset($exercise_info['question'][$current_question_ident]['wrong_answers'])) {
$exercise_info['question'][$current_question_ident]['wrong_answers'] = array(); $exercise_info['question'][$current_question_ident]['wrong_answers'] = [];
} }
$exercise_info['question'][$current_question_ident]['wrong_answers'][] = $data; $exercise_info['question'][$current_question_ident]['wrong_answers'][] = $data;
} }
@ -778,7 +788,6 @@ function startElementQti1($parser, $name, $attributes)
if ($current_element == 'TEXTENTRYINTERACTION') { if ($current_element == 'TEXTENTRYINTERACTION') {
$correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
$current_question_item_body .= "[".$correct_answer_value."]"; $current_question_item_body .= "[".$correct_answer_value."]";
} }
if ($current_element == 'BR') { if ($current_element == 'BR') {
$current_question_item_body .= "<br />"; $current_question_item_body .= "<br />";
@ -796,9 +805,9 @@ function startElementQti1($parser, $name, $attributes)
case 'ITEM': case 'ITEM':
//retrieve current question //retrieve current question
$current_question_ident = $attributes['IDENT']; $current_question_ident = $attributes['IDENT'];
$exercise_info['question'][$current_question_ident] = array(); $exercise_info['question'][$current_question_ident] = [];
$exercise_info['question'][$current_question_ident]['answer'] = array(); $exercise_info['question'][$current_question_ident]['answer'] = [];
$exercise_info['question'][$current_question_ident]['correct_answers'] = array(); $exercise_info['question'][$current_question_ident]['correct_answers'] = [];
$exercise_info['question'][$current_question_ident]['tempdir'] = $questionTempDir; $exercise_info['question'][$current_question_ident]['tempdir'] = $questionTempDir;
break; break;
case 'SECTION': case 'SECTION':
@ -1095,11 +1104,11 @@ function qtiProcessManifest($filePath)
$exercisesSysPath = $sysPath.$courseDir.'/document/'; $exercisesSysPath = $sysPath.$courseDir.'/document/';
$webPath = api_get_path(WEB_CODE_PATH); $webPath = api_get_path(WEB_CODE_PATH);
$exercisesWebPath = $webPath.'document/document.php?'.api_get_cidreq().'&action=download&id='; $exercisesWebPath = $webPath.'document/document.php?'.api_get_cidreq().'&action=download&id=';
$links = array( $links = [
'manifest' => array(), 'manifest' => [],
'system' => array(), 'system' => [],
'web' => array(), 'web' => [],
); ];
$tableDocuments = Database::get_course_table(TABLE_DOCUMENT); $tableDocuments = Database::get_course_table(TABLE_DOCUMENT);
$countResources = count($xml->resources->resource->file); $countResources = count($xml->resources->resource->file);
for ($i = 0; $i < $countResources; $i++) { for ($i = 0; $i < $countResources; $i++) {

@ -262,7 +262,7 @@ class ImsAnswerMatching extends Answer
$out = ' <responseDeclaration identifier="'.$questionIdent.'" cardinality="single" baseType="identifier">'."\n"; $out = ' <responseDeclaration identifier="'.$questionIdent.'" cardinality="single" baseType="identifier">'."\n";
$out .= ' <correctResponse>'."\n"; $out .= ' <correctResponse>'."\n";
$gradeArray = array(); $gradeArray = [];
if (isset($this->leftList) && is_array($this->leftList)) { if (isset($this->leftList) && is_array($this->leftList)) {
foreach ($this->leftList as $leftKey => $leftElement) { foreach ($this->leftList as $leftKey => $leftElement) {
$i = 0; $i = 0;
@ -325,23 +325,23 @@ class ImsAnswerHotspot extends Answer
switch ($answer['hotspot_type']) { switch ($answer['hotspot_type']) {
case 'square': case 'square':
$type = 'rect'; $type = 'rect';
$res = array(); $res = [];
$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res); $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
$coords = $res[1].','.$res[2].','.((int) $res[1] + (int) $res[3]).",".((int) $res[2] + (int) $res[4]); $coords = $res[1].','.$res[2].','.((int) $res[1] + (int) $res[3]).",".((int) $res[2] + (int) $res[4]);
break; break;
case 'circle': case 'circle':
$type = 'circle'; $type = 'circle';
$res = array(); $res = [];
$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res); $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1] - $res[3]), 2) + pow(($res[2] - $res[4]))); $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1] - $res[3]), 2) + pow(($res[2] - $res[4])));
break; break;
case 'poly': case 'poly':
$type = 'poly'; $type = 'poly';
$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']); $coords = str_replace([';', '|'], [',', ','], $answer['hotspot_coord']);
break; break;
case 'delineation': case 'delineation':
$type = 'delineation'; $type = 'delineation';
$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']); $coords = str_replace([';', '|'], [',', ','], $answer['hotspot_coord']);
break; break;
} }
$text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";

@ -394,7 +394,7 @@ class ImsItem
* @return string string, the XML flow for an Item. * @return string string, the XML flow for an Item.
* @author Amand Tihon <amand@alrj.org> * @author Amand Tihon <amand@alrj.org>
*/ */
public function export($standalone = False) public function export($standalone = false)
{ {
global $charset; global $charset;
$head = $foot = ""; $head = $foot = "";

@ -138,7 +138,7 @@ class ScormQuestion extends Question
throw new \Exception('Question not supported. Exercise: '.$this->selectTitle()); throw new \Exception('Question not supported. Exercise: '.$this->selectTitle());
} }
return array($js, $html); return [$js, $html];
} }
/** /**
@ -311,7 +311,7 @@ class ScormAnswerMultipleChoice extends Answer
} }
$html .= '</table></td></tr>'; $html .= '</table></td></tr>';
return array($js, $html); return [$js, $html];
} }
} }
@ -364,7 +364,7 @@ class ScormAnswerTrueFalse extends Answer
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
$js .= $jstmpw; $js .= $jstmpw;
return array($js, $html); return [$js, $html];
} }
} }
@ -386,7 +386,7 @@ class ScormAnswerFillInBlanks extends Answer
$js = ''; $js = '';
$html = '<tr><td colspan="2"><table width="100%">'; $html = '<tr><td colspan="2"><table width="100%">';
// get all enclosed answers // get all enclosed answers
$blankList = array(); $blankList = [];
foreach ($this->answer as $i => $answer) { foreach ($this->answer as $i => $answer) {
$blankList[] = '['.$answer.']'; $blankList[] = '['.$answer.']';
} }
@ -440,7 +440,7 @@ class ScormAnswerFillInBlanks extends Answer
$js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
$js .= $jstmpw; $js .= $jstmpw;
return array($js, $html); return [$js, $html];
} }
} }
@ -467,7 +467,7 @@ class ScormAnswerMatching extends Answer
$nbrAnswers = $this->selectNbrAnswers(); $nbrAnswers = $this->selectNbrAnswers();
$cpt1 = 'A'; $cpt1 = 'A';
$cpt2 = 1; $cpt2 = 1;
$Select = array(); $Select = [];
$qId = $this->questionJSId; $qId = $this->questionJSId;
$s = ''; $s = '';
$jstmp = ''; $jstmp = '';
@ -540,7 +540,7 @@ class ScormAnswerMatching extends Answer
$html .= $s; $html .= $s;
$html .= '</table></td></tr>'."\n"; $html .= '</table></td></tr>'."\n";
return array($js, $html); return [$js, $html];
} }
} }
@ -576,7 +576,7 @@ class ScormAnswerFree extends Answer
$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
return array($js, $html); return [$js, $html];
} }
$html .= '<textarea minlength="20" name="'.$identifier.'" id="'.$identifier.'" ></textarea>'; $html .= '<textarea minlength="20" name="'.$identifier.'" id="'.$identifier.'" ></textarea>';
@ -587,7 +587,7 @@ class ScormAnswerFree extends Answer
$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";'; $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";';
$js .= $jstmpw; $js .= $jstmpw;
return array($js, $html); return [$js, $html];
} }
} }
@ -679,7 +679,7 @@ HTML;
// currently the free answers cannot be displayed, so ignore the textarea // currently the free answers cannot be displayed, so ignore the textarea
$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
return array($js, $html); return [$js, $html];
} }
} }
@ -791,7 +791,7 @@ class ScormAssessmentItem
* Start the itemBody * Start the itemBody
* *
*/ */
function start_js() public function start_js()
{ {
$js = '<script type="text/javascript" src="assets/api_wrapper.js"></script>'; $js = '<script type="text/javascript" src="assets/api_wrapper.js"></script>';
if ($this->standalone) { if ($this->standalone) {
@ -803,7 +803,7 @@ class ScormAssessmentItem
/** /**
* Common JS functions * Common JS functions
*/ */
function common_js() public function common_js()
{ {
$js = 'var questions = new Array();'; $js = 'var questions = new Array();';
$js .= 'var questions_answers = new Array();'; $js .= 'var questions_answers = new Array();';
@ -857,7 +857,7 @@ class ScormAssessmentItem
* End the itemBody part. * End the itemBody part.
* *
*/ */
function end_js() public function end_js()
{ {
if ($this->standalone) { if ($this->standalone) {
return '</script>'; return '</script>';
@ -870,7 +870,7 @@ class ScormAssessmentItem
* Start the itemBody * Start the itemBody
* *
*/ */
function start_body() public function start_body()
{ {
if ($this->standalone) { if ($this->standalone) {
return '<body><form id="dokeos_scorm_form" method="post" action="">'; return '<body><form id="dokeos_scorm_form" method="post" action="">';
@ -883,7 +883,7 @@ class ScormAssessmentItem
* End the itemBody part. * End the itemBody part.
* *
*/ */
function end_body() public function end_body()
{ {
if ($this->standalone) { if ($this->standalone) {
return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
@ -897,7 +897,7 @@ class ScormAssessmentItem
* This is a default behaviour, some classes may want to override this. * This is a default behaviour, some classes may want to override this.
* @return string|array A string, the XML flow for an Item. * @return string|array A string, the XML flow for an Item.
*/ */
function export() public function export()
{ {
list($js, $html) = $this->question->export(); list($js, $html) = $this->question->export();
if ($this->standalone) { if ($this->standalone) {
@ -915,7 +915,7 @@ class ScormAssessmentItem
. $this->end_page(); . $this->end_page();
return $res; return $res;
} else { } else {
return array($js, $html); return [$js, $html];
} }
} }
} }
@ -970,7 +970,7 @@ class ScormSection
* This opens the <item> block, with correct attributes. * This opens the <item> block, with correct attributes.
* *
*/ */
function start_page() public function start_page()
{ {
$charset = 'UTF-8'; $charset = 'UTF-8';
$head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>'; $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>';
@ -982,7 +982,7 @@ class ScormSection
* End the XML flow, closing the </item> tag. * End the XML flow, closing the </item> tag.
* *
*/ */
function end_page() public function end_page()
{ {
return '</html>'; return '</html>';
} }
@ -990,7 +990,7 @@ class ScormSection
/** /**
* Start document header * Start document header
*/ */
function start_header() public function start_header()
{ {
return '<head>'; return '<head>';
} }
@ -1083,7 +1083,7 @@ class ScormSection
* End the itemBody part. * End the itemBody part.
* *
*/ */
function end_js() public function end_js()
{ {
return '</script>'; return '</script>';
} }
@ -1092,7 +1092,7 @@ class ScormSection
* Start the itemBody * Start the itemBody
* *
*/ */
function start_body() public function start_body()
{ {
return '<body>'. return '<body>'.
'<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>". '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>".
@ -1104,7 +1104,7 @@ class ScormSection
* End the itemBody part. * End the itemBody part.
* *
*/ */
function end_body() public function end_body()
{ {
return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
} }
@ -1117,7 +1117,7 @@ class ScormSection
* @param $standalone: Boolean stating if it should be exported as a stand-alone question * @param $standalone: Boolean stating if it should be exported as a stand-alone question
* @return string string, the XML flow for an Item. * @return string string, the XML flow for an Item.
*/ */
function export() public function export()
{ {
global $charset; global $charset;
@ -1161,7 +1161,7 @@ class ScormSection
* Export the questions, as a succession of <items> * Export the questions, as a succession of <items>
* @author Amand Tihon <amand@alrj.org> * @author Amand Tihon <amand@alrj.org>
*/ */
function export_questions() public function export_questions()
{ {
$js = $html = ""; $js = $html = "";
$js_id = 0; $js_id = 0;
@ -1172,6 +1172,6 @@ class ScormSection
++$js_id; ++$js_id;
} }
return array($js, $html); return [$js, $html];
} }
} }

@ -29,14 +29,14 @@ class FreeAnswer extends Question
public function createAnswersForm($form) public function createAnswersForm($form)
{ {
$form->addElement('text', 'weighting', get_lang('Weighting')); $form->addElement('text', 'weighting', get_lang('Weighting'));
global $text, $class; global $text;
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
$form->addButtonSave($text, 'submitQuestion'); $form->addButtonSave($text, 'submitQuestion');
if (!empty($this->id)) { if (!empty($this->id)) {
$form->setDefaults(array('weighting' => float_format($this->weighting, 1))); $form->setDefaults(['weighting' => float_format($this->weighting, 1)]);
} else { } else {
if ($this->isContent == 1) { if ($this->isContent == 1) {
$form->setDefaults(array('weighting' => '10')); $form->setDefaults(['weighting' => '10']);
} }
} }
} }

@ -52,7 +52,7 @@ class GlobalMultipleAnswer extends Question
'<br /> '.Display::return_icon('fill_field.png'), '<br /> '.Display::return_icon('fill_field.png'),
$html $html
); );
$defaults = array(); $defaults = [];
$correct = 0; $correct = 0;
$answer = false; $answer = false;
if (!empty($this->id)) { if (!empty($this->id)) {
@ -66,7 +66,7 @@ class GlobalMultipleAnswer extends Question
// le nombre de r<EFBFBD>ponses est bien enregistr<EFBFBD> sous la forme int(nb) // le nombre de r<EFBFBD>ponses est bien enregistr<EFBFBD> sous la forme int(nb)
/* Ajout mise en forme nb reponse */ /* Ajout mise en forme nb reponse */
$form->addElement('hidden', 'nb_answers'); $form->addElement('hidden', 'nb_answers');
$boxes_names = array(); $boxes_names = [];
if ($nb_answers < 1) { if ($nb_answers < 1) {
$nb_answers = 1; $nb_answers = 1;
@ -131,24 +131,24 @@ class GlobalMultipleAnswer extends Question
'html_editor', 'html_editor',
'answer['.$i.']', 'answer['.$i.']',
null, null,
array(), [],
array( [
'ToolbarSet' => 'TestProposedAnswer', 'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%', 'Width' => '100%',
'Height' => '100', 'Height' => '100',
) ]
); );
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement( $form->addElement(
'html_editor', 'html_editor',
'comment['.$i.']', 'comment['.$i.']',
null, null,
array(), [],
array( [
'ToolbarSet' => 'TestProposedAnswer', 'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%', 'Width' => '100%',
'Height' => '100', 'Height' => '100',
) ]
); );
$form->addElement('html', '</tr>'); $form->addElement('html', '</tr>');
@ -196,7 +196,7 @@ class GlobalMultipleAnswer extends Question
$form->setDefaults($defaults); $form->setDefaults($defaults);
} }
} }
$form->setConstants(array('nb_answers' => $nb_answers)); $form->setConstants(['nb_answers' => $nb_answers]);
} }
/** /**

@ -152,7 +152,7 @@ function WriteFileCont($full_file_path, $content)
return false; return false;
} }
//if (!($fp = fopen(urldecode($full_file_path), 'w'))) { //if (!($fp = fopen(urldecode($full_file_path), 'w'))) {
//die('Could not open Quiz input.'); //die('Could not open Quiz input.');
//} //}
$fp = fopen(urldecode($full_file_path), 'w'); $fp = fopen(urldecode($full_file_path), 'w');
if ($fp !== false) { if ($fp !== false) {
@ -172,14 +172,14 @@ function WriteFileCont($full_file_path, $content)
function GetImgName($imageTag) function GetImgName($imageTag)
{ {
// Select src tag from img tag. // Select src tag from img tag.
$match = array(); $match = [];
//preg_match('/(src=(["\'])1.*(["\'])1)/i', $imageTag, $match); //src //preg_match('/(src=(["\'])1.*(["\'])1)/i', $imageTag, $match); //src
preg_match('/src(\s)*=(\s)*[\'"]([^\'"]*)[\'"]/i', $imageTag, $match); //get the img src as contained between " or ' preg_match('/src(\s)*=(\s)*[\'"]([^\'"]*)[\'"]/i', $imageTag, $match); //get the img src as contained between " or '
//list($key, $srctag) = each($match); //list($key, $srctag) = each($match);
$src = $match[3]; $src = $match[3];
//$src = substr($srctag, 5, (strlen($srctag) - 7)); //$src = substr($srctag, 5, (strlen($srctag) - 7));
if (stristr($src, 'http') === false) { if (stristr($src, 'http') === false) {
// Valid or invalid image name. // Valid or invalid image name.
if ($src == '') { if ($src == '') {
return ''; return '';
} else { } else {
@ -204,12 +204,12 @@ function GetImgName($imageTag)
function GetSrcName($imageTag) function GetSrcName($imageTag)
{ {
// Select src tag from img tag. // Select src tag from img tag.
$match = array(); $match = [];
preg_match("|(src=\".*\" )|U", $imageTag, $match); //src preg_match("|(src=\".*\" )|U", $imageTag, $match); //src
list(, $srctag) = each($match); list(, $srctag) = each($match);
$src = substr($srctag, 5, (strlen($srctag) - 7)); $src = substr($srctag, 5, (strlen($srctag) - 7));
if (stristr($src, 'http') === false) { if (stristr($src, 'http') === false) {
// valid or invalid image name // valid or invalid image name
return $src; return $src;
} else { } else {
return ''; return '';
@ -226,10 +226,10 @@ function GetSrcName($imageTag)
function GetImgParams($fname, $fpath, &$imgparams, &$imgcount) function GetImgParams($fname, $fpath, &$imgparams, &$imgcount)
{ {
// Select img tags from context. // Select img tags from context.
$imgparams = array(); $imgparams = [];
//phpinfo(); //phpinfo();
$contents = ReadFileCont("$fpath"."$fname"); $contents = ReadFileCont("$fpath"."$fname");
$matches = array(); $matches = [];
preg_match_all('(<img .*>)', $contents, $matches); preg_match_all('(<img .*>)', $contents, $matches);
$imgcount = 0; $imgcount = 0;
while (list(, $match) = each($matches)) { while (list(, $match) = each($matches)) {
@ -269,7 +269,7 @@ function GenerateHiddenList($imgparams)
function myarraysearch(&$array, $node) function myarraysearch(&$array, $node)
{ {
$match = false; $match = false;
$tmp_array = array(); $tmp_array = [];
for ($i = 0; $i < count($array); $i++) { for ($i = 0; $i < count($array); $i++) {
if (!strcmp($array[$i], $node)) { if (!strcmp($array[$i], $node)) {
$match = $node; $match = $node;
@ -302,7 +302,7 @@ function CheckImageName(&$imgparams, $string)
function ReplaceImgTag($content) function ReplaceImgTag($content)
{ {
$newcontent = $content; $newcontent = $content;
$matches = array(); $matches = [];
preg_match_all('(<img .*>)', $content, $matches); preg_match_all('(<img .*>)', $content, $matches);
while (list(, $match) = each($matches)) { while (list(, $match) = each($matches)) {
while (list(, $imageTag) = each($match)) { while (list(, $imageTag) = each($match)) {
@ -340,7 +340,7 @@ function FillFolderName($name, $nsize)
*/ */
function GenerateHpFolder($folder) function GenerateHpFolder($folder)
{ {
$filelist = array(); $filelist = [];
if ($dir = @opendir($folder)) { if ($dir = @opendir($folder)) {
while (($file = readdir($dir)) !== false) { while (($file = readdir($dir)) !== false) {
if ($file != '.') { if ($file != '.') {
@ -427,7 +427,7 @@ function CheckSubFolder($path)
function HotPotGCt($folder, $flag, $user_id) function HotPotGCt($folder, $flag, $user_id)
{ {
// Garbage Collector // Garbage Collector
$filelist = array(); $filelist = [];
if ($dir = @opendir($folder)) { if ($dir = @opendir($folder)) {
while (($file = readdir($dir)) !== false) { while (($file = readdir($dir)) !== false) {
if ($file != '.') { if ($file != '.') {

@ -20,16 +20,16 @@ if (!api_is_allowed_to_edit(null, true)) {
} }
if (api_is_in_gradebook()) { if (api_is_in_gradebook()) {
$interbreadcrumb[] = array( $interbreadcrumb[] = [
'url' => Category::getUrl(), 'url' => Category::getUrl(),
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); ];
} }
// The breadcrumbs. // The breadcrumbs.
$interbreadcrumb[] = array( $interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'.exercise/exercise.php?'.api_get_cidreq(), 'url' => api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq(),
'name' => get_lang('Exercises') 'name' => get_lang('Exercises')
); ];
$is_allowedToEdit = api_is_allowed_to_edit(null, true); $is_allowedToEdit = api_is_allowed_to_edit(null, true);
@ -88,7 +88,7 @@ $form = new FormValidator(
'post', 'post',
api_get_self()."?".api_get_cidreq(), api_get_self()."?".api_get_cidreq(),
null, null,
array('enctype' => 'multipart/form-data') ['enctype' => 'multipart/form-data']
); );
$form->addElement('header', $nameTools); $form->addElement('header', $nameTools);
$form->addElement('hidden', 'uploadPath'); $form->addElement('hidden', 'uploadPath');

@ -44,7 +44,7 @@ if (empty($hotpotatoes_path)) {
} }
if (!$is_allowedToEdit) { if (!$is_allowedToEdit) {
// api_not_allowed(); // api_not_allowed();
} }
if (!empty($_REQUEST['path'])) { if (!empty($_REQUEST['path'])) {
@ -99,13 +99,13 @@ $nameTools = get_lang('Results');
if ($is_allowedToEdit || $is_tutor) { if ($is_allowedToEdit || $is_tutor) {
$nameTools = get_lang('StudentScore'); $nameTools = get_lang('StudentScore');
$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises')); $interbreadcrumb[] = ["url" => "exercise.php", "name" => get_lang('Exercises')];
$objExerciseTmp = new Exercise(); $objExerciseTmp = new Exercise();
/*if ($objExerciseTmp->read($exercise_id)) { /*if ($objExerciseTmp->read($exercise_id)) {
$interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exercise_id, "name" => $objExerciseTmp->name); $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exercise_id, "name" => $objExerciseTmp->name);
}*/ }*/
} else { } else {
$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises')); $interbreadcrumb[] = ["url" => "exercise.php", "name" => get_lang('Exercises')];
$objExerciseTmp = new Exercise(); $objExerciseTmp = new Exercise();
/*if ($objExerciseTmp->read($exercise_id)) { /*if ($objExerciseTmp->read($exercise_id)) {
$nameTools = get_lang('Results').': '.$objExerciseTmp->name; $nameTools = get_lang('Results').': '.$objExerciseTmp->name;
@ -113,7 +113,7 @@ if ($is_allowedToEdit || $is_tutor) {
} }
Display :: display_header($nameTools); Display :: display_header($nameTools);
$actions = Display::div($actions, array('class'=> 'actions')); $actions = Display::div($actions, ['class'=> 'actions']);
$extra = '<script> $extra = '<script>
$(document).ready(function() { $(document).ready(function() {
@ -148,11 +148,11 @@ $(document).ready(function() {
</script>'; </script>';
$extra .= '<div id="dialog-confirm" title="'.get_lang("ConfirmYourChoice").'">'; $extra .= '<div id="dialog-confirm" title="'.get_lang("ConfirmYourChoice").'">';
$form = new FormValidator('report', 'post', null, null, array('class' => 'form-vertical')); $form = new FormValidator('report', 'post', null, null, ['class' => 'form-vertical']);
$form->addElement('radio', 'export_format', null, get_lang('ExportAsCSV'), 'csv', array('id' => 'export_format_csv_label')); $form->addElement('radio', 'export_format', null, get_lang('ExportAsCSV'), 'csv', ['id' => 'export_format_csv_label']);
//$form->addElement('radio', 'export_format', null, get_lang('ExportAsXLS'), 'xls', array('id' => 'export_format_xls_label')); //$form->addElement('radio', 'export_format', null, get_lang('ExportAsXLS'), 'xls', array('id' => 'export_format_xls_label'));
//$form->addElement('checkbox', 'load_extra_data', null, get_lang('LoadExtraData'), '0', array('id' => 'export_format_xls_label')); //$form->addElement('checkbox', 'load_extra_data', null, get_lang('LoadExtraData'), '0', array('id' => 'export_format_xls_label'));
$form->setDefaults(array('export_format' => 'csv')); $form->setDefaults(['export_format' => 'csv']);
$extra .= $form->returnForm(); $extra .= $form->returnForm();
$extra .= '</div>'; $extra .= '</div>';
@ -168,7 +168,7 @@ $action_links = '';
// Generating group list // Generating group list
$group_list = GroupManager::get_group_list(); $group_list = GroupManager::get_group_list();
$group_parameters = array('group_all:'.get_lang('All'), 'group_none:'.get_lang('None')); $group_parameters = ['group_all:'.get_lang('All'), 'group_none:'.get_lang('None')];
foreach ($group_list as $group) { foreach ($group_list as $group) {
$group_parameters[] = $group['id'].':'.$group['name']; $group_parameters[] = $group['id'].':'.$group['name'];
@ -179,7 +179,7 @@ if (!empty($group_parameters)) {
if ($is_allowedToEdit || $is_tutor) { if ($is_allowedToEdit || $is_tutor) {
// The order is important you need to check the the $column variable in the model.ajax.php file // The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array( $columns = [
get_lang('FirstName'), get_lang('FirstName'),
get_lang('LastName'), get_lang('LastName'),
get_lang('LoginName'), get_lang('LoginName'),
@ -187,33 +187,33 @@ if ($is_allowedToEdit || $is_tutor) {
get_lang('StartDate'), get_lang('StartDate'),
get_lang('Score'), get_lang('Score'),
get_lang('Actions') get_lang('Actions')
); ];
// Column config // Column config
// @todo fix search firstname/lastname that doesn't work. rmove search for the moment // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
$column_model = array( $column_model = [
array('name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'false'), ['name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'false'],
array( [
'name' => 'lastname', 'name' => 'lastname',
'index' => 'lastname', 'index' => 'lastname',
'width' => '50', 'width' => '50',
'align' => 'left', 'align' => 'left',
'formatter' => 'action_formatter', 'formatter' => 'action_formatter',
'search' => 'false', 'search' => 'false',
), ],
array( [
'name' => 'login', 'name' => 'login',
'hidden' => 'true', 'hidden' => 'true',
'index' => 'username', 'index' => 'username',
'width' => '40', 'width' => '40',
'align' => 'left', 'align' => 'left',
'search' => 'false', 'search' => 'false',
), ],
array('name' => 'group_name', 'index' => 'group_id', 'width' => '40', 'align' => 'left', 'search' => 'false'), ['name' => 'group_name', 'index' => 'group_id', 'width' => '40', 'align' => 'left', 'search' => 'false'],
array('name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'), ['name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'],
array('name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'), ['name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'],
array('name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'), ['name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'],
); ];
$action_links = ' $action_links = '
// add username as title in lastname filed - ref 4226 // add username as title in lastname filed - ref 4226
@ -227,19 +227,19 @@ if ($is_allowedToEdit || $is_tutor) {
}'; }';
} else { } else {
//The order is important you need to check the the $column variable in the model.ajax.php file //The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array( $columns = [
get_lang('StartDate'), get_lang('StartDate'),
get_lang('Score'), get_lang('Score'),
get_lang('Actions') get_lang('Actions')
); ];
//Column config //Column config
// @todo fix search firstname/lastname that doesn't work. rmove search for the moment // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
$column_model = array( $column_model = [
array('name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'), ['name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'],
array('name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'), ['name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'],
array('name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'), ['name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'],
); ];
} }
//Autowidth //Autowidth
@ -296,11 +296,12 @@ $(function() {
$columns, $columns,
$column_model, $column_model,
$extra_params, $extra_params,
array(), [],
$action_links, $action_links,
true true
); );
if ($is_allowedToEdit || $is_tutor) { ?> if ($is_allowedToEdit || $is_tutor) {
?>
//setSearchSelect("status"); //setSearchSelect("status");
// //
//view:true, del:false, add:false, edit:false, excel:true} //view:true, del:false, add:false, edit:false, excel:true}
@ -322,7 +323,8 @@ $(function() {
var sgrid = $("#results")[0]; var sgrid = $("#results")[0];
sgrid.triggerToolbar(); sgrid.triggerToolbar();
<?php } ?> <?php
} ?>
}); });
</script> </script>
<form id="export_report_form" method="post" action="hotpotatoes_exercise_report.php?<?php echo api_get_cidreq(); ?>"> <form id="export_report_form" method="post" action="hotpotatoes_exercise_report.php?<?php echo api_get_cidreq(); ?>">

@ -9,10 +9,10 @@
class HotpotatoesExerciseResult class HotpotatoesExerciseResult
{ {
//stores the list of exercises //stores the list of exercises
private $exercises_list = array(); private $exercises_list = [];
//stores the results //stores the results
private $results = array(); private $results = [];
/** /**
* Gets the results of all students (or just one student if access is limited) * Gets the results of all students (or just one student if access is limited)
@ -23,7 +23,7 @@ class HotpotatoesExerciseResult
*/ */
public function getExercisesReporting($document_path, $hotpotato_name) public function getExercisesReporting($document_path, $hotpotato_name)
{ {
$return = array(); $return = [];
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
@ -61,14 +61,14 @@ class HotpotatoesExerciseResult
ORDER BY c_id ASC, exe_date ASC"; ORDER BY c_id ASC, exe_date ASC";
} }
$results = array(); $results = [];
$resx = Database::query($sql); $resx = Database::query($sql);
while ($rowx = Database::fetch_array($resx, 'ASSOC')) { while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
$results[] = $rowx; $results[] = $rowx;
} }
$hpresults = array(); $hpresults = [];
$resx = Database::query($sql); $resx = Database::query($sql);
while ($rowx = Database::fetch_array($resx, 'ASSOC')) { while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
$hpresults[] = $rowx; $hpresults[] = $rowx;
@ -77,7 +77,7 @@ class HotpotatoesExerciseResult
// Print the Result of Hotpotatoes Tests // Print the Result of Hotpotatoes Tests
if (is_array($hpresults)) { if (is_array($hpresults)) {
for ($i = 0; $i < sizeof($hpresults); $i++) { for ($i = 0; $i < sizeof($hpresults); $i++) {
$return[$i] = array(); $return[$i] = [];
$title = GetQuizName($hpresults[$i]['exe_name'], $document_path); $title = GetQuizName($hpresults[$i]['exe_name'], $document_path);
if ($title == '') { if ($title == '') {
$title = basename($hpresults[$i]['exe_name']); $title = basename($hpresults[$i]['exe_name']);
@ -141,11 +141,11 @@ class HotpotatoesExerciseResult
// Results // Results
foreach ($this->results as $row) { foreach ($this->results as $row) {
if (api_is_western_name_order()) { if (api_is_western_name_order()) {
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
} else { } else {
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
} }
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';

@ -48,21 +48,20 @@ class HotSpot extends Question
$form->addElement( $form->addElement(
'file', 'file',
'imageUpload', 'imageUpload',
array( [
'<img src="'.$icon.'" />', '<img src="'.$icon.'" />',
get_lang('UploadJpgPicture'), get_lang('UploadJpgPicture'),
) ]
); );
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
// Saving a question // Saving a question
$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
//$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
$form->addRule( $form->addRule(
'imageUpload', 'imageUpload',
get_lang('OnlyImagesAllowed'), get_lang('OnlyImagesAllowed'),
'filetype', 'filetype',
array('jpg', 'jpeg', 'png', 'gif') ['jpg', 'jpeg', 'png', 'gif']
); );
$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
} else { } else {
@ -92,7 +91,7 @@ class HotSpot extends Question
return false; return false;
} }
function createAnswersForm($form) public function createAnswersForm($form)
{ {
// nothing // nothing
} }
@ -136,7 +135,6 @@ class HotSpotDelineation extends HotSpot
*/ */
public function processCreation($form, $exercise) public function processCreation($form, $exercise)
{ {
$file_info = $form->getSubmitValue('imageUpload');
parent::processCreation($form, $exercise); parent::processCreation($form, $exercise);
} }

@ -18,10 +18,10 @@ header('Content-Type: text/html; charset=UTF-8');
$file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php'); $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php');
foreach ($file as &$value) { foreach ($file as &$value) {
$variable = explode('=', $value, 2); $variable = explode('=', $value, 2);
if (count($variable) > 1) { if (count($variable) > 1) {
$variable = substr(trim($variable[0]), 1); $variable = substr(trim($variable[0]), 1);
$variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' '; $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' ';
echo $variable; echo $variable;
} }
} }

@ -162,7 +162,7 @@ if ($submitAnswers || $buttonBack) {
$select_question = $_POST['select_question']; $select_question = $_POST['select_question'];
$try = isset($_POST['try']) ? $_POST['try'] : []; $try = isset($_POST['try']) ? $_POST['try'] : [];
$url = $_POST['url']; $url = $_POST['url'];
$destination = array(); $destination = [];
$threadhold1 = $_POST['threadhold1']; $threadhold1 = $_POST['threadhold1'];
$threadhold2 = $_POST['threadhold2']; $threadhold2 = $_POST['threadhold2'];
@ -374,13 +374,13 @@ if ($modifyAnswers) {
} }
} }
$reponse = array(); $reponse = [];
$comment = array(); $comment = [];
$weighting = array(); $weighting = [];
$hotspot_coordinates = array(); $hotspot_coordinates = [];
$hotspot_type = array(); $hotspot_type = [];
$destination_items = array(); $destination_items = [];
$destination = array(); $destination = [];
for ($i = 1; $i <= $nbrAnswers; $i++) { for ($i = 1; $i <= $nbrAnswers; $i++) {
$reponse[$i] = $objAnswer->selectAnswer($i); $reponse[$i] = $objAnswer->selectAnswer($i);
@ -433,7 +433,7 @@ if ($modifyAnswers) {
$url_noerror = $destination_items[4]; $url_noerror = $destination_items[4];
} }
$_SESSION['tmp_answers'] = array(); $_SESSION['tmp_answers'] = [];
$_SESSION['tmp_answers']['answer'] = $reponse; $_SESSION['tmp_answers']['answer'] = $reponse;
if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
@ -533,7 +533,7 @@ if ($modifyAnswers) {
} }
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
$hotspot_colors = array( $hotspot_colors = [
"", "",
"#4271B5", "#4271B5",
"#FE8E16", "#FE8E16",
@ -547,9 +547,9 @@ if ($modifyAnswers) {
"#F4EB24", "#F4EB24",
"#ED2024", "#ED2024",
"#3B3B3B" "#3B3B3B"
); ];
} else { } else {
$hotspot_colors = array( $hotspot_colors = [
"", // $i starts from 1 on next loop (ugly fix) "", // $i starts from 1 on next loop (ugly fix)
"#4271B5", "#4271B5",
"#FE8E16", "#FE8E16",
@ -564,7 +564,7 @@ if ($modifyAnswers) {
"#ED2024", "#ED2024",
"#3B3B3B", "#3B3B3B",
"#F7BDE2" "#F7BDE2"
); ];
} }
Display::tag( Display::tag(
@ -576,28 +576,30 @@ if ($modifyAnswers) {
echo Display::return_message($msgErr, 'normal'); //main API echo Display::return_message($msgErr, 'normal'); //main API
} }
$hotspot_admin_url = api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&hotspotadmin=' $hotspot_admin_url = api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&hotspotadmin='.$modifyAnswers.'&exerciseId='.$exerciseId; ?>
.$modifyAnswers.'&exerciseId='.$exerciseId.'&'.api_get_cidreq();
?>
<form method="post" action="<?php echo $hotspot_admin_url; ?>" class="form-horizontal" id="frm_exercise" <form method="post" action="<?php echo $hotspot_admin_url; ?>" class="form-horizontal" id="frm_exercise"
name="frm_exercise"> name="frm_exercise">
<div class="form-group"> <div class="form-group">
<div class="col-sm-12"> <div class="col-sm-12">
<?php if ($answerType == HOT_SPOT_DELINEATION) { ?> <?php if ($answerType == HOT_SPOT_DELINEATION) {
?>
<button type="submit" class="btn btn-danger" name="lessAnswers" value="lessAnswers"> <button type="submit" class="btn btn-danger" name="lessAnswers" value="lessAnswers">
<em class="fa fa-trash"></em> <?php echo get_lang('LessOAR'); ?> <em class="fa fa-trash"></em> <?php echo get_lang('LessOAR'); ?>
</button> </button>
<button type="submit" class="btn btn-primary" name="moreOARAnswers" value="moreOARAnswers"> <button type="submit" class="btn btn-primary" name="moreOARAnswers" value="moreOARAnswers">
<em class="fa fa-plus"></em> <?php echo get_lang('MoreOAR'); ?> <em class="fa fa-plus"></em> <?php echo get_lang('MoreOAR'); ?>
</button> </button>
<?php } else { ?> <?php
} else {
?>
<button type="submit" class="btn btn-danger" name="lessAnswers" value="lessAnswers"> <button type="submit" class="btn btn-danger" name="lessAnswers" value="lessAnswers">
<em class="fa fa-trash"></em> <?php echo get_lang('LessHotspots'); ?> <em class="fa fa-trash"></em> <?php echo get_lang('LessHotspots'); ?>
</button> </button>
<button type="submit" class="btn btn-primary" name="moreAnswers" value="moreAnswers"> <button type="submit" class="btn btn-primary" name="moreAnswers" value="moreAnswers">
<em class="fa fa-plus"></em> <?php echo get_lang('MoreHotspots'); ?> <em class="fa fa-plus"></em> <?php echo get_lang('MoreHotspots'); ?>
</button> </button>
<?php } ?> <?php
} ?>
<button type="submit" class="btn btn-primary" name="submitAnswers" value="submitAnswers"> <button type="submit" class="btn btn-primary" name="submitAnswers" value="submitAnswers">
<em class="fa fa-save"></em> <?php echo get_lang('AddQuestionToExercise'); ?> <em class="fa fa-save"></em> <?php echo get_lang('AddQuestionToExercise'); ?>
</button> </button>
@ -619,82 +621,80 @@ if ($modifyAnswers) {
} }
} else { } else {
echo '<th colspan="2">'.get_lang('Comment').'</th>'; echo '<th colspan="2">'.get_lang('Comment').'</th>';
} } ?>
?>
<th><?php echo get_lang('QuestionWeighting'); ?> *</th> <th><?php echo get_lang('QuestionWeighting'); ?> *</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$list = new LearnpathList(api_get_user_id()); $list = new LearnpathList(api_get_user_id());
// Loading list of LPs // Loading list of LPs
$flat_list = $list->get_flat_list(); $flat_list = $list->get_flat_list();
for ($i = 1; $i <= $nbrAnswers; $i++) { for ($i = 1; $i <= $nbrAnswers; $i++) {
// is an delineation // is an delineation
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
$option_lp = ''; $option_lp = '';
// setting the LP // setting the LP
$isSelected = false; $isSelected = false;
foreach ($flat_list as $id => $details) { foreach ($flat_list as $id => $details) {
$selected = ''; $selected = '';
if (isset($lp[$i]) && $id == $lp[$i]) { if (isset($lp[$i]) && $id == $lp[$i]) {
$isSelected = true; $isSelected = true;
$selected = 'selected="selected"'; $selected = 'selected="selected"';
} }
$option_lp .= '<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>'; $option_lp .= '<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>';
} }
if ($isSelected) { if ($isSelected) {
$option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp; $option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp;
} else { } else {
$option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP') $option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP')
.'</option>'.$option_lp; .'</option>'.$option_lp;
} }
// Feedback SELECT // Feedback SELECT
$question_list = $objExercise->selectQuestionList(); $question_list = $objExercise->selectQuestionList();
$option_feed = ''; $option_feed = '';
$option_feed .= '<option value="0">'.get_lang('SelectTargetQuestion').'</option>'; $option_feed .= '<option value="0">'.get_lang('SelectTargetQuestion').'</option>';
foreach ($question_list as $key => $questionid) { foreach ($question_list as $key => $questionid) {
$selected = ''; $selected = '';
$question = Question::read($questionid); $question = Question::read($questionid);
$val = 'Q'.$key.' :'.substrwords($question->selectTitle(), ICON_SIZE_SMALL); $val = 'Q'.$key.' :'.substrwords($question->selectTitle(), ICON_SIZE_SMALL);
if (isset($select_question[$i]) && $questionid == $select_question[$i]) { if (isset($select_question[$i]) && $questionid == $select_question[$i]) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
} }
$option_feed .= '<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>'; $option_feed .= '<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>';
} }
if (isset($select_question[$i]) && $select_question[$i] == -1) { if (isset($select_question[$i]) && $select_question[$i] == -1) {
$option_feed .= '<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>'; $option_feed .= '<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>';
} else { } else {
$option_feed .= '<option value="-1">'.get_lang('ExitTest').'</option>'; $option_feed .= '<option value="-1">'.get_lang('ExitTest').'</option>';
} }
//-------- IF it is a delineation //-------- IF it is a delineation
if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'delineation') { if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'delineation') {
$option1 = $option2 = $option3 = ''; $option1 = $option2 = $option3 = '';
for ($k = 1; $k <= 100; $k++) { for ($k = 1; $k <= 100; $k++) {
$selected1 = $selected2 = $selected3 = ''; $selected1 = $selected2 = $selected3 = '';
if ($k == $threadhold1[$i]) { if ($k == $threadhold1[$i]) {
$selected1 = 'selected="selected"'; $selected1 = 'selected="selected"';
} }
if ($k == $threadhold2[$i]) { if ($k == $threadhold2[$i]) {
$selected2 = 'selected="selected"'; $selected2 = 'selected="selected"';
} }
if ($k == $threadhold3[$i]) { if ($k == $threadhold3[$i]) {
$selected3 = 'selected="selected"'; $selected3 = 'selected="selected"';
} }
$option1 .= '<option '.$selected1.' >'.$k.' % </option>'; $option1 .= '<option '.$selected1.' >'.$k.' % </option>';
$option2 .= '<option '.$selected2.' >'.$k.' % </option>'; $option2 .= '<option '.$selected2.' >'.$k.' % </option>';
$option3 .= '<option '.$selected3.'>'.$k.' %</option>'; $option3 .= '<option '.$selected3.'>'.$k.' %</option>';
} } ?>
?>
<tr> <tr>
<td> <td>
<span class="fa fa-square fa-2x" aria-hidden="true" <span class="fa fa-square fa-2x" aria-hidden="true"
@ -732,18 +732,18 @@ if ($modifyAnswers) {
</p> </p>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="delineation"/> <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="delineation"/>
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php
echo(empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); echo(empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>"/>
?>"/>
</td> </td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td> <td>
<div class="checkbox"> <div class="checkbox">
<p> <p>
<label> <label>
<input type="checkbox" class="checkbox" <input type="checkbox" class="checkbox"
name="<?php echo 'try['.$i; ?>]" <?php if ($try[$i] == 1) { name="<?php echo 'try['.$i; ?>]" <?php if ($try[$i] == 1) {
echo 'checked'; echo 'checked';
} ?> /> } ?> />
<?php echo get_lang('TryAgain'); ?> <?php echo get_lang('TryAgain'); ?>
</label> </label>
</p> </p>
@ -766,12 +766,14 @@ if ($modifyAnswers) {
</select> </select>
</p> </p>
</td> </td>
<?php } else { ?> <?php
} else {
?>
<td> &nbsp;</td> <td> &nbsp;</td>
<?php <?php
} }
} elseif (false) { } elseif (false) {
?> ?>
<tr> <tr>
<th colspan="2"><?php echo get_lang('IfNoError'); ?></th> <th colspan="2"><?php echo get_lang('IfNoError'); ?></th>
<th colspan="3"><?php echo get_lang('Feedback'); ?></th> <th colspan="3"><?php echo get_lang('Feedback'); ?></th>
@ -791,7 +793,8 @@ if ($modifyAnswers) {
name="comment[<?php echo $i; ?>]" name="comment[<?php echo $i; ?>]"
style="width: 100%"><?php echo Security::remove_XSS($comment[$i]); ?></textarea> style="width: 100%"><?php echo Security::remove_XSS($comment[$i]); ?></textarea>
</td> </td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td> <td>
<table> <table>
<tr> <tr>
@ -802,8 +805,8 @@ if ($modifyAnswers) {
<input type="checkbox" class="checkbox" <input type="checkbox" class="checkbox"
name="<?php echo 'try[' name="<?php echo 'try['
.$i; ?>]" <?php if ($try[$i] == 1) { .$i; ?>]" <?php if ($try[$i] == 1) {
echo 'checked'; echo 'checked';
} ?> /> } ?> />
<?php echo get_lang('TryAgain'); ?> <?php echo get_lang('TryAgain'); ?>
</label> </label>
</p> </p>
@ -830,29 +833,37 @@ if ($modifyAnswers) {
</tr> </tr>
</table> </table>
</td> </td>
<?php } else { ?> <?php
} else {
?>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php } ?> <?php
} ?>
</tr> </tr>
<?php <?php
} elseif ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') { } elseif ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') {
// if it's an OAR // if it's an OAR
if ($i == 2) { if ($i == 2) {
?> ?>
<tr> <tr>
<th width="5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></th> <th width="5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></th>
<th><?php echo get_lang('OAR'); ?>*</th> <th><?php echo get_lang('OAR'); ?>*</th>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<th colspan="2"><?php echo get_lang('Comment'); ?></th> <th colspan="2"><?php echo get_lang('Comment'); ?></th>
<th><?php if ($answerType == HOT_SPOT_DELINEATION) { <th><?php if ($answerType == HOT_SPOT_DELINEATION) {
echo get_lang('Scenario'); echo get_lang('Scenario');
} ?></th> } ?></th>
<?php } else { ?> <?php
} else {
?>
<th colspan="3"><?php echo get_lang('Comment'); ?></th> <th colspan="3"><?php echo get_lang('Comment'); ?></th>
<?php } ?> <?php
} ?>
<th>&nbsp;</th> <th>&nbsp;</th>
</tr> </tr>
<?php } ?> <?php
} ?>
<tr> <tr>
<td> <td>
<span class="fa fa-square fa-2x" aria-hidden="true" <span class="fa fa-square fa-2x" aria-hidden="true"
@ -871,10 +882,10 @@ if ($modifyAnswers) {
? Security::remove_XSS($comment[$i]) : ''; ?></textarea> ? Security::remove_XSS($comment[$i]) : ''; ?></textarea>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="oar"/> <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="oar"/>
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php
echo(empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); echo(empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>"/>
?>"/>
</td> </td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td> <td>
<div class="checkbox"> <div class="checkbox">
<p> <p>
@ -883,8 +894,8 @@ if ($modifyAnswers) {
name="<?php echo 'try['.$i; ?>]" <?php if (isset($try[$i]) name="<?php echo 'try['.$i; ?>]" <?php if (isset($try[$i])
&& $try[$i] == 1 && $try[$i] == 1
) { ) {
echo 'checked'; echo 'checked';
} ?> /> } ?> />
<?php echo get_lang('TryAgain'); ?> <?php echo get_lang('TryAgain'); ?>
</label> </label>
</p> </p>
@ -907,16 +918,17 @@ if ($modifyAnswers) {
</select> </select>
</p> </p>
</td> </td>
<?php } else { ?> <?php
} else {
?>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php <?php
} }
} }
//end if is delineation //end if is delineation
} else { } else {
$commentValue = isset($comment[$i]) ? $comment[$i] : null; $commentValue = isset($comment[$i]) ? $comment[$i] : null;
$responseValue = isset($reponse[$i]) ? $reponse[$i] : null; $responseValue = isset($reponse[$i]) ? $reponse[$i] : null; ?>
?>
<tr> <tr>
<td> <td>
<span class="fa fa-square fa-2x" style="color: <?php echo $hotspot_colors[$i]; ?>" <span class="fa fa-square fa-2x" style="color: <?php echo $hotspot_colors[$i]; ?>"
@ -928,38 +940,40 @@ if ($modifyAnswers) {
</td> </td>
<?php <?php
$form = new FormValidator('form_'.$i); $form = new FormValidator('form_'.$i);
$config = array( $config = [
'ToolbarSet' => 'TestProposedAnswer', 'ToolbarSet' => 'TestProposedAnswer',
'cols-size' => [0, 12, 0] 'cols-size' => [0, 12, 0]
); ];
$form->addHtmlEditor('comment['.$i.']', null, false, false, $config); $form->addHtmlEditor('comment['.$i.']', null, false, false, $config);
$renderer = $form->defaultRenderer(); $renderer = $form->defaultRenderer();
$form_template = '{content}'; $form_template = '{content}';
$renderer->setFormTemplate($form_template); $renderer->setFormTemplate($form_template);
$element_template = ' $element_template = '
{label} {label}
{element}'; {element}';
$renderer->setElementTemplate($element_template); $renderer->setElementTemplate($element_template);
$form->setDefaults(array('comment['.$i.']' => $commentValue)); $form->setDefaults(['comment['.$i.']' => $commentValue]);
$return = $form->returnForm(); $return = $form->returnForm(); ?>
?>
<td colspan="2" align="left"><?php echo $return; ?></td> <td colspan="2" align="left"><?php echo $return; ?></td>
<?php } ?> <?php
} ?>
<td> <td>
<?php <?php
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') { if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') {
?> ?>
<input type="hidden" name="weighting[<?php echo $i; ?>]" class="form-cotrol" value="0"/> <input type="hidden" name="weighting[<?php echo $i; ?>]" class="form-cotrol" value="0"/>
<?php } else { ?> <?php
} else {
?>
<input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]"
value="<?php echo(isset($weighting[$i]) ? $weighting[$i] : 10); ?>"/> value="<?php echo(isset($weighting[$i]) ? $weighting[$i] : 10); ?>"/>
<?php <?php
} }
} }
if ($answerType == HOT_SPOT) { if ($answerType == HOT_SPOT) {
?> ?>
<input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]"
value="<?php echo(isset($weighting[$i]) ? $weighting[$i] : 10); ?>"/> value="<?php echo(isset($weighting[$i]) ? $weighting[$i] : 10); ?>"/>
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]"
@ -968,62 +982,67 @@ if ($modifyAnswers) {
: $hotspot_coordinates[$i]); ?>"/> : $hotspot_coordinates[$i]); ?>"/>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" <input type="hidden" name="hotspot_type[<?php echo $i; ?>]"
value="<?php echo(empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>"/> value="<?php echo(empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>"/>
<?php } ?> <?php
} ?>
</td> </td>
</tr> </tr>
<?php <?php
} }
$list = new LearnpathList(api_get_user_id()); $list = new LearnpathList(api_get_user_id());
$flat_list = $list->get_flat_list(); $flat_list = $list->get_flat_list();
$option_lp = ''; $option_lp = '';
$isSelected = false; $isSelected = false;
foreach ($flat_list as $id => $details) { foreach ($flat_list as $id => $details) {
$selected = ''; $selected = '';
if (isset($lp_noerror) && $id == $lp_noerror) { if (isset($lp_noerror) && $id == $lp_noerror) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
$isSelected = true; $isSelected = true;
} }
$option_lp .= '<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>'; $option_lp .= '<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>';
} }
if ($isSelected) { if ($isSelected) {
$option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp; $option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp;
} else { } else {
$option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>' $option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>'
.$option_lp; .$option_lp;
} }
// Feedback SELECT // Feedback SELECT
$question_list = $objExercise->selectQuestionList(); $question_list = $objExercise->selectQuestionList();
$option_feed = ''; $option_feed = '';
$option_feed .= '<option value="0">'.get_lang('SelectTargetQuestion').'</option>'; $option_feed .= '<option value="0">'.get_lang('SelectTargetQuestion').'</option>';
$selectQuestionNoError = isset($selectQuestionNoError) ? $selectQuestionNoError : null; $selectQuestionNoError = isset($selectQuestionNoError) ? $selectQuestionNoError : null;
foreach ($question_list as $key => $questionid) { foreach ($question_list as $key => $questionid) {
$selected = ''; $selected = '';
$question = Question::read($questionid); $question = Question::read($questionid);
$val = 'Q'.$key.' :'.substrwords($question->selectTitle(), ICON_SIZE_SMALL); $val = 'Q'.$key.' :'.substrwords($question->selectTitle(), ICON_SIZE_SMALL);
if ($questionid == $selectQuestionNoError) { if ($questionid == $selectQuestionNoError) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
} }
$option_feed .= '<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>'; $option_feed .= '<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>';
} }
if ($selectQuestionNoError == -1) { if ($selectQuestionNoError == -1) {
$option_feed .= '<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>'; $option_feed .= '<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>';
} else { } else {
$option_feed .= '<option value="-1">'.get_lang('ExitTest').'</option>'; $option_feed .= '<option value="-1">'.get_lang('ExitTest').'</option>';
} }
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
?> ?>
<tr> <tr>
<th colspan="2"><?php echo get_lang('IfNoError'); ?></th> <th colspan="2"><?php echo get_lang('IfNoError'); ?></th>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<th colspan="2"><?php echo get_lang('Feedback'); ?></th> <th colspan="2"><?php echo get_lang('Feedback'); ?></th>
<th><?php echo get_lang('Scenario'); ?></th> <th><?php echo get_lang('Scenario'); ?></th>
<?php } else { ?> <?php
} else {
?>
<th colspan="3"><?php echo get_lang('Feedback'); ?></th> <th colspan="3"><?php echo get_lang('Feedback'); ?></th>
<?php } ?> <?php
} ?>
<th>&nbsp;</th> <th>&nbsp;</th>
</tr> </tr>
<tr> <tr>
@ -1034,15 +1053,16 @@ if ($modifyAnswers) {
<textarea class="form-control" wrap="virtual" rows="3" cols="25" <textarea class="form-control" wrap="virtual" rows="3" cols="25"
name="comment_noerror"><?php echo Security::remove_XSS($comment_noerror); ?></textarea> name="comment_noerror"><?php echo Security::remove_XSS($comment_noerror); ?></textarea>
</td> </td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td> <td>
<div class="checkbox"> <div class="checkbox">
<p> <p>
<label> <label>
<input type="checkbox" class="checkbox" <input type="checkbox" class="checkbox"
name="try_noerror" <?php if ($try_noerror == 1) { name="try_noerror" <?php if ($try_noerror == 1) {
echo 'checked'; echo 'checked';
} ?> /> } ?> />
<?php echo get_lang('TryAgain'); ?> <?php echo get_lang('TryAgain'); ?>
</label> </label>
</p> </p>
@ -1065,11 +1085,15 @@ if ($modifyAnswers) {
</p> </p>
</td> </td>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php } else { ?> <?php
} else {
?>
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
<?php } ?> <?php
} ?>
</tr> </tr>
<?php } ?> <?php
} ?>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -1077,9 +1101,8 @@ if ($modifyAnswers) {
<div class="col-xs-12"> <div class="col-xs-12">
<?php <?php
$swf_loaded = $answerType == HOT_SPOT_DELINEATION ? 'hotspot_delineation_admin' : 'hotspot_admin'; $swf_loaded = $answerType == HOT_SPOT_DELINEATION ? 'hotspot_delineation_admin' : 'hotspot_admin';
$height = 450; $height = 450;
$relPath = api_get_path(WEB_CODE_PATH); $relPath = api_get_path(WEB_CODE_PATH); ?>
?>
<div id="hotspot-container" class="center-block"> <div id="hotspot-container" class="center-block">
</div> </div>
</div> </div>
@ -1087,21 +1110,25 @@ if ($modifyAnswers) {
</form> </form>
<script> <script>
$(document).on('ready', function () { $(document).on('ready', function () {
<?php if ($answerType == HOT_SPOT_DELINEATION) { ?> <?php if ($answerType == HOT_SPOT_DELINEATION) {
?>
new DelineationQuestion({ new DelineationQuestion({
questionId: <?php echo $modifyAnswers ?>, questionId: <?php echo $modifyAnswers ?>,
selector: '#hotspot-container', selector: '#hotspot-container',
for: 'admin', for: 'admin',
relPath: '<?php echo $relPath ?>' relPath: '<?php echo $relPath ?>'
}); });
<?php } else { ?> <?php
} else {
?>
new HotspotQuestion({ new HotspotQuestion({
questionId: <?php echo $modifyAnswers ?>, questionId: <?php echo $modifyAnswers ?>,
selector: '#hotspot-container', selector: '#hotspot-container',
for: 'admin', for: 'admin',
relPath: '<?php echo $relPath ?>' relPath: '<?php echo $relPath ?>'
}); });
<?php } ?> <?php
} ?>
}); });
</script> </script>
<?php <?php

@ -29,7 +29,7 @@ if (isset($_GET['lang'])) {
} }
$file = file($hotspot_lang_file); $file = file($hotspot_lang_file);
$temp = array(); $temp = [];
foreach ($file as $value) { foreach ($file as $value) {
$explode = explode('=', $value); $explode = explode('=', $value);

@ -17,17 +17,17 @@ $objExercise = new Exercise();
$result = $objExercise->read($exercise_id); $result = $objExercise->read($exercise_id);
if (!$result) { if (!$result) {
api_not_allowed(true); api_not_allowed(true);
} }
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => "exercise.php?".api_get_cidreq(), "url" => "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises'), "name" => get_lang('Exercises'),
); ];
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => "admin.php?exerciseId=$exercise_id&".api_get_cidreq(), "url" => "admin.php?exerciseId=$exercise_id&".api_get_cidreq(),
"name" => $objExercise->selectTitle(true), "name" => $objExercise->selectTitle(true),
); ];
//Add the JS needed to use the jqgrid //Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js(); $htmlHeadXtra[] = api_get_jqgrid_js();
@ -41,43 +41,43 @@ $minutes = 60;
$url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes; $url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes;
//The order is important you need to check the the $column variable in the model.ajax.php file //The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score')); $columns = [get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score')];
//Column config //Column config
$column_model = array( $column_model = [
array( [
'name' => 'firstname', 'name' => 'firstname',
'index' => 'firstname', 'index' => 'firstname',
'width' => '100', 'width' => '100',
'align' => 'left', 'align' => 'left',
), ],
array( [
'name' => 'lastname', 'name' => 'lastname',
'index' => 'lastname', 'index' => 'lastname',
'width' => '100', 'width' => '100',
'align' => 'left', 'align' => 'left',
), ],
array( [
'name' => 'start_date', 'name' => 'start_date',
'index' => 'start_date', 'index' => 'start_date',
'width' => '100', 'width' => '100',
'align' => 'left', 'align' => 'left',
), ],
array( [
'name' => 'question', 'name' => 'question',
'index' => 'count_questions', 'index' => 'count_questions',
'width' => '60', 'width' => '60',
'align' => 'left', 'align' => 'left',
'sortable' => 'false', 'sortable' => 'false',
), ],
array( [
'name' => 'score', 'name' => 'score',
'index' => 'score', 'index' => 'score',
'width' => '50', 'width' => '50',
'align' => 'left', 'align' => 'left',
'sortable' => 'false', 'sortable' => 'false',
), ],
); ];
//Autowidth //Autowidth
$extra_params['autowidth'] = 'true'; $extra_params['autowidth'] = 'true';
//height auto //height auto
@ -99,7 +99,7 @@ $(function() {
$columns, $columns,
$column_model, $column_model,
$extra_params, $extra_params,
array(), [],
null, null,
true true
); );
@ -111,7 +111,7 @@ $(function() {
$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'. $actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
echo $actions = Display::div($actions, array('class'=> 'actions')); echo $actions = Display::div($actions, ['class'=> 'actions']);
echo Display::grid_html('live_stats'); echo Display::grid_html('live_stats');

@ -32,9 +32,9 @@ class Matching extends Question
*/ */
public function createAnswersForm($form) public function createAnswersForm($form)
{ {
$defaults = array(); $defaults = [];
$nb_matches = $nb_options = 2; $nb_matches = $nb_options = 2;
$matches = array(); $matches = [];
$answer = null; $answer = null;
$counter = 1; $counter = 1;
@ -123,11 +123,11 @@ class Matching extends Question
); );
} }
$editorConfig = array( $editorConfig = [
'ToolbarSet' => 'TestMatching', 'ToolbarSet' => 'TestMatching',
'Width' => '100%', 'Width' => '100%',
'Height' => '125' 'Height' => '125'
); ];
for ($i = 1; $i <= $nb_matches; ++$i) { for ($i = 1; $i <= $nb_matches; ++$i) {
$renderer = &$form->defaultRenderer(); $renderer = &$form->defaultRenderer();
@ -215,7 +215,7 @@ class Matching extends Question
$form->addHtml('</table>'); $form->addHtml('</table>');
global $text; global $text;
$group = array(); $group = [];
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
$group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true); $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true);
$group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true); $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true);
@ -231,10 +231,10 @@ class Matching extends Question
} }
$form->setConstants( $form->setConstants(
array( [
'nb_matches' => $nb_matches, 'nb_matches' => $nb_matches,
'nb_options' => $nb_options 'nb_options' => $nb_options
) ]
); );
} }

@ -32,11 +32,11 @@ class MultipleAnswer extends Question
*/ */
public function createAnswersForm($form) public function createAnswersForm($form)
{ {
$editorConfig = array( $editorConfig = [
'ToolbarSet' => 'TestProposedAnswer', 'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%', 'Width' => '100%',
'Height' => '125' 'Height' => '125'
); ];
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759. $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759.
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
@ -59,7 +59,7 @@ class MultipleAnswer extends Question
$form->addHtml($html); $form->addHtml($html);
$defaults = array(); $defaults = [];
$correct = 0; $correct = 0;
$answer = false; $answer = false;
if (!empty($this->id)) { if (!empty($this->id)) {
@ -71,7 +71,7 @@ class MultipleAnswer extends Question
} }
$form->addElement('hidden', 'nb_answers'); $form->addElement('hidden', 'nb_answers');
$boxes_names = array(); $boxes_names = [];
if ($nb_answers < 1) { if ($nb_answers < 1) {
$nb_answers = 1; $nb_answers = 1;
@ -136,7 +136,7 @@ class MultipleAnswer extends Question
$form->addHtmlEditor("comment[$i]", null, null, false, $editorConfig); $form->addHtmlEditor("comment[$i]", null, null, false, $editorConfig);
$form->addElement('text', 'weighting['.$i.']', null, array('style' => "width: 60px;", 'value' => '0')); $form->addElement('text', 'weighting['.$i.']', null, ['style' => "width: 60px;", 'value' => '0']);
$form->addHtml('</tr>'); $form->addHtml('</tr>');
} }
@ -178,13 +178,13 @@ class MultipleAnswer extends Question
$form->setDefaults($defaults); $form->setDefaults($defaults);
} }
} }
$form->setConstants(array('nb_answers' => $nb_answers)); $form->setConstants(['nb_answers' => $nb_answers]);
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function processAnswersCreation($form, $exercise) public function processAnswersCreation($form, $exercise)
{ {
$questionWeighting = $nbrGoodAnswers = 0; $questionWeighting = $nbrGoodAnswers = 0;
$objAnswer = new Answer($this->id); $objAnswer = new Answer($this->id);
@ -228,7 +228,7 @@ class MultipleAnswer extends Question
public function return_header($exercise, $counter = null, $score = null) public function return_header($exercise, $counter = null, $score = null)
{ {
$header = parent::return_header($exercise, $counter, $score); $header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class .'"> $header .= '<table class="'.$this->question_table_class.'">
<tr> <tr>
<th>'.get_lang("Choice").'</th> <th>'.get_lang("Choice").'</th>
<th>'. get_lang("ExpectedChoice").'</th> <th>'. get_lang("ExpectedChoice").'</th>

@ -51,7 +51,7 @@ class MultipleAnswerCombination extends Question
$form->addHeader(get_lang('Answers')); $form->addHeader(get_lang('Answers'));
$form->addHtml($html); $form->addHtml($html);
$defaults = array(); $defaults = [];
$correct = 0; $correct = 0;
$answer = false; $answer = false;
@ -64,7 +64,7 @@ class MultipleAnswerCombination extends Question
} }
$form->addElement('hidden', 'nb_answers'); $form->addElement('hidden', 'nb_answers');
$boxes_names = array(); $boxes_names = [];
if ($nb_answers < 1) { if ($nb_answers < 1) {
$nb_answers = 1; $nb_answers = 1;
@ -125,8 +125,8 @@ class MultipleAnswerCombination extends Question
'html_editor', 'html_editor',
'answer['.$i.']', 'answer['.$i.']',
null, null,
array(), [],
array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100') ['ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100']
); );
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
@ -134,8 +134,8 @@ class MultipleAnswerCombination extends Question
'html_editor', 'html_editor',
'comment['.$i.']', 'comment['.$i.']',
null, null,
array(), [],
array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100') ['ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100']
); );
$form->addHtml('</tr>'); $form->addHtml('</tr>');
@ -173,12 +173,12 @@ class MultipleAnswerCombination extends Question
} }
} }
$form->setConstants(array('nb_answers' => $nb_answers)); $form->setConstants(['nb_answers' => $nb_answers]);
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function processAnswersCreation($form, $exercise) public function processAnswersCreation($form, $exercise)
{ {
$questionWeighting = $nbrGoodAnswers = 0; $questionWeighting = $nbrGoodAnswers = 0;

@ -24,10 +24,10 @@ class MultipleAnswerCombinationTrueFalse extends MultipleAnswerCombination
parent::__construct(); parent::__construct();
$this->type = MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE; $this->type = MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE;
$this->isContent = $this->getIsContent(); $this->isContent = $this->getIsContent();
$this->options = array( $this->options = [
'1' => get_lang('True'), '1' => get_lang('True'),
'0' => get_lang('False'), '0' => get_lang('False'),
'2' => get_lang('DontKnow'), '2' => get_lang('DontKnow'),
); ];
} }
} }

@ -25,7 +25,7 @@ class MultipleAnswerTrueFalse extends Question
parent::__construct(); parent::__construct();
$this->type = MULTIPLE_ANSWER_TRUE_FALSE; $this->type = MULTIPLE_ANSWER_TRUE_FALSE;
$this->isContent = $this-> getIsContent(); $this->isContent = $this-> getIsContent();
$this->options = array(1 => 'True', 2 => 'False', 3 => 'DoubtScore'); $this->options = [1 => 'True', 2 => 'False', 3 => 'DoubtScore'];
} }
/** /**
@ -40,7 +40,7 @@ class MultipleAnswerTrueFalse extends Question
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$obj_ex = Session::read('objExercise'); $obj_ex = Session::read('objExercise');
$renderer = & $form->defaultRenderer(); $renderer = & $form->defaultRenderer();
$defaults = array(); $defaults = [];
$html = '<table class="table table-striped table-hover">'; $html = '<table class="table table-striped table-hover">';
$html .= '<thead>'; $html .= '<thead>';
@ -153,12 +153,12 @@ class MultipleAnswerTrueFalse extends Question
'html_editor', 'html_editor',
'comment['.$i.']', 'comment['.$i.']',
null, null,
array(), [],
array( [
'ToolbarSet' => 'TestProposedAnswer', 'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%', 'Width' => '100%',
'Height' => '100', 'Height' => '100',
) ]
); );
} }
@ -197,9 +197,9 @@ class MultipleAnswerTrueFalse extends Question
$renderer->setElementTemplate($doubtScoreInputTemplate, 'option[3]'); $renderer->setElementTemplate($doubtScoreInputTemplate, 'option[3]');
// 3 scores // 3 scores
$form->addElement('text', 'option[1]', get_lang('Correct'), array('class' => 'span1', 'value' => '1')); $form->addElement('text', 'option[1]', get_lang('Correct'), ['class' => 'span1', 'value' => '1']);
$form->addElement('text', 'option[2]', get_lang('Wrong'), array('class' => 'span1', 'value' => '-0.5')); $form->addElement('text', 'option[2]', get_lang('Wrong'), ['class' => 'span1', 'value' => '-0.5']);
$form->addElement('text', 'option[3]', get_lang('DoubtScore'), array('class' => 'span1', 'value' => '0')); $form->addElement('text', 'option[3]', get_lang('DoubtScore'), ['class' => 'span1', 'value' => '0']);
$form->addRule('option[1]', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('option[1]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('option[2]', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('option[2]', get_lang('ThisFieldIsRequired'), 'required');
@ -233,7 +233,7 @@ class MultipleAnswerTrueFalse extends Question
} else { } else {
$form->setDefaults($defaults); $form->setDefaults($defaults);
} }
$form->setConstants(array('nb_answers' => $nb_answers)); $form->setConstants(['nb_answers' => $nb_answers]);
} }
/** /**
@ -246,7 +246,7 @@ class MultipleAnswerTrueFalse extends Question
$nb_answers = $form->getSubmitValue('nb_answers'); $nb_answers = $form->getSubmitValue('nb_answers');
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$correct = array(); $correct = [];
$options = Question::readQuestionOption($this->id, $course_id); $options = Question::readQuestionOption($this->id, $course_id);
if (!empty($options)) { if (!empty($options)) {
@ -271,15 +271,15 @@ class MultipleAnswerTrueFalse extends Question
it's possible that there are more options in the future */ it's possible that there are more options in the future */
$new_options = Question::readQuestionOption($this->id, $course_id); $new_options = Question::readQuestionOption($this->id, $course_id);
$sorted_by_position = array(); $sorted_by_position = [];
foreach ($new_options as $item) { foreach ($new_options as $item) {
$sorted_by_position[$item['position']] = $item; $sorted_by_position[$item['position']] = $item;
} }
/* Saving quiz_question.extra values that has the correct scores of /* Saving quiz_question.extra values that has the correct scores of
the true, false, doubt options registered in this format the true, false, doubt options registered in this format
XX:YY:ZZZ where XX is a float score value.*/ XX:YY:ZZZ where XX is a float score value.*/
$extra_values = array(); $extra_values = [];
for ($i = 1; $i <= 3; $i++) { for ($i = 1; $i <= 3; $i++) {
$score = trim($form -> getSubmitValue('option['.$i.']')); $score = trim($form -> getSubmitValue('option['.$i.']'));
$extra_values[] = $score; $extra_values[] = $score;
@ -295,7 +295,7 @@ class MultipleAnswerTrueFalse extends Question
// change the default values from the form 1 and 2 by the correct "option id" registered // change the default values from the form 1 and 2 by the correct "option id" registered
$goodAnswer = $sorted_by_position[$goodAnswer]['id']; $goodAnswer = $sorted_by_position[$goodAnswer]['id'];
} }
$questionWeighting += $extra_values[0]; //By default 0 has the correct answers $questionWeighting += $extra_values[0]; //By default 0 has the correct answers
$objAnswer->createAnswer($answer, $goodAnswer, $comment, '', $i); $objAnswer->createAnswer($answer, $goodAnswer, $comment, '', $i);
} }
@ -309,7 +309,7 @@ class MultipleAnswerTrueFalse extends Question
/** /**
* @inheritdoc * @inheritdoc
*/ */
function return_header($exercise = null, $counter = null, $score = null) public function return_header($exercise, $counter = null, $score = null)
{ {
$header = parent::return_header($exercise, $counter, $score); $header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class .'"> $header .= '<table class="'.$this->question_table_class .'">

@ -20,7 +20,7 @@ class OralExpression extends Question
private $storePath; private $storePath;
private $fileName; private $fileName;
private $filePath; private $filePath;
public $available_extensions = array('wav', 'ogg'); public $available_extensions = ['wav', 'ogg'];
/** /**
* Constructor * Constructor
@ -40,16 +40,16 @@ class OralExpression extends Question
$form->addText( $form->addText(
'weighting', 'weighting',
get_lang('Weighting'), get_lang('Weighting'),
array('class' => 'span1') ['class' => 'span1']
); );
global $text; global $text;
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
$form->addButtonSave($text, 'submitQuestion'); $form->addButtonSave($text, 'submitQuestion');
if (!empty($this->id)) { if (!empty($this->id)) {
$form -> setDefaults(array('weighting' => float_format($this->weighting, 1))); $form -> setDefaults(['weighting' => float_format($this->weighting, 1)]);
} else { } else {
if ($this->isContent == 1) { if ($this->isContent == 1) {
$form->setDefaults(array('weighting' => '10')); $form->setDefaults(['weighting' => '10']);
} }
} }
} }

@ -35,11 +35,11 @@ $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['l
$learnpathItemViewId = isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : null; $learnpathItemViewId = isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : null;
$origin = api_get_origin(); $origin = api_get_origin();
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => "exercise.php?".api_get_cidreq(), "url" => "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises') "name" => get_lang('Exercises')
); ];
$interbreadcrumb[] = array("url" => "#", "name" => $objExercise->selectTitle(true)); $interbreadcrumb[] = ["url" => "#", "name" => $objExercise->selectTitle(true)];
$time_control = false; $time_control = false;
$clock_expired_time = ExerciseLib::get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id); $clock_expired_time = ExerciseLib::get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
@ -217,23 +217,23 @@ if (!empty($attempts)) {
if (in_array( if (in_array(
$objExercise->results_disabled, $objExercise->results_disabled,
array( [
RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS, RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS,
RESULT_DISABLE_SHOW_SCORE_ONLY, RESULT_DISABLE_SHOW_SCORE_ONLY,
RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES, RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES,
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT
) ]
)) { )) {
$row['result'] = $score; $row['result'] = $score;
} }
if (in_array( if (in_array(
$objExercise->results_disabled, $objExercise->results_disabled,
array( [
RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS, RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS,
RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES, RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES,
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT, RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT,
) ]
) || ( ) || (
$objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY && $objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&
$objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END) $objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END)
@ -249,47 +249,47 @@ if (!empty($attempts)) {
} }
$header_names = []; $header_names = [];
$table = new HTML_Table(array('class' => 'table table-striped table-hover')); $table = new HTML_Table(['class' => 'table table-striped table-hover']);
// Hiding score and answer // Hiding score and answer
switch ($objExercise->results_disabled) { switch ($objExercise->results_disabled) {
case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT: case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT:
if ($blockShowAnswers) { if ($blockShowAnswers) {
$header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); $header_names = [get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')];
} else { } else {
$header_names = array( $header_names = [
get_lang('Attempt'), get_lang('Attempt'),
get_lang('StartDate'), get_lang('StartDate'),
get_lang('IP'), get_lang('IP'),
get_lang('Score'), get_lang('Score'),
get_lang('Details'), get_lang('Details'),
); ];
} }
break; break;
case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS: case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS:
case RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES: case RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES:
$header_names = array( $header_names = [
get_lang('Attempt'), get_lang('Attempt'),
get_lang('StartDate'), get_lang('StartDate'),
get_lang('IP'), get_lang('IP'),
get_lang('Score'), get_lang('Score'),
get_lang('Details'), get_lang('Details'),
); ];
break; break;
case RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS: case RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS:
$header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP')); $header_names = [get_lang('Attempt'), get_lang('StartDate'), get_lang('IP')];
break; break;
case RESULT_DISABLE_SHOW_SCORE_ONLY: case RESULT_DISABLE_SHOW_SCORE_ONLY:
if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) { if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
$header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); $header_names = [get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')];
} else { } else {
$header_names = array( $header_names = [
get_lang('Attempt'), get_lang('Attempt'),
get_lang('StartDate'), get_lang('StartDate'),
get_lang('IP'), get_lang('IP'),
get_lang('Score'), get_lang('Score'),
get_lang('Details'), get_lang('Details'),
); ];
} }
break; break;
} }

@ -19,19 +19,18 @@ if (!api_is_allowed_to_edit(null, true)) {
} }
// the breadcrumbs // the breadcrumbs
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."exercise/exercise.php?".api_get_cidreq(), "url" => api_get_path(WEB_CODE_PATH)."exercise/exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises') "name" => get_lang('Exercises')
); ];
$is_allowedToEdit = api_is_allowed_to_edit(null, true); $is_allowedToEdit = api_is_allowed_to_edit(null, true);
/** /**
* This function displays the form to import the zip file with qti2 * This function displays the form to import the zip file with qti2
*/ */
function ch_qti2_display_form() function displayForm()
{ {
$name_tools = get_lang('ImportQtiQuiz'); $form = '<div class="actions">';
$form = '<div class="actions">';
$form .= '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?show=test&'.api_get_cidreq().'">'. $form .= '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?show=test&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>';
$form .= '</div>'; $form .= '</div>';
@ -40,9 +39,9 @@ function ch_qti2_display_form()
'post', 'post',
api_get_self()."?".api_get_cidreq(), api_get_self()."?".api_get_cidreq(),
null, null,
array('enctype' => 'multipart/form-data') ['enctype' => 'multipart/form-data']
); );
$formValidator->addElement('header', $name_tools); $formValidator->addHeader(get_lang('ImportQtiQuiz'));
$formValidator->addElement('file', 'userFile', get_lang('DownloadFile')); $formValidator->addElement('file', 'userFile', get_lang('DownloadFile'));
$formValidator->addButtonImport(get_lang('Upload')); $formValidator->addButtonImport(get_lang('Upload'));
$form .= $formValidator->returnForm(); $form .= $formValidator->returnForm();
@ -54,7 +53,7 @@ function ch_qti2_display_form()
* @param array $array_file ($_FILES) * @param array $array_file ($_FILES)
* @return string|array * @return string|array
*/ */
function ch_qti2_import_file($array_file) function importFile($array_file)
{ {
$unzip = 0; $unzip = 0;
$process = process_uploaded_file($array_file, false); $process = process_uploaded_file($array_file, false);
@ -80,7 +79,7 @@ $message = null;
// import file // import file
if ((api_is_allowed_to_edit(null, true))) { if ((api_is_allowed_to_edit(null, true))) {
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
$imported = ch_qti2_import_file($_FILES['userFile']); $imported = importFile($_FILES['userFile']);
if (is_numeric($imported) && !empty($imported)) { if (is_numeric($imported) && !empty($imported)) {
header('Location: '.api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&exerciseId='.$imported); header('Location: '.api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&exerciseId='.$imported);
@ -97,7 +96,7 @@ Display::display_header(get_lang('ImportQtiQuiz'), 'Exercises');
echo $message; echo $message;
// display qti form // display qti form
ch_qti2_display_form(); displayForm();
// display the footer // display the footer
Display::display_footer(); Display::display_footer();

@ -14,7 +14,7 @@ $this_section = SECTION_COURSES;
api_protect_course_script(true); api_protect_course_script(true);
// breadcrumbs // breadcrumbs
$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises')); $interbreadcrumb[] = ["url" => "exercise.php", "name" => get_lang('Exercises')];
// Tool name // Tool name
$nameTools = get_lang('AddQuestionToExercise'); $nameTools = get_lang('AddQuestionToExercise');
@ -25,7 +25,7 @@ $form = new FormValidator('add_question', 'post', api_get_self().'?'.api_get_cid
$form->addElement('header', '', get_lang('AddQuestionToExercise')); $form->addElement('header', '', get_lang('AddQuestionToExercise'));
$question_list = Question::get_question_type_list(); $question_list = Question::get_question_type_list();
$question_list_options = array(); $question_list_options = [];
foreach ($question_list as $key=> $value) { foreach ($question_list as $key=> $value) {
$question_list_options[$key] = addslashes(get_lang($value[1])); $question_list_options[$key] = addslashes(get_lang($value[1]));
} }
@ -34,7 +34,7 @@ $form->addElement(
'question_type_hidden', 'question_type_hidden',
get_lang('QuestionType'), get_lang('QuestionType'),
$question_list_options, $question_list_options,
array('id' => 'question_type_hidden') ['id' => 'question_type_hidden']
); );
//session id //session id
@ -61,7 +61,7 @@ $form->addElement(
'is_content', 'is_content',
null, null,
get_lang('GenerateDefaultContent'), get_lang('GenerateDefaultContent'),
array('checked' => true) ['checked' => true]
); );
// the submit button // the submit button

@ -38,11 +38,11 @@ class UniqueAnswer extends Question
// Getting the exercise list // Getting the exercise list
$obj_ex = Session::read('objExercise'); $obj_ex = Session::read('objExercise');
$editor_config = array( $editor_config = [
'ToolbarSet' => 'TestProposedAnswer', 'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%', 'Width' => '100%',
'Height' => '125' 'Height' => '125'
); ];
//this line defines how many questions by default appear when creating a choice question //this line defines how many questions by default appear when creating a choice question
// The previous default value was 2. See task #1759. // The previous default value was 2. See task #1759.
@ -82,7 +82,7 @@ class UniqueAnswer extends Question
$form->addHeader(get_lang('Answers')); $form->addHeader(get_lang('Answers'));
$form->addHtml($html); $form->addHtml($html);
$defaults = array(); $defaults = [];
$correct = 0; $correct = 0;
if (!empty($this->id)) { if (!empty($this->id)) {
$answer = new Answer($this->id); $answer = new Answer($this->id);
@ -95,7 +95,7 @@ class UniqueAnswer extends Question
//Feedback SELECT //Feedback SELECT
$question_list = $obj_ex->selectQuestionList(); $question_list = $obj_ex->selectQuestionList();
$select_question = array(); $select_question = [];
$select_question[0] = get_lang('SelectTargetQuestion'); $select_question[0] = get_lang('SelectTargetQuestion');
if (is_array($question_list)) { if (is_array($question_list)) {
foreach ($question_list as $key => $questionid) { foreach ($question_list as $key => $questionid) {
@ -114,14 +114,14 @@ class UniqueAnswer extends Question
$list = new LearnpathList(api_get_user_id()); $list = new LearnpathList(api_get_user_id());
$flat_list = $list->get_flat_list(); $flat_list = $list->get_flat_list();
$select_lp_id = array(); $select_lp_id = [];
$select_lp_id[0] = get_lang('SelectTargetLP'); $select_lp_id[0] = get_lang('SelectTargetLP');
foreach ($flat_list as $id => $details) { foreach ($flat_list as $id => $details) {
$select_lp_id[$id] = cut($details['lp_name'], 20); $select_lp_id[$id] = cut($details['lp_name'], 20);
} }
$temp_scenario = array(); $temp_scenario = [];
if ($nb_answers < 1) { if ($nb_answers < 1) {
$nb_answers = 1; $nb_answers = 1;
@ -133,17 +133,16 @@ class UniqueAnswer extends Question
for ($i = 1; $i <= $nb_answers; ++$i) { for ($i = 1; $i <= $nb_answers; ++$i) {
$form->addHtml('<tr>'); $form->addHtml('<tr>');
if (isset($answer) && is_object($answer)) { if (isset($answer) && is_object($answer)) {
if ($answer->correct[$i]) { if (isset($answer->correct[$i]) && $answer->correct[$i]) {
$correct = $i; $correct = $i;
} }
$defaults['answer['.$i.']'] = $answer->answer[$i]; $defaults['answer['.$i.']'] = isset($answer->answer[$i]) ? $answer->answer[$i] : '';
$defaults['comment['.$i.']'] = $answer->comment[$i]; $defaults['comment['.$i.']'] = isset($answer->comment[$i]) ? $answer->comment[$i] : '';
$defaults['weighting['.$i.']'] = float_format( $defaults['weighting['.$i.']'] = isset($answer->weighting[$i]) ? float_format($answer->weighting[$i], 1) : 0;
$answer->weighting[$i], $item_list = [];
1 if (isset($answer->destination[$i])) {
); $item_list = explode('@@', $answer->destination[$i]);
}
$item_list = explode('@@', $answer->destination[$i]);
$try = isset($item_list[0]) ? $item_list[0] : ''; $try = isset($item_list[0]) ? $item_list[0] : '';
$lp = isset($item_list[1]) ? $item_list[1] : ''; $lp = isset($item_list[1]) ? $item_list[1] : '';
@ -171,8 +170,8 @@ class UniqueAnswer extends Question
$defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2'); $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
$defaults['weighting[2]'] = 0; $defaults['weighting[2]'] = 0;
$temp_scenario['destination'.$i] = array('0'); $temp_scenario['destination'.$i] = ['0'];
$temp_scenario['lp'.$i] = array('0'); $temp_scenario['lp'.$i] = ['0'];
} }
$defaults['scenario'] = $temp_scenario; $defaults['scenario'] = $temp_scenario;
@ -233,7 +232,7 @@ class UniqueAnswer extends Question
); );
// Direct feedback // Direct feedback
//Adding extra feedback fields //Adding extra feedback fields
$group = array(); $group = [];
$group['try'.$i] = $form->createElement( $group['try'.$i] = $form->createElement(
'checkbox', 'checkbox',
'try'.$i, 'try'.$i,
@ -256,10 +255,10 @@ class UniqueAnswer extends Question
'text', 'text',
'url'.$i, 'url'.$i,
get_lang('Other').': ', get_lang('Other').': ',
array( [
'class' => 'col-md-2', 'class' => 'col-md-2',
'placeholder' => get_lang('Other') 'placeholder' => get_lang('Other')
) ]
); );
$form->addGroup($group, 'scenario'); $form->addGroup($group, 'scenario');
@ -270,7 +269,7 @@ class UniqueAnswer extends Question
} else { } else {
$form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config); $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
} }
$form->addText('weighting['.$i.']', null, null, array('value' => '0')); $form->addText('weighting['.$i.']', null, null, ['value' => '0']);
$form->addHtml('</tr>'); $form->addHtml('</tr>');
} }
@ -311,10 +310,10 @@ class UniqueAnswer extends Question
// Default sample content. // Default sample content.
$form->setDefaults($defaults); $form->setDefaults($defaults);
} else { } else {
$form->setDefaults(array('correct' => 1)); $form->setDefaults(['correct' => 1]);
} }
} }
$form->setConstants(array('nb_answers' => $nb_answers)); $form->setConstants(['nb_answers' => $nb_answers]);
} }
/** /**

@ -35,11 +35,11 @@ class UniqueAnswerNoOption extends Question
// getting the exercise list // getting the exercise list
$obj_ex = Session::read('objExercise'); $obj_ex = Session::read('objExercise');
$editor_config = array( $editor_config = [
'ToolbarSet' => 'TestProposedAnswer', 'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%', 'Width' => '100%',
'Height' => '125' 'Height' => '125'
); ];
//this line define how many question by default appear when creating a choice question //this line define how many question by default appear when creating a choice question
$nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3; // The previous default value was 2. See task #1759. $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3; // The previous default value was 2. See task #1759.
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
@ -77,7 +77,7 @@ class UniqueAnswerNoOption extends Question
$form->addHeader(get_lang('Answers')); $form->addHeader(get_lang('Answers'));
$form->addHtml($html); $form->addHtml($html);
$defaults = array(); $defaults = [];
$correct = 0; $correct = 0;
$answer = false; $answer = false;
if (!empty($this->id)) { if (!empty($this->id)) {
@ -88,7 +88,7 @@ class UniqueAnswerNoOption extends Question
} }
} }
$temp_scenario = array(); $temp_scenario = [];
if ($nb_answers < 1) { if ($nb_answers < 1) {
$nb_answers = 1; $nb_answers = 1;
echo Display::return_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); echo Display::return_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
@ -96,7 +96,7 @@ class UniqueAnswerNoOption extends Question
$editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : false; $editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : false;
if ($editQuestion) { if ($editQuestion) {
//fixing $nb_answers //fixing $nb_answers
$new_list = array(); $new_list = [];
$count = 1; $count = 1;
if (isset($_POST['lessAnswers'])) { if (isset($_POST['lessAnswers'])) {
if (!isset($_SESSION['less_answer'])) { if (!isset($_SESSION['less_answer'])) {
@ -193,10 +193,10 @@ class UniqueAnswerNoOption extends Question
$form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"'); $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
$form->addElement('html_editor', 'answer['.$i.']', null, array(), $editor_config); $form->addElement('html_editor', 'answer['.$i.']', null, [], $editor_config);
$form->addElement('html_editor', 'comment['.$i.']', null, array(), $editor_config); $form->addElement('html_editor', 'comment['.$i.']', null, [], $editor_config);
$form->addElement('text', 'weighting['.$i.']', null, array('style' => 'width: 60px;', 'value' => '0')); $form->addElement('text', 'weighting['.$i.']', null, ['style' => 'width: 60px;', 'value' => '0']);
$form->addElement('html', '</tr>'); $form->addElement('html', '</tr>');
$i++; $i++;
} }
@ -244,10 +244,10 @@ class UniqueAnswerNoOption extends Question
$form->addElement('hidden', 'position['.$i.']', '666'); $form->addElement('hidden', 'position['.$i.']', '666');
$form->addElement('radio', 'correct', null, null, $i, ['class' => 'checkbox', 'disabled' => true]); $form->addElement('radio', 'correct', null, null, $i, ['class' => 'checkbox', 'disabled' => true]);
$form->addElement('html_editor', 'answer['.$i.']', null, array(), $editor_config); $form->addElement('html_editor', 'answer['.$i.']', null, [], $editor_config);
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('html_editor', 'comment['.$i.']', null, array(), $editor_config); $form->addElement('html_editor', 'comment['.$i.']', null, [], $editor_config);
//$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple'); //$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple');
@ -284,7 +284,7 @@ class UniqueAnswerNoOption extends Question
} }
$form->addElement('hidden', 'nb_answers'); $form->addElement('hidden', 'nb_answers');
$form->setConstants(array('nb_answers' => $nb_answers)); $form->setConstants(['nb_answers' => $nb_answers]);
} }
/** /**

@ -32,10 +32,10 @@ $(document).ready( function(){
// Action handling // Action handling
lp_upload_quiz_action_handling(); lp_upload_quiz_action_handling();
$interbreadcrumb[] = array( $interbreadcrumb[] = [
"url" => "exercise.php?".api_get_cidreq(), "url" => "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises') "name" => get_lang('Exercises')
); ];
// Display the header // Display the header
Display :: display_header(get_lang('ImportExcelQuiz'), 'Exercises'); Display :: display_header(get_lang('ImportExcelQuiz'), 'Exercises');
@ -69,7 +69,7 @@ function lp_upload_quiz_main()
'POST', 'POST',
api_get_self().'?'.api_get_cidreq().'&lp_id='.$lp_id, api_get_self().'?'.api_get_cidreq().'&lp_id='.$lp_id,
'', '',
array('enctype' => 'multipart/form-data') ['enctype' => 'multipart/form-data']
); );
$form->addElement('header', get_lang('ImportExcelQuiz')); $form->addElement('header', get_lang('ImportExcelQuiz'));
$form->addElement('file', 'user_upload_quiz', get_lang('FileUpload')); $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload'));
@ -78,16 +78,16 @@ function lp_upload_quiz_main()
Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')).get_lang('DownloadExcelTemplate').'</a>'; Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')).get_lang('DownloadExcelTemplate').'</a>';
$form->addElement('label', '', $link); $form->addElement('label', '', $link);
$table = new HTML_Table(array('class' => 'table')); $table = new HTML_Table(['class' => 'table']);
$tableList = array( $tableList = [
UNIQUE_ANSWER => get_lang('UniqueSelect'), UNIQUE_ANSWER => get_lang('UniqueSelect'),
MULTIPLE_ANSWER => get_lang('MultipleSelect'), MULTIPLE_ANSWER => get_lang('MultipleSelect'),
FILL_IN_BLANKS => get_lang('FillBlanks'), FILL_IN_BLANKS => get_lang('FillBlanks'),
MATCHING => get_lang('Matching'), MATCHING => get_lang('Matching'),
FREE_ANSWER => get_lang('FreeAnswer'), FREE_ANSWER => get_lang('FreeAnswer'),
GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer') GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer')
); ];
$table->setHeaderContents(0, 0, get_lang('QuestionType')); $table->setHeaderContents(0, 0, get_lang('QuestionType'));
$table->setHeaderContents(0, 1, '#'); $table->setHeaderContents(0, 1, '#');
@ -106,7 +106,7 @@ function lp_upload_quiz_main()
'user_custom_score', 'user_custom_score',
null, null,
get_lang('UseCustomScoreForAllQuestions'), get_lang('UseCustomScoreForAllQuestions'),
array('id' => 'user_custom_score') ['id' => 'user_custom_score']
); );
$form->addElement('html', '<div id="options" style="display:none">'); $form->addElement('html', '<div id="options" style="display:none">');
$form->addElement('text', 'correct_score', get_lang('CorrectScore')); $form->addElement('text', 'correct_score', get_lang('CorrectScore'));

@ -142,9 +142,9 @@ class Browser
* @param string $browserName * @param string $browserName
* @return bool True if the browser is the specified browser * @return bool True if the browser is the specified browser
*/ */
function isBrowser($browserName) public function isBrowser($browserName)
{ {
return (0 == strcasecmp($this->_browser_name, trim($browserName))); return 0 == strcasecmp($this->_browser_name, trim($browserName));
} }
/** /**

@ -1,28 +1,28 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
require_once __DIR__.'/../../global.inc.php';
use Chamilo\CoreBundle\Component\Editor\Connector; use Chamilo\CoreBundle\Component\Editor\Connector;
use Chamilo\CoreBundle\Component\Editor\Finder; use Chamilo\CoreBundle\Component\Editor\Finder;
require_once __DIR__.'/../../global.inc.php';
error_reporting(-1); error_reporting(-1);
/** @var Connector $connector */ /** @var Connector $connector */
$connector = new Connector(); $connector = new Connector();
// Check driver list in configuration // Check driver list in configuration
$driverList = api_get_configuration_value('editor_driver_list'); $driverList = api_get_configuration_value('editor_driver_list');
if (empty($driverList)) { if (empty($driverList)) {
$driverList = array( $driverList = [
'PersonalDriver', 'PersonalDriver',
'CourseDriver', 'CourseDriver',
//'CourseUserDriver', //'CourseUserDriver',
//'HomeDriver' //'HomeDriver'
); ];
} }
$connector->setDriverList($driverList); $connector->setDriverList($driverList);
$operations = $connector->getOperations(); $operations = $connector->getOperations();
// Run elFinder // Run elFinder

@ -1,10 +1,10 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
require_once __DIR__.'/../../global.inc.php';
use Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor; use Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor;
require_once __DIR__.'/../../global.inc.php';
$template = new Template(); $template = new Template();
$editor = new CkEditor(); $editor = new CkEditor();

@ -18,8 +18,8 @@ class SelectTheme extends HTML_QuickForm_select
parent::__construct($elementName, $elementLabel, $options, $attributes); parent::__construct($elementName, $elementLabel, $options, $attributes);
// Get all languages // Get all languages
$themes = api_get_themes(); $themes = api_get_themes();
$this->_options = array(); $this->_options = [];
$this->_values = array(); $this->_values = [];
$this->addOption('--', ''); // no theme select $this->addOption('--', ''); // no theme select
foreach ($themes as $themeValue => $themeName) { foreach ($themes as $themeValue => $themeName) {
$this->addOption($themeName, $themeValue); $this->addOption($themeName, $themeValue);

@ -30,7 +30,7 @@ abstract class HookEvent implements HookEventInterface
{ {
$this->observers = new SplObjectStorage(); $this->observers = new SplObjectStorage();
$this->eventName = $eventName; $this->eventName = $eventName;
$this->eventData = array(); $this->eventData = [];
$this->manager = HookManagement::create(); $this->manager = HookManagement::create();
$this->loadAttachments(); $this->loadAttachments();
} }

Loading…
Cancel
Save