Adding new exercise type of question Delineation and Scenario, updating swf of hotspots see #2974 (partial),

skala
Julio Montoya 15 years ago
parent 5ccfdc9f89
commit f39f25ae01
  1. 3
      main/exercice/admin.php
  2. 1
      main/exercice/answer.class.php
  3. 2
      main/exercice/answer_admin.inc.php
  4. 2
      main/exercice/exercice.php
  5. 64
      main/exercice/exercice_submit.php
  6. 539
      main/exercice/exercise.class.php
  7. 29
      main/exercice/exercise.lib.php
  8. 20
      main/exercice/exercise_admin.php
  9. 22
      main/exercice/exercise_result.php
  10. 158
      main/exercice/exercise_show.php
  11. 338
      main/exercice/exercise_submit_modal.php
  12. 8
      main/exercice/export/scorm/scorm_classes.php
  13. 35
      main/exercice/hotspot.class.php
  14. 23
      main/exercice/hotspot_actionscript.as.php
  15. 19
      main/exercice/hotspot_actionscript_admin.as.php
  16. 746
      main/exercice/hotspot_admin.inc.php
  17. 18
      main/exercice/hotspot_answers.as.php
  18. 4
      main/exercice/hotspot_lang_conversion.php
  19. 21
      main/exercice/hotspot_save.inc.php
  20. 1
      main/exercice/hotspot_savescore.inc.php
  21. 2
      main/exercice/hotspot_updatescore.inc.php
  22. 20
      main/exercice/question.class.php
  23. 2
      main/exercice/question_admin.inc.php
  24. 25
      main/exercice/question_create.php
  25. 2
      main/inc/lib/add_course.lib.inc.php
  26. 2
      main/inc/lib/events.lib.inc.php
  27. 3
      main/inc/lib/exercise_show_functions.lib.php
  28. 1191
      main/inc/lib/geometry.lib.php
  29. 39
      main/inc/lib/text.lib.php
  30. 2
      main/install/migrate-db-1.8.7-1.8.8-pre.sql
  31. 0
      main/plugin/hotspot/JavaScriptFlashGateway.js
  32. 0
      main/plugin/hotspot/JavaScriptFlashGateway.swf
  33. 6
      main/plugin/hotspot/hotspot.js
  34. 0
      main/plugin/hotspot/hotspot_admin.fla
  35. BIN
      main/plugin/hotspot/hotspot_admin.swf
  36. BIN
      main/plugin/hotspot/hotspot_delineation_admin.fla
  37. BIN
      main/plugin/hotspot/hotspot_delineation_admin.swf
  38. BIN
      main/plugin/hotspot/hotspot_delineation_user.fla
  39. BIN
      main/plugin/hotspot/hotspot_delineation_user.swf
  40. BIN
      main/plugin/hotspot/hotspot_solution.fla
  41. 349
      main/plugin/hotspot/hotspot_solution.fla.as
  42. BIN
      main/plugin/hotspot/hotspot_solution.swf
  43. 0
      main/plugin/hotspot/hotspot_user.fla
  44. BIN
      main/plugin/hotspot/hotspot_user.swf
  45. 0
      main/plugin/hotspot/jsmethods.js
  46. 0
      main/plugin/hotspot/vbmethods.vbscript

@ -191,8 +191,7 @@ if($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
// reads question data
if($editQuestion) {
// question not found
if(!$objQuestion = Question::read($editQuestion))
{
if(!$objQuestion = Question::read($editQuestion)) {
die(get_lang('QuestionNotFound'));
}
// saves the object into the session

@ -503,7 +503,6 @@ class Answer
'$weighting','$position','$hotspot_coordinates','$hotspot_type','$destination'),";
}
$sql = api_substr($sql,0,-1);
Database::query($sql);
// moves $new_* arrays

@ -84,7 +84,7 @@ if($modifyIn)
$weighting=unserialize($weighting);
}
elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION)
{
$color=unserialize($color);
$reponse=unserialize($reponse);

@ -798,7 +798,7 @@ if ($show == 'test') {
if ($session_id == $row['session_id']) {
//Settings
//$actions = Display::url(Display::return_icon('edit.gif',get_lang('Edit'), array('width'=>'20px')), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']);
//$actions = Display::url(Display::return_icon('edit.png',get_lang('Edit'), array('width'=>'20px')), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']);
$actions = Display::url(Display::return_icon('edit.png',get_lang('Edit'),array('width' =>'22px')), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']);

@ -17,7 +17,7 @@
* the administrator
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya multiple fill in blank option added (2008) and Cleaning exercises (2010)
* @author Julio Montoya multiple fill in blank option added (2008) and Cleaning exercises (2010), Adding hotspot delineation support (2011)
*/
require_once 'exercise.class.php';
@ -25,8 +25,7 @@ require_once 'question.class.php';
require_once 'answer.class.php';
require_once 'exercise.lib.php';
// debug var. Set to 0 to hide all debug display. Set to 1 to display debug messages.
$debug = 0;
//$debug = 1; //debug value is set in the exercise.class.php file
// name of the language file that needs to be included
$language_file = 'exercice';
@ -35,6 +34,8 @@ require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
if($debug) { error_log('Entered exercise_submit.php: '.print_r($_POST,1)); }
// Notice for unauthorized people.
api_protect_course_script(true);
$is_allowedToEdit = api_is_allowed_to_edit(null,true);
@ -80,6 +81,9 @@ if (empty ($formSent)) {
if (empty ($exerciseResult)) {
$exerciseResult = $_REQUEST['exerciseResult'];
}
if (empty ($exerciseResultCoordinates)) {
$exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates'];
}
if (empty ($exerciseType)) {
$exerciseType = $_REQUEST['exerciseType'];
}
@ -110,39 +114,6 @@ if ($buttonCancel) {
exit;
}
if ($origin == 'builder') {
/* Clears the exercise session */
if ($debug) {error_log('origin = builder'); };
if (isset ($_SESSION['objExercise'])) {
api_session_unregister('objExercise');
unset ($objExercise);
}
if (isset ($_SESSION['objQuestion'])) {
api_session_unregister('objQuestion');
unset ($objQuestion);
}
if (isset ($_SESSION['objAnswer'])) {
api_session_unregister('objAnswer');
unset ($objAnswer);
}
if (isset ($_SESSION['questionList'])) {
api_session_unregister('questionList');
unset ($questionList);
}
if (isset ($_SESSION['newquestionList'])) {
api_session_unregister('newquestionList');
unset ($newquestionList);
}
if (isset ($_SESSION['exerciseResult'])) {
api_session_unregister('exerciseResult');
unset ($exerciseResult);
}
if (isset ($_SESSION['exerciseResultCoordinates'])) {
api_session_unregister('exerciseResultCoordinates');
unset ($exerciseResultCoordinates);
}
}
$safe_lp_id = ($learnpath_id == '') ? 0 : $learnpath_id;
$safe_lp_item_id = ($learnpath_item_id == '') ? 0 : $learnpath_item_id;
$safe_lp_item_view_id = ($learnpath_item_view_id == '') ? 0 : $learnpath_item_view_id;
@ -323,12 +294,13 @@ if ($formSent && isset($_POST)) {
}
// if the user has answered at least one question
if (is_array($choice)) {
if ($debug > 0) {if ($debug > 0) { error_log('$choice is an array'); } }
if ($debug) { error_log('$choice is an array '.print_r($choice, 1)); }
// Also store hotspot spots in the session ($exerciseResultCoordinates
// will be stored in the session at the end of this script)
if (isset ($_POST['hotspot'])) {
$exerciseResultCoordinates = $_POST['hotspot'];
if ($debug) { error_log('$_POST[hotspot] data '.print_r($exerciseResultCoordinates, 1)); }
}
if ($exerciseType == ALL_ON_ONE_PAGE) {
// $exerciseResult receives the content of the form.
@ -338,7 +310,7 @@ if ($formSent && isset($_POST)) {
// gets the question ID from $choice. It is the key of the array
list ($key) = array_keys($choice);
// if the user didn't already answer this question
if (!isset ($exerciseResult[$key])) {
if (!isset($exerciseResult[$key])) {
// stores the user answer into the array
$exerciseResult[$key] = $choice[$key];
//saving each question
@ -351,6 +323,7 @@ if ($formSent && isset($_POST)) {
$choice = $exerciseResult[$questionId];
if (isset($exe_id)) {
//Manage the question and answer attempts
if ($debug > 0) { error_log('manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
$objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false);
}
//END of saving and qualifying
@ -367,10 +340,10 @@ if ($formSent && isset($_POST)) {
// if all questions on one page OR if it is the last question (only for an exercise with one question per page)
if ($exerciseType == ALL_ON_ONE_PAGE || $questionNum >= $nbrQuestions) {
if ($debug > 0) { error_log('Redirecting to exercise_result.php - Remove debug option to let this happen'); }
if ( api_is_allowed_to_session_edit() ) {
// goes to the script that will show the result of the exercise
if ($exerciseType == ALL_ON_ONE_PAGE) {
if ($debug) { error_log('Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
header("Location: exercise_result.php?exerciseType=$exerciseType&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
exit;
} else {
@ -378,19 +351,24 @@ if ($formSent && isset($_POST)) {
//Verify if the current test is fraudulent
if (exercise_time_control_is_valid($exerciseId)) {
$sql_exe_result = "";
if ($debug) { error_log('exercise_time_control_is_valid is valid'); }
} else {
$sql_exe_result = ", exe_result = 0";
if ($debug) { error_log('exercise_time_control_is_valid is NOT valid then exe_result = 0 '); }
}
//Clean incomplete - @todo why setting to blank the data_tracking?
//$update_query = 'UPDATE ' . $stat_table . ' SET ' . "status = '', data_tracking='', exe_date = '" . api_get_utc_datetime() . "' $sql_exe_result " . ' WHERE exe_id = ' . Database::escape_string($exe_id);
$update_query = "UPDATE $stat_table SET status = '', exe_date = '".api_get_utc_datetime() ."' , orig_lp_item_view_id = '$safe_lp_item_view_id' $sql_exe_result WHERE exe_id = ".$exe_id;
if ($debug) {error_log($update_query);};
if ($debug) { error_log('Updating track_e_exercises '.$update_query); }
Database::query($update_query);
}
if ($debug) { error_log('Redirecting to exercise_show.php'); }
header("Location: exercise_show.php?id=$exe_id&exerciseType=$exerciseType&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
exit;
}
} else {
if ($debug) { error_log('Redirecting to exercice_submit.php'); }
header("Location: exercice_submit.php?exerciseId=$exerciseId");
exit;
}
@ -586,13 +564,13 @@ if (!empty ($error)) {
if ($questionNum != $i) {
continue;
} else {
if ($objQuestionTmp->selectType() == HOT_SPOT) {
if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
$number_of_hotspot_questions++;
}
break;
}
} else {
if ($objQuestionTmp->selectType() == HOT_SPOT) {
if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
$number_of_hotspot_questions++;
}
}
@ -655,7 +633,7 @@ if (!empty ($error)) {
}
}
// end foreach()
echo $objExercise->show_button($nbrQuestions, $questionNum);
echo $objExercise->show_button($nbrQuestions, $questionNum, $exerciseId);
echo '</table>
</td>
</tr>

@ -16,6 +16,8 @@ define('EXERCISE_FEEDBACK_TYPE_END',0);
define('EXERCISE_FEEDBACK_TYPE_DIRECT',1);
define('EXERCISE_FEEDBACK_TYPE_EXAM',2);
$debug = 1; //All exercise scripts should depend in this debug variable
require_once dirname(__FILE__).'/../inc/lib/exercise_show_functions.lib.php';
if(!class_exists('Exercise')):
@ -522,8 +524,9 @@ class Exercise {
$propagate_neg = $this->propagate_neg;
$session_id = api_get_session_id();
if ($feedbacktype==1){
$results_disabled = 1;
//If direct we do not show results
if ($feedbacktype == EXERCISE_FEEDBACK_TYPE_DIRECT) {
//$results_disabled = 1;
} else {
$results_disabled = intval($this->results_disabled);
}
@ -878,8 +881,11 @@ class Exercise {
if($type=='full') {
// feedback type
$radios_feedback = array();
$radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_1','onclick' => 'check_feedback()'));
$radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
$radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'),'1',array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()'));
$radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2'));
$form -> addGroup($radios_feedback, null, get_lang('FeedbackType'));
$feedback_option[0]=get_lang('ExerciseAtTheEndOfTheTest');
@ -888,11 +894,11 @@ class Exercise {
//Can't modify a DirectFeedback question
if ($this->selectFeedbackType() != 1 ) {
// $form -> addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
//$form -> addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
// test type
$radios = array();
$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('QuestionsPerPageOne'),'2','onclick = "check_per_page_one() " ');
$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('QuestionsPerPageAll'),'1',array('onclick' => 'check_per_page_all()', 'id'=>'OptionPageAll'));
$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('QuestionsPerPageOne'),'2',array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('QuestionsPerPageAll'),'1',array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
$form -> addGroup($radios, null, get_lang('QuestionsPerPage'));
} else {
@ -1454,7 +1460,7 @@ class Exercise {
Database::query($sql);
}
public function show_button($nbrQuestions, $questionNum) {
public function show_button($nbrQuestions, $questionNum, $exerciseId) {
$html = '';
$html = '<div style="margin-top:-10px;">';
$confirmation_alert = $this->type == 1? " onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\" ":"";
@ -1465,6 +1471,12 @@ class Exercise {
$submit_btn = '';
$html .='<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/thickbox.js" type="text/javascript"></script>';
$html .='<style type="text/css" media="all">@import "' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/thickbox.css";</style>';
//$html .='<br /><a href="exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&origin='.$origin.'&hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&exerciseId='.$exerciseId.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox button" id="validationButton">';
$html .='<a href="exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&origin='.$origin.'&hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&exerciseId='.$exerciseId.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox button" id="validationButton">';
$html .= get_lang('ValidateAnswer').'</a></button>';
$html .='<br />';
} else {
if (api_is_allowed_to_session_edit() ) {
if ($this->type == ALL_ON_ONE_PAGE || $nbrQuestions == $questionNum) {
@ -1486,7 +1498,6 @@ class Exercise {
return $html;
}
/**
* So the time control will work
*/
@ -1669,9 +1680,20 @@ class Exercise {
* @todo reduce parameters of this function
* @return string html code
*/
function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0) {
global $_configuration, $feedback_type;
function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0, $hotspot_delineation_result = array()) {
global $_configuration, $feedback_type, $debug;
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
if ($debug) error_log('manage_answer called exe_id '.$exeId);
if ($debug) error_log('manage_answer $from '.$from);
if ($debug) error_log('manage_answer $saved_results '.$saved_results);
if ($debug) error_log('manage_answer $from_database '.$from_database);
if ($debug) error_log('manage_answer $show_result '.$show_result);
if ($debug) error_log('manage_answer $propagate_neg '.$propagate_neg);
if ($debug) error_log('manage_answer $$hotspot_delineation_result '.print_r($hotspot_delineation_result, 1));
$extra_data = array();
$html = '';
$questionId = intval($questionId);
@ -1689,6 +1711,8 @@ class Exercise {
$quesId = $objQuestionTmp->selectId();
$extra = $objQuestionTmp->extra;
$next = 1; //not for now
//Extra information of the question
if (!empty($extra)){
$extra = explode(':', $extra);
@ -1706,13 +1730,16 @@ class Exercise {
// Construction of the Answer object
$objAnswerTmp = new Answer($questionId);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
if ($debug) error_log('Count of answers :'.$nbrAnswers);
if ($debug) error_log('$answerType : '.$answerType);
$questionScore = 0;
if ($answerType == FREE_ANSWER) {
$nbrAnswers = 1;
}
$user_answer = '';
// Get answer list for matching
$sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.$questionId.'" ';
$res_answer = Database::query($sql_answer);
@ -1731,6 +1758,10 @@ class Exercise {
$answerWeighting = $objAnswerTmp->selectWeighting($answerId);
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
//delineation
$delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
$answer_delineation_destination=$objAnswerTmp->selectDestination(1);
switch ($answerType) {
// for unique answer
case UNIQUE_ANSWER :
@ -1942,18 +1973,6 @@ class Exercise {
//$temp = $answer;
$temp = text_filter($answer);
/* // Deprecated code
// TeX parsing
// 1. find everything between the [tex] and [/tex] tags
$startlocations = api_strpos($temp, '[tex]');
$endlocations = api_strpos($temp, '[/tex]');
if ($startlocations !== false && $endlocations !== false) {
$texstring = api_substr($temp, $startlocations, $endlocations - $startlocations +6);
// 2. replace this by {texcode}
$temp = str_replace($texstring, '{texcode}', $temp);
}
*/
$answer = '';
$j = 0;
//initialise answer tags
@ -2103,13 +2122,10 @@ class Exercise {
while ($real_answer = Database::fetch_array($res_answer)) {
$real_list[$real_answer['id']]= $real_answer['answer'];
}
$sql_select_answer = 'SELECT id, answer, correct, id_auto FROM '.$table_ans.'
WHERE question_id="'.$questionId.'" AND correct <> 0 ORDER BY id_auto';
$res_answers = Database::query($sql_select_answer);
$questionScore = 0;
while ($a_answers = Database::fetch_array($res_answers)) {
@ -2160,9 +2176,9 @@ class Exercise {
}
break;
}
// for hotspot with no order
case HOT_SPOT :
if ($from_database) {
if ($show_result) {
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
@ -2190,6 +2206,45 @@ class Exercise {
$studentChoice = false;
}
break;
// for hotspot with delineation
case HOT_SPOT_DELINEATION :
if ($from_database) {
// getting the user answer
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$query = "SELECT hotspot_correct, hotspot_coordinate from ".$TBL_TRACK_HOTSPOT." where hotspot_exe_id = '".$exeId."' and hotspot_question_id= '".$questionId."' AND hotspot_answer_id='1'"; //by default we take 1 because it's a delineation
$resq = Database::query($query);
$row = Database::fetch_array($resq,'ASSOC');
$choice = $row['hotspot_correct'];
$user_answer = $row['hotspot_coordinate'];
// THIS is very important otherwise the poly_compile will throw an error!!
// round-up the coordinates
$coords = explode('/',$user_answer);
$user_array = '';
foreach ($coords as $coord) {
list($x,$y) = explode(';',$coord);
$user_array .= round($x).';'.round($y).'/';
}
$user_array = substr($user_array,0,-1);
} else {
if ($studentChoice) {
$newquestionList[]=$questionid;
}
if ($answerId===1) {
$studentChoice =$choice[$answerId];
$questionScore +=$answerWeighting;
if ($hotspot_delineation_result[1]==1) {
$totalScore +=$answerWeighting; //adding the total
}
//$totalScore +=$answerWeighting; we do not if the hotspot is right or not
}
}
$_SESSION['hotspot_coord'][1] = $delineation_cord;
$_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
break;
} // end switch Answertype
global $origin;
@ -2197,6 +2252,7 @@ class Exercise {
if ($show_result) {
if ($from == 'exercise_result') {
if ($debug) error_log('Showing questions $from '.$from);
//display answers (if not matching type, or if the answer is correct)
if ($answerType != MATCHING || $answerCorrect) {
if (in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION))) {
@ -2227,7 +2283,151 @@ class Exercise {
ExerciseShowFunctions::display_hotspot_answer($answerId, $answer, $studentChoice, $answerComment);
}
} elseif($answerType == HOT_SPOT_ORDER) {
if ($origin != 'learnpath') {
ExerciseShowFunctions::display_hotspot_order_answer($answerId, $answer, $studentChoice, $answerComment);
}
} elseif ($answerType == HOT_SPOT_DELINEATION) {
$user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
//$_SESSION['exerciseResultCoordinates']=str_replace('/','|',$user_answer);
//if (!$comes_from_popup) {
//round-up the coordinates
$coords = explode('/',$user_answer);
$user_array = '';
foreach ($coords as $coord) {
list($x,$y) = explode(';',$coord);
$user_array .= round($x).';'.round($y).'/';
}
$user_array = substr($user_array,0,-1);
if ($next) {
//$tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
// Save into db
/* $sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate )
VALUES ('".Database::escape_string($_user['user_id'])."', '".Database::escape_string($_course['id'])."', '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."', '".Database::escape_string($answerId)."', '".Database::escape_string($studentChoice)."', '".Database::escape_string($user_array)."')";
$result = api_sql_query($sql,__FILE__,__LINE__);*/
$user_answer = $user_array;
// we compare only the delineation not the other points
$answer_question = $_SESSION['hotspot_coord'][1];
$answerDestination = $_SESSION['hotspot_dest'][1];
//calculating the area
$poly_user = convert_coordinates($user_answer,'/');
$poly_answer = convert_coordinates($answer_question,'|');
$max_coord = poly_get_max($poly_user,$poly_answer);
$poly_user_compiled = poly_compile($poly_user,$max_coord);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
$overlap = $poly_results['both'];
$poly_answer_area = $poly_results['s1'];
$poly_user_area = $poly_results['s2'];
$missing = $poly_results['s1Only'];
$excess = $poly_results['s2Only'];
//$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 ($overlap < 1) {
//shortcut to avoid complicated calculations
$final_overlap = 0;
$final_missing = 100;
$final_excess = 100;
} 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);}
// 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);}
// 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);}
}
//checking the destination parameters parsing the "@@"
$destination_items= explode('@@', $answerDestination);
$threadhold_total = $destination_items[0];
$threadhold_items=explode(';',$threadhold_total);
$threadhold1 = $threadhold_items[0]; // overlap
$threadhold2 = $threadhold_items[1]; // excess
$threadhold3 = $threadhold_items[2]; //missing
// if is delineation
if ($answerId===1) {
//setting colors
if ($final_overlap>=$threadhold1) {
$overlap_color=true; //echo 'a';
}
//echo $excess.'-'.$threadhold2;
if ($final_excess<=$threadhold2) {
$excess_color=true; //echo 'b';
}
//echo '--------'.$missing.'-'.$threadhold3;
if ($final_missing<=$threadhold3) {
$missing_color=true; //echo 'c';
}
// if pass
if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
$next=1; //go to the oars
$result_comment=get_lang('Acceptable');
$final_answer = 1; // do not update with update_exercise_attempt
} else {
$next=0;
$result_comment=get_lang('Unacceptable');
$comment=$answerDestination=$objAnswerTmp->selectComment(1);
$answerDestination=$objAnswerTmp->selectDestination(1);
//checking the destination parameters parsing the "@@"
$destination_items= explode('@@', $answerDestination);
}
} 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
$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);
//$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
$inter= $result['success'];
//$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
$poly_answer = convert_coordinates($delineation_cord,'|');
$max_coord = poly_get_max($poly_user,$poly_answer);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
if ($overlap == false) {
//all good, no overlap
$next = 1;
continue;
} else {
if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
$organs_at_risk_hit++;
//show the feedback
$next=0;
$comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
$answerDestination=$objAnswerTmp->selectDestination($answerId);
$destination_items= explode('@@', $answerDestination);
/*
$try_hotspot=$destination_items[1];
$lp_hotspot=$destination_items[2];
$select_question_hotspot=$destination_items[3];
$url_hotspot=$destination_items[4];*/
}
}
} else { // the first delineation feedback
if ($dbg_local>0) { error_log(__LINE__.' first',0);}
}
} elseif($answerType==MATCHING) {
if ($origin != 'learnpath') {
echo '<tr>';
@ -2237,6 +2437,8 @@ class Exercise {
}
}
} else {
if ($debug) error_log('Showing questions $from '.$from);
switch($answerType) {
case UNIQUE_ANSWER :
case UNIQUE_ANSWER_NO_OPTION:
@ -2276,6 +2478,137 @@ class Exercise {
case HOT_SPOT:
ExerciseShowFunctions::display_hotspot_answer($answerId, $answer, $studentChoice, $answerComment);
break;
case HOT_SPOT_DELINEATION:
$user_answer = $user_array;
if ($next) {
//$tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
// Save into db
/* $sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate )
VALUES ('".Database::escape_string($_user['user_id'])."', '".Database::escape_string($_course['id'])."', '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."', '".Database::escape_string($answerId)."', '".Database::escape_string($studentChoice)."', '".Database::escape_string($user_array)."')";
$result = api_sql_query($sql,__FILE__,__LINE__);*/
$user_answer = $user_array;
// we compare only the delineation not the other points
$answer_question = $_SESSION['hotspot_coord'][1];
$answerDestination = $_SESSION['hotspot_dest'][1];
//calculating the area
$poly_user = convert_coordinates($user_answer,'/');
$poly_answer = convert_coordinates($answer_question,'|');
$max_coord = poly_get_max($poly_user,$poly_answer);
$poly_user_compiled = poly_compile($poly_user,$max_coord);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
$overlap = $poly_results['both'];
$poly_answer_area = $poly_results['s1'];
$poly_user_area = $poly_results['s2'];
$missing = $poly_results['s1Only'];
$excess = $poly_results['s2Only'];
//$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 ($overlap < 1) {
//shortcut to avoid complicated calculations
$final_overlap = 0;
$final_missing = 100;
$final_excess = 100;
} 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);}
// 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);}
// 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);}
}
//checking the destination parameters parsing the "@@"
$destination_items= explode('@@', $answerDestination);
$threadhold_total = $destination_items[0];
$threadhold_items=explode(';',$threadhold_total);
$threadhold1 = $threadhold_items[0]; // overlap
$threadhold2 = $threadhold_items[1]; // excess
$threadhold3 = $threadhold_items[2]; //missing
// if is delineation
if ($answerId===1) {
//setting colors
if ($final_overlap>=$threadhold1) {
$overlap_color=true; //echo 'a';
}
//echo $excess.'-'.$threadhold2;
if ($final_excess<=$threadhold2) {
$excess_color=true; //echo 'b';
}
//echo '--------'.$missing.'-'.$threadhold3;
if ($final_missing<=$threadhold3) {
$missing_color=true; //echo 'c';
}
// if pass
if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
$next=1; //go to the oars
$result_comment=get_lang('Acceptable');
$final_answer = 1; // do not update with update_exercise_attempt
} else {
$next=0;
$result_comment=get_lang('Unacceptable');
$comment=$answerDestination=$objAnswerTmp->selectComment(1);
$answerDestination=$objAnswerTmp->selectDestination(1);
//checking the destination parameters parsing the "@@"
$destination_items= explode('@@', $answerDestination);
}
} 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
$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);
//$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
$inter= $result['success'];
//$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
$poly_answer = convert_coordinates($delineation_cord,'|');
$max_coord = poly_get_max($poly_user,$poly_answer);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
if ($overlap == false) {
//all good, no overlap
$next = 1;
continue;
} else {
if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
$organs_at_risk_hit++;
//show the feedback
$next=0;
$comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
$answerDestination=$objAnswerTmp->selectDestination($answerId);
$destination_items= explode('@@', $answerDestination);
/*
$try_hotspot=$destination_items[1];
$lp_hotspot=$destination_items[2];
$select_question_hotspot=$destination_items[3];
$url_hotspot=$destination_items[4];*/
}
}
} else { // the first delineation feedback
if ($dbg_local>0) { error_log(__LINE__.' first',0);}
}
break;
case HOT_SPOT_ORDER:
ExerciseShowFunctions::display_hotspot_order_answer($answerId, $answer, $studentChoice, $answerComment);
break;
@ -2316,9 +2649,149 @@ class Exercise {
}
}
$extra_data = array('final_overlap' => $final_overlap, 'final_missing'=>$final_missing, 'final_excess'=> $final_excess,
'overlap_color' => $overlap_color, 'missing_color'=>$missing_color, 'excess_color'=> $excess_color,
'threadhold1' => $threadhold1, 'threadhold2'=>$threadhold2, 'threadhold3'=> $threadhold3,
);
if ($from == 'exercise_result') {
// if answer is hotspot. To the difference of exercise_show.php, we use the results from the session (from_db=0)
// TODO Change this, because it is wrong to show the user some results that haven't been stored in the database yet
if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) {
if ($debug) error_log('$from AND this is a hotspot kind of question ');
$my_exe_id = 0;
$from_database = 0;
if ($answerType == HOT_SPOT_DELINEATION) {
if (0) {
if ($overlap_color) {
$overlap_color='green';
} else {
$overlap_color='red';
}
if ($missing_color) {
$missing_color='green';
} else {
$missing_color='red';
}
if ($excess_color) {
$excess_color='green';
} else {
$excess_color='red';
}
if (!is_numeric($final_overlap)) {
$final_overlap = 0;
}
if (!is_numeric($final_missing)) {
$final_missing = 0;
}
if (!is_numeric($final_excess)) {
$final_excess = 0;
}
if ($final_overlap>100) {
$final_overlap = 100;
}
$table_resume='<table class="data_table">
<tr class="row_odd" >
<td></td>
<td ><b>'.get_lang('Requirements').'</b></td>
<td><b>'.get_lang('YourAnswer').'</b></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Overlap').'</b></td>
<td>'.get_lang('Min').' '.$threadhold1.'</td>
<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
</tr>
<tr>
<td><b>'.get_lang('Excess').'</b></td>
<td>'.get_lang('Max').' '.$threadhold2.'</td>
<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Missing').'</b></td>
<td>'.get_lang('Max').' '.$threadhold3.'</td>
<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
</tr>
</table>';
if ($next==0) {
$try = $try_hotspot;
$lp = $lp_hotspot;
$destinationid= $select_question_hotspot;
$url=$url_hotspot;
} else {
//show if no error
//echo 'no error';
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$answerDestination=$objAnswerTmp->selectDestination($nbrAnswers);
}
echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
<p style="text-align:center">';
$message='<p>'.get_lang('YourDelineation').'</p>';
$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' '.$result_comment.'<br />';
if ($organs_at_risk_hit>0)
$message.='<p><b>'.get_lang('OARHit').'</b></p>';
$message.='<p>'.$comment.'</p>';
echo $message;
} else {
echo $hotspot_delineation_result[0]; //prints message
$from_database = 1; // the hotspot_solution.swf needs this variable
}
//save the score attempts
if (1 ) {
$final_answer = $hotspot_delineation_result[1]; //getting the answer 1 or 0 comes from exercise_submit_modal.php
if ($final_answer == 0) {
$questionScore = 0;
}
exercise_attempt($questionScore, 1, $quesId, $exeId, 0); // we always insert the answer_id 1 = delineation
//we will only save one item
exercise_attempt_hotspot($exeId,$quesId,1, $my_hotspot_answer, $exerciseResultCoordinates[$quesId]);
} else {
if ($final_answer==0) {
$questionScore = 0;
$answer=0;
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0);
if (is_array($exerciseResultCoordinates[$quesId])) {
foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
exercise_attempt_hotspot($exeId,$quesId,$idx,0,$val);
}
}
} else {
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0);
if (is_array($exerciseResultCoordinates[$quesId])) {
foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
exercise_attempt_hotspot($exeId,$quesId,$idx,$choice[$idx],$val);
}
}
}
}
$my_exe_id = $exeId;
}
// We made an extra table for the answers
if($origin != 'learnpath') {
echo "</table></td></tr>"; //echo Security::remove_XSS($questionId);
?>
<tr>
<td colspan="2">
<i><?php echo get_lang('Hotspot'); ?></i><br /><br />
<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_solution.swf?modifyAnswers=<?php echo Security::remove_XSS($questionId); ?>&exe_id=<?php echo $my_exe_id; ?>&from_db=<?php echo $from_database; ?>" width="552" height="352">
<param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers=<?php echo Security::remove_XSS($questionId); ?>&exe_id=<?php echo $my_exe_id; ?>&from_db=<?php echo $from_database; ?>" />
</object>
</td>
</tr>
<?php
}
}
if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) {
// We made an extra table for the answers
if ($show_result) {
@ -2337,6 +2810,7 @@ class Exercise {
}
}
}
if ($origin != 'learnpath') {
if ($show_result) {
echo '</table>';
@ -2405,6 +2879,7 @@ class Exercise {
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$answer = $choice;
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
// } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
} elseif ($answerType == HOT_SPOT) {
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
if (isset($exerciseResultCoordinates[$questionId]) && !empty($exerciseResultCoordinates[$questionId])) {
@ -2426,11 +2901,10 @@ class Exercise {
if ($propagate_neg == 0 && $questionScore < 0) {
$questionScore = 0;
}
$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting);
$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting,'extra'=>$extra_data);
return $return_array;
} //End function
function send_notification($arrques, $arrans) {
// Email configuration settings
@ -2596,8 +3070,6 @@ class Exercise {
</td>
</tr>';
}
$html = '<table width="100%">
<tr>
<td colspan="2">
@ -2648,6 +3120,9 @@ class Exercise {
return $quiz_id;
}
function process_geometry() {
}
}
endif;
?>

@ -40,7 +40,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
$answerType = $objQuestionTmp->selectType();
$pictureName = $objQuestionTmp->selectPicture();
if ($answerType != HOT_SPOT) {
if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
// Question is not a hotspot
if (!$only_questions) {
@ -452,7 +452,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
} else {
return($s);
}
} elseif ($answerType == HOT_SPOT) {
} elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
// Question is a HOT_SPOT
//checking document/images visibility
if (api_is_platform_admin() || api_is_course_admin()) {
@ -496,6 +496,15 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
}
$answer_list .= '</dl></div>';
if ($answerType == HOT_SPOT_DELINEATION) {
$answer_list='';
$swf_file = 'hotspot_delineation_user';
$swf_height = 405;
} else {
$swf_file = 'hotspot_user';
$swf_height = 436;
}
if (!$only_questions) {
if ($show_title) {
echo '<div id="question_title" class="sectiontitle">'.get_lang('Question').' '.$current_item.' : '.$questionName.'</div>';
@ -631,8 +640,9 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
// Check to see if the version meets the requirements for playback
if (hasReqestedVersion) { // if we\'ve detected an acceptable version
var oeTags = \'<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_user.swf?modifyAnswers='.$questionId.'&amp;canClick:'.$canClick.'" width="560" height="436">\'
+ \'<param name="movie" value="../plugin/hotspot/hotspot_user.swf?modifyAnswers='.$questionId.'&amp;canClick:'.$canClick.'" />\'
var oeTags = \'<object type="application/x-shockwave-flash" data="../plugin/hotspot/'.$swf_file.'?modifyAnswers='.$questionId.'&amp;canClick:'.$canClick.'" width="600" height="'.$swf_height.'">\'
+ \'<param name="wmode" value="transparent">\'
+ \'<param name="movie" value="../plugin/hotspot/'.$swf_file.'?modifyAnswers='.$questionId.'&amp;canClick:'.$canClick.'" />\'
+ \'<\/object>\';
document.write(oeTags); // embed the Flash Content SWF when all tests are passed
} else { // flash is too old or we can\'t detect the plugin
@ -653,7 +663,6 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
return $nbrAnswers;
}
function get_exercise_track_exercise_info($exe_id) {
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
@ -1074,22 +1083,22 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
$html_link = '';
if ($is_allowedToEdit || $is_tutor) {
if ($revised) {
$html_link.= "<a href='exercise_show.php?".api_get_cidreq()."&action=edit&id=$id'>".Display :: return_icon('edit.gif', get_lang('Edit'));
$html_link.= "<a href='exercise_show.php?".api_get_cidreq()."&action=edit&id=$id'>".Display :: return_icon('edit.png', get_lang('Edit'), array(), 22);
$html_link.= '&nbsp;';
} else {
$html_link.="<a href='exercise_show.php?".api_get_cidreq()."&action=qualify&id=$id'>".Display :: return_icon('quiz.gif', get_lang('Qualify'));
$html_link.='&nbsp;';
}
$html_link.="</a>";
if (api_is_platform_admin() || $is_tutor) {
$html_link.=' <a href="exercice.php?'.api_get_cidreq().'&show=result&filter=' . $filter . '&exerciseId='.$exercise_id.'&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.png', get_lang('Delete')).'</a>';
$html_link.='&nbsp;';
}
if ($is_allowedToEdit) {
if ($filter==2){
$html_link.=' <a href="exercice_history.php?'.api_get_cidreq().'&exe_id=' . $id . '">' .Display :: return_icon('history.gif', get_lang('ViewHistoryChange')).'</a>';
}
}
if (api_is_platform_admin() || $is_tutor) {
$html_link.=' <a href="exercice.php?'.api_get_cidreq().'&show=result&filter=' . $filter . '&exerciseId='.$exercise_id.'&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.png', get_lang('Delete')).'</a>';
$html_link.='&nbsp;';
}
} else {
if ($revised) {
$html_link.="<a href='exercise_show.php?".api_get_cidreq()."&id=$id'>" . get_lang('Show') . "</a> ";

@ -102,33 +102,37 @@ $htmlHeadXtra[] = '<script>
}
}
function check_per_page_one()
{
if (document.getElementById(\'divtimecontrol\').style.display==\'none\')
{
function check_per_page_one() {
if (document.getElementById(\'divtimecontrol\').style.display==\'none\') {
document.getElementById(\'divtimecontrol\').style.display=\'block\';
document.getElementById(\'divtimecontrol\').display=block;
document.getElementById(\'timecontrol\').display=none;
}
document.getElementById(\'exerciseType_0\').checked=true;
}
function check_per_page_all() {
if (document.getElementById(\'divtimecontrol\').style.display==\'block\')
{
if (document.getElementById(\'divtimecontrol\').style.display==\'block\') {
document.getElementById(\'divtimecontrol\').style.display=\'none\';
document.getElementById(\'enabletimercontroltotalminutes\').value=\'\';
}
if (document.getElementById(\'exerciseType_1\').checked) {
document.getElementById(\'exerciseType_0\').checked = true;
}
}
function check_feedback() {
document.getElementById(\'result_disabled_0\').checked = true;
}
function check_results_disabled() {
function check_direct_feedback() {
document.getElementById(\'option_page_one\').checked = true;
}
function check_results_disabled() {
document.getElementById(\'exerciseType_2\').checked = true;
}
</script>';

@ -54,8 +54,6 @@ $main_user_table = Database::get_main_table(TABLE_MAIN_USER);
$main_admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$main_course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
//debug param. 0: no display - 1: debug display
$debug=0;
if($debug>0){error_log('Entered exercise_result.php: '.print_r($_POST,1));}
// general parameters passed via POST/GET
@ -66,7 +64,6 @@ if ( empty ( $learnpath_item_view_id ) ) { $learnpath_item_view_id = intval($_R
if ( empty ( $formSent ) ) { $formSent = $_REQUEST['formSent'];}
if ( empty ( $exerciseResult ) ) { $exerciseResult = $_SESSION['exerciseResult'];}
if ( empty ( $exerciseResultCoordinates)){ $exerciseResultCoordinates = $_SESSION['exerciseResultCoordinates'];}
if ( empty ( $questionId ) ) { $questionId = $_REQUEST['questionId'];}
if ( empty ( $choice ) ) { $choice = $_REQUEST['choice'];}
if ( empty ( $questionNum ) ) { $questionNum = $_REQUEST['questionNum'];}
@ -77,9 +74,9 @@ if ( empty ( $exerciseType ) ) { $exerciseType = $_REQUEST[
//@todo There should be some doc about this settings
$_configuration['live_exercise_tracking'] = false;
if($_configuration['live_exercise_tracking']) define('ENABLED_LIVE_EXERCISE_TRACKING',1);
if ($_configuration['live_exercise_tracking']) define('ENABLED_LIVE_EXERCISE_TRACKING',1);
if($_configuration['live_exercise_tracking'] && $exerciseType == 1){
if ($_configuration['live_exercise_tracking'] && $exerciseType == 1){
$_configuration['live_exercise_tracking'] = false;
}
$arrques = array();
@ -97,7 +94,7 @@ $url = api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq().'&s
// if the above variables are empty or incorrect, we don't have any result to show, so stop the script
if(!is_array($exerciseResult) || !is_array($questionList) || !is_object($objExercise)) {
if ($debug) {error_log('Exit exercise result'); error_log('$exerciseResult:'.print_r($exerciseResult,1)); error_log('$questionList:'.print_r($questionList,1));error_log('$objExercise:'.print_r($objExercise,1));}
if ($debug) {error_log('Exit exercise result'); error_log('$exerciseResult: '.print_r($exerciseResult,1)); error_log('$questionList:'.print_r($questionList,1));error_log('$objExercise:'.print_r($objExercise,1));}
header('Location: exercice.php');
exit();
}
@ -152,8 +149,8 @@ if ($objExercise->results_disabled == 2) {
// I'm in a preview mode as course admin. Display the action menu.
if (api_is_course_admin() && $origin != 'learnpath') {
echo '<div class="actions">';
echo Display::return_icon('back.png', get_lang('GoBackToQuestionList')).'<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.get_lang('GoBackToQuestionList').'</a>';
echo Display::return_icon('edit.gif', get_lang('ModifyExercise')).'<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 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>';
echo '</div>';
}
@ -183,7 +180,6 @@ if ($show_results || $show_only_score) {
echo $exercise_header = $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName']));
}
// Loop over all question to show results for each of them, one by one
foreach ($questionList as $questionId) {
// destruction of the Question object
@ -202,6 +198,9 @@ foreach ($questionList as $questionId) {
$answerType = $objQuestionTmp->selectType();
$quesId = $objQuestionTmp->selectId();
//this variable commes from exercise_submit_modal.php
$hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$quesId];
if ($show_results) {
// show titles
if ($origin != 'learnpath') {
@ -232,10 +231,11 @@ foreach ($questionList as $questionId) {
}
// We're inside *one* question. Go through each possible answer for this question
$result = $objExercise->manage_answer($exeId, $questionId, $choice,'exercise_result', $exerciseResultCoordinates, true, false, $show_results, $objExercise->selectPropagateNeg());
$result = $objExercise->manage_answer($exeId, $questionId, $choice,'exercise_result', $exerciseResultCoordinates, true, false, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result);
$totalScore += $result['score'];
$totalWeighting += $result['weight'];
} // end huge foreach() block that loops over all questions
} // end foreach() block that loops over all questions
if ($origin != 'learnpath') {
if ($show_results || $show_only_score) {

@ -26,8 +26,7 @@ require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
if ( empty ( $origin ) ) {
if (empty($origin) ) {
$origin = $_REQUEST['origin'];
}
@ -46,10 +45,8 @@ $main_course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$debug=0;
// General parameters passed via POST/GET
if($debug>0) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); }
if($debug) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); }
if ( empty ( $formSent ) ) { $formSent = $_REQUEST['formSent']; }
if ( empty ( $exerciseResult ) ) { $exerciseResult = $_SESSION['exerciseResult'];}
@ -245,8 +242,6 @@ if (!empty($track_exercise_info)) {
$show_results = false;
}
//var_dump($show_results);
if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) {
$show_results = false;
}
@ -365,6 +360,154 @@ foreach ($questionList as $questionId) {
</tr>
</table><br/>';
}
} else if($answerType == HOT_SPOT_DELINEATION) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), 'database');
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
$final_overlap = $question_result['extra']['final_overlap'];
$final_missing = $question_result['extra']['final_missing'];
$final_excess = $question_result['extra']['final_excess'];
$overlap_color = $question_result['extra']['overlap_color'];
$missing_color = $question_result['extra']['missing_color'];
$excess_color = $question_result['extra']['excess_color'];
$threadhold1 = $question_result['extra']['threadhold1'];
$threadhold2 = $question_result['extra']['threadhold2'];
$threadhold3 = $question_result['extra']['threadhold3'];
if ($show_results) {
if ($overlap_color) {
$overlap_color='green';
} else {
$overlap_color='red';
}
if ($missing_color) {
$missing_color='green';
} else {
$missing_color='red';
}
if ($excess_color) {
$excess_color='green';
} else {
$excess_color='red';
}
if (!is_numeric($final_overlap)) {
$final_overlap = 0;
}
if (!is_numeric($final_missing)) {
$final_missing = 0;
}
if (!is_numeric($final_excess)) {
$final_excess = 0;
}
if ($final_excess>100) {
$final_excess = 100;
}
$table_resume='<table class="data_table">
<tr class="row_odd" >
<td></td>
<td ><b>'.get_lang('Requirements').'</b></td>
<td><b>'.get_lang('YourAnswer').'</b></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Overlap').'</b></td>
<td>'.get_lang('Min').' '.$threadhold1.'</td>
<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
</tr>
<tr>
<td><b>'.get_lang('Excess').'</b></td>
<td>'.get_lang('Max').' '.$threadhold2.'</td>
<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Missing').'</b></td>
<td>'.get_lang('Max').' '.$threadhold3.'</td>
<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
</tr></table>';
if ($answerType!= HOT_SPOT_DELINEATION) {
$item_list=explode('@@',$destination);
//print_R($item_list);
$try = $item_list[0];
$lp = $item_list[1];
$destinationid= $item_list[2];
$url=$item_list[3];
$table_resume='';
} else {
if ($next==0) {
$try = $try_hotspot;
$lp = $lp_hotspot;
$destinationid= $select_question_hotspot;
$url=$url_hotspot;
} else {
//show if no error
//echo 'no error';
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$answerDestination=$objAnswerTmp->selectDestination($nbrAnswers);
}
}
echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
//<p style="text-align:center">
if ($answerType == HOT_SPOT_DELINEATION) {
if ($organs_at_risk_hit>0) {
$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
} else {
$message='<p>'.get_lang('YourDelineation').'</p>';
$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
}
$message.='<p>'.$comment.'</p>';
echo $message;
// by default we assume that the answer is ok but if the final answer after calculating the area in hotspot delineation =0 then update
if ($final_answer==0) {
//update_exercise_attempt(0, 0,$questionId,$exeId, 0 ); //we do not update the user_id
//update_event_exercice($exeId, )
}
} else {
echo '<p>'.$comment.'</p>';
}
//echo '<a onclick="self.parent.tb_remove();" href="#" style="float:right;">'.get_lang('Close').'</a>';
//showing the score
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
$questionScore= mysql_result($resfree,0,"marks");
$totalScore+=$questionScore;
?>
</table>
</td></tr>
<?php
echo '<tr>
<td colspan="2">
<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" width="556" height="350">
<param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" />
</object>
</td>
</tr>
</table>';
}
}
if ($show_results) {
@ -456,7 +599,6 @@ foreach ($questionList as $questionId) {
$questionScore=0;
}
}
echo '</td>
</tr>
</table>';

@ -4,26 +4,13 @@
* @package chamilo.exercise
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file=array('exercice');
require_once '../inc/global.inc.php';
require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
api_protect_course_script(false);
require_once api_get_path(INCLUDE_PATH) . 'reduced_header.inc.php';
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
$dbg_local = 0;
api_protect_course_script();
// answer types
define('UNIQUE_ANSWER', 1);
define('MULTIPLE_ANSWER', 2);
define('FILL_IN_BLANKS', 3);
define('MATCHING', 4);
define('FREE_ANSWER', 5);
define('HOT_SPOT', 6);
define('HOT_SPOT_ORDER', 7);
define('HOT_SPOT_DELINEATION', 8);
require_once 'exercise.class.php';
require_once 'question.class.php';
require_once 'answer.class.php';
@ -34,20 +21,35 @@ if (empty ($exerciseResult)) {
}
if (empty($exerciseResultCoordinates)) {
//$exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates'];
$exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates'];
}
if (empty($origin)) {
$origin = Security::remove_XSS($_REQUEST['origin']);
}
// if origin is learnpath
if (empty ($learnpath_id)) {
$learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']);
}
if (empty ($learnpath_item_id)) {
$learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']);
}
$_SESSION['hotspot_coord']=array();
$newquestionList= $_SESSION['newquestionList'];
$questionList = $_SESSION['questionList'];
$exerciseId = intval($_GET['exerciseId']);
$exerciseType = intval($_GET['exerciseType']);
$questionNum = intval($_GET['questionnum']);
$nbrQuestions = intval($_GET['nbrQuestions']);
//clean extra session variables
api_session_unregister('objExerciseExtra'.$exerciseId);
api_session_unregister('exerciseResultExtra'.$exerciseId);
api_session_unregister('questionListExtra'.$exerciseId);
//round-up the coordinates
$coords = explode('/',$_GET['hotspot']);
$user_array = '';
@ -57,9 +59,10 @@ if (is_array($coords) && count($coords)>0){
$user_array .= round($x).';'.round($y).'/';
}
}
$user_array = substr($user_array,0,-1);
if (isset( $_GET['choice'])){
if (isset($_GET['choice'])){
$choice_value = intval($_GET['choice']);
}
// getting the options by js
@ -101,9 +104,10 @@ if (empty($choice_value)) {
choice_js=-1; // this is an error
}
//alert(choice_js);
";
echo 'window.location.href = "exercise_submit_modal.php?hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";</script>';
// 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.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";</script>';
}
$choice=array();
@ -112,8 +116,7 @@ $questionid= $questionList[$questionNum];
$choice[$questionid]=$choice_value;
// initializing
if(!is_array($exerciseResult))
{
if(!is_array($exerciseResult)) {
$exerciseResult=array();
}
@ -154,13 +157,12 @@ if($questionNum >= $nbrQuestions)
//print_r($choice); echo "<br>";
// creates a temporary Question object
if (in_array($questionid,$questionList))
{
if (in_array($questionid, $questionList)) {
$objQuestionTmp = Question :: read($questionid);
$questionName=$objQuestionTmp->selectTitle();
$questionName =$objQuestionTmp->selectTitle();
$questionDescription=$objQuestionTmp->selectDescription();
$questionWeighting=$objQuestionTmp->selectWeighting();
$answerType=$objQuestionTmp->selectType();
$questionWeighting =$objQuestionTmp->selectWeighting();
$answerType =$objQuestionTmp->selectType();
$quesId =$objQuestionTmp->selectId(); //added by priya saini
}
@ -168,9 +170,6 @@ $objAnswerTmp=new Answer($questionid);
$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
//echo 'answe_type '.$answerType;echo '<br />';
if($answerType == FREE_ANSWER)
$nbrAnswers = 1;
$choice=$exerciseResult[$questionid];
$destination=array();
$comment='';
@ -179,70 +178,61 @@ $_SESSION['hotspot_coord']=array();
$_SESSION['hotspot_dest']=array();
$overlap_color=$missing_color=$excess_color=false;
$organs_at_risk_hit=0;
if (!empty($choice_value))
{
$wrong_results = false;
$hot_spot_load = false;
if (!empty($choice_value)) {
for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
$answer=$objAnswerTmp->selectAnswer($answerId);
$answerComment=$objAnswerTmp->selectComment($answerId);
$answerDestination=$objAnswerTmp->selectDestination($answerId);
$answerCorrect=$objAnswerTmp->isCorrect($answerId);
$answerWeighting=$objAnswerTmp->selectWeighting($answerId);
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
$answerDestination = $objAnswerTmp->selectDestination($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$answerWeighting = $objAnswerTmp->selectWeighting($answerId);
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
//delineation
$delineation_cord=$objAnswerTmp->selectHotspotCoordinates(1);
$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 == $answerId)?1:0;
$studentChoice=($choice_value == $numAnswer)?1:0;
if($studentChoice) {
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
$questionScore +=$answerWeighting;
$totalScore +=$answerWeighting;
$newquestionList[]=$questionid;
}
break;
case HOT_SPOT_DELINEATION : $studentChoice=$choice[$answerId];
case HOT_SPOT_DELINEATION :
$studentChoice=$choice[$answerId];
if($studentChoice) {
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
$newquestionList[]=$questionid;
}
if ($answerId===1) {
$_SESSION['hotspot_coord'][1]=$delineation_cord;
$_SESSION['hotspot_dest'][1]=$answer_delineation_destination;
$questionScore +=$answerWeighting;
$totalScore +=$answerWeighting;
$_SESSION['hotspot_coord'][1] =$delineation_cord;
$_SESSION['hotspot_dest'][1] =$answer_delineation_destination;
}
break;
}
if($answerType != MATCHING || $answerCorrect)
{
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
{
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
//display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect);
//echo $questionScore;
if ($studentChoice)
{
if ($studentChoice) {
$destination=$answerDestination;
$comment=$answerComment;
}
}
elseif($answerType == HOT_SPOT_DELINEATION)
{
if ($next)
{
} elseif($answerType == HOT_SPOT_DELINEATION) {
if ($next) {
if ($dbg_local>0) { error_log(__LINE__.' - next',0);}
$tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
// Save into db
$sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate )
VALUES ('".Database::escape_string($_user['user_id'])."', '".Database::escape_string($_course['id'])."', '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."', '".Database::escape_string($answerId)."', '".Database::escape_string($studentChoice)."', '".Database::escape_string($user_array)."')";
$result = Database::query($sql);
$hot_spot_load = true; //apparently the script is called twice
$user_answer = $user_array;
//$_SESSION['exerciseResultCoordinates'][$questionId]=$exerciseResultCoordinates;
$_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];
@ -252,14 +242,20 @@ if (!empty($choice_value))
$poly_answer = convert_coordinates($answer_question,'|');
$max_coord = poly_get_max($poly_user,$poly_answer);
if (empty($_GET['hotspot'])) { //no user response
$overlap = -2;
} else {
$poly_user_compiled = poly_compile($poly_user,$max_coord);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
$overlap = $poly_results['both'];
$poly_answer_area = $poly_results['s1'];
$poly_user_area = $poly_results['s2'];
$missing = $poly_results['s1Only'];
$excess = $poly_results['s2Only'];
}
//$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 ($overlap < 1) {
@ -286,48 +282,42 @@ if (!empty($choice_value))
$threadhold2 = $threadhold_items[1]; // excess
$threadhold3 = $threadhold_items[2]; //missing
// echo $final_overlap.' '.$threadhold1 .' - '. $final_missing.' '. $threadhold2 .' - '. $final_excess.' '. $threadhold3;
// if is delineation
if ($answerId===1)
{
if ($answerId===1) {
//setting colors
if ($final_overlap>=$threadhold1)
{
if ($final_overlap>=$threadhold1) {
$overlap_color=true; //echo 'a';
}
//echo $excess.'-'.$threadhold2;
if ($final_excess<=$threadhold2)
{
if ($final_excess<=$threadhold2) {
$excess_color=true; //echo 'b';
}
//echo '--------'.$missing.'-'.$threadhold3;
if ($final_missing<=$threadhold3)
{
if ($final_missing<=$threadhold3) {
$missing_color=true; //echo 'c';
}
// if pass
if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3)
{
//if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
$next=1; //go to the oars
$result_comment=get_lang('Acceptable');
}
else
{
$next=0;
} else {
$next=1; //Go to the oars. If $next = 0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
$wrong_results = true;
$result_comment=get_lang('Unacceptable');
$comment=$answerDestination=$objAnswerTmp->selectComment(1);
$sepecial_comment = $comment=$answerDestination=$objAnswerTmp->selectComment(1);
$answerDestination=$objAnswerTmp->selectDestination(1);
$destination_items= explode('@@', $answerDestination);
$try_hotspot=$destination_items[1];
$lp_hotspot=$destination_items[2];
$select_question_hotspot=$destination_items[3];
$url_hotspot=$destination_items[4];
//echo 'show the feedback';
}
}
elseif($answerId>1)
{
} 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
@ -339,25 +329,34 @@ if (!empty($choice_value))
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list);
//$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
$inter= $result['success'];
//$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
$poly_answer = convert_coordinates($delineation_cord,'|');
$max_coord = poly_get_max($poly_user,$poly_answer);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$max_coord = poly_get_max($poly_user,$poly_answer); //getting max coordinates
$test = false;
// if ($answerId == 2 ){$test = true;} for test oars
if (empty($_GET['hotspot'])) { //no user response
$overlap = false;
} else {
// poly_compile really works tested with gnuplot
$poly_user_compiled = poly_compile($poly_user,$max_coord,$test);//$poly_user is already set when answerid = 1
$poly_answer_compiled = poly_compile($poly_answer,$max_coord,$test);
$overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
}
if (!$overlap) {
if ($overlap == false) {
//all good, no overlap
$next = 1;
continue;
} else {
if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
$organs_at_risk_hit++;
//show the feedback
$next=0;
$next=1;
$comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
$answerDestination=$objAnswerTmp->selectDestination($answerId);
$destination_items= explode('@@', $answerDestination);
@ -367,16 +366,12 @@ if (!empty($choice_value))
$url_hotspot=$destination_items[4];
}
}
}
else
{ // the first delineation feedback
} else {
// the first delineation feedback
if ($dbg_local>0) { error_log(__LINE__.' first',0);}
//we send the error
}
}
}
}
if ($overlap_color) {
@ -394,59 +389,75 @@ if (!empty($choice_value))
} else {
$excess_color='red';
}
if (!is_numeric($final_overlap)) {
$final_overlap = 0;
}
if (!is_numeric($final_missing)) {
$final_missing = 0;
}
if (!is_numeric($final_excess)) {
$final_excess = 0;
}
if ($final_excess>100) {
$final_excess = 100;
}
$table_resume='<table class="data_table" >
<tr class="row_odd" >
<td></td>
<td ><b>'.get_lang('Required').'</b></td>
<td ><b>'.get_lang('Requirements').'</b></td>
<td><b>'.get_lang('YourAnswer').'</b></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Overlap').'</b></td>
<td>'.get_lang('Min').' '.$threadhold1.'</td>
<td><div style="color:'.$overlap_color.'">'.$final_overlap.'</div></td>
<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Missing').'</b></td>
<td>'.get_lang('Max').' '.$threadhold3.'</td>
<td><div style="color:'.$missing_color.'">'.$final_missing.'</div></td>
</tr>
<tr>
<td><b>'.get_lang('Excess').'</b></td>
<td>'.get_lang('Max').' '.$threadhold2.'</td>
<td><div style="color:'.$excess_color.'">'.$final_excess.'</div></td>
<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Missing').'</b></td>
<td>'.get_lang('Max').' '.$threadhold3.'</td>
<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
</tr>
</table>';
//var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
}
$_SESSION['newquestionList']=$newquestionList;
if ($choice_value==-1) {
$links. '<a href="#" onclick="self.parent.tb_remove();">'.get_lang('ChooseAnAnswer').'</a>';
}
if ($answerType!= HOT_SPOT_DELINEATION)
{
if ($answerType!= HOT_SPOT_DELINEATION) {
if (!empty($destination)) {
$item_list=explode('@@',$destination);
//print_R($item_list);
$try = $item_list[0];
$lp = $item_list[1];
$destinationid= $item_list[2];
$url=$item_list[3];
}
$table_resume='';
} else {
if ($next==0) {
$try = $try_hotspot;
$lp = $lp_hotspot;
$destinationid= $select_question_hotspot;
$url=$url_hotspot;
} else {
if ($organs_at_risk_hit==0 && $wrong_results==false ) {
// no error = no oar and no wrong result for delineation
//show if no error
//echo 'no error';
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$answerDestination=$objAnswerTmp->selectDestination($nbrAnswers);
$comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
$answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
//we send the error
$destination_items= explode('@@', $answerDestination);
@ -454,33 +465,21 @@ if ($answerType!= HOT_SPOT_DELINEATION)
$lp=$destination_items[2];
$destinationid=$destination_items[3];
$url=$destination_items[4];
$exerciseResult[$questionid] = 1;
} else {
$exerciseResult[$questionid] = 0;
}
}
//$pre_list_destination=explode(';',$list_dest);
/*
$destination_list=array();
foreach($pre_list_destination as $value)
{
if ($value!='')
$destination_list[]=$value;
}*/
//echo '<pre>';print_r($destination);
$links='';
// the link to retry the question
if ($try==1)
{
if ($try==1) {
$num_value_array= (array_keys($questionList, $questionid));
$links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
}
// the link to theory (a learning path)
if (!empty($lp))
{
if (!empty($lp)) {
$lp_url= api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
require_once('../newscorm/learnpathList.class.php');
$list = new LearnpathList(api_get_user_id());
@ -489,68 +488,84 @@ if (!empty($lp))
}
$links.='<br />';
// the link to an external website or link
if (!empty($url)) {
$links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
}
// the link to finish the test
if ($destinationid==-1)
{
if ($destinationid==-1) {
$links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
}
// the link to other question
else
{
if (in_array($destinationid,$questionList))
{
} else {
// the link to other question
if (in_array($destinationid,$questionList)) {
$objQuestionTmp = Question :: read($destinationid);
$questionName=$objQuestionTmp->selectTitle();
$num_value_array= (array_keys($questionList, $destinationid));
$links.= Display :: return_icon('quiz.gif', '', array ('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 />';
}
}
echo '<script> function SendEx(num)
{
if (num==-1)
{
self.parent.window.location.href = "exercise_result.php?origin='.$origin.'";
echo '<script>
function SendEx(num) {
if (num==-1) {
self.parent.window.location.href = "exercise_result.php?take_session=1&exerciseId='.$exerciseId.'&questionNum="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
self.parent.tb_remove();
}
else
{
self.parent.window.location.href = "exercice_submit.php?tryagain=1&exerciseId='.$exerciseId.'&questionNum="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'";
} else {
self.parent.window.location.href = "exercice_submit.php?tryagain=1&exerciseId='.$exerciseId.'&questionNum="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
self.parent.tb_remove();
}
}
</script>';
if ($links!='') {
echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
<a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;" id="exercise_close_link">'.get_lang('Close').'</a>
<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
<p style="text-align:center">';
<a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;" id="exercise_close_link">'.api_ucfirst(get_lang('Close')).'</a>
<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
if ($answerType == HOT_SPOT_DELINEATION) {
if ($organs_at_risk_hit>0) {
//$message='<p>'.get_lang('YourDelineation').'</p>';
//$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
//if ($wrong_results) { }
$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
$message.='<p>'.$comment.'</p>';
} else {
$message='<p>'.get_lang('YourDelineation').'</p>';
$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' '.$result_comment.'<br />';
if ($organs_at_risk_hit>0)
$message.='<p><b>'.get_lang('OARHit').'</b></p>';
$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message.='<p>'.$comment.'</p>';
}
echo $message;
} else {
echo '<p>'.$comment.'</p>';
}
echo '<h3>'.$links.'</h3>';
//echo '<a onclick="self.parent.tb_remove();" href="#" style="float:right;">'.get_lang('Close').'</a>';
echo '</div>';
$_SESSION['hot_spot_result']=$message;
//saving the hotspot delineation results
/*
if ($hot_spot_load) { // apparently the popup load 2 times @todo check this
$exeId = create_event_exercice($exerciseId);
// only insert the user delineation
//for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
$tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
// Save into db
$sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate )
VALUES ('".Database::escape_string($_user['user_id'])."', '".Database::escape_string($_course['id'])."', '".Database::escape_string($exeId)."', '".Database::escape_string($questionid)."', '".Database::escape_string($answerId)."', '".Database::escape_string($exerciseResult[$questionid])."', '".Database::escape_string($user_array)."')";
$result = api_sql_query($sql,__FILE__,__LINE__);
//}
}*/
$_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
//reseting the exerciseResult variable
api_session_register('exerciseResult');
//save this variables just in case the exercise loads an LP with other exercise
$_SESSION['objExerciseExtra'.$exerciseId] = $_SESSION['objExercise'];
$_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
$_SESSION['questionListExtra'.$exerciseId] = $_SESSION['questionList'];
} else {
$questionNum++;
echo '<script>
@ -558,4 +573,3 @@ if ($links!='') {
//self.parent.tb_remove();
</script>';
}
?>

@ -86,6 +86,14 @@ class ScormQuestion extends Question
break;
case MULTIPLE_ANSWER_COMBINATION:
$this->answer = new ScormAnswerMultipleChoice($this->id, false);
$this->answer->questionJSId = $this->js_id;
break;
case HOT_SPOT_ORDER:
$this->answer = new ScormAnswerHotspot($this->id);
$this->answer->questionJSId = $this->js_id;
break;
case HOT_SPOT_DELINEATION:
$this->answer = new ScormAnswerHotspot($this->id);
$this->answer->questionJSId = $this->js_id;
break;
default :

@ -89,8 +89,41 @@ class HotSpot extends Question {
function processAnswersCreation ($form) {
// nothing
}
}
class HotSpotDelineation extends HotSpot {
static $typePicture = 'hotspot_delineation.gif';
static $explanationLangVar = 'HotspotDelineation';
function HotSpotDelineation(){
parent::question();
$this -> type = HOT_SPOT_DELINEATION;
}
function createForm ($form) {
parent::createForm ($form);
}
function processCreation ($form, $objExercise) {
$file_info = $form -> getSubmitValue('imageUpload');
parent::processCreation ($form, $objExercise);
}
function createAnswersForm ($form) {
parent::createAnswersForm ($form);
// nothing
}
function processAnswersCreation ($form) {
parent::processAnswersCreation ($form);
// nothing
}
}
endif;
?>

@ -1,6 +1,5 @@
<?php //$id:$
/* For licensing terms, see /license.txt */
//error_log(__FILE__);
/**
* This file generates the ActionScript variables code used by the HotSpot .swf
* @package dokeos.exercise
@ -8,16 +7,15 @@
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
session_cache_limiter("none");
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
// set vars
$questionId = $_GET['modifyAnswers'];
$questionId = intval($_GET['modifyAnswers']);
$objQuestion = Question::read($questionId);
$answer_type = $objQuestion->selectType(); //very important
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$picturePath = $documentPath.'/images';
@ -31,9 +29,12 @@ $courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
// Query db for answers
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
if ($answer_type==HOT_SPOT_DELINEATION) {
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' AND hotspot_type = 'delineation' ORDER BY id";
} else {
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
}
$result = Database::query($sql);
// Init
$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
$i = 0;
@ -63,6 +64,11 @@ while ($hotspot = Database::fetch_assoc($result))
{
$output .= "&hotspot_".$hotspot['id']."_type=delineation";
}
// No error
if ($hotspot['hotspot_type'] == 'noerror')
{
$output .= "&hotspot_".$hotspot['id']."_type=noerror";
}
// This is a good answer, count + 1 for nmbr of clicks
if ($hotspot['hotspot_type'] > 0)
@ -77,11 +83,8 @@ while ($hotspot = Database::fetch_assoc($result))
// Generate empty
$i++;
for ($i; $i <= 12; $i++)
{
for ($i; $i <= 12; $i++) {
$output .= "&hotspot_".$i."=false";
}
// Output
echo $output."&nmbrTries=".$nmbrTries."&done=done";
?>

@ -1,6 +1,5 @@
<?php //$id:$
/* For licensing terms, see /license.txt */
//error_log(__FILE__);
/**
* This file generates the ActionScript variables code used by the HotSpot .swf
* @package dokeos.exercise
@ -13,7 +12,7 @@ include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
// set vars
$questionId = $_GET['modifyAnswers'];
$questionId = intval($_GET['modifyAnswers']);
$objQuestion = Question::read($questionId);
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
@ -42,11 +41,16 @@ $nmbrTries = 0;
$answers=$_SESSION['tmp_answers'];
$nbrAnswers = count($answers['answer']);
for($i=1;$i <= $nbrAnswers;$i++)
{
for($i=1;$i <= $nbrAnswers;$i++) {
$output .= "&hotspot_".$i."=true";
$output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
if ($answer_type==HOT_SPOT_DELINEATION) {
if ($i==1)
$output .= "&hotspot_".$i."_type=delineation";
else
$output .= "&hotspot_".$i."_type=oar";
} else {
// Square or rectancle
if ($answers['hotspot_type'][$i] == 'square' )
{
@ -64,10 +68,11 @@ for($i=1;$i <= $nbrAnswers;$i++)
{
$output .= "&hotspot_".$i."_type=poly";
}
// Delineation
/*// Delineation
if ($answers['hotspot_type'][$i] == 'delineation')
{
$output .= "&hotspot_".$i."_type=delineation";
}*/
}
// This is a good answer, count + 1 for nmbr of clicks
@ -81,11 +86,9 @@ for($i=1;$i <= $nbrAnswers;$i++)
// Generate empty
$i++;
for ($i; $i <= 12; $i++)
{
for ($i; $i <= 12; $i++) {
$output .= "&hotspot_".$i."=false";
}
// Output
echo $output."&nmbrTries=".$nmbrTries."&done=done";
?>

@ -1,4 +1,4 @@
<?php //$id:$
<?php
/* For licensing terms, see /dokeos_license.txt */
//error_log(__FILE__);
/**
@ -7,12 +7,13 @@
* @author Toon Keppens
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
require_once(api_get_path(LIBRARY_PATH).'text.lib.php');
// ALLOWED_TO_INCLUDE is defined in admin.php
if(!defined('ALLOWED_TO_INCLUDE')) {
exit();
}
$modifyAnswers = $_GET['hotspotadmin'];
$modifyAnswers = intval($_GET['hotspotadmin']);
if(!is_object($objQuestion)) {
$objQuestion = Question :: read($modifyAnswers);
@ -21,7 +22,6 @@ if(!is_object($objQuestion)) {
$questionName = $objQuestion->selectTitle();
$answerType = $objQuestion->selectType();
$pictureName = $objQuestion->selectPicture();
$debug = 0; // debug variable to get where we are
$okPicture=empty($pictureName)?false:true;
@ -56,23 +56,25 @@ if($modifyIn) {
$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);
$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);
}
// The answer form has been submitted
$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin='.$modifyAnswers. '&exerciseId='.$exerciseId;
// the answer form has been submitted
if ($submitAnswers || $buttonBack) {
if($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\n";}
$questionWeighting=$nbrGoodAnswers=0;
if ($answerType==HOT_SPOT) {
if($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\n";}
$questionWeighting=$nbrGoodAnswers=0;
for($i=1;$i <= $nbrAnswers;$i++) {
if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
@ -106,11 +108,9 @@ if ($submitAnswers || $buttonBack) {
} // end for()
if (empty($msgErr)) {
if(empty($msgErr)) {
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]); //it can be float
@ -129,33 +129,210 @@ if ($submitAnswers || $buttonBack) {
$editQuestion=$questionId;
unset($modifyAnswers);
echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'"</script>';
echo '<script type="text/javascript">window.location.href="'.$hotspot_admin_url.'"</script>';
}
if($debug>0){echo '$modifyIn was set - end'."<br />\n";}
} else {
if($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\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('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\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 '<pre>';print_r($_POST);echo '</pre>';
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
$select_question_noerror=$_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 ($select_question_noerror=='') {
$question_str=0;
} else {
$question_str=$select_question_noerror;
}
$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('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\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 '<script type="text/javascript">window.location.href="'.$hotspot_admin_url.'"</script>';
}
if($debug>0){echo '$modifyIn was set - end'."<br />\n";}
}
}
if($modifyAnswers) {
if ($modifyAnswers) {
if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers is set'."<br />\n";}
// construction of the Answer object
$objAnswer=new Answer($objQuestion -> id);
api_session_register('objAnswer');
if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is HOT_SPOT'."<br />\n";}
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
if(!$nbrAnswers) {
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++) {
@ -166,9 +343,37 @@ if($modifyAnswers) {
$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];
$select_question_noerror=$destination_items[3];
$url_noerror=$destination_items[4];
}
$_SESSION['tmp_answers'] = array();
@ -179,8 +384,31 @@ if($modifyAnswers) {
$_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;
}
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--;
@ -196,6 +424,7 @@ if($modifyAnswers) {
$msgErr=get_lang('MinHotspot');
}
}
}
if($moreAnswers) {
if ($nbrAnswers < 12) {
@ -209,6 +438,23 @@ if($modifyAnswers) {
$_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');
}
}
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');
}
@ -216,6 +462,9 @@ if($modifyAnswers) {
if($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\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",
@ -230,6 +479,7 @@ if($modifyAnswers) {
"#ED2024",
"#45C7F0",
"#F7BDE2");
}
Display::tag('h3',get_lang('Question').": ".$questionName.' <img src="../img/info3.gif" title="'.strip_tags(get_lang('HotspotChoose')).'" alt="'.strip_tags(get_lang('HotspotChoose')).'" />');
if(!empty($msgErr)) {
@ -237,7 +487,7 @@ if(!empty($msgErr)) {
}
?>
<form method="post" action="<?php echo api_get_self(); ?>?hotspotadmin=<?php echo $modifyAnswers; ?>" id="frm_exercise" name="frm_exercise">
<form method="post" action="<?php echo $hotspot_admin_url; ?>" id="frm_exercise" name="frm_exercise">
<table border="0" cellpadding="0" cellspacing="2" width="100%">
<tr>
<td colspan="2" valign="bottom">
@ -246,24 +496,30 @@ if(!empty($msgErr)) {
//ie6 fix
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
?>
<input type="submit" class="save" name="submitAnswers" value="<?php echo get_lang('Save'); ?>" />
<input type="submit" class="plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" />
<?php if ($answerType==HOT_SPOT_DELINEATION) {?>
<input type="submit" class="minus" name="lessAnswers" value="<?php echo get_lang('LessOAR'); ?>" >
<input type="submit" class="plus" name="moreOARAnswers" value="<?php echo get_lang('MoreOAR'); ?>" />
<?php } else { ?>
<input type="submit" class="minus" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" >
<!--<input type="submit" class="cancel" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))); ?>')) return false;" >-->
<input type="submit" class="plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" />
<?php } ?>
<input type="submit" class="cancel" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))); ?>')) return false;" >
<input type="submit" class="save" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" />
<?php
} else {
?>
<button type="submit" class="save" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" /><?php echo get_lang('AddQuestionToExercise'); ?></button>
<button type="submit" class="plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" /><?php echo get_lang('MoreHotspots'); ?></button>
<?php if ($answerType==HOT_SPOT_DELINEATION) {?>
<button type="submit" class="minus" name="lessAnswers" value="<?php echo get_lang('LessOAR'); ?>" ><?php echo get_lang('LessOAR'); ?></button>
<button type="submit" class="plus" name="moreOARAnswers" value="<?php echo get_lang('MoreOAR'); ?>" /><?php echo get_lang('MoreOAR'); ?></button>
<?php } else { ?>
<button type="submit" class="minus" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" ><?php echo get_lang('LessHotspots'); ?></button>
<!--<button type="submit" class="cancel" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))); ?>')) return false;" ><?php echo get_lang('Cancel'); ?></button>-->
<button type="submit" class="plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" /><?php echo get_lang('MoreHotspots'); ?></button>
<?php } ?>
<button type="submit" class="cancel" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))); ?>')) return false;" ><?php echo get_lang('Cancel'); ?></button>
<button type="submit" class="save" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" /><?php echo get_lang('AddQuestionToExercise'); ?></button>
<?php
}
?>
</td>
</tr>
<tr>
@ -277,26 +533,294 @@ if(!empty($msgErr)) {
</tr>
-->
<tr>
<th width="5" >&nbsp;<?php /* echo get_lang('HotSpot'); */ ?></th>
<th width="5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></th>
<th><?php echo get_lang('HotspotDescription'); ?> *</th>
<?php if ($answerType==HOT_SPOT_DELINEATION) echo '<th >'.get_lang('Thresholds').'</th>'; ?>
<?php if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<th><?php echo get_lang('HotspotDescription'); ?>*</th>
<?php if ($objExercise->selectFeedbackType()== EXERCISE_FEEDBACK_TYPE_DIRECT) {?>
<th><?php echo get_lang('Comment'); ?></th>
<?php if ($answerType==HOT_SPOT_DELINEATION) echo '<th >'.get_lang('Scenario').'</th>'; ?>
<?php } else {?>
<th colspan="2"><?php echo get_lang('Comment'); ?></th>
<?php }?>
<th><?php echo get_lang('QuestionWeighting'); ?> *</th>
</tr>
<?php
require_once '../newscorm/learnpathList.class.php';
//require_once(api_get_path(LIBRARY_PATH).'text.lib.php');
$list = new LearnpathList(api_get_user_id());
$flat_list = $list->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
$is_selected = false;
foreach ($flat_list as $id => $details) {
$select_lp_id[$id] = $details['lp_name'];
$selected = '';
if ($id==$lp[$i]) {
$is_selected = true;
$selected='selected="selected"';
}
$option_lp.='<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>';
}
if ($is_selected) {
$option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp;
} else {
$option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>'.$option_lp;
}
//Feedback SELECT
$question_list=$objExercise->selectQuestionList();
$option_feed='';
$option_feed.='<option value="0">'.get_lang('SelectTargetQuestion').'</option>';
foreach ($question_list as $key=>$questionid) {
$selected='';
$question = Question::read($questionid);
$val='Q'.$key.' :'.substrwords($question->selectTitle(),'22');
$select_lp_id[$id] = $details['lp_name'];
if ($questionid==$select_question[$i]){
$selected='selected="selected"';
}
$option_feed.='<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>';
}
if ($select_question[$i]==-1)
$option_feed.='<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>';
else
$option_feed.='<option value="-1">'.get_lang('ExitTest').'</option>';
//-------- 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.='<option '.$selected1.' >'.$k.'</option>';
$option2.='<option '.$selected2.' >'.$k.'</option>';
$option3.='<option '.$selected3.'>'.$k.'</option>';
}
?>
<tr>
<td valign="top">
<div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div>
<input type="hidden" name="reponse[<?php echo $i; ?>]" value="delineation" />
</td>
<td valign="top" align="left">
<b><?php echo get_lang('Delineation'); ?></b><br /><br />
<?php echo get_lang('MinOverlap'); ?><br/><br/>
<?php echo get_lang('MaxExcess'); ?><br/><br/>
<?php echo get_lang('MaxMissing'); ?><br/><br/>
</td>
<td>
<br/><br/>
<select name="threadhold1[<?php echo $i; ?>]" >
<?php echo $option1; ?>
</select>%
<br/><br/>
<select name="threadhold2[<?php echo $i; ?>]" >
<?php echo $option2; ?>
</select>%
<br/><br/>
<select name="threadhold3[<?php echo $i; ?>]" >
<?php echo $option3; ?>
</select>%
<br/>
</td>
<td align="left">
<br />
<textarea wrap="virtual" rows="3" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo stripslashes(htmlentities($comment[$i])); ?></textarea>
<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]); ?>" />
<br/>
<?php echo get_lang('LearnerIsInformed');?>
</td>
<?php
if ($objExercise->selectFeedbackType()== EXERCISE_FEEDBACK_TYPE_DIRECT) {?>
<td>
<table>
<tr>
<td>
<input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]" <?php if ($try[$i]==1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?>
<br /><br />
<?php echo get_lang('SeeTheory');?> <br />
<select name="lp[<?php echo $i; ?>]" >
<?php echo $option_lp; ?>
</select>
<br /><br />
<?php echo get_lang('Other');?> <br />
<input name="url[<?php echo $i; ?>]" value="<?php echo $url[$i];?>">
<br /> <br />
<?php echo get_lang('SelectQuestion');?> <br />
<select name="select_question[<?php echo $i; ?>]" >
<?php echo $option_feed; ?>
</select>
</td>
</tr>
</table>
</td>
<?php } else {?>
<td> &nbsp;</td>
<?php } ?>
<?php
}
//
//elseif ($_SESSION['tmp_answers']['hotspot_type'][$i]=='noerror' || $_SESSION['tmp_answers']['answer'][$i]=='noerror')
elseif (false)
{
?>
<tr>
<th colspan="2" ><?php echo get_lang('IfNoError'); ?></th>
<th colspan="3" ><?php echo get_lang('Feedback'); ?></th>
<!-- th colspan="1" ><?php echo get_lang('Scenario'); ?></th -->
<th></th>
</tr>
<tr>
<td colspan="2" valign="top" align="left">
<?php echo get_lang('LearnerHasNoMistake'); ?>
<input type="hidden" name="reponse[<?php echo $i; ?>]" value="noerror" />
<input type="hidden" name="weighting[<?php echo $i; ?>]" value="0" />
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="noerror" />
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="0;0|0|0" />
</td>
<td colspan="2" align="left">
<textarea wrap="virtual" rows="3" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo stripslashes(htmlentities($comment[$i])); ?></textarea>
</td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {?>
<td>
<table>
<tr>
<td>
<input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]" <?php if ($try[$i]==1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?>
<br /><br />
<?php echo get_lang('SeeTheory');?> <br />
<select name="lp[<?php echo $i; ?>]" >
<?php echo $option_lp; ?>
</select>
<br /><br />
<?php echo get_lang('Other');?> <br />
<input name="url[<?php echo $i; ?>]" value="<?php echo $url[$i]; ?>">
<br /> <br />
<?php echo get_lang('SelectQuestion');?> <br />
<select name="select_question[<?php echo $i; ?>]">
<?php echo $option_feed; ?>
</select>
</td>
</tr>
</table>
</td>
<?php } else { ?>
<th colspan="2"><?php echo get_lang('HotspotDescription'); ?>*</th>
<td>&nbsp;</td>
<?php } ?>
<th><?php echo get_lang('QuestionWeighting'); ?>*</th>
</tr>
<?php
}
// if it's an OAR
elseif ($_SESSION['tmp_answers']['hotspot_type'][$i]=='oar') {
if ($i==2) {
?>
<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) {?>
<th colspan="2" ><?php echo get_lang('Comment'); ?></th>
<th ><?php if ($answerType==HOT_SPOT_DELINEATION) echo get_lang('Scenario'); ?></th>
<?php } else { ?>
<th colspan="3" ><?php echo get_lang('Comment'); ?></th>
<?php } ?>
<th>&nbsp;</th>
</tr>
<?php
for($i=1;$i <= $nbrAnswers;$i++) {
}
?>
<tr>
<td valign="top"><div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div></td>
<?php if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td valign="top" align="left"><input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo api_htmlentities($reponse[$i], ENT_QUOTES, api_get_system_encoding()); ?>" size="45" /></td>
<td valign="top">
<div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div>
</td>
<td valign="top" align="left">
<input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo htmlentities($reponse[$i]); ?>" size="20" />
</td>
<td colspan="2" align="left">
<textarea wrap="virtual" rows="3" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo stripslashes(htmlentities($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]); ?>" />
</td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<td>
<table>
<tr>
<td>
<input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]" <?php if ($try[$i]==1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?>
<br /><br />
<?php echo get_lang('SeeTheory');?> <br />
<select name="lp[<?php echo $i; ?>]" >
<?php echo $option_lp; ?>
</select>
<br /><br />
<?php echo get_lang('Other');?> <br />
<input name="url[<?php echo $i; ?>]" value="<?php echo $url[$i]; ?>">
<br /><br />
<?php echo get_lang('SelectQuestion');?> <br />
<select name="select_question[<?php echo $i; ?>]">
<?php echo $option_feed; ?>
</select>
</td>
</tr>
</table>
</td>
<?php } else {?>
<td>&nbsp;</td>
<?php } ?>
<?php
}
} else { //end if is delineation
?>
<td valign="top">
<div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div>
</td>
<td valign="top" align="left">
<input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo htmlentities($reponse[$i]); ?>" size="45" />
</td>
<?php
require_once(api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php");
$oFCKeditor = new FCKeditor("comment[$i]") ;
@ -309,20 +833,134 @@ if(!empty($msgErr)) {
$return = $oFCKeditor->CreateHtml();
/*<td align="left"><textarea wrap="virtual" rows="1" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo api_htmlentities($comment[$i], ENT_QUOTES, api_get_system_encoding()); ?></textarea></td>*/
?>
<td align="left"><?php echo $return; ?></td>
<td>&nbsp;</td>
<td align="left" ><?php echo $return; ?></td>
<?php
}
?>
<td valign="top">
<?php
//if ($answerType==HOT_SPOT_DELINEATION && $i!=2)
if ($answerType==HOT_SPOT_DELINEATION) {
if ($_SESSION['tmp_answers']['hotspot_type'][$i]=='oar') { ?>
<input type="hidden" name="weighting[<?php echo $i; ?>]" size="3" value="0" />
<?php } else { ?>
<td valign="top" align="left" colspan="2"><input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo api_htmlentities($reponse[$i], ENT_QUOTES, api_get_system_encoding()); ?>" size="45" /></td>
<?php } ?>
<input type="text" name="weighting[<?php echo $i; ?>]" size="3" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
<?php }
}
<td valign="top"><input type="text" name="weighting[<?php echo $i; ?>]" size="5" value="<?php echo (isset($weighting[$i]) ? float_format($weighting[$i],1) : 10); ?>" />
if ($answerType==HOT_SPOT) {
?>
<input type="text" name="weighting[<?php echo $i; ?>]" size="3" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /></td>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" />
<?php
}
?>
</td>
</tr>
<?php
}
require_once('../newscorm/learnpathList.class.php');
//require_once(api_get_path(LIBRARY_PATH).'text.lib.php');
$list = new LearnpathList(api_get_user_id());
$flat_list = $list->get_flat_list();
$select_lp_id=array();
$option_lp='';
//$option_lp.='<option value="0">'.get_lang('SelectTargetLP').'</option>';
foreach ($flat_list as $id => $details) {
$selected = '';
$select_lp_id[$id] = $details['lp_name'];
if ($id==$lp_noerror) {
$selected='selected="selected"';
$is_selected = true;
}
$option_lp.='<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>';
}
if ($is_selected) {
$option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp;
} else {
$option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>'.$option_lp;
}
//Feedback SELECT
$question_list=$objExercise->selectQuestionList();
$option_feed='';
$option_feed.='<option value="0">'.get_lang('SelectTargetQuestion').'</option>';
foreach ($question_list as $key=>$questionid)
{
$selected='';
$question = Question::read($questionid);
$val='Q'.$key.' :'.substrwords($question->selectTitle(),'22');
$select_lp_id[$id] = $details['lp_name'];
if ($questionid==$select_question_noerror){
$selected='selected="selected"';
}
$option_feed.='<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>';
}
if ($select_question_noerror==-1)
$option_feed.='<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>';
else
$option_feed.='<option value="-1">'.get_lang('ExitTest').'</option>';
if ($answerType==HOT_SPOT_DELINEATION) {
?>
<tr>
<th colspan="2" ><?php echo get_lang('IfNoError'); ?></th>
<?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 { ?>
<th colspan="3" ><?php echo get_lang('Feedback'); ?></th>
<?php } ?>
<th>&nbsp;</th>
</tr>
<tr>
<td colspan="2" valign="top" align="left">
<?php echo get_lang('LearnerHasNoMistake'); ?>
</td>
<td colspan="2" align="left">
<textarea wrap="virtual" rows="3" cols="25" name="comment_noerror" style="width: 100%"><?php echo stripslashes(htmlentities($comment_noerror)); ?></textarea>
</td>
<?php if ($objExercise->selectFeedbackType()== EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<td>
<table>
<tr>
<td>
<input type="checkbox" class="checkbox" name="try_noerror" <?php if ($try_noerror==1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?>
<br /><br />
<?php echo get_lang('SeeTheory');?> <br />
<select name="lp_noerror" >
<?php echo $option_lp; ?>
</select>
<br /><br />
<?php echo get_lang('Other');?> <br />
<input name="url_noerror" value="<?php echo $url_noerror; ?>">
<br /><br />
<?php echo get_lang('SelectQuestion');?> <br />
<select name="select_question_noerror">
<?php echo $option_feed; ?>
</select>
</td>
</tr>
</table>
</td>
<td>&nbsp;</td>
<?php } else { ?>
<td colspan="2">&nbsp;</td>
<?php } ?>
</tr>
<?php
}
?>
</table>
</td>
</tr>
@ -333,11 +971,15 @@ if(!empty($msgErr)) {
// Version check based upon the values entered above in "Globals"
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
<?php
$swf_loaded = $answerType==HOT_SPOT_DELINEATION ? 'hotspot_delineation_admin' : 'hotspot_admin';
$height = 450;
?>
// Check to see if the version meets the requirements for playback
if (hasReqestedVersion) { // if we've detected an acceptable version
var oeTags = '<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_admin.swf?modifyAnswers=<?php echo $modifyAnswers ?>" width="600" height="450">'
+ '<param name="movie" value="../plugin/hotspot/hotspot_admin.swf?modifyAnswers=<?php echo $modifyAnswers ?>" />'
var oeTags = '<object type="application/x-shockwave-flash" data="../plugin/hotspot/<?php echo $swf_loaded ?>.swf?modifyAnswers=<?php echo $modifyAnswers ?>" width="600" height="<?php echo $height ?>">'
+ '<param name="movie" value="../plugin/hotspot/<?php echo $swf_loaded ?>.swf?modifyAnswers=<?php echo $modifyAnswers ?>" />'
+ '<param name="test" value="OOoowww fo shooww" />'
+ '</object>';
document.write(oeTags); // embed the Flash Content SWF when all tests are passed
@ -354,7 +996,9 @@ if(!empty($msgErr)) {
</tr>
</table>
</form>
<?php
if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers was set - end'."<br />\n";}
}
?>

@ -3,7 +3,7 @@
/**
* This file generates the ActionScript variables code used by the HotSpot .swf
* @package chamilo.exercise
* @author Toon Keppens
* @author Toon Keppens, Julio Montoya adding hotspot "medical" support
*/
include('exercise.class.php');
@ -29,9 +29,14 @@ $pictureHeight = $pictureSize[1];
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
$answer_type = $objQuestion->selectType();
// Query db for answers
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
if ($answer_type==HOT_SPOT_DELINEATION) {
// Query db for answers
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' AND hotspot_type <> 'noerror' ORDER BY id";
} else {
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
}
$result = Database::query($sql);
// Init
$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
@ -58,6 +63,10 @@ while ($hotspot = Database::fetch_array($result)) {
if ($hotspot['hotspot_type'] == 'delineation') {
$output .= "&hotspot_".$hotspot['id']."_type=delineation";
}
// oar
if ($hotspot['hotspot_type'] == 'oar') {
$output .= "&hotspot_".$hotspot['id']."_type=delineation";
}
$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
$i++;
}
@ -91,10 +100,7 @@ if(isset($_SESSION['exerciseResultCoordinates']) && $from_db==0) {
$output2 .= $row['hotspot_coordinate']."|";
}
}
$output .= "&p_hotspot_answers=".api_substr($output2,0,-1)."&done=done";
$explode = explode('&', $output);
echo $output;
?>

@ -2,8 +2,8 @@
/* For licensing terms, see /license.txt */
//error_log(__FILE__);
/**
* Hotspot languae conversion
* @package dokeos.exercise
* Hotspot language conversion
* @package chamilo.exercise
* @author
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/

@ -14,28 +14,22 @@ include('answer.class.php');
include('../inc/global.inc.php');
$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
$questionId = $_GET['questionId'];
$answerId = $_GET['answerId'];
$questionId = intval($_GET['questionId']);
$answerId = intval($_GET['answerId']);
if ($_GET['type'] == "square" || $_GET['type'] == "circle")
{
if ($_GET['type'] == "square" || $_GET['type'] == "circle") {
$hotspot_type = $_GET['type'];
$hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
}
if ($_GET['type'] == "poly" || $_GET['type'] == "delineation")
{
if ($_GET['type'] == "poly" || $_GET['type'] == "delineation" || $_GET['type'] == "oar") {
$hotspot_type = $_GET['type'];
$tmp_coord = explode(",",$_GET['co']);
$i = 0;
$hotspot_coordinates = "";
foreach ($tmp_coord as $coord)
{
if ($i%2 == 0)
{
foreach ($tmp_coord as $coord) {
if ($i%2 == 0) {
$delimiter = ";";
}
else
{
} else {
$delimiter = "|";
}
$hotspot_coordinates .= $coord.$delimiter;
@ -46,4 +40,3 @@ if ($_GET['type'] == "poly" || $_GET['type'] == "delineation")
$sql = "UPDATE $TBL_ANSWER SET hotspot_coordinates = '".Database::escape_string($hotspot_coordinates)."',hotspot_type = '".Database::escape_string($hotspot_type)."' WHERE id = '".Database::escape_string($answerId)."' AND question_id ='".Database::escape_string($questionId)."' LIMIT 1 ;";
$result = Database::query($sql);
echo "done=done";
?>

@ -56,4 +56,3 @@ $result = Database::query($sql);
// Save insert id into session if users changes answer.
$insert_id = Database::insert_id();
$_SESSION['exerciseResult'][$questionId]['ids'][$answerOrderId] = $insert_id;
?>

@ -60,6 +60,4 @@ $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOT
// update db
$update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId];
$sql = "UPDATE $TBL_TRACK_E_HOTSPOT SET coordinate = '".Database::escape_string($coordinates)."' WHERE id ='".Database::escape_string($update_id)."' LIMIT 1 ;;";
error_log( $sql );
$result = Database::query($sql);
?>

@ -57,6 +57,7 @@ abstract class Question
MATCHING => array('matching.class.php' , 'Matching'),
FREE_ANSWER => array('freeanswer.class.php' , 'FreeAnswer'),
HOT_SPOT => array('hotspot.class.php' , 'HotSpot'),
HOT_SPOT_DELINEATION => array('hotspot.class.php' , 'HotspotDelineation'),
MULTIPLE_ANSWER_COMBINATION => array('multiple_answer_combination.class.php' , 'MultipleAnswerCombination'),
UNIQUE_ANSWER_NO_OPTION => array('unique_answer_no_option.class.php' , 'UniqueAnswerNoOption'),
MULTIPLE_ANSWER_TRUE_FALSE => array('multiple_answer_true_false.class.php' , 'MultipleAnswerTrueFalse'),
@ -661,6 +662,18 @@ abstract class Question
Database::query($sql);
}
if ($type == HOT_SPOT_DELINEATION ) {
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$sql="INSERT INTO $TBL_ANSWERS (id , question_id , answer , correct , comment , ponderation , position , hotspot_coordinates , hotspot_type ) VALUES ('1', '".Database::escape_string($this->id)."', '', NULL , '', '10' , '1', '0;0|0|0', 'delineation')";
api_sql_query($sql,__FILE__,__LINE__);
//$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
//$sql="INSERT INTO $TBL_ANSWERS (`id` , `question_id` , `answer` , `correct` , `comment` , `ponderation` , `position` , `hotspot_coordinates` , `hotspot_type` ) VALUES ('2', '".Database::escape_string($this->id)."', '', NULL , '', NULL , '1', '0;0|0|0', 'noerror')";
//api_sql_query($sql,__FILE__,__LINE__);
}
if (api_get_setting('search_enabled')=='true') {
if ($exerciseId != 0) {
$this -> search_engine_edit($exerciseId, TRUE);
@ -1041,7 +1054,7 @@ abstract class Question
//$radios_results_enabled[]=$test;
// question level
//@todo move levles into a table
$select_level = array (1,2,3,4,5);
//$radios_results_enabled[] =
foreach($select_level as $val) {
@ -1155,7 +1168,10 @@ abstract class Question
if (!isset($feedbacktype)) $feedbacktype=0;
if ($feedbacktype==1) {
//2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
$question_type_custom_list = array ( UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER]);
//$question_type_custom_list = array ( UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER]);
$question_type_custom_list = array ( UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER],HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION]);
} else {
unset($question_type_custom_list[HOT_SPOT_DELINEATION]);
}
//blocking edition

@ -89,7 +89,7 @@ if(is_object($objQuestion)) {
// TODO: maybe here is the better place to index this tool, including answers text
// redirect
if($objQuestion -> type != HOT_SPOT)
if($objQuestion -> type != HOT_SPOT && $objQuestion -> type != HOT_SPOT_DELINEATION)
echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'"</script>';
else
echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'&hotspotadmin='.$objQuestion->id.'"</script>';

@ -72,14 +72,27 @@ $form->addRule('question_type_hidden', get_lang('InvalidQuestionType'), 'validqu
if ($form->validate()) {
$values = $form->exportValues();
//echo 'form validates';
//print_r($values);
foreach (Question::$questionTypes as $question_type_id => $question_type_class_and_name) {
if (get_lang($question_type_class_and_name[1]) == $values['question_type_hidden']) {
$answer_type = $question_type_id;
}
}
// check feedback_type from current exercise for type of question delineation
$exercise_id = intval($values['exercice']);
$sql = "SELECT feedback_type FROM $tbl_exercices WHERE id = '$exercise_id'";
$rs_feedback_type = Database::query($sql,__FILE__,__LINE__);
$row_feedback_type = Database::fetch_row($rs_feedback_type);
$feedback_type = $row_feedback_type[0];
// if question type does not belong to self-evaluation (immediate feedback) it'll send an error
if (($answer_type == HOT_SPOT_DELINEATION && $feedback_type != 1) ||
($feedback_type == 1 && ($answer_type != HOT_SPOT_DELINEATION && $answer_type != UNIQUE_ANSWER))) {
header('Location: question_create.php?'.api_get_cidreq().'&error=true');
exit;
}
header('Location: admin.php?exerciseId='.$values['exercice'].'&newQuestion=yes&isContent='.$values['is_content'].'&answerType='.$answer_type);
exit;
} else {
@ -110,21 +123,21 @@ $pictures_question_types[3] = 'fill_in_blanks.gif';
$pictures_question_types[4] = 'matching.gif';
$pictures_question_types[5] = 'open_answer.gif';
$pictures_question_types[6] = 'hotspot.gif';
$pictures_question_types[8] = 'hotspot_delineation.gif';
$pictures_question_types[9] = 'mcmac.gif';
$pictures_question_types[10] = 'mcuao.gif';
$pictures_question_types[11] = 'mcmao.gif';
$pictures_question_types[12] = 'mcmaco.gif';
foreach (Question::$questionTypes as $key=>$value) {
if ($key != HOT_SPOT_DELINEATION ) { // DELINEATION hide
?>
ddlObj1.addItem('<table width="100%"><tr><td style="width: 37px;" valign="top"><?php Display::display_icon($pictures_question_types[$key],addslashes(get_lang($value[1])),array('height'=>'40px;', 'style' => 'vertical-align:top; cursor:hand;')); ?></td><td><span class="thistext" style="cursor:hand"><?php echo addslashes(get_lang($value[1])); ?></span><br/><sub><?php /*echo addslashes(get_lang($value[1].'Comment'));*/ ?></sub></td></tr></table>','');
<?php
}
}
?>
</script>
<?php
function check_question_type($parameter) {
foreach (Question::$questionTypes as $key=>$value) {
@ -137,5 +150,3 @@ function check_question_type($parameter) {
return false;
}
}
?>

@ -670,7 +670,7 @@ function update_Db_course($course_db_name) {
ponderation float(6,2) NOT NULL default 0,
position mediumint unsigned NOT NULL default 1,
hotspot_coordinates text,
hotspot_type enum('square','circle','poly','delineation') default NULL,
hotspot_type enum('square','circle','poly','delineation','oar') default NULL,
destination text NOT NULL,
id_auto int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id, question_id),

@ -455,7 +455,7 @@ function exercise_attempt($score, $answer, $quesId, $exeId, $j, $exercise_id = 0
'".$j."',
'".$reallyNow."'
)";
error_log($sql);
if (!empty($quesId) && !empty($exeId) && !empty($user_id)) {
$res = Database::query($sql);
if (defined('ENABLED_LIVE_EXERCISE_TRACKING')){

@ -304,7 +304,7 @@ class ExerciseShowFunctions {
<tr>
<td width="5%" align="center">
<?php
//var_dump($studentChoice);
$question = new MultipleAnswerCombinationTrueFalse();
if (isset($question->options[$studentChoice])) {
@ -358,4 +358,5 @@ class ExerciseShowFunctions {
</tr>
<?php
}
}

File diff suppressed because it is too large Load Diff

@ -672,3 +672,42 @@ function _text_parse_texexplorer($textext) {
*/
return $textext;
}
/**
* This function splits the string into words and then joins them back together again one by one.
* Example: "Test example of a long string"
* substrwords(5) = Test ... *
* @param string
* @param int the max number of character
* @param string how the string will be end
* @return a reduce string
*/
function substrwords($text,$maxchar,$end='...')
{
if(strlen($text)>$maxchar)
{
$words=explode(" ",$text);
$output = '';
$i=0;
while(1)
{
$length = (strlen($output)+strlen($words[$i]));
if($length>$maxchar)
{
break;
}
else
{
$output = $output." ".$words[$i];
$i++;
};
};
}
else
{
$output = $text;
return $output;
}
return $output.$end;
}

@ -211,3 +211,5 @@ INSERT INTO course_setting(variable,value,category) VALUES ('enable_lp_auto_laun
INSERT INTO course_setting(variable,value,category) VALUES ('pdf_export_watermark_text','','course');
ALTER TABLE quiz ADD COLUMN propagate_neg INT NOT NULL DEFAULT 0;
ALTER TABLE quiz_answer MODIFY COLUMN hotspot_type ENUM('square','circle','poly','delineation','oar');

@ -92,6 +92,12 @@ function saveDelineationHotspot(question_id, hotspot_id, coordinates)
document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = coordinates;
document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = "delineation";
}
function saveOARHotspot(question_id, hotspot_id, coordinates)
{
document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = coordinates;
document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = "oar";
}
function jsdebug(debug_string)
{
alert(debug_string);

@ -0,0 +1,349 @@
// javascript Proxy
import com.macromedia.javascript.JavaScriptProxy;
var JS_proxy:JavaScriptProxy = new JavaScriptProxy();
System.useCodepage = true;
// get id from querystring
myURL = this._url;
//myURL = "http://localhost/dokeosSVN/main/plugin/hotspot/hotspot_solution.swf?modifyAnswers=1&exe_id=2&from_db=3";
tmpAr = myURL.split("?");
tmpAr = tmpAr[1].split("&");
id = tmpAr[0].split("=");
id = id[1];
exe_id = tmpAr[1].split("=");
exe_id = exe_id[1];
from_db = tmpAr[2].split("=");
from_db = from_db[1];
// get URL to load lang and hotspot variables
//myURL = this._url;
myPos = myURL.lastIndexOf("/");
myURL = myURL.substring(0, myPos);
myPos = myURL.lastIndexOf("/");
myURL = myURL.substring(0, myPos);
myPos = myURL.lastIndexOf("/");
myURL = myURL.substring(0, myPos);
// movie properties
var movieWidth:Number = 380;
var movieHeight:Number = 400;
// hotspot properties
var startWidth:Number = 0; // \__ if these values are set, shape will be drawn right and down from the mouse;
var startHeight:Number = 0; // /
var pType:String = ""; // possible values: circle, square, poly;
// other settings
var i:Number = 1;
var isDrawing:Boolean = false;
var hotspots_c:Array = new Array('0x4271B5','0xFE8E16','0x45C7F0','0xBCD631','0xD63173','0xD7D7D7','0x90AFDD','0xAF8640','0x4F9242','0xF4EB24','0xED2024','0x3B3B3B');
// make array with all elements
var hotspots:Array = new Array();
// get data from database
this.createEmptyMovieClip("target_mc", 2000);
//_answers
loadVariables(myURL + "/exercice/hotspot_answers.as.php?modifyAnswers="+id+"&exe_id="+exe_id+"&from_db="+from_db, target_mc);
var param_interval:Number = setInterval(checkParamsLoaded, 100);
// language variables
var str_choose:String = "";
var lang_interval:Number
// counter for language (if language can't be loaded after 2 sec,
// english will be loaded
var counter:Number = 0;
// booleans for loading
var langLoaded:Boolean = false;
var varsLoaded:Boolean = false;
var imageLoaded:Boolean = false;
// image preloader
var loadListener:Object = new Object();
loadListener.onLoadComplete = function(){
_root.imageLoaded = true;
_root.showInterface();
}
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);
var mc:MovieClip = _root.image_mc;
/////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
/////////////////////////////////////////////////////////////////////////////////
// show hotspots, user can't click anymore
function showHotspots(num){
for(j=1;j<=_root.hotspots.length;j++){
_root.map_mc["hotspot"+j]._alpha = num;
}
}
function showUserpoints(num){
for(j=1;j<=_root.hotspots.length;j++){
_root["hotspot_answer"+j]._alpha = num;
if(num==0){
_root["hotspot_answer"+j].hotspot_mc._visible = false;
}else{
_root["hotspot_answer"+j].hotspot_mc._visible = true;
}
}
}
function showInterface(){
if((_root.langLoaded == true) and (_root.varsLoaded == true) and (_root.imageLoaded == true)){
_root.showUserpoints(100);
_root.showHotspots(100);
_root.loading_mc._visible = false;
}
}
// get language file
function getLang(){
counter++;
if (_root.lang_mc.done != undefined) {
_root.show_userPoints_btn.label = _root.lang_mc.showUserPoints;
_root.show_hotspots_btn.label = _root.lang_mc.showHotspots;
// check if interface can be showed (if everything else is loaded)
_root.langLoaded = true;
_root.showInterface();
// clear interval
clearInterval(_root.lang_interval);
}else if(counter==20){
// clear interval
clearInterval(_root.lang_interval);
// set counter to zero
_root.counter = 0;
// set new interval (get english version)
loadVariables(myURL + "/lang/english/hotspot.inc.php", _root.lang_mc);
_root.lang_interval = setInterval(getLang, 100);
}
}
function checkParamsLoaded() {
if (target_mc.done != undefined) {
// once we know the language, get language-variables from language file
language = target_mc["hotspot_lang"];
_root.createEmptyMovieClip("lang_mc", 2001);
//loadVariables(myURL + "/lang/" + language + "/hotspot.inc.php", _root.lang_mc);
loadVariables(myURL + "/exercice/hotspot.inc.php", _root.lang_mc);
_root.lang_interval = setInterval(getLang, 100);
// start loading external image
_root.mcLoader.loadClip("../../courses/" + target_mc["courseCode"] + "/document/images/" + target_mc["hotspot_image"], mc);
// make needed array's: filled if hotspot exists, empty if not
for(m = 1; m <= 12; m++){
// make seperate lists
if(target_mc["hotspot_" + m]=="true"){
// add to general list
tmpAr = Array();
tmpAr.push(m);
tmpAr.push(target_mc["hotspot_" + m + "_type"]);
_root.hotspots.push(tmpAr);
if (target_mc["hotspot_" + m + "_type"] != 'poly' && target_mc["hotspot_" + m + "_type"] != 'delineation'){
// x;y|height|width
_root["p_hotspot_" + m] = new Array;
$coordinates = target_mc["hotspot_" + m + "_coord"].split("|");
$tmp_xy = $coordinates[0].split(";");
$x = $tmp_xy[0];
$y = $tmp_xy[1];
$height = $coordinates[1];
$widht = $coordinates[2];
_root["p_hotspot_" + m].push($x);
_root["p_hotspot_" + m].push($y);
_root["p_hotspot_" + m].push($height);
_root["p_hotspot_" + m].push($widht);
}else{
// p1_x;p1_y|p2_x;p2_y|...
_root["p_hotspot_" + m] = new Array();
$coordinates = target_mc["hotspot_" + m + "_coord"].split("|");
for(k=0;k<$coordinates.length;k++){
$tmp_xy = $coordinates[k].split(";");
tempArray = Array();
tempArray.push($tmp_xy[0]);
tempArray.push($tmp_xy[1]);
_root["p_hotspot_" + m].push(tempArray);
}
}
}else{
_root["p_hotspot_" + m] = Array();
}
}
// set border around image
_root.map_mc._width = int(target_mc.hotspot_image_width) + 1;
_root.map_mc._height = int(target_mc.hotspot_image_height) + 1;
// draw the hotspots
drawShapes();
// check if interface can be showed (if everything else is loaded)
_root.varsLoaded = true;
_root.showInterface();
// clear interval
clearInterval(param_interval);
}
}
// draw the shapes that are given from the database
function drawShapes(){
// draw points where user clicked
_root.drawPoints();
// draw hotspots
for (var j:String in hotspots) {
if(j <> ""){
// +1 because array names starts from 1
_root.i = int(j) + 1;
// -1 because array values starts from 0
_root.pType = _root.hotspots[_root.i - 1][1];
if(_root.pType=="poly" || _root.pType=="delineation"){
drawPoly();
}
else{
drawShape(true);
}
_root.map_mc["hotspot" + _root.i]._alpha = 0;
}
}
}
function drawPoints(){
answers = _root.target_mc.p_hotspot_answers.split("|");
if(answers[0]!=''){
j = 1;
k = 500;
for(var z:String in answers){
if(target_mc["hotspot_"+j+"_type"]=="delineation")
{
// trace poly
delineation_coords = answers[j-1].split("/");
drawDelineation(j, delineation_coords);
}
else
{
xy = answers[j-1].split(";");
$x = xy[0];
$y = xy[1];
// create new hotspot
_root.createEmptyMovieClip("hotspot_answer" + j, k);
// attach correct type of hotspot
_root["hotspot_answer" + j].attachMovie("numbers", "hotspot_mc", _root["hotspot_answer" + j].getNextHighestDepth());
_root["hotspot_answer" + j].hotspot_mc._width = 33;
_root["hotspot_answer" + j].hotspot_mc._height = 22;
_root["hotspot_answer" + j].hotspot_mc._x = int($x) + _root.map_mc._x;
_root["hotspot_answer" + j].hotspot_mc._y = int($y) + _root.map_mc._y;
_root["hotspot_answer" + j].hotspot_mc.order_txt.text = int(j);
_root["hotspot_answer" + j].hotspot_mc._visible = false;
_root["hotspot_answer" + j]._alpha = 0;
}
j++;
k++;
}
}
}
function drawShape(userDrawing){
// create new hotspot
_root.map_mc.createEmptyMovieClip("hotspot" + _root.i, _root.i);
// attach correct type of hotspot
_root.map_mc["hotspot" + _root.i].attachMovie(_root.pType, "hotspot_mc", _root.map_mc["hotspot" + _root.i].getNextHighestDepth());
_root.map_mc["hotspot" + _root.i].hotspot_mc._visible = true;
_root.map_mc["hotspot" + _root.i].hotspot_mc.center_mc._alpha = 60;
_root.map_mc["hotspot" + _root.i].hotspot_mc._x = _root["p_hotspot_"+ _root.i][0];
_root.map_mc["hotspot" + _root.i].hotspot_mc._y = _root["p_hotspot_"+ _root.i][1];
_root.map_mc["hotspot" + _root.i].hotspot_mc._width = _root["p_hotspot_"+ _root.i][2];
_root.map_mc["hotspot" + _root.i].hotspot_mc._height = _root["p_hotspot_"+ _root.i][3];
colorchange = new Color(_root.map_mc["hotspot" + _root.i].hotspot_mc);
colorchange.setRGB(_root.hotspots_c[_root.i - 1]);
}
// when black lines of hotspots are deleted, draw the exact same poly with coordinates
// that are saved in the array
function drawPoly(){
// create empty movieclip
_root.map_mc.createEmptyMovieClip("hotspot" + _root.i, _root.i);
// begin filling the movieclip
_root.map_mc["hotspot" + _root.i].beginFill(_root.hotspots_c[_root.i - 1], 60);
// set linestyle
_root.map_mc["hotspot" + _root.i].lineStyle(1, _root.hotspots_c[_root.i - 1], 100);
// move mouse to first coordinate
_root.map_mc["hotspot" + _root.i].moveTo(_root["p_hotspot_"+_root.i][0][0],_root["p_hotspot_"+_root.i][0][1]);
// draw lines to all coordinates
v = _root["p_hotspot_"+_root.i].length;
for (k=1;k<v;k++){
_root.map_mc["hotspot" + _root.i].lineTo(_root["p_hotspot_"+_root.i][k][0],_root["p_hotspot_"+_root.i][k][1]);
}
// attach first and last coordinates
_root.map_mc["hotspot" + _root.i].lineTo(_root["p_hotspot_"+_root.i][0][0],_root["p_hotspot_"+_root.i][0][1]);
// stop filling the movieclip
_root.map_mc["hotspot" + _root.i].endFill();
}
function drawDelineation(level, coords){
// create empty movieclip
_root.map_mc.createEmptyMovieClip("hotspot_delineation" + level, 2000+level);
// begin filling the movieclip
_root.map_mc["hotspot_delineation" + level].beginFill(0xFFFFFF, 60);
// set linestyle
_root.map_mc["hotspot_delineation" + level].lineStyle(1,0x000000, 100);
// move mouse to first coordinate
xy_origin = coords[0].split(";");
_root.map_mc["hotspot_delineation" + level].moveTo(xy_origin[0],xy_origin[1]);
// draw lines to all coordinates
v = coords.length;
for (k=1;k<v;k++){
xy = coords[k].split(";");
_root.map_mc["hotspot_delineation" + level].lineTo(xy[0],xy[1]);
}
// attach first and last coordinates
_root.map_mc["hotspot_delineation" + level].lineTo(xy_origin[0],xy_origin[1]);
// stop filling the movieclip
_root.map_mc["hotspot_delineation" + level].endFill();
}
function jsdebug(debug_string){
_root.JS_proxy.jsdebug(debug_string);
}
Loading…
Cancel
Save