Add new exercise feedback type EXERCISE_FEEDBACK_TYPE_POPUP see BT#15827

pull/2958/head
Julio Montoya 7 years ago
parent 9dd242e149
commit b6267722dc
  1. 6
      main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
  2. 71
      main/exercise/UniqueAnswerImage.php
  3. 2
      main/exercise/admin.php
  4. 200
      main/exercise/exercise.class.php
  5. 7
      main/exercise/exercise_admin.php
  6. 10
      main/exercise/exercise_result.php
  7. 2
      main/exercise/exercise_show.php
  8. 4
      main/exercise/exercise_submit.php
  9. 112
      main/exercise/exercise_submit_modal.php
  10. 53
      main/exercise/hotspot_admin.inc.php
  11. 2
      main/exercise/hotspot_answers.as.php
  12. 6
      main/exercise/multiple_answer_true_false.class.php
  13. 4
      main/exercise/overview.php
  14. 12
      main/exercise/question.class.php
  15. 3
      main/exercise/question_list_admin.inc.php
  16. 5
      main/exercise/question_pool.php
  17. 125
      main/exercise/unique_answer.class.php
  18. 2
      main/exercise/unique_answer_no_option.class.php
  19. 3
      main/inc/lib/api.lib.php
  20. 20
      main/inc/lib/document.lib.php
  21. 44
      main/inc/lib/exercise.lib.php
  22. 13
      main/inc/lib/geometry.lib.php
  23. 1
      main/inc/lib/urlmanager.lib.php

@ -77,7 +77,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
.'</th>';
// show column comment when feedback is enable
if ($objEx->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($objEx->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$html .= '<th>'.get_lang('Comment').'</th>';
}
$html .= '</tr>';
@ -173,7 +173,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
// show comment when feedback is enable
if ($objEx->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($objEx->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$form->addElement(
'html_editor',
'comment['.$i.']',
@ -318,7 +318,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
.get_lang('YourDegreeOfCertainty')
.'</th>'
;
if ($exercise->feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($exercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$header .= '<th>'.get_lang('Comment').'</th>';
} else {
$header .= '<th>&nbsp;</th>';

@ -43,13 +43,18 @@ class UniqueAnswerImage extends UniqueAnswer
$numberAnswers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$feedbackTitle = '';
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
//Scenario
$commentTitle = '<th>'.get_lang('Comment').'</th>';
$feedbackTitle = '<th>'.get_lang('Scenario').'</th>';
} else {
$commentTitle = '<th >'.get_lang('Comment').'</th>';
switch ($objExercise->getFeedbackType()) {
case EXERCISE_FEEDBACK_TYPE_DIRECT:
// Scenario
$commentTitle = '<th width="20%">'.get_lang('Comment').'</th>';
$feedbackTitle = '<th width="20%">'.get_lang('Scenario').'</th>';
break;
case EXERCISE_FEEDBACK_TYPE_POPUP:
$commentTitle = '<th width="20%">'.get_lang('Comment').'</th>';
break;
default:
$commentTitle = '<th width="40%">'.get_lang('Comment').'</th>';
break;
}
$html = '<div class="alert alert-success" role="alert">'.
@ -196,49 +201,17 @@ class UniqueAnswerImage extends UniqueAnswer
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$form->addHtmlEditor(
'comment['.$i.']',
null,
null,
false,
$editorConfig
);
// Direct feedback
// Adding extra feedback fields
$group = [];
$group['try'.$i] = $form->createElement('checkbox', 'try'.$i, null, get_lang('TryAgain'));
$group['lp'.$i] = $form->createElement(
'select',
'lp'.$i,
get_lang('SeeTheory').': ',
$selectLpId
);
$group['destination'.$i] = $form->createElement(
'select',
'destination'.$i,
get_lang('GoToQuestion').': ',
$selectQuestion
);
$group['url'.$i] = $form->createElement(
'text',
'url'.$i,
get_lang('Other').': ',
[
'class' => 'col-md-2',
'placeholder' => get_lang('Other'),
]
);
$form->addGroup($group, 'scenario');
$renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}',
'scenario'
);
} else {
$form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig);
switch ($objExercise->getFeedbackType()) {
case EXERCISE_FEEDBACK_TYPE_DIRECT:
$this->setDirectOptions($i, $form, $renderer, $selectLpId, $selectQuestion);
break;
case EXERCISE_FEEDBACK_TYPE_POPUP:
default:
$form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig);
break;
}
$form->addText('weighting['.$i.']', null, null, ['class' => "col-md-1", 'value' => '0']);
$form->addText('weighting['.$i.']', null, null, ['class' => 'col-md-1', 'value' => '0']);
$form->addHtml('</tr>');
}

@ -453,7 +453,7 @@ if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspot
// if we are in question authoring, display warning to user is feedback not shown at the end of the test -ref #6619
// this test to display only message in the question authoring page and not in the question list page too
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM) {
echo Display::return_message(get_lang('TestFeedbackNotShown'), 'normal');
}

@ -308,14 +308,15 @@ class Exercise
return $this->attempts;
}
/** returns the number of FeedbackType *
* 0=>Feedback , 1=>DirectFeedback, 2=>NoFeedback.
/**
* Returns the number of FeedbackType
* 0: Feedback , 1: DirectFeedback, 2: NoFeedback.
*
* @return int - exercise attempts
*/
public function selectFeedbackType()
public function getFeedbackType()
{
return $this->feedback_type;
return (int) $this->feedback_type;
}
/**
@ -1523,7 +1524,7 @@ class Exercise
// If direct we do not show results
$results_disabled = (int) $this->results_disabled;
if ($feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (in_array($feedback_type, [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
$results_disabled = 0;
}
$expired_time = (int) $this->expired_time;
@ -1886,14 +1887,13 @@ class Exercise
$type = 'full';
}
// form title
// Form title
$form_title = get_lang('NewEx');
if (!empty($_GET['exerciseId'])) {
$form_title = get_lang('ModifyExercise');
} else {
$form_title = get_lang('NewEx');
}
$form->addElement('header', $form_title);
$form->addHeader($form_title);
// Title.
if (api_get_configuration_value('save_titles_as_html')) {
@ -1940,6 +1940,7 @@ class Exercise
'Width' => '100%',
'Height' => '150',
];
if (is_array($type)) {
$editor_config = array_merge($editor_config, $type);
}
@ -1954,56 +1955,9 @@ class Exercise
$skillList = [];
if ($type === 'full') {
//Can't modify a DirectFeedback question
if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT) {
// feedback type
$radios_feedback = [];
$radios_feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('ExerciseAtTheEndOfTheTest'),
'0',
[
'id' => 'exerciseType_0',
'onclick' => 'check_feedback()',
]
);
if (api_get_setting('enable_quiz_scenario') === 'true') {
// Can't convert a question from one feedback to another
// if there is more than 1 question already added
if ($this->selectNbrQuestions() == 0) {
$radios_feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('DirectFeedback'),
'1',
[
'id' => 'exerciseType_1',
'onclick' => 'check_direct_feedback()',
]
);
}
}
$radios_feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('NoFeedback'),
'2',
['id' => 'exerciseType_2']
);
$form->addGroup(
$radios_feedback,
null,
[
get_lang('FeedbackType'),
get_lang('FeedbackDisplayOptions'),
]
);
// Can't modify a DirectFeedback question.
if (!in_array($this->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
$this->setResultFeedbackGroup($form);
// Type of results display on the final page
$this->setResultDisabledGroup($form);
@ -2037,41 +1991,7 @@ class Exercise
} else {
// if is Direct feedback but has not questions we can allow to modify the question type
if ($this->getQuestionCount() === 0) {
// feedback type
$radios_feedback = [];
$radios_feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('ExerciseAtTheEndOfTheTest'),
'0',
['id' => 'exerciseType_0', 'onclick' => 'check_feedback()']
);
if (api_get_setting('enable_quiz_scenario') == 'true') {
$radios_feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('DirectFeedback'),
'1',
['id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()']
);
}
$radios_feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('NoFeedback'),
'2',
['id' => 'exerciseType_2']
);
$form->addGroup(
$radios_feedback,
null,
[get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')]
);
$this->setResultFeedbackGroup($form);
$this->setResultDisabledGroup($form);
// Type of questions disposition on page
@ -2090,7 +2010,7 @@ class Exercise
$group->freeze();
// we force the options to the DirectFeedback exercisetype
$form->addElement('hidden', 'exerciseFeedbackType', EXERCISE_FEEDBACK_TYPE_DIRECT);
$form->addElement('hidden', 'exerciseFeedbackType', $this->getFeedbackType());
$form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
// Type of questions disposition on page
@ -2461,7 +2381,7 @@ class Exercise
$defaults['exerciseTitle'] = $this->get_formated_title();
$defaults['exerciseDescription'] = $this->selectDescription();
$defaults['exerciseAttempts'] = $this->selectAttempts();
$defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
$defaults['exerciseFeedbackType'] = $this->getFeedbackType();
$defaults['results_disabled'] = $this->selectResultsDisabled();
$defaults['propagate_neg'] = $this->selectPropagateNeg();
$defaults['save_correct_answers'] = $this->selectSaveCorrectAnswers();
@ -2544,6 +2464,71 @@ class Exercise
}
}
/**
* @param $form
*/
public function setResultFeedbackGroup(FormValidator $form)
{
// Feedback type.
$feedback = [];
$feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('ExerciseAtTheEndOfTheTest'),
EXERCISE_FEEDBACK_TYPE_END,
[
'id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_END,
'onclick' => 'check_feedback()',
]
);
if (api_get_setting('enable_quiz_scenario') === 'true') {
// Can't convert a question from one feedback to another
// if there is more than 1 question already added
if ($this->selectNbrQuestions() == 0) {
$feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('DirectFeedback'),
EXERCISE_FEEDBACK_TYPE_DIRECT,
[
'id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_DIRECT,
'onclick' => 'check_direct_feedback()',
]
);
}
}
$feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('ExerciseDirectPopUp'),
EXERCISE_FEEDBACK_TYPE_POPUP,
['id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_POPUP, 'onclick' => 'check_direct_feedback()']
);
$feedback[] = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('NoFeedback'),
EXERCISE_FEEDBACK_TYPE_EXAM,
['id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_EXAM]
);
$form->addGroup(
$feedback,
null,
[
get_lang('FeedbackType'),
get_lang('FeedbackDisplayOptions'),
]
);
}
/**
* function which process the creation of exercises.
*
@ -3093,7 +3078,9 @@ class Exercise
$html = $label = '';
$hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;
if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) {
if (in_array($this->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]) &&
$this->type == ONE_PER_PAGE
) {
$urlTitle = get_lang('ContinueTest');
if ($questionNum == count($this->questionList)) {
$urlTitle = get_lang('EndTest');
@ -3101,7 +3088,7 @@ class Exercise
$html .= Display::url(
$urlTitle,
'exercise_submit_modal.php?'.http_build_query([
api_get_path(WEB_CODE_PATH).'exercise/exercise_submit_modal.php?'.http_build_query([
'learnpath_id' => $safe_lp_id,
'learnpath_item_id' => $safe_lp_item_id,
'learnpath_item_view_id' => $safe_lp_item_view_id,
@ -3348,7 +3335,7 @@ class Exercise
global $learnpath_id, $learnpath_item_id;
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
$em = Database::getManager();
$feedback_type = $this->selectFeedbackType();
$feedback_type = $this->getFeedbackType();
$results_disabled = $this->selectResultsDisabled();
if ($debug) {
@ -4816,8 +4803,12 @@ class Exercise
$coords = explode('/', $user_answer);
$user_array = '';
foreach ($coords as $coord) {
list($x, $y) = explode(';', $coord);
$user_array .= round($x).';'.round($y).'/';
if (!empty($coord)) {
$parts = explode(';', $coord);
if (!empty($parts)) {
$user_array .= round($parts[0]).';'.round($parts[1]).'/';
}
}
}
$user_array = substr($user_array, 0, -1);
@ -7200,7 +7191,10 @@ class Exercise
if ($currentQuestion != $i) {
continue;
} else {
if ($this->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (!in_array(
$this->getFeedbackType(),
[EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]
)) {
// if the user has already answered this question
if (isset($exerciseResult[$questionId])) {
echo Display::return_message(
@ -9650,7 +9644,7 @@ class Exercise
['id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()']
);
if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (in_array($this->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
$group = $form->addGroup(
$resultDisabledGroup,
null,

@ -185,7 +185,6 @@ if ($form->validate()) {
Display::display_header($nameTools, get_lang('Exercise'));
echo '<div class="actions">';
if ($objExercise->id != 0) {
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.
Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
@ -199,7 +198,7 @@ if ($form->validate()) {
}
$lp_id = (int) $lp_id;
echo "<a href=\"../lp/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-2\">".
Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"), '', ICON_SIZE_MEDIUM)."</a>";
Display::return_icon('back.png', get_lang("BackTo").' '.get_lang('LearningPaths'), '', ICON_SIZE_MEDIUM)."</a>";
} else {
echo '<a href="exercise.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).
@ -208,11 +207,11 @@ if ($form->validate()) {
}
echo '</div>';
if ($objExercise->feedback_type == 1) {
if (in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
echo Display::return_message(get_lang('DirectFeedbackCantModifyTypeQuestion'));
}
if (api_get_setting('search_enabled') == 'true' &&
if (api_get_setting('search_enabled') === 'true' &&
!extension_loaded('xapian')
) {
echo Display::return_message(get_lang('SearchXapianModuleNotInstalled'), 'error');

@ -100,7 +100,7 @@ if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) {
echo '</div>';
}
$feedback_type = $objExercise->feedback_type;
$feedback_type = $objExercise->getFeedbackType();
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info['data_tracking'])) {
@ -222,7 +222,7 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
Session::erase('duration_time');
}
Display::display_footer();
} elseif ($origin == 'embeddable') {
} elseif ($origin === 'embeddable') {
if (api_is_allowed_to_session_edit()) {
Session::erase('objExercise');
Session::erase('exe_id');
@ -232,14 +232,12 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
}
Session::write('attempt_remaining', $remainingMessage);
showEmbeddableFinishButton();
Display::display_reduced_footer();
} else {
$lp_mode = Session::read('lp_mode');
$url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type.'#atoc_'.$learnpath_item_id;
$href = $lp_mode == 'fullscreen' ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'"';
$url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->getFeedbackType().'#atoc_'.$learnpath_item_id;
$href = $lp_mode === 'fullscreen' ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'"';
if (api_is_allowed_to_session_edit()) {
Session::erase('objExercise');

@ -127,7 +127,7 @@ if (empty($objExercise)) {
$objExercise = new Exercise();
$objExercise->read($exercise_id);
}
$feedback_type = $objExercise->feedback_type;
$feedback_type = $objExercise->getFeedbackType();
// Only users can see their own results
if (!$is_allowedToEdit) {

@ -667,7 +667,7 @@ if ($formSent && isset($_POST)) {
// stores the user answer into the array
$exerciseResult[$key] = $choice[$key];
//saving each question
if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (!in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
$nro_question = $current_question; // - 1;
$questionId = $key;
// gets the student choice for this question
@ -1395,7 +1395,7 @@ if (!empty($error)) {
$i++;
continue;
} else {
if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (!in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
// if the user has already answered this question
if (isset($exerciseResult[$questionId])) {
// construction of the Question object

@ -10,7 +10,7 @@ use ChamiloSession as Session;
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(false);
api_protect_course_script();
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
@ -31,23 +31,30 @@ $origin = api_get_origin();
// if origin is learnpath
$learnpath_id = 0;
if (isset($_REQUEST['learnpath_id'])) {
$learnpath_id = intval($_REQUEST['learnpath_id']);
$learnpath_id = (int) $_REQUEST['learnpath_id'];
}
$learnpath_item_id = 0;
if (isset($_REQUEST['learnpath_item_id'])) {
$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
$learnpath_item_id = (int) $_REQUEST['learnpath_item_id'];
}
/** @var Exercise $objExercise */
$objExercise = Session::read('objExercise');
if (empty($objExercise)) {
api_not_allowed();
}
$_SESSION['hotspot_coord'] = [];
$newquestionList = Session::read('newquestionList', []);
$newQuestionList = Session::read('newquestionList', []);
$questionList = Session::read('questionList');
$exerciseId = intval($_GET['exerciseId']);
$exerciseType = intval($_GET['exerciseType']);
$questionNum = intval($_GET['num']);
$nbrQuestions = isset($_GET['nbrQuestions']) ? intval($_GET['nbrQuestions']) : null;
$exerciseId = (int) $_GET['exerciseId'];
$exerciseType = (int) $_GET['exerciseType'];
$questionNum = (int) $_GET['num'];
$nbrQuestions = isset($_GET['nbrQuestions']) ? (int) $_GET['nbrQuestions'] : null;
//clean extra session variables
// Clean extra session variables
Session::erase('objExerciseExtra'.$exerciseId);
Session::erase('exerciseResultExtra'.$exerciseId);
Session::erase('questionListExtra'.$exerciseId);
@ -73,7 +80,6 @@ if (isset($_GET['choice'])) {
}
echo '<div id="delineation-container">';
// Getting the options by js
if (empty($choice_value)) {
echo "<script>
@ -114,9 +120,9 @@ if (empty($choice_value)) {
}
$choice = [];
$questionid = $questionList[$questionNum];
$questionId = $questionList[$questionNum];
// $choice_value => value of the user selection
$choice[$questionid] = isset($choice_value) ? $choice_value : null;
$choice[$questionId] = isset($choice_value) ? $choice_value : null;
// initializing
if (!is_array($exerciseResult)) {
@ -125,7 +131,7 @@ if (!is_array($exerciseResult)) {
// if the user has answered at least one question
if (is_array($choice)) {
if ($exerciseType == EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (in_array($exerciseType, [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
// $exerciseResult receives the content of the form.
// Each choice of the student is stored into the array $choice
$exerciseResult = $choice;
@ -145,8 +151,8 @@ Session::write('exerciseResult', $exerciseResult);
Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
// creates a temporary Question object
if (in_array($questionid, $questionList)) {
$objQuestionTmp = Question:: read($questionid);
if (in_array($questionId, $questionList)) {
$objQuestionTmp = Question:: read($questionId);
$questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
$questionWeighting = $objQuestionTmp->selectWeighting();
@ -154,9 +160,9 @@ if (in_array($questionid, $questionList)) {
$quesId = $objQuestionTmp->selectId(); //added by priya saini
}
$objAnswerTmp = new Answer($questionid);
$objAnswerTmp = new Answer($questionId);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
$choice = $exerciseResult[$questionid];
$choice = $exerciseResult[$questionId];
$destination = [];
$comment = '';
$next = 1;
@ -182,24 +188,21 @@ 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);
}
switch ($answerType) {
// for unique answer
case UNIQUE_ANSWER:
$studentChoice = ($choice_value == $numAnswer) ? 1 : 0;
$studentChoice = $choice_value == $numAnswer ? 1 : 0;
if ($studentChoice) {
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
$newquestionList[] = $questionid;
$newQuestionList[] = $questionId;
}
break;
case HOT_SPOT_DELINEATION:
$studentChoice = $choice[$answerId];
if ($studentChoice) {
$newquestionList[] = $questionid;
$newQuestionList[] = $questionId;
}
if ($answerId === 1) {
$questionScore += $answerWeighting;
@ -219,7 +222,7 @@ if (!empty($choice_value)) {
if ($next) {
$hot_spot_load = true; //apparently the script is called twice
$user_answer = $user_array;
$_SESSION['exerciseResultCoordinates'][$questionid] = $user_answer; //needed for exercise_result.php
$_SESSION['exerciseResultCoordinates'][$questionId] = $user_answer; //needed for exercise_result.php
// we compare only the delineation not the other points
$answer_question = $_SESSION['hotspot_coord'][1];
@ -320,16 +323,10 @@ if (!empty($choice_value)) {
$url_hotspot = $destination_items[4];
} elseif ($answerId > 1) {
if ($objAnswerTmp->selectHotspotType($answerId) === 'noerror') {
if ($dbg_local > 0) {
error_log(__LINE__.' - answerId is of type noerror', 0);
}
//type no error shouldn't be treated
// Type no error shouldn't be treated
$next = 1;
continue;
}
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);
@ -397,20 +394,18 @@ if (!empty($choice_value)) {
}
}
$overlap_color = 'red';
if ($overlap_color) {
$overlap_color = 'green';
} else {
$overlap_color = 'red';
}
$missing_color = 'red';
if ($missing_color) {
$missing_color = 'green';
} else {
$missing_color = 'red';
}
$excess_color = 'red';
if ($excess_color) {
$excess_color = 'green';
} else {
$excess_color = 'red';
}
if (!is_numeric($final_overlap)) {
@ -452,29 +447,32 @@ if (!empty($choice_value)) {
</tr>
</table>';
}
Session::write('newquestionList', $newquestionList);
Session::write('newquestionList', $newQuestionList);
$links = '';
if (isset($choice_value) && $choice_value == -1) {
if ($answerType != HOT_SPOT_DELINEATION) {
$links .= '<a href="#" onclick="tb_remove();">'.get_lang('ChooseAnAnswer').'</a><br />';
if ($objExercise->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (isset($choice_value) && $choice_value == -1) {
if ($answerType != HOT_SPOT_DELINEATION) {
$links .= '<a href="#" onclick="tb_remove();">'.get_lang('ChooseAnAnswer').'</a><br />';
}
}
}
$destinationid = null;
$destinationId = null;
if ($answerType != HOT_SPOT_DELINEATION) {
if (!empty($destination)) {
$item_list = explode('@@', $destination);
$try = $item_list[0];
$lp = $item_list[1];
$destinationid = $item_list[2];
$destinationId = $item_list[2];
$url = $item_list[3];
}
$table_resume = '';
} else {
$try = $try_hotspot;
$lp = $lp_hotspot;
$destinationid = $select_question_hotspot;
$destinationId = $select_question_hotspot;
$url = $url_hotspot;
$exerciseResult[$questionId] = 0;
if ($organs_at_risk_hit == 0 && $wrong_results == false) {
// no error = no oar and no wrong result for delineation
// show if no error
@ -484,17 +482,15 @@ if ($answerType != HOT_SPOT_DELINEATION) {
$destination_items = explode('@@', $answerDestination);
$try = $destination_items[1];
$lp = $destination_items[2];
$destinationid = $destination_items[3];
$destinationId = $destination_items[3];
$url = $destination_items[4];
$exerciseResult[$questionid] = 1;
} else {
$exerciseResult[$questionid] = 0;
$exerciseResult[$questionId] = 1;
}
}
// the link to retry the question
if (isset($try) && $try == 1) {
$num_value_array = array_keys($questionList, $questionid);
$num_value_array = array_keys($questionList, $questionId);
$links .= Display:: return_icon(
'reload.gif',
'',
@ -513,6 +509,7 @@ if (!empty($lp)) {
['style' => 'padding-left:0px;padding-right:5px;']
).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
}
$links .= '<br />';
// the link to an external website or link
@ -524,8 +521,13 @@ if (!empty($url)) {
).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
}
if ($objExercise->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_POPUP) {
$nextQuestion = $questionNum + 1;
$destinationId = isset($questionList[$nextQuestion]) ? $questionList[$nextQuestion] : -1;
}
// the link to finish the test
if ($destinationid == -1) {
if ($destinationId == -1) {
$links .= Display:: return_icon(
'finish.gif',
'',
@ -533,10 +535,10 @@ if ($destinationid == -1) {
).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
} else {
// the link to other question
if (in_array($destinationid, $questionList)) {
$objQuestionTmp = Question::read($destinationid);
if (in_array($destinationId, $questionList)) {
$objQuestionTmp = Question::read($destinationId);
$questionName = $objQuestionTmp->selectTitle();
$num_value_array = array_keys($questionList, $destinationid);
$num_value_array = array_keys($questionList, $destinationId);
$icon = Display::return_icon(
'quiz.png',
'',
@ -583,8 +585,8 @@ if (!empty($links)) {
echo '</div>';
Session::write('hot_spot_result', $message);
$_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = [$message, $exerciseResult[$questionid]];
//reseting the exerciseResult variable
$_SESSION['hotspot_delineation_result'][$exerciseId][$questionId] = [$message, $exerciseResult[$questionId]];
// Resetting the exerciseResult variable
Session::write('exerciseResult', $exerciseResult);
//save this variables just in case the exercise loads an LP with other exercise

@ -159,9 +159,9 @@ if ($submitAnswers || $buttonBack) {
}
$questionWeighting = $nbrGoodAnswers = 0;
$select_question = $_POST['select_question'];
$select_question = isset($_POST['select_question']) ? $_POST['select_question'] : null;
$try = isset($_POST['try']) ? $_POST['try'] : [];
$url = $_POST['url'];
$url = isset($_POST['url']) ? $_POST['url'] : '';
$destination = [];
$threadhold1 = $_POST['threadhold1'];
@ -169,10 +169,6 @@ if ($submitAnswers || $buttonBack) {
$threadhold3 = $_POST['threadhold3'];
for ($i = 1; $i <= $nbrAnswers; $i++) {
if ($debug > 0) {
echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
}
$reponse[$i] = trim($reponse[$i]);
$comment[$i] = trim($comment[$i]);
$weighting[$i] = $weighting[$i];
@ -180,19 +176,19 @@ if ($submitAnswers || $buttonBack) {
if (empty($threadhold1[$i])) {
$threadhold1_str = 0;
} else {
$threadhold1_str = intval($threadhold1[$i]);
$threadhold1_str = (int) $threadhold1[$i];
}
if (empty($threadhold2[$i])) {
$threadhold2_str = 0;
} else {
$threadhold2_str = intval($threadhold2[$i]);
$threadhold2_str = (int) $threadhold2[$i];
}
if (empty($threadhold3[$i])) {
$threadhold3_str = 0;
} else {
$threadhold3_str = intval($threadhold3[$i]);
$threadhold3_str = (int) $threadhold3[$i];
}
$threadhold_total = $threadhold1_str.';'.$threadhold2_str.';'.$threadhold3_str;
@ -209,9 +205,8 @@ if ($submitAnswers || $buttonBack) {
$lp_str = $lp[$i];
}
if ($url[$i] == '') {
$url_str = '';
} else {
$url_str = '';
if (isset($url[$i]) && !empty($url[$i])) {
$url_str = $url[$i];
}
@ -245,14 +240,14 @@ if ($submitAnswers || $buttonBack) {
$objAnswer->cancel();
break;
}
} // end for()
}
//now the noerror section
$selectQuestionNoError = Security::remove_XSS($_POST['select_question_noerror']);
$lp_noerror = Security::remove_XSS($_POST['lp_noerror']);
// now the noerror section
$selectQuestionNoError = isset($_POST['select_question_noerror']) ? Security::remove_XSS($_POST['select_question_noerror']) : null;
$lp_noerror = isset($_POST['lp_noerror']) ? Security::remove_XSS($_POST['lp_noerror']) : '';
$try_noerror = isset($_POST['try_noerror']) ? Security::remove_XSS($_POST['try_noerror']) : null;
$url_noerror = Security::remove_XSS($_POST['url_noerror']);
$comment_noerror = Security::remove_XSS($_POST['comment_noerror']);
$url_noerror = isset($_POST['url_noerror']) ? Security::remove_XSS($_POST['url_noerror']) : null;
$comment_noerror = isset($_POST['comment_noerror']) ? Security::remove_XSS($_POST['comment_noerror']) : null;
$threadhold_total = '0;0;0';
if ($try_noerror == 'on') {
@ -385,7 +380,7 @@ if (isset($modifyAnswers)) {
for ($i = 1; $i <= $nbrAnswers; $i++) {
$reponse[$i] = $objAnswer->selectAnswer($i);
if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($objExercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$comment[$i] = $objAnswer->selectComment($i);
}
@ -436,7 +431,7 @@ if (isset($modifyAnswers)) {
$_SESSION['tmp_answers'] = [];
$_SESSION['tmp_answers']['answer'] = $reponse;
if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($objExercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$_SESSION['tmp_answers']['comment'] = $comment;
}
@ -474,7 +469,7 @@ if (isset($modifyAnswers)) {
$nbrAnswers--;
// Remove the last answer
$tmp = array_pop($_SESSION['tmp_answers']['answer']);
if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($objExercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$tmp = array_pop($_SESSION['tmp_answers']['comment']);
}
$tmp = array_pop($_SESSION['tmp_answers']['weighting']);
@ -494,7 +489,7 @@ if (isset($modifyAnswers)) {
// Add a new answer
$_SESSION['tmp_answers']['answer'][] = '';
if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($objExercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$_SESSION['tmp_answers']['comment'][] = '';
}
$_SESSION['tmp_answers']['weighting'][] = '1';
@ -615,7 +610,7 @@ if (isset($modifyAnswers)) {
<th width="5">&nbsp;</th>
<th><?php echo get_lang('HotspotDescription'); ?> *</th>
<?php
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
if ($objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
echo '<th>'.get_lang('Comment').'</th>';
if ($answerType == HOT_SPOT_DELINEATION) {
echo '<th >'.get_lang('Scenario').'</th>';
@ -736,7 +731,7 @@ if (isset($modifyAnswers)) {
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php
echo empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]; ?>"/>
</td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
<?php if ($objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td>
<div class="checkbox">
@ -795,7 +790,7 @@ if (isset($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->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td>
<table>
@ -850,7 +845,7 @@ if (isset($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->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<th colspan="2"><?php echo get_lang('Comment'); ?></th>
<th><?php if ($answerType == HOT_SPOT_DELINEATION) {
@ -883,7 +878,7 @@ if (isset($modifyAnswers)) {
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php
echo empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]; ?>"/>
</td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
<?php if ($objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td>
<div class="checkbox">
@ -1029,7 +1024,7 @@ if (isset($modifyAnswers)) {
?>
<tr>
<th colspan="2"><?php echo get_lang('IfNoError'); ?></th>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
<?php if ($objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<th colspan="2"><?php echo get_lang('Feedback'); ?></th>
<th><?php echo get_lang('Scenario'); ?></th>
@ -1049,7 +1044,7 @@ if (isset($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->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
?>
<td>
<div class="checkbox">

@ -127,7 +127,7 @@ if (in_array(
}
$hideExpectedAnswer = false;
if ($objExercise->selectFeedbackType() == 0 &&
if ($objExercise->getFeedbackType() == 0 &&
$objExercise->selectResultsDisabled() == RESULT_DISABLE_SHOW_SCORE_ONLY
) {
$hideExpectedAnswer = true;

@ -52,7 +52,7 @@ class MultipleAnswerTrueFalse extends Question
$html .= '<th>'.get_lang('Answer').'</th>';
// show column comment when feedback is enable
if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($obj_ex->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$html .= '<th>'.get_lang('Comment').'</th>';
}
@ -146,7 +146,7 @@ class MultipleAnswerTrueFalse extends Question
);
// show comment when feedback is enable
if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($obj_ex->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$form->addElement(
'html_editor',
'comment['.$i.']',
@ -327,7 +327,7 @@ class MultipleAnswerTrueFalse extends Question
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
}
if ($exercise->feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM ||
if ($exercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM ||
in_array(
$exercise->results_disabled,
[

@ -286,7 +286,7 @@ if (!empty($attempts)) {
]
) || (
$objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&
$objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END
$objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_END
)
) {
if ($blockShowAnswers &&
@ -355,7 +355,7 @@ if (!empty($attempts)) {
$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) {
if ($objExercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_END) {
$header_names = [get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')];
} else {
$header_names = [

@ -1810,17 +1810,17 @@ abstract class Question
*/
public static function displayTypeMenu($objExercise)
{
$feedback_type = $objExercise->feedback_type;
$feedbackType = $objExercise->getFeedbackType();
$exerciseId = $objExercise->id;
// 1. by default we show all the question types
$question_type_custom_list = self::get_question_type_list();
if (!isset($feedback_type)) {
$feedback_type = 0;
if (!isset($feedbackType)) {
$feedbackType = 0;
}
if ($feedback_type == 1) {
if (in_array($feedbackType, [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
//2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
$question_type_custom_list = [
UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER],
@ -1869,7 +1869,7 @@ abstract class Question
ICON_SIZE_BIG
);
} else {
if ($feedback_type == 1) {
if (in_array($feedbackType, [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
echo $url = "<a href=\"question_pool.php?".api_get_cidreq()."&type=1&fromExercise=$exerciseId\">";
} else {
echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">';
@ -2397,7 +2397,7 @@ abstract class Question
{
return
in_array($this->type, $this->questionTypeWithFeedback) &&
$exercise->feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM;
$exercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM;
}
/**

@ -43,7 +43,6 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&
<?php echo get_lang('AreYouSureToDelete'); ?>
</p>
</div>
<script>
$(function () {
$("#dialog:ui-dialog").dialog("destroy");
@ -148,7 +147,7 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&
</script>
<?php
//we filter the type of questions we can add
// Filter the type of questions we can add
Question::displayTypeMenu($objExercise);
echo '<div id="message"></div>';

@ -478,7 +478,10 @@ $new_question_list = [];
$new_question_list['-1'] = get_lang('All');
if (!empty($_course)) {
foreach ($question_list as $key => $item) {
if ($objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (in_array(
$objExercise->getFeedbackType(),
[EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]
)) {
if (!in_array($key, [HOT_SPOT_DELINEATION, UNIQUE_ANSWER])) {
continue;
}

@ -58,12 +58,18 @@ class UniqueAnswer extends Question
*/
$feedback_title = '';
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
//Scenario
$comment_title = '<th width="20%">'.get_lang('Comment').'</th>';
$feedback_title = '<th width="20%">'.get_lang('Scenario').'</th>';
} else {
$comment_title = '<th width="40%">'.get_lang('Comment').'</th>';
switch ($obj_ex->getFeedbackType()) {
case EXERCISE_FEEDBACK_TYPE_DIRECT:
// Scenario
$comment_title = '<th width="20%">'.get_lang('Comment').'</th>';
$feedback_title = '<th width="20%">'.get_lang('Scenario').'</th>';
break;
case EXERCISE_FEEDBACK_TYPE_POPUP:
$comment_title = '<th width="20%">'.get_lang('Comment').'</th>';
break;
default:
$comment_title = '<th width="40%">'.get_lang('Comment').'</th>';
break;
}
$html = '<table class="table table-striped table-hover">
@ -218,52 +224,14 @@ class UniqueAnswer extends Question
'required'
);
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$form->addHtmlEditor(
'comment['.$i.']',
null,
null,
false,
$editor_config
);
// Direct feedback
//Adding extra feedback fields
$group = [];
$group['try'.$i] = $form->createElement(
'checkbox',
'try'.$i,
null,
get_lang('TryAgain')
);
$group['lp'.$i] = $form->createElement(
'select',
'lp'.$i,
get_lang('SeeTheory').': ',
$select_lp_id
);
$group['destination'.$i] = $form->createElement(
'select',
'destination'.$i,
get_lang('GoToQuestion').': ',
$select_question
);
$group['url'.$i] = $form->createElement(
'text',
'url'.$i,
get_lang('Other').': ',
[
'class' => 'col-md-2',
'placeholder' => get_lang('Other'),
]
);
$form->addGroup($group, 'scenario');
$renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}',
'scenario'
);
} else {
$form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
switch ($obj_ex->getFeedbackType()) {
case EXERCISE_FEEDBACK_TYPE_DIRECT:
$this->setDirectOptions($i, $form, $renderer, $select_lp_id, $select_question);
break;
case EXERCISE_FEEDBACK_TYPE_POPUP:
default:
$form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
break;
}
$form->addText('weighting['.$i.']', null, null, ['value' => '0']);
$form->addHtml('</tr>');
@ -314,6 +282,59 @@ class UniqueAnswer extends Question
$form->setConstants(['nb_answers' => $nb_answers]);
}
public function setDirectOptions($i, FormValidator $form, $renderer, $select_lp_id, $select_question)
{
$editor_config = [
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '125',
];
$form->addHtmlEditor(
'comment['.$i.']',
null,
null,
false,
$editor_config
);
// Direct feedback
//Adding extra feedback fields
$group = [];
$group['try'.$i] = $form->createElement(
'checkbox',
'try'.$i,
null,
get_lang('TryAgain')
);
$group['lp'.$i] = $form->createElement(
'select',
'lp'.$i,
get_lang('SeeTheory').': ',
$select_lp_id
);
$group['destination'.$i] = $form->createElement(
'select',
'destination'.$i,
get_lang('GoToQuestion').': ',
$select_question
);
$group['url'.$i] = $form->createElement(
'text',
'url'.$i,
get_lang('Other').': ',
[
'class' => 'col-md-2',
'placeholder' => get_lang('Other'),
]
);
$form->addGroup($group, 'scenario');
$renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}',
'scenario'
);
}
/**
* {@inheritdoc}
*/

@ -54,7 +54,7 @@ class UniqueAnswerNoOption extends Question
*/
$feedback_title = '';
if ($obj_ex->selectFeedbackType() == 1) {
if ($obj_ex->getFeedbackType() == 1) {
$editor_config['Width'] = '250';
$editor_config['Height'] = '110';
$comment_title = '<th width="50%" >'.get_lang('Comment').'</th>';

@ -468,7 +468,8 @@ define('ONE_PER_PAGE', 2);
define('EXERCISE_FEEDBACK_TYPE_END', 0); //Feedback - show score and expected answers
define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1); //DirectFeedback - Do not show score nor answers
define('EXERCISE_FEEDBACK_TYPE_EXAM', 2); //NoFeedback - Show score only
define('EXERCISE_FEEDBACK_TYPE_EXAM', 2); // NoFeedback - Show score only
define('EXERCISE_FEEDBACK_TYPE_POPUP', 3); // Popup BT#15827
define('RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS', 0); //show score and expected answers
define('RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS', 1); //Do not show score nor answers

@ -5052,7 +5052,7 @@ class DocumentManager
if ($filetype == 'file') {
// Check the extension
$ext = explode('.', $path);
$ext = strtolower($ext[sizeof($ext) - 1]);
$ext = strtolower($ext[count($ext) - 1]);
// HTML-files an some other types are shown in a frameset by default.
$is_browser_viewable_file = self::isBrowserViewable($ext);
@ -5126,19 +5126,19 @@ class DocumentManager
preg_match('/shared_folder_session_'.$sessionId.'\/sf_user_'.api_get_user_id().'$/', urldecode($forcedownload_link)) ||
$isAllowedToEdit || api_is_platform_admin()
) {
$force_download_html = ($size == 0) ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.
$force_download_html = $size == 0 ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.
Display::return_icon($forcedownload_icon, get_lang('Download'), [], ICON_SIZE_SMALL).'</a>';
}
} elseif (!preg_match('/shared_folder/', urldecode($forcedownload_link)) ||
$isAllowedToEdit ||
api_is_platform_admin()
) {
$force_download_html = ($size == 0) ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.
$force_download_html = $size == 0 ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.
Display::return_icon($forcedownload_icon, get_lang('Download'), [], ICON_SIZE_SMALL).'</a>';
}
}
} else {
$force_download_html = ($size == 0) ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.' download="'.$document_data['basename'].'">'.
$force_download_html = $size == 0 ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.' download="'.$document_data['basename'].'">'.
Display::return_icon($forcedownload_icon, get_lang('Download'), [], ICON_SIZE_SMALL).'</a>';
}
@ -5146,8 +5146,8 @@ class DocumentManager
if (api_get_setting('allow_my_files') === 'true' &&
api_get_setting('users_copy_files') === 'true' && api_is_anonymous() === false
) {
$copy_myfiles_link = $filetype == 'file' ? $pageUrl.'?'.$courseParams.'&action=copytomyfiles&id='.$document_data['id'] : api_get_self().'?'.$courseParams;
if ($filetype == 'file') {
$copy_myfiles_link = $filetype === 'file' ? $pageUrl.'?'.$courseParams.'&action=copytomyfiles&id='.$document_data['id'] : api_get_self().'?'.$courseParams;
if ($filetype === 'file') {
$copyToMyFiles = '<a href="'.$copy_myfiles_link.'" style="float:right"'.$prevent_multiple_click.'>'.
Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), [], ICON_SIZE_SMALL).'&nbsp;&nbsp;</a>';
@ -5159,8 +5159,8 @@ class DocumentManager
$pdf_icon = '';
if (!$isAllowedToEdit &&
$filetype === 'file' &&
api_get_setting('students_export2pdf') == 'true' &&
$filetype == 'file' &&
in_array($extension, ['html', 'htm'])
) {
$pdf_icon = ' <a style="float:right".'.$prevent_multiple_click.' href="'.$pageUrl.'?'.$courseParams.'&action=export_to_pdf&id='.$document_data['id'].'&curdirpath='.$curdirpath.'">'.
@ -5172,7 +5172,7 @@ class DocumentManager
Display::return_icon('open_in_new_window.png', get_lang('OpenInANewWindow'), [], ICON_SIZE_SMALL).'&nbsp;&nbsp;</a>';
}
if ($filetype == 'file') {
if ($filetype === 'file') {
// Sound preview
if (preg_match('/mp3$/i', urldecode($checkExtension)) ||
(preg_match('/wav$/i', urldecode($checkExtension))) ||
@ -5195,7 +5195,7 @@ class DocumentManager
$url = 'show_content.php?'.$courseParams.'&id='.$document_data['id'];
$class = 'ajax';
if ($visibility == false) {
$class = "ajax text-muted";
$class = 'ajax text-muted';
}
return Display::url(
@ -5274,7 +5274,7 @@ class DocumentManager
'</a>';
}
} else {
if ($filetype == 'file') {
if ($filetype === 'file') {
// Sound preview with jplayer
if (preg_match('/mp3$/i', urldecode($checkExtension)) ||
(preg_match('/wav$/i', urldecode($checkExtension))) ||

@ -61,7 +61,7 @@ class ExerciseLib
return false;
}
if ($exercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
if ($exercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_END) {
$show_comment = false;
}
@ -428,7 +428,7 @@ class ExerciseLib
]
)) {
$header = Display::tag('th', get_lang('Options'));
if ($exercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END) {
if ($exercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) {
$header .= Display::tag('th', get_lang('Feedback'));
}
$s .= '<table class="table table-hover table-striped">';
@ -4409,18 +4409,22 @@ EOT;
// Getting attempt info
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exeId);
$studentInfo = api_get_user_info($exercise_stat_info['exe_user_id']);
// Getting question list
$question_list = [];
$studentInfo = [];
if (!empty($exercise_stat_info['data_tracking'])) {
$studentInfo = api_get_user_info($exercise_stat_info['exe_user_id']);
$question_list = explode(',', $exercise_stat_info['data_tracking']);
} else {
// Try getting the question list only if save result is off
if ($save_user_result == false) {
$question_list = $objExercise->get_validated_question_list();
}
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (in_array(
$objExercise->getFeedbackType(),
[EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]
)) {
$question_list = $objExercise->get_validated_question_list();
}
}
@ -4458,7 +4462,7 @@ EOT;
// Not display expected answer, but score, and feedback
$show_all_but_expected_answer = false;
if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&
$objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END
$objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_END
) {
$show_all_but_expected_answer = true;
$show_results = true;
@ -4523,7 +4527,7 @@ EOT;
if (($show_results || $show_only_score) && $origin !== 'embeddable') {
if (isset($exercise_stat_info['exe_user_id'])) {
if ($studentInfo) {
if (!empty($studentInfo)) {
// Shows exercise header
echo $objExercise->showExerciseResultHeader(
$studentInfo,
@ -4549,7 +4553,10 @@ EOT;
$exerciseResultCoordinates = null;
$delineationResults = null;
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (in_array(
$objExercise->getFeedbackType(),
[EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]
)) {
$loadChoiceFromSession = true;
$fromDatabase = false;
$exerciseResult = Session::read('exerciseResult');
@ -4739,7 +4746,6 @@ EOT;
$totalScoreText = null;
$certificateBlock = '';
if (($show_results || $show_only_score) && $showTotalScore) {
if ($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
echo '<h1 style="text-align : center; margin : 20px 0;">'.get_lang('YourResults').'</h1><br />';
@ -4774,14 +4780,16 @@ EOT;
}
$totalScoreText .= '</div>';
$certificateBlock = self::generateAndShowCertificateBlock(
$total_score,
$total_weight,
$objExercise,
$studentInfo['id'],
$courseCode,
$sessionId
);
if (!empty($studentInfo)) {
$certificateBlock = self::generateAndShowCertificateBlock(
$total_score,
$total_weight,
$objExercise,
$studentInfo['id'],
$courseCode,
$sessionId
);
}
}
if ($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
@ -5379,7 +5387,9 @@ EOT;
{
$em = Database::getManager();
if (ONE_PER_PAGE != $exercise['type'] || EXERCISE_FEEDBACK_TYPE_DIRECT == $exercise['feedback_type']) {
if (ONE_PER_PAGE != $exercise['type'] ||
in_array($exercise['feedback_type'], [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])
) {
return false;
}

@ -327,9 +327,16 @@ function convert_coordinates($coords, $sep = '|')
{
$points = [];
$pairs = explode($sep, $coords);
foreach ($pairs as $idx => $pcoord) {
list($x, $y) = explode(';', $pcoord);
$points[] = ['x' => $x, 'y' => $y];
if (!empty($pairs)) {
foreach ($pairs as $idx => $pcoord) {
if (empty($pcoord)) {
continue;
}
$parts = explode(';', $pcoord);
if (!empty($parts)) {
$points[] = ['x' => $parts[0], 'y' => $parts[1]];
}
}
}
return $points;

@ -1316,6 +1316,7 @@ class UrlManager
}
}
}
$response->addAssign(
'ajax_list_courses',
'innerHTML',

Loading…
Cancel
Save