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. 5
      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. 78
      main/exercice/exercice_submit.php
  6. 659
      main/exercice/exercise.class.php
  7. 31
      main/exercice/exercise.lib.php
  8. 22
      main/exercice/exercise_admin.php
  9. 32
      main/exercice/exercise_result.php
  10. 170
      main/exercice/exercise_show.php
  11. 592
      main/exercice/exercise_submit_modal.php
  12. 8
      main/exercice/export/scorm/scorm_classes.php
  13. 37
      main/exercice/hotspot.class.php
  14. 27
      main/exercice/hotspot_actionscript.as.php
  15. 71
      main/exercice/hotspot_actionscript_admin.as.php
  16. 982
      main/exercice/hotspot_admin.inc.php
  17. 36
      main/exercice/hotspot_answers.as.php
  18. 4
      main/exercice/hotspot_lang_conversion.php
  19. 23
      main/exercice/hotspot_save.inc.php
  20. 3
      main/exercice/hotspot_savescore.inc.php
  21. 4
      main/exercice/hotspot_updatescore.inc.php
  22. 20
      main/exercice/question.class.php
  23. 2
      main/exercice/question_admin.inc.php
  24. 33
      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. 5
      main/inc/lib/exercise_show_functions.lib.php
  28. 1213
      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. 24
      main/plugin/hotspot/JavaScriptFlashGateway.js
  32. 0
      main/plugin/hotspot/JavaScriptFlashGateway.swf
  33. 22
      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. 172
      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
@ -460,7 +459,7 @@ if ($newQuestion || $editQuestion) {
$type = $_REQUEST['answerType'];
?><input type="hidden" name="Type" value="<?php echo $type; ?>" />
<?php
require 'question_admin.inc.php';
require 'question_admin.inc.php';
}
if(isset($_GET['hotspotadmin'])) {

@ -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;
@ -307,7 +278,7 @@ if ($_configuration['live_exercise_tracking'] && $objExercise->type == ONE_PER_P
// if the user has submitted the form
if ($formSent && isset($_POST)) {
if ($formSent && isset($_POST)) {
if ($debug > 0) { error_log('$formSent was set'); }
// Initializing
@ -319,16 +290,17 @@ if ($formSent && isset($_POST)) {
//Only for hotspot
if (!isset($choice) && isset($_REQUEST['hidden_hotspot_id'])) {
$hotspot_id = (int)($_REQUEST['hidden_hotspot_id']);
$choice = array($hotspot_id => '');
$choice = array($hotspot_id => '');
}
// 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'];
$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
@ -366,11 +339,11 @@ 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 ($exerciseType == ALL_ON_ONE_PAGE || $questionNum >= $nbrQuestions) {
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 ($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;
}
@ -585,14 +563,14 @@ if (!empty ($error)) {
// if it is not the right question, goes to the next loop iteration
if ($questionNum != $i) {
continue;
} else {
if ($objQuestionTmp->selectType() == HOT_SPOT) {
} else {
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')):
@ -520,10 +522,11 @@ class Exercise {
$random_answers = $this->random_answers;
$active = $this->active;
$propagate_neg = $this->propagate_neg;
$session_id = api_get_session_id();
if ($feedbacktype==1){
$results_disabled = 1;
$session_id = api_get_session_id();
//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,12 +894,12 @@ 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 {
// if is Directfeedback but has not questions we can allow to modify the question type
@ -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) {
@ -1484,8 +1496,7 @@ class Exercise {
}
$html .= '</div>'; //margin top -10
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);
@ -1688,6 +1710,8 @@ class Exercise {
$answerType = $objQuestionTmp->selectType();
$quesId = $objQuestionTmp->selectId();
$extra = $objQuestionTmp->extra;
$next = 1; //not for now
//Extra information of the question
if (!empty($extra)){
@ -1706,12 +1730,15 @@ 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 = '';
$user_answer = '';
// Get answer list for matching
$sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.$questionId.'" ';
@ -1723,13 +1750,17 @@ class Exercise {
$real_answers = array();
$quiz_question_options = Question::readQuestionOption($questionId);
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$answerWeighting = $objAnswerTmp->selectWeighting($answerId);
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
//delineation
$delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
$answer_delineation_destination=$objAnswerTmp->selectDestination(1);
switch ($answerType) {
// for 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
@ -2102,13 +2121,10 @@ class Exercise {
$real_list =array();
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);
WHERE question_id="'.$questionId.'" AND correct <> 0 ORDER BY id_auto';
$res_answers = Database::query($sql_select_answer);
$questionScore = 0;
@ -2159,11 +2175,11 @@ class Exercise {
$matching[$numAnswer] = $choice[$numAnswer];
}
break;
}
// for hotspot with no order
case HOT_SPOT :
if ($from_database) {
}
// 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);
$query = "SELECT hotspot_correct FROM ".$TBL_TRACK_HOTSPOT." where hotspot_exe_id = '".$exeId."' and hotspot_question_id= '".$questionId."' AND hotspot_answer_id='".Database::escape_string($answerId)."'";
@ -2190,13 +2206,53 @@ 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;
global $origin;
if ($show_result) {
if ($from == 'exercise_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))) {
@ -2222,12 +2278,156 @@ class Exercise {
if($origin != 'learnpath') {
ExerciseShowFunctions::display_free_answer($choice,0,0);
}
} elseif($answerType == HOT_SPOT) {
} elseif($answerType == HOT_SPOT) {
if ($origin != 'learnpath') {
ExerciseShowFunctions::display_hotspot_answer($answerId, $answer, $studentChoice, $answerComment);
}
}
} elseif($answerType == HOT_SPOT_ORDER) {
ExerciseShowFunctions::display_hotspot_order_answer($answerId, $answer, $studentChoice, $answerComment);
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>';
@ -2236,7 +2436,9 @@ class Exercise {
}
}
}
} else {
} else {
if ($debug) error_log('Showing questions $from '.$from);
switch($answerType) {
case UNIQUE_ANSWER :
case UNIQUE_ANSWER_NO_OPTION:
@ -2273,14 +2475,145 @@ class Exercise {
</tr>
</table>';
break;
case HOT_SPOT:
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;
case MATCHING:
if ($origin != 'learnpath') {
if ($origin != 'learnpath') {
echo '<tr>';
echo '<td>'.text_filter($answer_matching[$answerId]).'</td><td>'.text_filter($user_answer).' / <b><span style="color: #008000;">'.text_filter($answer_matching[$answerCorrect]).'</span></b></td>';
echo '</tr>';
@ -2314,11 +2647,151 @@ class Exercise {
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
}
}
}
$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 ($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,8 +2879,9 @@ 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) {
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])) {
foreach($exerciseResultCoordinates[$questionId] as $idx => $val) {
exercise_attempt_hotspot($exeId,$quesId,$idx,$choice[$idx],$val,$this->id);
@ -2426,10 +2901,9 @@ 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) {
@ -2596,8 +3070,6 @@ class Exercise {
</td>
</tr>';
}
$html = '<table width="100%">
<tr>
<td colspan="2">
@ -2616,38 +3088,41 @@ class Exercise {
<br />';
return $html;
}
/**
* Create a quiz from quiz data
* @param string Title
* @param int Time before it expires (in minutes)
* @param int Type of exercise
* @param int Whether it's randomly picked questions (1) or not (0)
* @param int Whether the exercise is visible to the user (1) or not (0)
* @param int Whether the results are show to the user (0) or not (1)
* @param int Maximum number of attempts (0 if no limit)
* @param int Feedback type
* @return int New exercise ID
*/
function create_quiz ($title, $expired_time = 0, $type = 2, $random = 0, $active = 1, $results_disabled = 0, $max_attempt = 0, $feedback = 3) {
$tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
$expired_time = filter_var($expired_time,FILTER_SANITIZE_NUMBER_INT);
$type = filter_var($type,FILTER_SANITIZE_NUMBER_INT);
$random = filter_var($random,FILTER_SANITIZE_NUMBER_INT);
$active = filter_var($active,FILTER_SANITIZE_NUMBER_INT);
$results_disabled = filter_var($results_disabled,FILTER_SANITIZE_NUMBER_INT);
$max_attempt = filter_var($max_attempt,FILTER_SANITIZE_NUMBER_INT);
$feedback = filter_var($feedback,FILTER_SANITIZE_NUMBER_INT);
$sid = api_get_session_id();
// Save a new quiz
$sql = "INSERT INTO $tbl_quiz (title,type,random,active,results_disabled, ".
"max_attempt,start_time,end_time,feedback_type,expired_time, session_id) ".
" VALUES('".Database::escape_string($title)."',$type,$random,$active, ".
"$results_disabled,$max_attempt,'','',$feedback,$expired_time,$sid)";
$rs = Database::query($sql);
$quiz_id = Database::get_last_insert_id();
return $quiz_id;
}
/**
* Create a quiz from quiz data
* @param string Title
* @param int Time before it expires (in minutes)
* @param int Type of exercise
* @param int Whether it's randomly picked questions (1) or not (0)
* @param int Whether the exercise is visible to the user (1) or not (0)
* @param int Whether the results are show to the user (0) or not (1)
* @param int Maximum number of attempts (0 if no limit)
* @param int Feedback type
* @return int New exercise ID
*/
function create_quiz ($title, $expired_time = 0, $type = 2, $random = 0, $active = 1, $results_disabled = 0, $max_attempt = 0, $feedback = 3) {
$tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
$expired_time = filter_var($expired_time,FILTER_SANITIZE_NUMBER_INT);
$type = filter_var($type,FILTER_SANITIZE_NUMBER_INT);
$random = filter_var($random,FILTER_SANITIZE_NUMBER_INT);
$active = filter_var($active,FILTER_SANITIZE_NUMBER_INT);
$results_disabled = filter_var($results_disabled,FILTER_SANITIZE_NUMBER_INT);
$max_attempt = filter_var($max_attempt,FILTER_SANITIZE_NUMBER_INT);
$feedback = filter_var($feedback,FILTER_SANITIZE_NUMBER_INT);
$sid = api_get_session_id();
// Save a new quiz
$sql = "INSERT INTO $tbl_quiz (title,type,random,active,results_disabled, ".
"max_attempt,start_time,end_time,feedback_type,expired_time, session_id) ".
" VALUES('".Database::escape_string($title)."',$type,$random,$active, ".
"$results_disabled,$max_attempt,'','',$feedback,$expired_time,$sid)";
$rs = Database::query($sql);
$quiz_id = Database::get_last_insert_id();
return $quiz_id;
}
function process_geometry() {
}
}
endif;
?>
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()) {
@ -495,6 +495,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) {
@ -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;';
}
$html_link.="</a>";
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,32 +102,36 @@ $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;
}
document.getElementById(\'exerciseType_2\').checked = true;
function check_results_disabled() {
document.getElementById(\'exerciseType_2\').checked = true;
}

@ -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,13 +74,13 @@ 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();
$arrans = array();
$arrans = array();
// set admin name as person who sends the results e-mail (lacks policy about whom should really send the results)
@ -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>';
}
@ -182,7 +179,6 @@ $user_info = api_get_user_info(api_get_user_id());
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) {
@ -202,11 +198,14 @@ 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') {
echo $objQuestionTmp->return_header($objExercise->feedbacktype);
if ($answerType == HOT_SPOT) {
if ($answerType == HOT_SPOT) {
?>
<tr>
<td valign="top" colspan="2">
@ -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) {
@ -284,9 +284,9 @@ if ($origin != 'learnpath') {
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
$user_info = UserManager::get_user_info_by_id(api_get_user_id());
$firstName = $user_info['firstname'];
$lastName = $user_info['lastname'];
$mail = $user_info['email'];
$firstName = $user_info['firstname'];
$lastName = $user_info['lastname'];
$mail = $user_info['email'];
$coursecode = api_get_course_id();
$courseName = $_SESSION['_course']['name'];

@ -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;
}
@ -298,7 +293,7 @@ foreach ($questionList as $questionId) {
$objQuestionTmp = Question::read($questionId);
$total_weighting +=$objQuestionTmp->selectWeighting();
}
foreach ($questionList as $questionId) {
$counter++;
$choice=$exerciseResult[$questionId];
@ -345,7 +340,7 @@ foreach ($questionList as $questionId) {
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) {
if ($show_results) {
if ($show_results) {
echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" >
<table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
@ -365,8 +360,156 @@ 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) {
if ($answerType != HOT_SPOT) {
echo '</table>';
@ -455,9 +598,8 @@ foreach ($questionList as $questionId) {
if ($questionScore==-1) {
$questionScore=0;
}
}
echo '</td>
}
echo '</td>
</tr>
</table>';
}
@ -571,4 +713,4 @@ api_session_unregister('questionList');
unset ($questionList);
api_session_unregister('exerciseResult');
unset ($exerciseResult);
unset ($exerciseResult);

@ -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,63 +59,64 @@ 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
if (empty($choice_value)) {
echo '<script type="text/javascript">'."
// this works for only radio buttons
echo '<script type="text/javascript">'."
// this works for only radio buttons
var f= self.parent.window.document.frm_exercise;
var choice_js='';
var choice_js='';
var hotspot = new Array();
var hotspotcoord = new Array();
var counter=0;
for( var i = 0; i < f.elements.length; i++ )
{
for( var i = 0; i < f.elements.length; i++ )
{
if (f.elements[i].type=='radio' && f.elements[i].checked)
{
//alert( f.elements[i].name);
{
//alert( f.elements[i].name);
choice_js = f.elements[i].value;
counter ++;
}
counter ++;
}
if (f.elements[i].type=='hidden' )
{
{
name = f.elements[i].name;
if (name.substr(0,7)=='hotspot')
hotspot.push(f.elements[i].value);
hotspot.push(f.elements[i].value);
if (name.substr(0,20)=='hotspot_coordinates')
hotspotcoord.push(f.elements[i].value);
//hotspot = f.elements[i].value;
}
}
if (counter==0)
hotspotcoord.push(f.elements[i].value);
//hotspot = f.elements[i].value;
}
}
if (counter==0)
{
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>';
choice_js=-1; // this is an error
}
//alert(choice_js);
";
// 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();
$questionid= $questionList[$questionNum];
// $choice_value => value of the user selection
$choice[$questionid]=$choice_value;
// initializing
if(!is_array($exerciseResult))
{
if(!is_array($exerciseResult)) {
$exerciseResult=array();
}
@ -123,54 +126,50 @@ if(is_array($choice)) {
if($exerciseType == 1) {
// $exerciseResult receives the content of the form.
// Each choice of the student is stored into the array $choice
$exerciseResult=$choice;
$exerciseResult=$choice;
} else {
// 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])) {
// stores the user answer into the array
$exerciseResult[$key]=$choice[$key];
$exerciseResult[$key]=$choice[$key];
}
}
}
}
// the script "exercise_result.php" will take the variable $exerciseResult from the session
api_session_register('exerciseResult');
api_session_register('exerciseResultCoordinates');
api_session_register('exerciseResultCoordinates');
/*
/*
// if it is the last question (only for a sequential exercise)
if($questionNum >= $nbrQuestions)
{
{
if($debug>0){echo str_repeat('&nbsp;',0).'Redirecting to exercise_result.php - Remove debug option to let this happen'."<br />\n";}
// goes to the script that will show the result of the exercise
// header("Location: exercise_result.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
// echo 'location result';
// echo 'location result';
}*/
// gets the student choice for this question
// gets the student choice for this question
//print_r($choice); echo "<br>";
// creates a temporary Question object
if (in_array($questionid,$questionList))
{
$objQuestionTmp = Question :: read($questionid);
$questionName=$objQuestionTmp->selectTitle();
if (in_array($questionid, $questionList)) {
$objQuestionTmp = Question :: read($questionid);
$questionName =$objQuestionTmp->selectTitle();
$questionDescription=$objQuestionTmp->selectDescription();
$questionWeighting=$objQuestionTmp->selectWeighting();
$answerType=$objQuestionTmp->selectType();
$quesId =$objQuestionTmp->selectId(); //added by priya saini
$questionWeighting =$objQuestionTmp->selectWeighting();
$answerType =$objQuestionTmp->selectType();
$quesId =$objQuestionTmp->selectId(); //added by priya saini
}
$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,94 +178,91 @@ $_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;
if($studentChoice) {
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
$newquestionList[]=$questionid;
}
break;
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;
$studentChoice=($choice_value == $numAnswer)?1:0;
if($studentChoice) {
$questionScore +=$answerWeighting;
$totalScore +=$answerWeighting;
$newquestionList[]=$questionid;
}
break;
case HOT_SPOT_DELINEATION :
$studentChoice=$choice[$answerId];
if($studentChoice) {
$newquestionList[]=$questionid;
}
if ($answerId===1) {
$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);
$user_answer = $user_array;
//$_SESSION['exerciseResultCoordinates'][$questionId]=$exerciseResultCoordinates;
$hot_spot_load = true; //apparently the script is called twice
$user_answer = $user_array;
$_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];
$answer_question = $_SESSION['hotspot_coord'][1];
$answerDestination = $_SESSION['hotspot_dest'][1];
$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'];
$poly_user = convert_coordinates($user_answer,'/');
$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) {
//shortcut to avoid complicated calculations
$final_overlap = 0;
$final_missing = 100;
$final_excess = 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);
@ -278,56 +274,50 @@ if (!empty($choice_value))
$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);}
}
$destination_items= explode('@@', $answerDestination);
$threadhold_total = $destination_items[0];
$threadhold_items=explode(';',$threadhold_total);
$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
$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)
{
$next=1; //go to the oars
$result_comment=get_lang('Acceptable');
}
else
{
$next=0;
$result_comment=get_lang('Unacceptable');
$comment=$answerDestination=$objAnswerTmp->selectComment(1);
}
// if pass
//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=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');
$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];
$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
@ -335,50 +325,55 @@ if (!empty($choice_value))
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
//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);
//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) {
$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
$poly_answer = convert_coordinates($delineation_cord,'|');
$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 == 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++;
$organs_at_risk_hit++;
//show the feedback
$next=0;
$comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
$answerDestination=$objAnswerTmp->selectDestination($answerId);
$next=1;
$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];
$url_hotspot=$destination_items[4];
}
}
}
else
{ // the first delineation feedback
if ($dbg_local>0) { error_log(__LINE__.' first',0);}
} else {
// the first delineation feedback
if ($dbg_local>0) { error_log(__LINE__.' first',0);}
//we send the error
}
}
}
}
}
}
if ($overlap_color) {
$overlap_color='green';
} else {
@ -394,168 +389,187 @@ if (!empty($choice_value))
} else {
$excess_color='red';
}
$table_resume='<table class="data_table" >
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('YourAnswer').'</b></td>
<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.'</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>
<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.'</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) {
if ($choice_value==-1) {
$links. '<a href="#" onclick="self.parent.tb_remove();">'.get_lang('ChooseAnAnswer').'</a>';
}
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];
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);
$try=$destination_items[1];
$lp=$destination_items[2];
$destinationid=$destination_items[3];
$url=$destination_items[4];
$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)
{
$num_value_array= (array_keys($questionList, $questionid));
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());
$flat_list = $list->get_flat_list();
$list = new LearnpathList(api_get_user_id());
$flat_list = $list->get_flat_list();
$links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
}
$links.='<br />';
// the link to an external website or link
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));
$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.'";
self.parent.tb_remove();
}
else
{
self.parent.window.location.href = "exercice_submit.php?tryagain=1&exerciseId='.$exerciseId.'&questionNum="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'";
self.parent.tb_remove();
}
}
</script>';
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.'&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">';
if ($answerType == HOT_SPOT_DELINEATION) {
$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>';
<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').' <b>'.$result_comment.'</b><br />';
$message.='<p>'.$comment.'</p>';
}
echo $message;
} else {
} 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;
$_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>
self.parent.window.location.href = "exercice_submit.php?exerciseId='.$exerciseId.'&questionNum='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
//self.parent.tb_remove();
</script>';
}
?>
self.parent.window.location.href = "exercice_submit.php?exerciseId='.$exerciseId.'&questionNum='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
//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;
?>
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'];
$objQuestion = Question::read($questionId);
$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";
?>
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,8 +12,8 @@ include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
// set vars
$questionId = $_GET['modifyAnswers'];
$objQuestion = Question::read($questionId);
$questionId = intval($_GET['modifyAnswers']);
$objQuestion = Question::read($questionId);
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
@ -25,9 +24,9 @@ $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
$courseLang = $_course['language'];
$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 = '$questionId' ORDER BY id";
@ -42,32 +41,38 @@ $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];
// Square or rectancle
if ($answers['hotspot_type'][$i] == 'square' )
{
$output .= "&hotspot_".$i."_type=square";
}
// Circle or ovale
if ($answers['hotspot_type'][$i] == 'circle')
{
$output .= "&hotspot_".$i."_type=circle";
}
// Polygon
if ($answers['hotspot_type'][$i] == 'poly')
{
$output .= "&hotspot_".$i."_type=poly";
}
// Delineation
if ($answers['hotspot_type'][$i] == 'delineation')
{
$output .= "&hotspot_".$i."_type=delineation";
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' )
{
$output .= "&hotspot_".$i."_type=square";
}
// Circle or ovale
if ($answers['hotspot_type'][$i] == 'circle')
{
$output .= "&hotspot_".$i."_type=circle";
}
// Polygon
if ($answers['hotspot_type'][$i] == 'poly')
{
$output .= "&hotspot_".$i."_type=poly";
}
/*// 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";
?>
echo $output."&nmbrTries=".$nmbrTries."&done=done";

File diff suppressed because it is too large Load Diff

@ -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');
@ -14,9 +14,9 @@ include('../inc/global.inc.php');
// set vars
$userId = $_user['user_id'];
$questionId = $_GET['modifyAnswers'];
$exe_id = $_GET['exe_id'];
$from_db = isset($_GET['from_db']) ? $_GET['from_db'] : 0;
$objQuestion = Question :: read($questionId);
$exe_id = $_GET['exe_id'];
$from_db = isset($_GET['from_db']) ? $_GET['from_db'] : 0;
$objQuestion = Question :: read($questionId);
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
@ -26,12 +26,17 @@ $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
$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";
@ -57,7 +62,11 @@ while ($hotspot = Database::fetch_array($result)) {
// Delineation
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++;
}
@ -70,7 +79,7 @@ for ($i; $i <= 12; $i++) {
// set vars
$questionId = $_GET['modifyAnswers'];
$course_code = $_course['id'];
$course_code = $_course['id'];
// Get clicks
if(isset($_SESSION['exerciseResultCoordinates']) && $from_db==0) {
@ -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;
?>
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;
@ -45,5 +39,4 @@ 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";
?>
echo "done=done";

@ -55,5 +55,4 @@ $sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (user_id , course_id , quiz_id , questi
$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;
?>
$_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);
?>
$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'),
@ -660,6 +661,18 @@ abstract class Question
$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', 'square')";
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) {
@ -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) {
?>
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
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) {
@ -136,6 +149,4 @@ function check_question_type($parameter) {
} else {
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])) {
@ -357,5 +357,6 @@ class ExerciseShowFunctions {
<?php } ?>
</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');

@ -74,7 +74,7 @@ function Exception(name, message)
}
/**
* Set the name of the exception.
* Set the name of the exception.
*/
Exception.prototype.setName = function(name)
{
@ -82,7 +82,7 @@ Exception.prototype.setName = function(name)
}
/**
* Get the exception's name.
* Get the exception's name.
*/
Exception.prototype.getName = function()
{
@ -90,7 +90,7 @@ Exception.prototype.getName = function()
}
/**
* Set a message on the exception.
* Set a message on the exception.
*/
Exception.prototype.setMessage = function(msg)
{
@ -98,7 +98,7 @@ Exception.prototype.setMessage = function(msg)
}
/**
* Get the exception message.
* Get the exception message.
*/
Exception.prototype.getMessage = function()
{
@ -153,7 +153,7 @@ FlashTag.prototype.setBgcolor = function(bgc)
}
/**
* Sets any variables to be passed into the Flash content.
* Sets any variables to be passed into the Flash content.
*/
FlashTag.prototype.setFlashvars = function(fv)
{
@ -161,7 +161,7 @@ FlashTag.prototype.setFlashvars = function(fv)
}
/**
* Get the Flash tag as a string.
* Get the Flash tag as a string.
*/
FlashTag.prototype.toString = function()
{
@ -189,7 +189,7 @@ FlashTag.prototype.toString = function()
else
{
flashTag += '<embed src="'+this.src+'" ';
flashTag += 'quality="high" ';
flashTag += 'quality="high" ';
flashTag += 'bgcolor="#'+this.bgcolor+'" ';
flashTag += 'width="'+this.width+'" ';
flashTag += 'height="'+this.height+'" ';
@ -209,7 +209,7 @@ FlashTag.prototype.toString = function()
}
/**
* Write the Flash tag out. Pass in a reference to the document to write to.
* Write the Flash tag out. Pass in a reference to the document to write to.
*/
FlashTag.prototype.write = function(doc)
{
@ -218,7 +218,7 @@ FlashTag.prototype.write = function(doc)
/**
* The FlashSerializer serializes JavaScript variables of types object, array, string,
* number, date, boolean, null or undefined into XML.
* number, date, boolean, null or undefined into XML.
*/
/**
@ -296,9 +296,9 @@ FlashSerializer.prototype.serialize = function(args)
FlashSerializer.prototype._serializeXML = function(obj)
{
var doc = new Object();
doc.xml = '<fp>';
doc.xml = '<fp>';
this._serializeNode(obj, doc, null);
doc.xml += '</fp>';
doc.xml += '</fp>';
return doc.xml;
}
@ -401,7 +401,7 @@ function FlashProxy(uid, proxySwfName)
* Call a function in your Flash content. Arguments should be:
* 1. ActionScript function name to call,
* 2. any number of additional arguments of type object,
* array, string, number, boolean, date, null, or undefined.
* array, string, number, boolean, date, null, or undefined.
*/
FlashProxy.prototype.call = function()
{

@ -10,11 +10,11 @@ function validateFlashVar(counter, lang_1, lang_2)
return true;
//alert(counter);
//alert(flashVar);
if(counter != flashVar)
{
alert(lang_1 + counter + lang_2);
return false;
}
else
@ -36,20 +36,20 @@ function updateFlashVar()
* @param int ID of the area (square or ellipse)
* @param int Whether the answer is correct or not
* @param int X-coordinate (horizontal) of the answer point
* @param int Y-coordinate (vertical) of the answer point
* @param int Y-coordinate (vertical) of the answer point
*/
function saveHotspot(question_id, hotspot_id, answer, hotspot_x, hotspot_y)
{
newHotspot = document.createElement("input");
newHotspot.type = "hidden";
newHotspot.name = "hotspot["+question_id+"]["+hotspot_id+"]";
newHotspot.value = hotspot_x + ";" + hotspot_y;
newHotspot.value = hotspot_x + ";" + hotspot_y;
document.frm_exercise.appendChild(newHotspot);
newHotspot = document.createElement("input");
newHotspot.type = "hidden";
newHotspot.name = "choice["+question_id+"]["+hotspot_id+"]";
newHotspot.value = answer;
newHotspot.value = answer;
document.frm_exercise.appendChild(newHotspot);
}
/*
@ -67,11 +67,11 @@ function saveDelineationUserAnswer(question_id, hotspot_id, answer, coordinates)
newHotspot.name = "hotspot["+question_id+"]["+hotspot_id+"]";
newHotspot.value = coordinates;
document.frm_exercise.appendChild(newHotspot);
newHotspot = document.createElement("input");
newHotspot.type = "hidden";
newHotspot.name = "choice["+question_id+"]["+hotspot_id+"]";
newHotspot.value = answer;
newHotspot.value = answer;
document.frm_exercise.appendChild(newHotspot);
}
@ -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);
}

@ -1,86 +1,86 @@
// Globals
// Major version of Flash required
var requiredMajorVersion = 7;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
//
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
// NS/Opera version >= 3 check for Flash plugin in plugin array
if (navigator.plugins != null && navigator.plugins.length > 0) {
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
descArray = flashDescription.split(" ");
tempArrayMajor = descArray[2].split(".");
versionMajor = tempArrayMajor[0];
versionMinor = tempArrayMajor[1];
if ( descArray[3] != "" ) {
tempArrayMinor = descArray[3].split("r");
} else {
tempArrayMinor = descArray[4].split("r");
}
versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
} else {
flashVer = -1;
}
}
// MSN/WebTV 2.6 supports Flash 4
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
// WebTV 2.5 supports Flash 3
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
// older WebTV supports Flash 2
else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
// Can\'t detect in all other cases
else {
flashVer = -1;
}
return flashVer;
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
reqVer = parseFloat(reqMajorVer + "." + reqRevision);
// loop backwards through the versions until we find the newest version
for (i=25;i>0;i--) {
if (isIE && isWin && !isOpera) {
versionStr = VBGetSwfVer(i);
} else {
versionStr = JSGetSwfVer(i);
}
if (versionStr == -1 ) {
return false;
} else if (versionStr != 0) {
if(isIE && isWin && !isOpera) {
tempArray = versionStr.split(" ");
tempString = tempArray[1];
versionArray = tempString .split(",");
} else {
versionArray = versionStr.split(".");
}
versionMajor = versionArray[0];
versionMinor = versionArray[1];
versionRevision = versionArray[2];
versionString = versionMajor + "." + versionRevision; // 7.0r24 == 7.24
versionNum = parseFloat(versionString);
// is the major.revision >= requested major.revision AND the minor version >= requested minor
if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
return true;
} else {
return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
}
}
}
}
// Globals
// Major version of Flash required
var requiredMajorVersion = 7;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
//
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
// NS/Opera version >= 3 check for Flash plugin in plugin array
if (navigator.plugins != null && navigator.plugins.length > 0) {
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
descArray = flashDescription.split(" ");
tempArrayMajor = descArray[2].split(".");
versionMajor = tempArrayMajor[0];
versionMinor = tempArrayMajor[1];
if ( descArray[3] != "" ) {
tempArrayMinor = descArray[3].split("r");
} else {
tempArrayMinor = descArray[4].split("r");
}
versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
} else {
flashVer = -1;
}
}
// MSN/WebTV 2.6 supports Flash 4
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
// WebTV 2.5 supports Flash 3
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
// older WebTV supports Flash 2
else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
// Can\'t detect in all other cases
else {
flashVer = -1;
}
return flashVer;
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
reqVer = parseFloat(reqMajorVer + "." + reqRevision);
// loop backwards through the versions until we find the newest version
for (i=25;i>0;i--) {
if (isIE && isWin && !isOpera) {
versionStr = VBGetSwfVer(i);
} else {
versionStr = JSGetSwfVer(i);
}
if (versionStr == -1 ) {
return false;
} else if (versionStr != 0) {
if(isIE && isWin && !isOpera) {
tempArray = versionStr.split(" ");
tempString = tempArray[1];
versionArray = tempString .split(",");
} else {
versionArray = versionStr.split(".");
}
versionMajor = versionArray[0];
versionMinor = versionArray[1];
versionRevision = versionArray[2];
versionString = versionMajor + "." + versionRevision; // 7.0r24 == 7.24
versionNum = parseFloat(versionString);
// is the major.revision >= requested major.revision AND the minor version >= requested minor
if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
return true;
} else {
return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
}
}
}
}

Loading…
Cancel
Save