selectTitle(); $answerType = $objQuestion->selectType(); $pictureName = $objQuestion->selectPicture(); $debug = 0; // debug variable to get where we are $okPicture = empty($pictureName) ? false : true; // if we come from the warning box "this question is used in serveral exercises" if ($modifyIn) { if ($debug > 0) { echo '$modifyIn was set' . "
\n"; } // if the user has chosed to modify the question only in the current exercise if ($modifyIn == 'thisExercise') { // duplicates the question $questionId = $objQuestion->duplicate(); // deletes the old question $objQuestion->delete($exerciseId); // removes the old question ID from the question list of the Exercise object $objExercise->removeFromList($modifyAnswers); // adds the new question ID into the question list of the Exercise object $objExercise->addToList($questionId); // construction of the duplicated Question $objQuestion = Question :: read($questionId); // adds the exercise ID into the exercise list of the Question object $objQuestion->addToList($exerciseId); // copies answers from $modifyAnswers to $questionId $objAnswer->duplicate($questionId); // construction of the duplicated Answers $objAnswer = new Answer($questionId); } $color = unserialize($color); $reponse = unserialize($reponse); $comment = unserialize($comment); $weighting = unserialize($weighting); $hotspot_coordinates = unserialize($hotspot_coordinates); $hotspot_type = unserialize($hotspot_type); $destination = unserialize($destination); unset($buttonBack); } $hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $exerciseId; // the answer form has been submitted $submitAnswers = isset($submitAnswers) ? $submitAnswers : false; $buttonBack = isset($buttonBack) ? $buttonBack : false; $nbrAnswers = isset($nbrAnswers) ? $nbrAnswers : 0; if ($submitAnswers || $buttonBack) { if ($answerType == HOT_SPOT) { if ($debug > 0) { echo '$submitAnswers or $buttonBack was set' . "
\n"; } $questionWeighting = $nbrGoodAnswers = 0; for ($i = 1; $i <= $nbrAnswers; $i++) { if ($debug > 0) { echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; } $reponse[$i] = trim($reponse[$i]); $comment[$i] = trim($comment[$i]); $weighting[$i] = $weighting[$i]; // it can be float // checks if field is empty if (empty($reponse[$i]) && $reponse[$i] != '0') { $msgErr = get_lang('HotspotGiveAnswers'); // clears answers already recorded into the Answer object $objAnswer->cancel(); break; } if ($weighting[$i] <= 0) { $msgErr = get_lang('HotspotWeightingError'); // clears answers already recorded into the Answer object $objAnswer->cancel(); break; } if ($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i])) { $msgErr = get_lang('HotspotNotDrawn'); // clears answers already recorded into the Answer object $objAnswer->cancel(); break; } } // end for() if (empty($msgErr)) { for ($i = 1; $i <= $nbrAnswers; $i++) { if ($debug > 0) { echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; } $reponse[$i] = trim($reponse[$i]); $comment[$i] = trim($comment[$i]); $weighting[$i] = ($weighting[$i]); //it can be float if ($weighting[$i]) { $questionWeighting+=$weighting[$i]; } // creates answer $objAnswer->createAnswer($reponse[$i], '', $comment[$i], $weighting[$i], $i, $hotspot_coordinates[$i], $hotspot_type[$i]); } // end for() // saves the answers into the data base $objAnswer->save(); // sets the total weighting of the question $objQuestion->updateWeighting($questionWeighting); $objQuestion->save($exerciseId); $editQuestion = $questionId; unset($modifyAnswers); echo ''; } if ($debug > 0) { echo '$modifyIn was set - end' . "
\n"; } } else { if ($debug > 0) { echo '$submitAnswers or $buttonBack was set' . "
\n"; } $questionWeighting = $nbrGoodAnswers = 0; $select_question = $_POST['select_question']; $try = $_POST['try']; $url = $_POST['url']; $destination = array(); $threadhold1 = $_POST['threadhold1']; $threadhold2 = $_POST['threadhold2']; $threadhold3 = $_POST['threadhold3']; for ($i = 1; $i <= $nbrAnswers; $i++) { if ($debug > 0) { echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; } $reponse[$i] = trim($reponse[$i]); $comment[$i] = trim($comment[$i]); $weighting[$i] = $weighting[$i]; if (empty($threadhold1[$i])) $threadhold1_str = 0; else $threadhold1_str = intval($threadhold1[$i]); if (empty($threadhold2[$i])) $threadhold2_str = 0; else $threadhold2_str = intval($threadhold2[$i]); if (empty($threadhold3[$i])) $threadhold3_str = 0; else $threadhold3_str = intval($threadhold3[$i]); $threadhold_total = $threadhold1_str . ';' . $threadhold2_str . ';' . $threadhold3_str; //echo '
';print_r($_POST);echo '
'; if ($try[$i] == 'on') { $try_str = 1; } else { $try_str = 0; } if (empty($lp[$i])) { $lp_str = 0; } else { $lp_str = $lp[$i]; } if ($url[$i] == '') { $url_str = ''; } else { $url_str = $url[$i]; } if ($select_question[$i] == '') { $question_str = 0; } else { $question_str = $select_question[$i]; } $destination[$i] = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str; // the last answer is the IF NO ERROR section witch has not have the reponse, weight and coordinates values //if ($i!=$nbrAnswers && !($answerType==HOT_SPOT_DELINEATION)) // { // checks if field is empty if (empty($reponse[$i]) && $reponse[$i] != '0') { $msgErr = get_lang('HotspotGiveAnswers'); // clears answers already recorded into the Answer object $objAnswer->cancel(); break; } if ($weighting[$i] <= 0 && $_SESSION['tmp_answers']['hotspot_type'][$i] != 'oar') { $msgErr = get_lang('HotspotWeightingError'); // clears answers already recorded into the Answer object $objAnswer->cancel(); break; } if ($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i])) { $msgErr = get_lang('HotspotNotDrawn'); // clears answers already recorded into the Answer object $objAnswer->cancel(); break; } } // end for() //now the noerror section $selectQuestionNoError = $_POST['select_question_noerror']; $lp_noerror = $_POST['lp_noerror']; $try_noerror = $_POST['try_noerror']; $url_noerror = $_POST['url_noerror']; $comment_noerror = $_POST['comment_noerror']; $threadhold_total = '0;0;0'; if ($try_noerror == 'on') { $try_str = 1; } else { $try_str = 0; } if (empty($lp_noerror)) { $lp_str = 0; } else { $lp_str = $lp_noerror; } if ($url_noerror == '') { $url_str = ''; } else { $url_str = $url_noerror; } if ($selectQuestionNoError == '') { $question_str = 0; } else { $question_str = $selectQuestionNoError; } $destination_noerror = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str; if (empty($msgErr)) { for ($i = 1; $i <= $nbrAnswers; $i++) { if ($debug > 0) { echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; } $reponse[$i] = trim($reponse[$i]); $comment[$i] = trim($comment[$i]); $weighting[$i] = ($weighting[$i]); //it can be float if ($weighting[$i]) { $questionWeighting+=$weighting[$i]; } // creates answer $objAnswer->createAnswer($reponse[$i], '', $comment[$i], $weighting[$i], $i, $hotspot_coordinates[$i], $hotspot_type[$i], $destination[$i]); } // end for() // saves the answers into the data base $objAnswer->createAnswer('noerror', '', $comment_noerror, '0', $nbrAnswers + 1, null, 'noerror', $destination_noerror); $objAnswer->save(); // sets the total weighting of the question $objQuestion->updateWeighting($questionWeighting); $objQuestion->save($exerciseId); $editQuestion = $questionId; unset($modifyAnswers); echo ''; } } } if ($modifyAnswers) { if ($debug > 0) { echo str_repeat(' ', 0) . '$modifyAnswers is set' . "
\n"; } // construction of the Answer object $objAnswer = new Answer($objQuestion->id); Session::write('objAnswer', $objAnswer); if ($debug > 0) { echo str_repeat(' ', 2) . '$answerType is HOT_SPOT' . "
\n"; } if ($answerType == HOT_SPOT_DELINEATION) { $try = $_POST['try']; for ($i = 1; $i <= $nbrAnswers; $i++) { if ($try[$i] == 'on') { $try[$i] = 1; } else { $try[$i] = 0; } } if ($_POST['try_noerror'] == 'on') { $try_noerror = 1; } else { $try_noerror = 0; } } if (!$nbrAnswers) { $nbrAnswers = $objAnswer->selectNbrAnswers(); if ($answerType == HOT_SPOT_DELINEATION) { // the magic happens here ... // we do this to not count the if no error section if ($nbrAnswers >= 2) $nbrAnswers--; } $reponse = array(); $comment = array(); $weighting = array(); $hotspot_coordinates = array(); $hotspot_type = array(); $destination_items = array(); $destination = array(); for ($i = 1; $i <= $nbrAnswers; $i++) { $reponse[$i] = $objAnswer->selectAnswer($i); if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { $comment[$i] = $objAnswer->selectComment($i); } $weighting[$i] = $objAnswer->selectWeighting($i); $hotspot_coordinates[$i] = $objAnswer->selectHotspotCoordinates($i); $hotspot_type[$i] = $objAnswer->selectHotspotType($i); if ($answerType == HOT_SPOT_DELINEATION) { $destination[$i] = $objAnswer->selectDestination($i); $destination_items = explode('@@', $destination[$i]); $threadhold_total = $destination_items[0]; $threadhold_items = explode(';', $threadhold_total); $threadhold1[$i] = $threadhold_items[0]; $threadhold2[$i] = $threadhold_items[1]; $threadhold3[$i] = $threadhold_items[2]; $try[$i] = $destination_items[1]; $lp[$i] = $destination_items[2]; $select_question[$i] = $destination_items[3]; $url[$i] = $destination_items[4]; } } } if ($answerType == HOT_SPOT_DELINEATION) { //added the noerror answer $reponse_noerror = 'noerror'; $comment_noerror = $objAnswer->selectComment($nbrAnswers + 1); $destination_noerror_list = $objAnswer->selectDestination($nbrAnswers + 1); $destination_items = explode('@@', $destination_noerror_list); $try_noerror = $destination_items[1]; $lp_noerror = $destination_items[2]; $selectQuestionNoError = $destination_items[3]; $url_noerror = $destination_items[4]; } $_SESSION['tmp_answers'] = array(); $_SESSION['tmp_answers']['answer'] = $reponse; if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { $_SESSION['tmp_answers']['comment'] = $comment; } $_SESSION['tmp_answers']['weighting'] = $weighting; $_SESSION['tmp_answers']['hotspot_coordinates'] = $hotspot_coordinates; $_SESSION['tmp_answers']['hotspot_type'] = $hotspot_type; if ($answerType == HOT_SPOT_DELINEATION) { $_SESSION['tmp_answers']['destination'] = $destination; } $lessAnswers = isset($lessAnswers) ? $lessAnswers : false; if ($lessAnswers) { if ($answerType == HOT_SPOT_DELINEATION) { $lest_answer = 1; // At least 1 answer if ($nbrAnswers > $lest_answer) { $nbrAnswers--; // Remove the last answer $tmp = array_pop($_SESSION['tmp_answers']['answer']); $tmp = array_pop($_SESSION['tmp_answers']['comment']); $tmp = array_pop($_SESSION['tmp_answers']['weighting']); $tmp = array_pop($_SESSION['tmp_answers']['hotspot_coordinates']); $tmp = array_pop($_SESSION['tmp_answers']['hotspot_type']); if (is_array($_SESSION['tmp_answers']['destination'])) { $tmp = array_pop($_SESSION['tmp_answers']['destination']); } } else { $msgErr = get_lang('MinHotspot'); } } else { // At least 1 answer if ($nbrAnswers > 1) { $nbrAnswers--; // Remove the last answer $tmp = array_pop($_SESSION['tmp_answers']['answer']); if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { $tmp = array_pop($_SESSION['tmp_answers']['comment']); } $tmp = array_pop($_SESSION['tmp_answers']['weighting']); $tmp = array_pop($_SESSION['tmp_answers']['hotspot_coordinates']); $tmp = array_pop($_SESSION['tmp_answers']['hotspot_type']); } else { $msgErr = get_lang('MinHotspot'); } } } $moreAnswers = isset($moreAnswers) ? $moreAnswers : false; if ($moreAnswers) { if ($nbrAnswers < 12) { $nbrAnswers++; // Add a new answer $_SESSION['tmp_answers']['answer'][] = ''; if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { $_SESSION['tmp_answers']['comment'][] = ''; } $_SESSION['tmp_answers']['weighting'][] = '1'; $_SESSION['tmp_answers']['hotspot_coordinates'][] = '0;0|0|0'; $_SESSION['tmp_answers']['hotspot_type'][] = 'square'; $_SESSION['tmp_answers']['destination'][] = ''; } else { $msgErr = get_lang('MaxHotspot'); } } $moreOARAnswers = isset($moreOARAnswers) ? $moreOARAnswers : false; if ($moreOARAnswers) { if ($nbrAnswers < 12) { // Add a new answer $nbrAnswers++; $_SESSION['tmp_answers']['answer'][] = ''; $_SESSION['tmp_answers']['comment'][] = ''; $_SESSION['tmp_answers']['weighting'][] = '1'; $_SESSION['tmp_answers']['hotspot_coordinates'][] = '0;0|0|0'; $_SESSION['tmp_answers']['hotspot_type'][] = 'oar'; $_SESSION['tmp_answers']['destination'][] = ''; } else { $msgErr = get_lang('MaxHotspot'); } } if ($debug > 0) { echo str_repeat(' ', 2) . '$usedInSeveralExercises is untrue' . "
\n"; } if ($debug > 0) { echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; } if ($answerType == HOT_SPOT_DELINEATION) { $hotspot_colors = array("", "#4271B5", "#FE8E16", "#45C7F0", "#BCD631", "#D63173", "#D7D7D7", "#90AFDD", "#AF8640", "#4F9242", "#F4EB24", "#ED2024", "#3B3B3B"); } else { $hotspot_colors = array("", // $i starts from 1 on next loop (ugly fix) "#4271B5", "#FE8E16", "#45C7F0", "#BCD631", "#D63173", "#D7D7D7", "#90AFDD", "#AF8640", "#4F9242", "#F4EB24", "#ED2024", "#3B3B3B", "#F7BDE2"); } Display::tag('h3', get_lang('Question') . ": " . $questionName . ' ' . strip_tags(get_lang('HotspotChoose')) . ''); if (!empty($msgErr)) { Display::display_normal_message($msgErr); //main API } $hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin=' . $modifyAnswers . '&exerciseId=' . $exerciseId; ?>
' . get_lang('Thresholds') . ''; ?> selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> ' . get_lang('Scenario') . ''; ?> get_flat_list(); //loading list of LPs for ($i = 1; $i <= $nbrAnswers; $i++) { // is an delineation if ($answerType == HOT_SPOT_DELINEATION) { $select_lp_id = array(); $option_lp = ''; // setting the LP $isSelected = false; foreach ($flat_list as $id => $details) { $select_lp_id[$id] = $details['lp_name']; $selected = ''; if ($id == $lp[$i]) { $isSelected = true; $selected = 'selected="selected"'; } $option_lp.=''; } if ($isSelected) { $option_lp = '' . $option_lp; } else { $option_lp = '' . $option_lp; } //Feedback SELECT $question_list = $objExercise->selectQuestionList(); $option_feed = ''; $option_feed.=''; foreach ($question_list as $key => $questionid) { $selected = ''; $question = Question::read($questionid); $val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL); $select_lp_id[$id] = $details['lp_name']; if ($questionid == $select_question[$i]) { $selected = 'selected="selected"'; } $option_feed.=''; } if ($select_question[$i] == -1) $option_feed.=''; else $option_feed.=''; //-------- IF it is a delineation if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'delineation') { for ($k = 1; $k <= 100; $k++) { $selected1 = $selected2 = $selected3 = ''; if ($k == $threadhold1[$i]) $selected1 = 'selected="selected"'; if ($k == $threadhold2[$i]) $selected2 = 'selected="selected"'; if ($k == $threadhold3[$i]) $selected3 = 'selected="selected"'; $option1.=''; $option2.=''; $option3.=''; } ?> selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> ToolbarSet = 'TestProposedAnswer'; $oFCKeditor->Config['ToolbarStartExpanded'] = 'false'; $oFCKeditor->Width = '100%'; $oFCKeditor->Height = '100'; $oFCKeditor->Value = $content; $return = $oFCKeditor->CreateHtml(); /* */ ?> get_flat_list(); $select_lp_id = array(); $option_lp = ''; $isSelected = false; foreach ($flat_list as $id => $details) { $selected = ''; $select_lp_id[$id] = $details['lp_name']; if ($id == $lp_noerror) { $selected = 'selected="selected"'; $isSelected = true; } $option_lp.=''; } if ($isSelected) { $option_lp = '' . $option_lp; } else { $option_lp = '' . $option_lp; } //Feedback SELECT $question_list = $objExercise->selectQuestionList(); $option_feed = ''; $option_feed.=''; $details = isset($details) ? $details : null; $id = isset($id) ? $id : 0; $selectQuestionNoError = isset($selectQuestionNoError) ? $selectQuestionNoError : null; foreach ($question_list as $key => $questionid) { $selected = ''; $question = Question::read($questionid); $val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL); $select_lp_id[$id] = $details['lp_name']; if ($questionid == $selectQuestionNoError) { $selected = 'selected="selected"'; } $option_feed.=''; } if ($selectQuestionNoError == -1) $option_feed.=''; else $option_feed.=''; if ($answerType == HOT_SPOT_DELINEATION) { ?> selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
  * *










%

%

%


/>








 
/>








 
  *  
/>








 
 
 
/>








   
0) { echo str_repeat(' ', 0) . '$modifyAnswers was set - end' . "
\n"; } }