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. 12
      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. 11
      main/exercise/export/aiken/aiken_import.inc.php
  16. 69
      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. 16
      main/exercise/hotpotatoes.lib.php
  23. 12
      main/exercise/hotpotatoes.php
  24. 62
      main/exercise/hotpotatoes_exercise_report.php
  25. 12
      main/exercise/hotpotatoes_exercise_result.class.php
  26. 10
      main/exercise/hotspot.class.php
  27. 147
      main/exercise/hotspot_admin.inc.php
  28. 2
      main/exercise/hotspot_lang_conversion.php
  29. 38
      main/exercise/live_stats.php
  30. 14
      main/exercise/matching.class.php
  31. 12
      main/exercise/multiple_answer.class.php
  32. 14
      main/exercise/multiple_answer_combination.class.php
  33. 4
      main/exercise/multiple_answer_combination_true_false.class.php
  34. 26
      main/exercise/multiple_answer_true_false.class.php
  35. 8
      main/exercise/oral_expression.class.php
  36. 34
      main/exercise/overview.php
  37. 17
      main/exercise/qti2.php
  38. 8
      main/exercise/question_create.php
  39. 43
      main/exercise/unique_answer.class.php
  40. 22
      main/exercise/unique_answer_no_option.class.php
  41. 14
      main/exercise/upload_exercise.php
  42. 4
      main/inc/lib/browser/Browser.php
  43. 10
      main/inc/lib/elfinder/connectorAction.php
  44. 4
      main/inc/lib/elfinder/templates.php
  45. 4
      main/inc/lib/formvalidator/Element/SelectTheme.php
  46. 2
      main/inc/lib/hook/HookEvent.php

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

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

@ -13,7 +13,7 @@ $this_section = SECTION_COURSES;
$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);
// 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') {
$directory_name = dirname($full_file_name);
$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] != '/') {
$dir .= '/';

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

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

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

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

@ -164,20 +164,20 @@ if ($form->validate()) {
exit;
} else {
if (api_is_in_gradebook()) {
$interbreadcrumb[] = array(
$interbreadcrumb[] = [
'url' => Category::getUrl(),
'name' => get_lang('ToolGradebook')
);
];
}
$nameTools = get_lang('ExerciseManagement');
$interbreadcrumb[] = array(
$interbreadcrumb[] = [
"url" => 'exercise.php?'.api_get_cidreq(),
'name' => get_lang('Exercises'),
);
$interbreadcrumb[] = array(
];
$interbreadcrumb[] = [
"url" => 'admin.php?exerciseId='.$objExercise->id.'&'.api_get_cidreq(),
"name" => $objExercise->selectTitle(true),
);
];
Display::display_header($nameTools, get_lang('Exercise'));

@ -24,18 +24,18 @@ if (!$is_allowedToEdit) {
exit;
}
$interbreadcrumb[] = array(
$interbreadcrumb[] = [
'url' => 'exercise_report.php?'.api_get_cidreq(),
'name' => get_lang('Exercises'),
);
$interbreadcrumb[] = array(
];
$interbreadcrumb[] = [
'url' => 'exercise_report.php?filter=2&'.api_get_cidreq(),
'name' => get_lang('StudentScore'),
);
$interbreadcrumb[] = array(
];
$interbreadcrumb[] = [
'url' => 'exercise_history.php?exe_id='.intval($_GET['exe_id']).'&'.api_get_cidreq(),
'name' => get_lang('Details'),
);
];
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$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'));
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']);
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');
$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') {
//so we are not in learnpath tool
@ -119,9 +119,9 @@ if ($origin != 'learnpath') {
if (api_is_course_admin() && $origin != 'learnpath') {
echo '<div class="actions">';
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.'">'.
Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).'</a>';
Display::return_icon('edit.png', get_lang('ModifyExercise'), [], 32).'</a>';
echo '</div>';
}
echo Display::page_header(get_lang('QuestionsToReview'));
@ -130,7 +130,7 @@ if ($time_control) {
echo $objExercise->return_time_left_div();
}
echo Display::div('', array('id'=>'message'));
echo Display::div('', ['id'=>'message']);
echo '<script>
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);
$remind_list = $exercise_stat_info['questions_to_check'];
$remind_list = explode(',', $remind_list);
$exercise_result = array();
$exercise_result = [];
foreach ($attempt_list as $question_id => $options) {
foreach ($options as $item) {
@ -207,17 +207,17 @@ foreach ($question_list as $questionId) {
$objQuestionTmp = Question:: read($questionId);
$quesId = $objQuestionTmp->selectId();
$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)) {
$attributes['checked'] = 1;
}
$label_attributes = array();
$label_attributes = [];
$label_attributes['class'] = 'checkbox';
$label_attributes['for'] = $check_id;
$label_attributes['class'] = "checkbox";
$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++;
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::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
echo Display::div($table, array('class'=>'question-check-test'));
echo Display::div($table, ['class'=>'question-check-test']);
$exerciseActions = Display::url(
get_lang('ReviewQuestions'),
'javascript://',
array('onclick'=>'review_questions();', 'class'=>'btn btn-success')
['onclick'=>'review_questions();', 'class'=>'btn btn-success']
);
$exerciseActions .= '&nbsp;'.Display::url(
get_lang('EndTest'),
'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($exerciseActions, array('class'=>'form-actions'));
echo Display::div('', ['class'=>'clear']);
echo Display::div($exerciseActions, ['class'=>'form-actions']);
if ($origin != 'learnpath') {
// We are not in learnpath tool

@ -45,7 +45,7 @@ class ExerciseResult
$filter = 0,
$exercise_id = 0
) {
$return = array();
$return = [];
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
$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";
}
$results = array();
$results = [];
$resx = Database::query($sql);
$bestAttemptPerUser = array();
$bestAttemptPerUser = [];
while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
if ($this->onlyBestAttempts) {
if (!isset($bestAttemptPerUser[$rowx['excruid']])) {
@ -172,7 +172,7 @@ class ExerciseResult
$studentsUserIdList = array_keys($students);
// Print the results of tests
$userWithResults = array();
$userWithResults = [];
if (is_array($results)) {
$i = 0;
foreach ($results as $result) {
@ -198,7 +198,7 @@ class ExerciseResult
continue;
}
$return[$i] = array();
$return[$i] = [];
if (empty($user_id)) {
$return[$i]['official_code'] = $result['official_code'];
if (api_is_western_name_order()) {

@ -42,7 +42,7 @@ if (isset($_REQUEST['learnpath_item_id'])) {
$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
}
$_SESSION['hotspot_coord'] = array();
$_SESSION['hotspot_coord'] = [];
$newquestionList = Session::read('newquestionList', []);
$questionList = Session::read('questionList');
$exerciseId = intval($_GET['exerciseId']);
@ -110,20 +110,20 @@ if (empty($choice_value)) {
// IMPORTANT
//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 ' 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 '</script>';
exit;
}
$choice = array();
$choice = [];
$questionid = $questionList[$questionNum];
// $choice_value => value of the user selection
$choice[$questionid] = isset($choice_value) ? $choice_value : null;
// initializing
if (!is_array($exerciseResult)) {
$exerciseResult = array();
$exerciseResult = [];
}
// if the user has answered at least one question
@ -170,11 +170,11 @@ if (in_array($questionid, $questionList)) {
$objAnswerTmp = new Answer($questionid);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
$choice = $exerciseResult[$questionid];
$destination = array();
$destination = [];
$comment = '';
$next = 1;
$_SESSION['hotspot_coord'] = array();
$_SESSION['hotspot_dest'] = array();
$_SESSION['hotspot_coord'] = [];
$_SESSION['hotspot_dest'] = [];
$overlap_color = $missing_color = $excess_color = false;
$organs_at_risk_hit = 0;
$wrong_results = false;
@ -195,7 +195,9 @@ if (!empty($choice_value)) {
//delineation
$delineation_cord = $objAnswerTmp->selectHotspotCoordinates(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) {
// for unique answer
@ -230,7 +232,9 @@ if (!empty($choice_value)) {
}
} elseif ($answerType == HOT_SPOT_DELINEATION) {
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
$user_answer = $user_array;
$_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
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) {
//shortcut to avoid complicated calculations
$final_overlap = 0;
@ -274,13 +280,19 @@ if (!empty($choice_value)) {
} else {
// 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);
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
$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
$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);
@ -324,12 +336,16 @@ if (!empty($choice_value)) {
}
} elseif ($answerId > 1) {
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
$next = 1;
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
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list);
@ -395,7 +411,9 @@ if (!empty($choice_value)) {
}
} else {
// 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(
'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 />';
}
@ -516,7 +534,7 @@ if (!empty($lp)) {
$links .= Display:: return_icon(
'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 />';
}
$links .= '<br />';
@ -526,7 +544,7 @@ if (!empty($url)) {
$links .= Display:: return_icon(
'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 />';
}
@ -535,7 +553,7 @@ if ($destinationid == -1) {
$links .= Display:: return_icon(
'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 />';
} else {
// the link to other question
@ -546,7 +564,7 @@ if ($destinationid == -1) {
$links .= Display:: return_icon(
'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 />';
}
}
@ -588,7 +606,7 @@ if ($links != '') {
echo '</div>';
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
Session::write('exerciseResult', $exerciseResult);
@ -599,7 +617,7 @@ if ($links != '') {
} else {
$questionNum++;
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();
</script>';
}

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

@ -29,7 +29,7 @@ function aiken_display_form()
'post',
api_get_self()."?".api_get_cidreq(),
null,
array('enctype' => 'multipart/form-data')
['enctype' => 'multipart/form-data']
);
$form_validator->addElement('header', $name_tools);
$form_validator->addElement('text', 'total_weight', get_lang('TotalWeight'));
@ -115,9 +115,9 @@ function aiken_import_exercise($file)
$uploadPath = 'aiken_'.api_get_unique_id().'/';
// set some default values for the new exercise
$exercise_info = array();
$exercise_info = [];
$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 (!preg_match('/.(zip|txt)$/i', $file)) {
@ -252,7 +252,7 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
$question_index = 0;
$correct_answer = '';
$answers_array = array();
$answers_array = [];
$new_question = true;
foreach ($data as $line => $info) {
if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/', $info)) {
@ -305,7 +305,7 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
}
$question_index++;
//emptying answers array when moving to next question
$answers_array = array();
$answers_array = [];
$new_question = true;
} else {
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')));
return $imported;
} else {
Display::addFlash(Display::return_message(get_lang($imported), 'error'));

@ -66,7 +66,6 @@ function import_exercise($file)
global $resourcesLinks;
$baseWorkDir = api_get_path(SYS_ARCHIVE_PATH).'qti2/';
if (!is_dir($baseWorkDir)) {
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
$exercise_info = array();
$exercise_info = [];
$exercise_info['name'] = preg_replace('/.zip$/i', '', $file);
$exercise_info['question'] = array();
$element_pile = array();
$exercise_info['question'] = [];
$element_pile = [];
// 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 (!preg_match('/.zip$/i', $file)) {
@ -102,7 +101,7 @@ function import_exercise($file)
$file_found = false;
$result = false;
$filePath = null;
$resourcesLinks = array();
$resourcesLinks = [];
// 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
@ -139,7 +138,6 @@ function import_exercise($file)
$resourcesLinks = qtiProcessManifest($baseWorkDir.'/'.$file);
}
}
}
}
@ -212,6 +210,7 @@ function import_exercise($file)
if (!empty($question_array['description'])) {
$description .= $question_array['description'];
}
$question->updateDescription($description);
$question->save($exercise);
@ -222,7 +221,7 @@ function import_exercise($file)
$answer->new_nbrAnswers = count($answerList);
$totalCorrectWeight = 0;
$j = 1;
$matchAnswerIds = array();
$matchAnswerIds = [];
if (!empty($answerList)) {
foreach ($answerList as $key => $answers) {
if (preg_match('/_/', $key)) {
@ -265,7 +264,6 @@ function import_exercise($file)
$question->save($exercise);
$answer->save();
}
// delete the temp dir where the exercise was unzipped
my_delete($baseWorkDir.$uploadPath);
@ -309,8 +307,8 @@ function qti_parse_file($exercisePath, $file, $questionFile)
//parse XML question file
//$data = str_replace(array('<p>', '</p>', '<front>', '</front>'), '', $data);
$data = ChamiloApi::stripGivenTags($data, array('p', 'front'));
$qtiVersion = array();
$data = ChamiloApi::stripGivenTags($data, ['p', 'front']);
$qtiVersion = [];
$match = preg_match('/ims_qtiasiv(\d)p(\d)/', $data, $qtiVersion);
$qtiMainVersion = 2; //by default, assume QTI version 2
if ($match) {
@ -318,9 +316,8 @@ function qti_parse_file($exercisePath, $file, $questionFile)
}
//used global variable start values declaration:
$record_item_body = false;
$non_HTML_tag_to_avoid = array(
$non_HTML_tag_to_avoid = [
"SIMPLECHOICE",
"CHOICEINTERACTION",
"INLINECHOICEINTERACTION",
@ -334,11 +331,12 @@ function qti_parse_file($exercisePath, $file, $questionFile)
"ITEMBODY",
"BR",
"IMG"
);
];
$question_format_supported = true;
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, false);
if ($qtiMainVersion == 1) {
xml_set_element_handler(
$xml_parser,
@ -354,6 +352,7 @@ function qti_parse_file($exercisePath, $file, $questionFile)
);
xml_set_character_data_handler($xml_parser, 'elementDataQti2');
}
if (!xml_parse($xml_parser, $data, feof($fp))) {
// if reading of the xml file in not successful :
// set errorFound, set error msg, break while statement
@ -379,9 +378,9 @@ function qti_parse_file($exercisePath, $file, $questionFile)
Display::return_message(
get_lang(
'Unknown question format in file %file',
array(
[
'%file' => $questionFile,
)
]
),
'error'
)
@ -449,7 +448,6 @@ function startElementQti2($parser, $name, $attributes)
if ($current_element == 'TEXTENTRYINTERACTION') {
$correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
$current_question_item_body .= "[".$correct_answer_value."]";
}
if ($current_element == 'BR') {
$current_question_item_body .= "<br />";
@ -506,6 +504,7 @@ function startElementQti2($parser, $name, $attributes)
break;
case 'EXTENDEDTEXTINTERACTION':
$exercise_info['question'][$current_question_ident]['type'] = FREE_ANSWER;
$exercise_info['question'][$current_question_ident]['description'] = '';
break;
case 'SIMPLEMATCHSET':
if (!isset($current_match_set)) {
@ -513,7 +512,7 @@ function startElementQti2($parser, $name, $attributes)
} else {
$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;
case 'SIMPLEASSOCIABLECHOICE':
$currentAssociableChoice = $attributes['IDENTIFIER'];
@ -522,14 +521,14 @@ function startElementQti2($parser, $name, $attributes)
case 'SIMPLECHOICE':
$current_answer_id = $attributes['IDENTIFIER'];
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;
case 'MAPENTRY':
if ($parent_element == 'MAPPING' || $parent_element == 'MAPENTRY') {
$answer_id = $attributes['MAPKEY'];
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'];
}
@ -598,9 +597,16 @@ function endElementQti2($parser, $name)
$record_item_body = false;
if ($exercise_info['question'][$current_question_ident]['type'] == FIB) {
$exercise_info['question'][$current_question_ident]['response_text'] = $current_question_item_body;
} else {
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;
}
array_pop($element_pile);
@ -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:
if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
$current_question_item_body .= $data;
}
switch ($current_element) {
case 'EXTENDEDTEXTINTERACTION':
$exercise_info['question'][$current_question_ident]['description'] .= $data;
break;
case 'SIMPLECHOICE':
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);
@ -703,7 +713,7 @@ function elementDataQti2($parser, $data)
);
} else {
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;
}
@ -778,7 +788,6 @@ function startElementQti1($parser, $name, $attributes)
if ($current_element == 'TEXTENTRYINTERACTION') {
$correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
$current_question_item_body .= "[".$correct_answer_value."]";
}
if ($current_element == 'BR') {
$current_question_item_body .= "<br />";
@ -796,9 +805,9 @@ function startElementQti1($parser, $name, $attributes)
case 'ITEM':
//retrieve current question
$current_question_ident = $attributes['IDENT'];
$exercise_info['question'][$current_question_ident] = array();
$exercise_info['question'][$current_question_ident]['answer'] = array();
$exercise_info['question'][$current_question_ident]['correct_answers'] = array();
$exercise_info['question'][$current_question_ident] = [];
$exercise_info['question'][$current_question_ident]['answer'] = [];
$exercise_info['question'][$current_question_ident]['correct_answers'] = [];
$exercise_info['question'][$current_question_ident]['tempdir'] = $questionTempDir;
break;
case 'SECTION':
@ -1095,11 +1104,11 @@ function qtiProcessManifest($filePath)
$exercisesSysPath = $sysPath.$courseDir.'/document/';
$webPath = api_get_path(WEB_CODE_PATH);
$exercisesWebPath = $webPath.'document/document.php?'.api_get_cidreq().'&action=download&id=';
$links = array(
'manifest' => array(),
'system' => array(),
'web' => array(),
);
$links = [
'manifest' => [],
'system' => [],
'web' => [],
];
$tableDocuments = Database::get_course_table(TABLE_DOCUMENT);
$countResources = count($xml->resources->resource->file);
for ($i = 0; $i < $countResources; $i++) {

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

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

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

@ -29,14 +29,14 @@ class FreeAnswer extends Question
public function createAnswersForm($form)
{
$form->addElement('text', 'weighting', get_lang('Weighting'));
global $text, $class;
global $text;
// setting the save button here and not in the question class.php
$form->addButtonSave($text, 'submitQuestion');
if (!empty($this->id)) {
$form->setDefaults(array('weighting' => float_format($this->weighting, 1)));
$form->setDefaults(['weighting' => float_format($this->weighting, 1)]);
} else {
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'),
$html
);
$defaults = array();
$defaults = [];
$correct = 0;
$answer = false;
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)
/* Ajout mise en forme nb reponse */
$form->addElement('hidden', 'nb_answers');
$boxes_names = array();
$boxes_names = [];
if ($nb_answers < 1) {
$nb_answers = 1;
@ -131,24 +131,24 @@ class GlobalMultipleAnswer extends Question
'html_editor',
'answer['.$i.']',
null,
array(),
array(
[],
[
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '100',
)
]
);
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement(
'html_editor',
'comment['.$i.']',
null,
array(),
array(
[],
[
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '100',
)
]
);
$form->addElement('html', '</tr>');
@ -196,7 +196,7 @@ class GlobalMultipleAnswer extends Question
$form->setDefaults($defaults);
}
}
$form->setConstants(array('nb_answers' => $nb_answers));
$form->setConstants(['nb_answers' => $nb_answers]);
}
/**

@ -172,7 +172,7 @@ function WriteFileCont($full_file_path, $content)
function GetImgName($imageTag)
{
// Select src tag from img tag.
$match = array();
$match = [];
//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 '
//list($key, $srctag) = each($match);
@ -204,7 +204,7 @@ function GetImgName($imageTag)
function GetSrcName($imageTag)
{
// Select src tag from img tag.
$match = array();
$match = [];
preg_match("|(src=\".*\" )|U", $imageTag, $match); //src
list(, $srctag) = each($match);
$src = substr($srctag, 5, (strlen($srctag) - 7));
@ -226,10 +226,10 @@ function GetSrcName($imageTag)
function GetImgParams($fname, $fpath, &$imgparams, &$imgcount)
{
// Select img tags from context.
$imgparams = array();
$imgparams = [];
//phpinfo();
$contents = ReadFileCont("$fpath"."$fname");
$matches = array();
$matches = [];
preg_match_all('(<img .*>)', $contents, $matches);
$imgcount = 0;
while (list(, $match) = each($matches)) {
@ -269,7 +269,7 @@ function GenerateHiddenList($imgparams)
function myarraysearch(&$array, $node)
{
$match = false;
$tmp_array = array();
$tmp_array = [];
for ($i = 0; $i < count($array); $i++) {
if (!strcmp($array[$i], $node)) {
$match = $node;
@ -302,7 +302,7 @@ function CheckImageName(&$imgparams, $string)
function ReplaceImgTag($content)
{
$newcontent = $content;
$matches = array();
$matches = [];
preg_match_all('(<img .*>)', $content, $matches);
while (list(, $match) = each($matches)) {
while (list(, $imageTag) = each($match)) {
@ -340,7 +340,7 @@ function FillFolderName($name, $nsize)
*/
function GenerateHpFolder($folder)
{
$filelist = array();
$filelist = [];
if ($dir = @opendir($folder)) {
while (($file = readdir($dir)) !== false) {
if ($file != '.') {
@ -427,7 +427,7 @@ function CheckSubFolder($path)
function HotPotGCt($folder, $flag, $user_id)
{
// Garbage Collector
$filelist = array();
$filelist = [];
if ($dir = @opendir($folder)) {
while (($file = readdir($dir)) !== false) {
if ($file != '.') {

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

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

@ -9,10 +9,10 @@
class HotpotatoesExerciseResult
{
//stores the list of exercises
private $exercises_list = array();
private $exercises_list = [];
//stores the results
private $results = array();
private $results = [];
/**
* 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)
{
$return = array();
$return = [];
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$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";
}
$results = array();
$results = [];
$resx = Database::query($sql);
while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
$results[] = $rowx;
}
$hpresults = array();
$hpresults = [];
$resx = Database::query($sql);
while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
$hpresults[] = $rowx;
@ -77,7 +77,7 @@ class HotpotatoesExerciseResult
// Print the Result of Hotpotatoes Tests
if (is_array($hpresults)) {
for ($i = 0; $i < sizeof($hpresults); $i++) {
$return[$i] = array();
$return[$i] = [];
$title = GetQuizName($hpresults[$i]['exe_name'], $document_path);
if ($title == '') {
$title = basename($hpresults[$i]['exe_name']);

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

@ -162,7 +162,7 @@ if ($submitAnswers || $buttonBack) {
$select_question = $_POST['select_question'];
$try = isset($_POST['try']) ? $_POST['try'] : [];
$url = $_POST['url'];
$destination = array();
$destination = [];
$threadhold1 = $_POST['threadhold1'];
$threadhold2 = $_POST['threadhold2'];
@ -374,13 +374,13 @@ if ($modifyAnswers) {
}
}
$reponse = array();
$comment = array();
$weighting = array();
$hotspot_coordinates = array();
$hotspot_type = array();
$destination_items = array();
$destination = array();
$reponse = [];
$comment = [];
$weighting = [];
$hotspot_coordinates = [];
$hotspot_type = [];
$destination_items = [];
$destination = [];
for ($i = 1; $i <= $nbrAnswers; $i++) {
$reponse[$i] = $objAnswer->selectAnswer($i);
@ -433,7 +433,7 @@ if ($modifyAnswers) {
$url_noerror = $destination_items[4];
}
$_SESSION['tmp_answers'] = array();
$_SESSION['tmp_answers'] = [];
$_SESSION['tmp_answers']['answer'] = $reponse;
if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
@ -533,7 +533,7 @@ if ($modifyAnswers) {
}
if ($answerType == HOT_SPOT_DELINEATION) {
$hotspot_colors = array(
$hotspot_colors = [
"",
"#4271B5",
"#FE8E16",
@ -547,9 +547,9 @@ if ($modifyAnswers) {
"#F4EB24",
"#ED2024",
"#3B3B3B"
);
];
} else {
$hotspot_colors = array(
$hotspot_colors = [
"", // $i starts from 1 on next loop (ugly fix)
"#4271B5",
"#FE8E16",
@ -564,7 +564,7 @@ if ($modifyAnswers) {
"#ED2024",
"#3B3B3B",
"#F7BDE2"
);
];
}
Display::tag(
@ -576,28 +576,30 @@ if ($modifyAnswers) {
echo Display::return_message($msgErr, 'normal'); //main API
}
$hotspot_admin_url = api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&hotspotadmin='
.$modifyAnswers.'&exerciseId='.$exerciseId.'&'.api_get_cidreq();
?>
$hotspot_admin_url = api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&hotspotadmin='.$modifyAnswers.'&exerciseId='.$exerciseId; ?>
<form method="post" action="<?php echo $hotspot_admin_url; ?>" class="form-horizontal" id="frm_exercise"
name="frm_exercise">
<div class="form-group">
<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">
<em class="fa fa-trash"></em> <?php echo get_lang('LessOAR'); ?>
</button>
<button type="submit" class="btn btn-primary" name="moreOARAnswers" value="moreOARAnswers">
<em class="fa fa-plus"></em> <?php echo get_lang('MoreOAR'); ?>
</button>
<?php } else { ?>
<?php
} else {
?>
<button type="submit" class="btn btn-danger" name="lessAnswers" value="lessAnswers">
<em class="fa fa-trash"></em> <?php echo get_lang('LessHotspots'); ?>
</button>
<button type="submit" class="btn btn-primary" name="moreAnswers" value="moreAnswers">
<em class="fa fa-plus"></em> <?php echo get_lang('MoreHotspots'); ?>
</button>
<?php } ?>
<?php
} ?>
<button type="submit" class="btn btn-primary" name="submitAnswers" value="submitAnswers">
<em class="fa fa-save"></em> <?php echo get_lang('AddQuestionToExercise'); ?>
</button>
@ -619,8 +621,7 @@ if ($modifyAnswers) {
}
} else {
echo '<th colspan="2">'.get_lang('Comment').'</th>';
}
?>
} ?>
<th><?php echo get_lang('QuestionWeighting'); ?> *</th>
</tr>
</thead>
@ -693,8 +694,7 @@ if ($modifyAnswers) {
$option1 .= '<option '.$selected1.' >'.$k.' % </option>';
$option2 .= '<option '.$selected2.' >'.$k.' % </option>';
$option3 .= '<option '.$selected3.'>'.$k.' %</option>';
}
?>
} ?>
<tr>
<td>
<span class="fa fa-square fa-2x" aria-hidden="true"
@ -732,10 +732,10 @@ if ($modifyAnswers) {
</p>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="delineation"/>
<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>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td>
<div class="checkbox">
<p>
@ -766,7 +766,9 @@ if ($modifyAnswers) {
</select>
</p>
</td>
<?php } else { ?>
<?php
} else {
?>
<td> &nbsp;</td>
<?php
}
@ -791,7 +793,8 @@ if ($modifyAnswers) {
name="comment[<?php echo $i; ?>]"
style="width: 100%"><?php echo Security::remove_XSS($comment[$i]); ?></textarea>
</td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td>
<table>
<tr>
@ -830,9 +833,12 @@ if ($modifyAnswers) {
</tr>
</table>
</td>
<?php } else { ?>
<?php
} else {
?>
<td>&nbsp;</td>
<?php } ?>
<?php
} ?>
</tr>
<?php
} elseif ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') {
@ -842,17 +848,22 @@ if ($modifyAnswers) {
<tr>
<th width="5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></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><?php if ($answerType == HOT_SPOT_DELINEATION) {
echo get_lang('Scenario');
} ?></th>
<?php } else { ?>
<?php
} else {
?>
<th colspan="3"><?php echo get_lang('Comment'); ?></th>
<?php } ?>
<?php
} ?>
<th>&nbsp;</th>
</tr>
<?php } ?>
<?php
} ?>
<tr>
<td>
<span class="fa fa-square fa-2x" aria-hidden="true"
@ -871,10 +882,10 @@ if ($modifyAnswers) {
? Security::remove_XSS($comment[$i]) : ''; ?></textarea>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="oar"/>
<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>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td>
<div class="checkbox">
<p>
@ -907,7 +918,9 @@ if ($modifyAnswers) {
</select>
</p>
</td>
<?php } else { ?>
<?php
} else {
?>
<td>&nbsp;</td>
<?php
}
@ -915,8 +928,7 @@ if ($modifyAnswers) {
//end if is delineation
} else {
$commentValue = isset($comment[$i]) ? $comment[$i] : null;
$responseValue = isset($reponse[$i]) ? $reponse[$i] : null;
?>
$responseValue = isset($reponse[$i]) ? $reponse[$i] : null; ?>
<tr>
<td>
<span class="fa fa-square fa-2x" style="color: <?php echo $hotspot_colors[$i]; ?>"
@ -928,10 +940,10 @@ if ($modifyAnswers) {
</td>
<?php
$form = new FormValidator('form_'.$i);
$config = array(
$config = [
'ToolbarSet' => 'TestProposedAnswer',
'cols-size' => [0, 12, 0]
);
];
$form->addHtmlEditor('comment['.$i.']', null, false, false, $config);
$renderer = $form->defaultRenderer();
$form_template = '{content}';
@ -941,18 +953,20 @@ if ($modifyAnswers) {
{element}';
$renderer->setElementTemplate($element_template);
$form->setDefaults(array('comment['.$i.']' => $commentValue));
$return = $form->returnForm();
?>
$form->setDefaults(['comment['.$i.']' => $commentValue]);
$return = $form->returnForm(); ?>
<td colspan="2" align="left"><?php echo $return; ?></td>
<?php } ?>
<?php
} ?>
<td>
<?php
if ($answerType == HOT_SPOT_DELINEATION) {
if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') {
?>
<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; ?>]"
value="<?php echo(isset($weighting[$i]) ? $weighting[$i] : 10); ?>"/>
<?php
@ -968,7 +982,8 @@ if ($modifyAnswers) {
: $hotspot_coordinates[$i]); ?>"/>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]"
value="<?php echo(empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>"/>
<?php } ?>
<?php
} ?>
</td>
</tr>
<?php
@ -1018,12 +1033,16 @@ if ($modifyAnswers) {
?>
<tr>
<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><?php echo get_lang('Scenario'); ?></th>
<?php } else { ?>
<?php
} else {
?>
<th colspan="3"><?php echo get_lang('Feedback'); ?></th>
<?php } ?>
<?php
} ?>
<th>&nbsp;</th>
</tr>
<tr>
@ -1034,7 +1053,8 @@ if ($modifyAnswers) {
<textarea class="form-control" wrap="virtual" rows="3" cols="25"
name="comment_noerror"><?php echo Security::remove_XSS($comment_noerror); ?></textarea>
</td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td>
<div class="checkbox">
<p>
@ -1065,11 +1085,15 @@ if ($modifyAnswers) {
</p>
</td>
<td>&nbsp;</td>
<?php } else { ?>
<?php
} else {
?>
<td colspan="2">&nbsp;</td>
<?php } ?>
<?php
} ?>
</tr>
<?php } ?>
<?php
} ?>
</tbody>
</table>
</div>
@ -1078,8 +1102,7 @@ if ($modifyAnswers) {
<?php
$swf_loaded = $answerType == HOT_SPOT_DELINEATION ? 'hotspot_delineation_admin' : 'hotspot_admin';
$height = 450;
$relPath = api_get_path(WEB_CODE_PATH);
?>
$relPath = api_get_path(WEB_CODE_PATH); ?>
<div id="hotspot-container" class="center-block">
</div>
</div>
@ -1087,21 +1110,25 @@ if ($modifyAnswers) {
</form>
<script>
$(document).on('ready', function () {
<?php if ($answerType == HOT_SPOT_DELINEATION) { ?>
<?php if ($answerType == HOT_SPOT_DELINEATION) {
?>
new DelineationQuestion({
questionId: <?php echo $modifyAnswers ?>,
selector: '#hotspot-container',
for: 'admin',
relPath: '<?php echo $relPath ?>'
});
<?php } else { ?>
<?php
} else {
?>
new HotspotQuestion({
questionId: <?php echo $modifyAnswers ?>,
selector: '#hotspot-container',
for: 'admin',
relPath: '<?php echo $relPath ?>'
});
<?php } ?>
<?php
} ?>
});
</script>
<?php

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

@ -20,14 +20,14 @@ if (!$result) {
api_not_allowed(true);
}
$interbreadcrumb[] = array(
$interbreadcrumb[] = [
"url" => "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises'),
);
$interbreadcrumb[] = array(
];
$interbreadcrumb[] = [
"url" => "admin.php?exerciseId=$exercise_id&".api_get_cidreq(),
"name" => $objExercise->selectTitle(true),
);
];
//Add the JS needed to use the jqgrid
$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;
//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_model = array(
array(
$column_model = [
[
'name' => 'firstname',
'index' => 'firstname',
'width' => '100',
'align' => 'left',
),
array(
],
[
'name' => 'lastname',
'index' => 'lastname',
'width' => '100',
'align' => 'left',
),
array(
],
[
'name' => 'start_date',
'index' => 'start_date',
'width' => '100',
'align' => 'left',
),
array(
],
[
'name' => 'question',
'index' => 'count_questions',
'width' => '60',
'align' => 'left',
'sortable' => 'false',
),
array(
],
[
'name' => 'score',
'index' => 'score',
'width' => '50',
'align' => 'left',
'sortable' => 'false',
),
);
],
];
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
@ -99,7 +99,7 @@ $(function() {
$columns,
$column_model,
$extra_params,
array(),
[],
null,
true
);
@ -111,7 +111,7 @@ $(function() {
$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>';
echo $actions = Display::div($actions, array('class'=> 'actions'));
echo $actions = Display::div($actions, ['class'=> 'actions']);
echo Display::grid_html('live_stats');

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

@ -32,11 +32,11 @@ class MultipleAnswer extends Question
*/
public function createAnswersForm($form)
{
$editorConfig = array(
$editorConfig = [
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'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['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
@ -59,7 +59,7 @@ class MultipleAnswer extends Question
$form->addHtml($html);
$defaults = array();
$defaults = [];
$correct = 0;
$answer = false;
if (!empty($this->id)) {
@ -71,7 +71,7 @@ class MultipleAnswer extends Question
}
$form->addElement('hidden', 'nb_answers');
$boxes_names = array();
$boxes_names = [];
if ($nb_answers < 1) {
$nb_answers = 1;
@ -136,7 +136,7 @@ class MultipleAnswer extends Question
$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>');
}
@ -178,7 +178,7 @@ class MultipleAnswer extends Question
$form->setDefaults($defaults);
}
}
$form->setConstants(array('nb_answers' => $nb_answers));
$form->setConstants(['nb_answers' => $nb_answers]);
}
/**

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

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

@ -25,7 +25,7 @@ class MultipleAnswerTrueFalse extends Question
parent::__construct();
$this->type = MULTIPLE_ANSWER_TRUE_FALSE;
$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();
$obj_ex = Session::read('objExercise');
$renderer = & $form->defaultRenderer();
$defaults = array();
$defaults = [];
$html = '<table class="table table-striped table-hover">';
$html .= '<thead>';
@ -153,12 +153,12 @@ class MultipleAnswerTrueFalse extends Question
'html_editor',
'comment['.$i.']',
null,
array(),
array(
[],
[
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '100',
)
]
);
}
@ -197,9 +197,9 @@ class MultipleAnswerTrueFalse extends Question
$renderer->setElementTemplate($doubtScoreInputTemplate, 'option[3]');
// 3 scores
$form->addElement('text', 'option[1]', get_lang('Correct'), array('class' => 'span1', 'value' => '1'));
$form->addElement('text', 'option[2]', get_lang('Wrong'), array('class' => 'span1', 'value' => '-0.5'));
$form->addElement('text', 'option[3]', get_lang('DoubtScore'), array('class' => 'span1', 'value' => '0'));
$form->addElement('text', 'option[1]', get_lang('Correct'), ['class' => 'span1', 'value' => '1']);
$form->addElement('text', 'option[2]', get_lang('Wrong'), ['class' => 'span1', 'value' => '-0.5']);
$form->addElement('text', 'option[3]', get_lang('DoubtScore'), ['class' => 'span1', 'value' => '0']);
$form->addRule('option[1]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('option[2]', get_lang('ThisFieldIsRequired'), 'required');
@ -233,7 +233,7 @@ class MultipleAnswerTrueFalse extends Question
} else {
$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');
$course_id = api_get_course_int_id();
$correct = array();
$correct = [];
$options = Question::readQuestionOption($this->id, $course_id);
if (!empty($options)) {
@ -271,7 +271,7 @@ class MultipleAnswerTrueFalse extends Question
it's possible that there are more options in the future */
$new_options = Question::readQuestionOption($this->id, $course_id);
$sorted_by_position = array();
$sorted_by_position = [];
foreach ($new_options as $item) {
$sorted_by_position[$item['position']] = $item;
}
@ -279,7 +279,7 @@ class MultipleAnswerTrueFalse extends Question
/* Saving quiz_question.extra values that has the correct scores of
the true, false, doubt options registered in this format
XX:YY:ZZZ where XX is a float score value.*/
$extra_values = array();
$extra_values = [];
for ($i = 1; $i <= 3; $i++) {
$score = trim($form -> getSubmitValue('option['.$i.']'));
$extra_values[] = $score;
@ -309,7 +309,7 @@ class MultipleAnswerTrueFalse extends Question
/**
* @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 .= '<table class="'.$this->question_table_class .'">

@ -20,7 +20,7 @@ class OralExpression extends Question
private $storePath;
private $fileName;
private $filePath;
public $available_extensions = array('wav', 'ogg');
public $available_extensions = ['wav', 'ogg'];
/**
* Constructor
@ -40,16 +40,16 @@ class OralExpression extends Question
$form->addText(
'weighting',
get_lang('Weighting'),
array('class' => 'span1')
['class' => 'span1']
);
global $text;
// setting the save button here and not in the question class.php
$form->addButtonSave($text, 'submitQuestion');
if (!empty($this->id)) {
$form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
$form -> setDefaults(['weighting' => float_format($this->weighting, 1)]);
} else {
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;
$origin = api_get_origin();
$interbreadcrumb[] = array(
$interbreadcrumb[] = [
"url" => "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises')
);
$interbreadcrumb[] = array("url" => "#", "name" => $objExercise->selectTitle(true));
];
$interbreadcrumb[] = ["url" => "#", "name" => $objExercise->selectTitle(true)];
$time_control = false;
$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(
$objExercise->results_disabled,
array(
[
RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS,
RESULT_DISABLE_SHOW_SCORE_ONLY,
RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES,
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT
)
]
)) {
$row['result'] = $score;
}
if (in_array(
$objExercise->results_disabled,
array(
[
RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS,
RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES,
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT,
)
]
) || (
$objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&
$objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END)
@ -249,47 +249,47 @@ if (!empty($attempts)) {
}
$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
switch ($objExercise->results_disabled) {
case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT:
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 {
$header_names = array(
$header_names = [
get_lang('Attempt'),
get_lang('StartDate'),
get_lang('IP'),
get_lang('Score'),
get_lang('Details'),
);
];
}
break;
case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS:
case RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES:
$header_names = array(
$header_names = [
get_lang('Attempt'),
get_lang('StartDate'),
get_lang('IP'),
get_lang('Score'),
get_lang('Details'),
);
];
break;
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;
case RESULT_DISABLE_SHOW_SCORE_ONLY:
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 {
$header_names = array(
$header_names = [
get_lang('Attempt'),
get_lang('StartDate'),
get_lang('IP'),
get_lang('Score'),
get_lang('Details'),
);
];
}
break;
}

@ -19,18 +19,17 @@ if (!api_is_allowed_to_edit(null, true)) {
}
// the breadcrumbs
$interbreadcrumb[] = array(
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."exercise/exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises')
);
];
$is_allowedToEdit = api_is_allowed_to_edit(null, true);
/**
* 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 .= '<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>';
@ -40,9 +39,9 @@ function ch_qti2_display_form()
'post',
api_get_self()."?".api_get_cidreq(),
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->addButtonImport(get_lang('Upload'));
$form .= $formValidator->returnForm();
@ -54,7 +53,7 @@ function ch_qti2_display_form()
* @param array $array_file ($_FILES)
* @return string|array
*/
function ch_qti2_import_file($array_file)
function importFile($array_file)
{
$unzip = 0;
$process = process_uploaded_file($array_file, false);
@ -80,7 +79,7 @@ $message = null;
// import file
if ((api_is_allowed_to_edit(null, true))) {
if (isset($_POST['submit'])) {
$imported = ch_qti2_import_file($_FILES['userFile']);
$imported = importFile($_FILES['userFile']);
if (is_numeric($imported) && !empty($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;
// display qti form
ch_qti2_display_form();
displayForm();
// display the footer
Display::display_footer();

@ -14,7 +14,7 @@ $this_section = SECTION_COURSES;
api_protect_course_script(true);
// breadcrumbs
$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises'));
$interbreadcrumb[] = ["url" => "exercise.php", "name" => get_lang('Exercises')];
// Tool name
$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'));
$question_list = Question::get_question_type_list();
$question_list_options = array();
$question_list_options = [];
foreach ($question_list as $key=> $value) {
$question_list_options[$key] = addslashes(get_lang($value[1]));
}
@ -34,7 +34,7 @@ $form->addElement(
'question_type_hidden',
get_lang('QuestionType'),
$question_list_options,
array('id' => 'question_type_hidden')
['id' => 'question_type_hidden']
);
//session id
@ -61,7 +61,7 @@ $form->addElement(
'is_content',
null,
get_lang('GenerateDefaultContent'),
array('checked' => true)
['checked' => true]
);
// the submit button

@ -38,11 +38,11 @@ class UniqueAnswer extends Question
// Getting the exercise list
$obj_ex = Session::read('objExercise');
$editor_config = array(
$editor_config = [
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '125'
);
];
//this line defines how many questions by default appear when creating a choice question
// The previous default value was 2. See task #1759.
@ -82,7 +82,7 @@ class UniqueAnswer extends Question
$form->addHeader(get_lang('Answers'));
$form->addHtml($html);
$defaults = array();
$defaults = [];
$correct = 0;
if (!empty($this->id)) {
$answer = new Answer($this->id);
@ -95,7 +95,7 @@ class UniqueAnswer extends Question
//Feedback SELECT
$question_list = $obj_ex->selectQuestionList();
$select_question = array();
$select_question = [];
$select_question[0] = get_lang('SelectTargetQuestion');
if (is_array($question_list)) {
foreach ($question_list as $key => $questionid) {
@ -114,14 +114,14 @@ class UniqueAnswer extends Question
$list = new LearnpathList(api_get_user_id());
$flat_list = $list->get_flat_list();
$select_lp_id = array();
$select_lp_id = [];
$select_lp_id[0] = get_lang('SelectTargetLP');
foreach ($flat_list as $id => $details) {
$select_lp_id[$id] = cut($details['lp_name'], 20);
}
$temp_scenario = array();
$temp_scenario = [];
if ($nb_answers < 1) {
$nb_answers = 1;
@ -133,17 +133,16 @@ class UniqueAnswer extends Question
for ($i = 1; $i <= $nb_answers; ++$i) {
$form->addHtml('<tr>');
if (isset($answer) && is_object($answer)) {
if ($answer->correct[$i]) {
if (isset($answer->correct[$i]) && $answer->correct[$i]) {
$correct = $i;
}
$defaults['answer['.$i.']'] = $answer->answer[$i];
$defaults['comment['.$i.']'] = $answer->comment[$i];
$defaults['weighting['.$i.']'] = float_format(
$answer->weighting[$i],
1
);
$defaults['answer['.$i.']'] = isset($answer->answer[$i]) ? $answer->answer[$i] : '';
$defaults['comment['.$i.']'] = isset($answer->comment[$i]) ? $answer->comment[$i] : '';
$defaults['weighting['.$i.']'] = isset($answer->weighting[$i]) ? float_format($answer->weighting[$i], 1) : 0;
$item_list = [];
if (isset($answer->destination[$i])) {
$item_list = explode('@@', $answer->destination[$i]);
}
$try = isset($item_list[0]) ? $item_list[0] : '';
$lp = isset($item_list[1]) ? $item_list[1] : '';
@ -171,8 +170,8 @@ class UniqueAnswer extends Question
$defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
$defaults['weighting[2]'] = 0;
$temp_scenario['destination'.$i] = array('0');
$temp_scenario['lp'.$i] = array('0');
$temp_scenario['destination'.$i] = ['0'];
$temp_scenario['lp'.$i] = ['0'];
}
$defaults['scenario'] = $temp_scenario;
@ -233,7 +232,7 @@ class UniqueAnswer extends Question
);
// Direct feedback
//Adding extra feedback fields
$group = array();
$group = [];
$group['try'.$i] = $form->createElement(
'checkbox',
'try'.$i,
@ -256,10 +255,10 @@ class UniqueAnswer extends Question
'text',
'url'.$i,
get_lang('Other').': ',
array(
[
'class' => 'col-md-2',
'placeholder' => get_lang('Other')
)
]
);
$form->addGroup($group, 'scenario');
@ -270,7 +269,7 @@ class UniqueAnswer extends Question
} else {
$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>');
}
@ -311,10 +310,10 @@ class UniqueAnswer extends Question
// Default sample content.
$form->setDefaults($defaults);
} 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
$obj_ex = Session::read('objExercise');
$editor_config = array(
$editor_config = [
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '125'
);
];
//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['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
@ -77,7 +77,7 @@ class UniqueAnswerNoOption extends Question
$form->addHeader(get_lang('Answers'));
$form->addHtml($html);
$defaults = array();
$defaults = [];
$correct = 0;
$answer = false;
if (!empty($this->id)) {
@ -88,7 +88,7 @@ class UniqueAnswerNoOption extends Question
}
}
$temp_scenario = array();
$temp_scenario = [];
if ($nb_answers < 1) {
$nb_answers = 1;
echo Display::return_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
@ -96,7 +96,7 @@ class UniqueAnswerNoOption extends Question
$editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : false;
if ($editQuestion) {
//fixing $nb_answers
$new_list = array();
$new_list = [];
$count = 1;
if (isset($_POST['lessAnswers'])) {
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('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('text', 'weighting['.$i.']', null, array('style' => 'width: 60px;', 'value' => '0'));
$form->addElement('html_editor', 'comment['.$i.']', null, [], $editor_config);
$form->addElement('text', 'weighting['.$i.']', null, ['style' => 'width: 60px;', 'value' => '0']);
$form->addElement('html', '</tr>');
$i++;
}
@ -244,10 +244,10 @@ class UniqueAnswerNoOption extends Question
$form->addElement('hidden', 'position['.$i.']', '666');
$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->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');
@ -284,7 +284,7 @@ class UniqueAnswerNoOption extends Question
}
$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
lp_upload_quiz_action_handling();
$interbreadcrumb[] = array(
$interbreadcrumb[] = [
"url" => "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises')
);
];
// Display the header
Display :: display_header(get_lang('ImportExcelQuiz'), 'Exercises');
@ -69,7 +69,7 @@ function lp_upload_quiz_main()
'POST',
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('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>';
$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'),
MULTIPLE_ANSWER => get_lang('MultipleSelect'),
FILL_IN_BLANKS => get_lang('FillBlanks'),
MATCHING => get_lang('Matching'),
FREE_ANSWER => get_lang('FreeAnswer'),
GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer')
);
];
$table->setHeaderContents(0, 0, get_lang('QuestionType'));
$table->setHeaderContents(0, 1, '#');
@ -106,7 +106,7 @@ function lp_upload_quiz_main()
'user_custom_score',
null,
get_lang('UseCustomScoreForAllQuestions'),
array('id' => 'user_custom_score')
['id' => 'user_custom_score']
);
$form->addElement('html', '<div id="options" style="display:none">');
$form->addElement('text', 'correct_score', get_lang('CorrectScore'));

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

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

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

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

Loading…
Cancel
Save