From 9da7c7611f94dfe11d87af57f56ab1a7acff8f0c Mon Sep 17 00:00:00 2001 From: Patrick Cool Date: Thu, 18 Jan 2007 20:18:27 +0100 Subject: [PATCH] [svn r10789] table constansts, cleaning header and code --- main/exercice/GC.php | 68 +++-- main/exercice/Hpdownload.php | 89 +++--- main/exercice/addlimits.php | 30 +- main/exercice/admin.php | 128 ++++----- main/exercice/adminhp.php | 41 ++- main/exercice/answer.class.php | 47 ++- main/exercice/answer_admin.inc.php | 46 ++- main/exercice/exercice.php | 41 ++- main/exercice/exercice_submit.php | 77 +++-- main/exercice/exercise.class.php | 46 ++- main/exercice/exercise.lib.php | 89 +++--- main/exercice/exercise_admin.php | 54 ++-- main/exercice/exercise_result.php | 48 ++-- main/exercice/exercise_show.php | 37 ++- main/exercice/feedback.php | 29 +- main/exercice/fill_blanks.class.php | 108 ++++--- main/exercice/freeanswer.class.php | 82 +++--- main/exercice/hotpotatoes.lib.php | 271 +++++++++--------- main/exercice/hotpotatoes.php | 93 +++--- main/exercice/hotspot.class.php | 44 ++- main/exercice/hotspot_actionscript.as.php | 172 +++++------ .../hotspot_actionscript_admin.as.php | 155 +++++----- main/exercice/hotspot_admin.inc.php | 46 ++- main/exercice/hotspot_answers.as.php | 180 +++++------- main/exercice/hotspot_lang_conversion.php | 33 ++- main/exercice/hotspot_save.inc.php | 111 ++++--- main/exercice/hotspot_savescore.inc.php | 117 ++++---- main/exercice/hotspot_updatescore.inc.php | 131 ++++----- main/exercice/mark_free_answer.php | 44 ++- main/exercice/matching.class.php | 158 +++++----- main/exercice/multiple_answer.class.php | 127 ++++---- main/exercice/question.class.php | 42 ++- main/exercice/question_admin.inc.php | 89 +++--- main/exercice/question_list_admin.inc.php | 63 ++-- main/exercice/question_pool.php | 58 ++-- main/exercice/savescores.php | 67 ++--- main/exercice/showinframes.php | 95 +++--- main/exercice/testheaderpage.php | 64 ++--- main/exercice/unique_answer.class.php | 131 ++++----- 39 files changed, 1617 insertions(+), 1734 deletions(-) diff --git a/main/exercice/GC.php b/main/exercice/GC.php index ffe61740d9..32b9a429fa 100644 --- a/main/exercice/GC.php +++ b/main/exercice/GC.php @@ -1,46 +1,42 @@ -"; HotPotGC($_configuration['root_sys'],1,1); - - - // functions - + + + // functions + function HotPotGC($root_sys,$flag,$userID) - { + { // flag[0,1] - print or delete the HotPotatoes temp files (.t.html) $documentPath = $root_sys."courses"; require_once(api_get_path(LIBRARY_PATH)."fileManage.lib.php"); @@ -57,9 +53,9 @@ { $full_name = $folder."/".$file; if (is_dir($full_name)) - { + { HotPotGCt($folder."/".$file,$flag); - } + } else { $filelist[] = $file; @@ -69,12 +65,12 @@ } closedir($dir); } - while (list ($key, $val) = each ($filelist)) + while (list ($key, $val) = each ($filelist)) { if (stristr($val,$userID.".t.html")) { if ($flag == 1) { - my_delete($folder."/".$val); + my_delete($folder."/".$val); } else { diff --git a/main/exercice/Hpdownload.php b/main/exercice/Hpdownload.php index c9978e332d..8e882346e3 100644 --- a/main/exercice/Hpdownload.php +++ b/main/exercice/Hpdownload.php @@ -1,36 +1,31 @@ ->>>>>>>>>>>>>>>>>>> CLASS ANSWER <<<<<<<<<<<<<<<<<<<<*/ -/** - * This class allows to instantiate an object of type Answer - * - * 5 arrays are created to receive the attributes of each answer - * belonging to a specified question - * - * @author Olivier Brouckaert - * @package dokeos.exercise - */ class Answer { var $questionId; diff --git a/main/exercice/answer_admin.inc.php b/main/exercice/answer_admin.inc.php index e60aeb0777..bd2c1131ad 100644 --- a/main/exercice/answer_admin.inc.php +++ b/main/exercice/answer_admin.inc.php @@ -1,36 +1,30 @@ ->>>>>>>>>>>>>>>>>>> ANSWER ADMINISTRATION <<<<<<<<<<<<<<<<<<<<*/ /** -============================================================================== - * This script allows to manage answers - * - * It is included from the script admin.php - * @author Olivier Brouckaert - * @package dokeos.exercise -============================================================================== - */ +* This script allows to manage answers. It is included from the script admin.php +* @package dokeos.exercise +* @author Olivier Brouckaert +* @version $Id: answer_admin.inc.php 10789 2007-01-18 19:18:27Z pcool $ +*/ + // ALLOWED_TO_INCLUDE is defined in admin.php if(!defined('ALLOWED_TO_INCLUDE')) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index 6c8482c157..c02b103a87 100644 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -1,40 +1,33 @@ - * - * @param integer $questionId ID of the question to show - * @param boolean $onlyAnswers set to true to show only answers - * @package dokeos.exercise - ============================================================================== - */ +* Exercise library +* shows a question and its answers +* @package dokeos.exercise +* @author Olivier Brouckaert +* @version $Id: exercise.lib.php 10789 2007-01-18 19:18:27Z pcool $ +*/ + + require("../inc/lib/fckeditor/fckeditor.php") ; function showQuestion($questionId, $onlyAnswers=false, $origin=false) { @@ -98,7 +89,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false) { #$comment = $objAnswerTmp->selectComment(1); // - + $upload_path = api_get_path(REL_COURSE_PATH).$_SESSION['_course']['path'].'/document/'; $oFCKeditor = new FCKeditor("choice[".$questionId."]") ; $oFCKeditor->BasePath = api_get_path(WEB_PATH) . 'main/inc/lib/fckeditor/' ; @@ -108,13 +99,13 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false) $oFCKeditor->Width = '80%'; $oFCKeditor->Height = '300'; $oFCKeditor->Value = '' ; - + $TBL_LANGUAGES = Database::get_main_table(TABLE_MAIN_LANGUAGE); $sql="SELECT isocode FROM ".$TBL_LANGUAGES." WHERE english_name='".$_SESSION["_course"]["language"]."'"; $result_sql=api_sql_query($sql); $isocode_language=mysql_result($result_sql,0,0); $oFCKeditor->Config['DefaultLanguage'] = $isocode_language; - + $s .= "".$oFCKeditor->CreateHtml().""; //$s.=""; @@ -312,7 +303,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false) //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; //echo $tes; $s .= " - + - + "; diff --git a/main/exercice/exercise_admin.php b/main/exercice/exercise_admin.php index 7c43638432..8a7ffda4ff 100644 --- a/main/exercice/exercise_admin.php +++ b/main/exercice/exercise_admin.php @@ -1,45 +1,41 @@ -"exercice.php", "name"=> get_lang('Exercices')); - + Display::display_header($nameTools,"Exercise"); - + $form -> display (); } diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index 08bdb14053..eac7d5c94d 100644 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -1,44 +1,38 @@ - type = FILL_IN_BLANKS; } - + /** * function which redifines Question::createAnswersForm * @param the formvalidator instance */ function createAnswersForm ($form) { - - - + + + $defaults = array(); - + if(!empty($this->id)) { $objAnswer = new answer($this->id); $a_answer = explode('::', $objAnswer->selectAnswer(1)); $defaults['answer'] = $a_answer[0]; - $a_weightings = explode(',',$a_answer[1]); + $a_weightings = explode(',',$a_answer[1]); } else { $defaults['answer'] = get_lang('DefaultTextInBlanks'); } - + // javascript echo ' '; - - + + // answer $form -> addElement ('html', '

'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank').'
'); $form -> addElement ('textarea', 'answer',get_lang('Answer'),'id="answer" cols="65" rows="6" onkeyup="updateBlanks(this)"'); $form -> addRule ('answer',get_lang('GiveText'),'required'); $form -> addRule ('answer',get_lang('DefineBlanks'),'regex','/\[.*\]/'); - - + + $form -> addElement('html','
'); - + $form -> setDefaults($defaults); - + } - - + + /** * abstract function which creates the form to create / edit the answers of the question * @param the formvalidator instance */ - function processAnswersCreation($form) { - + function processAnswersCreation($form) + { $answer = $form -> getSubmitValue('answer'); - + //remove the :: eventually written by the user $answer = str_replace('::','',$answer); - + // get the blanks weightings $nb = preg_match_all('/\[[^\]]*\]/', $answer, $blanks); if($nb>0) @@ -154,15 +150,11 @@ class FillBlanks extends Question { } $answer = substr($answer,0,-1); } - $this -> save(); - $objAnswer = new answer($this->id); $objAnswer->createAnswer($answer,0,'',0,''); $objAnswer->save(); - } - } endif; diff --git a/main/exercice/freeanswer.class.php b/main/exercice/freeanswer.class.php index 8d6ee91576..69f2948c45 100644 --- a/main/exercice/freeanswer.class.php +++ b/main/exercice/freeanswer.class.php @@ -1,52 +1,40 @@ - type = FREE_ANSWER; } - + /** * function which redifines Question::createAnswersForm * @param the formvalidator instance */ - function createAnswersForm ($form) { - + function createAnswersForm ($form) { + $form -> addElement('text','weighting',get_lang('Weighting'),'size="5"'); if(!empty($this->id)) { @@ -69,23 +57,19 @@ class FreeAnswer extends Question { else { $form -> setDefaults(array('weighting' => '1')); } - + } - - + + /** * abstract function which creates the form to create / edit the answers of the question * @param the formvalidator instance */ - function processAnswersCreation($form) { - + function processAnswersCreation($form) + { $this -> weighting = $form -> getSubmitValue('weighting'); - $this->save(); - } - } - endif; ?> \ No newline at end of file diff --git a/main/exercice/hotpotatoes.lib.php b/main/exercice/hotpotatoes.lib.php index a211a3f89f..38c397c817 100644 --- a/main/exercice/hotpotatoes.lib.php +++ b/main/exercice/hotpotatoes.lib.php @@ -1,43 +1,40 @@ "title>", 2 => "/title>"); - + $s_contents = substr($contents,0,strpos($contents,$pattern["2"])-1); $e_contents = substr($s_contents,strpos($contents,$pattern["1"])+strlen($pattern["1"]),strlen($s_contents)); - + $title = $e_contents; } return $title; - + } /** * Gets the comment about a file from the corresponding database record * @param string File path * @return string Comment from the database record - */ + */ function GetComment($path) { global $dbTable; - $query = "select comment from $dbTable where path='$path'"; + $query = "select comment from $dbTable where path='$path'"; $result = api_sql_query($query,__FILE__,__LINE__); - while($row = mysql_fetch_array($result)) - { - return $row[0]; + while($row = mysql_fetch_array($result)) + { + return $row[0]; } - return ""; + return ""; } /** * Sets the comment in the database for a particular path * @param string File path * @param string Comment to set - * @return string Result of the database operation (api_sql_query will output some message directly on error anyway) - */ + * @return string Result of the database operation (api_sql_query will output some message directly on error anyway) + */ function SetComment($path,$comment) { global $dbTable; - $query = "update $dbTable set comment='$comment' where path='$path'"; + $query = "update $dbTable set comment='$comment' where path='$path'"; $result = api_sql_query($query,__FILE__,__LINE__); - return "$result"; + return "$result"; } /** * Get the name of the file from a path (without the extension) - * + * * This assumes the path is made of elements split by '/', not '\' or '\\' * @param string Path - * @return string File name - */ + * @return string File name + */ function GetFileName($fname) { $name = explode('/',$fname); $name = $name[sizeof($name)-1]; - return $name; + return $name; } /** * Reads the file contents into a string * @param string Urlencoded path - * @return string The file contents - */ + * @return string The file contents + */ function ReadFileCont($full_file_path) { - if (!($fp = fopen(urldecode($full_file_path), "r"))) { -// if (!($fp = fopen($full_file_path, "r"))) { + if (!($fp = fopen(urldecode($full_file_path), "r"))) { +// if (!($fp = fopen($full_file_path, "r"))) { return ""; } $contents = fread($fp, filesize($full_file_path)); - fclose($fp); + fclose($fp); return $contents; -} +} /** * Writes the file contents into the file given * @param string Urlencoded path - * @param string The file contents - */ + * @param string The file contents + */ function WriteFileCont($full_file_path,$content) { - if (!($fp = fopen(urldecode($full_file_path), "w"))) { + if (!($fp = fopen(urldecode($full_file_path), "w"))) { //die("could not open Quiz input"); } fwrite($fp,$content); - fclose($fp); -} + fclose($fp); +} /** * Gets the name of an img whose path is given (without directories or extensions) * @param string An image tag () - * @return string The image file name or an empty string + * @return string The image file name or an empty string * @uses GetFileName No comment - */ + */ function GetImgName($imgtag) { // select src tag from img tag $match = array(); @@ -190,21 +187,24 @@ function GetImgName($imgtag) $src=$match[3]; //$src = substr($srctag,5,(strlen($srctag)-7)); if (stristr($src,"http")===false) // valid or invalid image name - { - + { if($src=="") - { return ""; } + { + return ""; + } else - { + { $tmp_src = GetFileName($src) ; if ($tmp_src == "") { - return $src; - } else { + return $src; + } + else + { return $tmp_src; } } - } + } else //the img tag contained "http", which means it is probably external. Ignore it. { return ""; @@ -214,8 +214,8 @@ function GetImgName($imgtag) /** * Gets the source path of an image tag * @param string An image tag - * @return string The image source or "" - */ + * @return string The image source or "" + */ function GetSrcName($imgtag) { // select src tag from img tag $match = array(); @@ -223,11 +223,14 @@ function GetSrcName($imgtag) list($key,$srctag)=each($match); $src = substr($srctag,5,(strlen($srctag)-7)); if (stristr($src,"http")==false) // valid or invalid image name - { + { return $src; - } + } else - { return ""; } + { + return ''; + + } } /** @@ -236,44 +239,44 @@ function GetSrcName($imgtag) * @param string File path * @param reference Reference to a list of image parameters (emptied, then used to return results) * @param reference Reference to a counter of images (emptied, then used to return results) - */ + */ function GetImgParams($fname,$fpath,&$imgparams,&$imgcount) { //select img tags from context $imgparams = array(); - //phpinfo(); + //phpinfo(); $contents = ReadFileCont("$fpath"."$fname"); $matches = array(); - preg_match_all("()",$contents,$matches); - $imgcount = 0; + preg_match_all("()",$contents,$matches); + $imgcount = 0; while (list($int,$match)=each($matches)) { //each match consists of a key and a value while(list($key,$imgtag)=each($match)) { - $imgname = GetImgName($imgtag); + $imgname = GetImgName($imgtag); if ($imgname!="" && !in_array($imgname,$imgparams)){ array_push($imgparams,$imgname); // name (+ type) of the images in the html test $imgcount = $imgcount + 1; // number of images in the html test } - } + } } } /** * Generates a list of hidden fields with the image params given as parameter to this function * @param array List of image parameters - * @return string String containing the hidden parameters built from the list given - */ + * @return string String containing the hidden parameters built from the list given + */ function GenerateHiddenList($imgparams) { $list = ""; if(is_array($imgparams)){ while (list($int,$string)=each($imgparams)) { - $list .= "\n"; + $list .= "\n"; } } - return $list; + return $list; } /** @@ -281,20 +284,20 @@ function GenerateHiddenList($imgparams) * @param reference Reference to the array to search * @param string Node we are looking for in the array * @return mixed Node name or false if not found - */ + */ function myarraysearch(&$array,$node) { $match = FALSE; $tmp_array = array(); for($i=0;$i)",$content,$matches); - $imgcount = 0; + preg_match_all("()",$content,$matches); + $imgcount = 0; while (list($int,$match)=each($matches)) { while(list($key,$imgtag)=each($match)) { - $imgname = GetSrcName($imgtag); + $imgname = GetSrcName($imgtag); if ($imgname=="") {} // valid or invalid image name else { - + $prehref = $imgname; $posthref = GetFileName($imgname); - $newcontent = str_replace($prehref,$posthref,$newcontent); + $newcontent = str_replace($prehref,$posthref,$newcontent); } - } + } } - return $newcontent; + return $newcontent; } /** * Fills the folder name up to a certain length with "0" * @param string Original folder name * @param integer Length to reach - * @return string Modified folder name - */ + * @return string Modified folder name + */ function FillFolderName($name,$nsize) { $str = ""; @@ -360,8 +363,8 @@ function FillFolderName($name,$nsize) /** * Generates the HotPotato folder tree * @param string Folder path - * @return string Folder name (modified) - */ + * @return string Folder name (modified) + */ function GenerateHpFolder($folder) { $filelist = array(); @@ -372,46 +375,46 @@ function GenerateHpFolder($folder) { $full_name = $folder."/".$file; if (is_dir($full_name)) - { + { $filelist[] = $file; - } + } } } } } $w = 0; do { - $name = FillFolderName(mt_rand(1,99999),6); - $checked = myarraysearch($filelist,$name); + $name = FillFolderName(mt_rand(1,99999),6); + $checked = myarraysearch($filelist,$name); //as long as we find the name in the array, continue looping. As soon as we have a new element, quit if ($checked) { $w = 1; } else { $w = 0; } } while ($w==1); - + return $name; } /** * Gets the folder name (strip down path) * @param string Path - * @return string Folder name stripped down - */ + * @return string Folder name stripped down + */ function GetFolderName($fname) -{ +{ $name = explode('/',$fname); - $name = $name[sizeof($name)-2]; + $name = $name[sizeof($name)-2]; return $name; } /** * Gets the folder path (withouth the name of the folder itself) ? * @param string Path - * @return string Path stripped down - */ + * @return string Path stripped down + */ function GetFolderPath($fname) -{ - $str = ""; - $name = explode('/',$fname); +{ + $str = ""; + $name = explode('/',$fname); for($i=0;$i < sizeof($name)-1; $i++) { $str = $str.$name[$i]."/"; } return $str; @@ -421,19 +424,19 @@ function GetFolderPath($fname) * Checks if there are subfolders * @param string Path * @return integer 1 if a subfolder was found, 0 otherwise - */ + */ function CheckSubFolder($path) { - $folder = GetFolderPath($path); + $folder = GetFolderPath($path); $dflag = 0; if ($dir = @opendir($folder)) { while (($file = readdir($dir)) !== false) { if ( $file != ".") { if ($file != "..") { $full_name = $folder."/".$file; - if (is_dir($full_name)) { + if (is_dir($full_name)) { $dflag = 1; // first directory - } + } } } } @@ -443,11 +446,11 @@ function CheckSubFolder($path) /** * Hotpotato Garbage Collector - * @param string Path + * @param string Path * @param integer Flag * @param integer User id * @return void No return value, but echoes results - */ + */ function HotPotGCt($folder,$flag,$userID) { // Garbage Collector $filelist = array(); @@ -458,9 +461,9 @@ function HotPotGCt($folder,$flag,$userID) { $full_name = $folder."/".$file; if (is_dir($full_name)) - { + { HotPotGCt($folder."/".$file,$flag,$userID); - } + } else { $filelist[] = $file; @@ -470,16 +473,16 @@ function HotPotGCt($folder,$flag,$userID) } closedir($dir); } - while (list ($key, $val) = each ($filelist)) + while (list ($key, $val) = each ($filelist)) { if (stristr($val,$userID.".t.html")) - { + { if ($flag == 1) { - my_delete($folder."/".$val); + my_delete($folder."/".$val); } else - { + { echo $folder."/".$val."
"; } } diff --git a/main/exercice/hotpotatoes.php b/main/exercice/hotpotatoes.php index b4ee5afe84..02038ea994 100644 --- a/main/exercice/hotpotatoes.php +++ b/main/exercice/hotpotatoes.php @@ -1,50 +1,49 @@ "./exercice.php", "name"=> get_lang('Exercices')); $is_allowedToEdit=(!empty($is_courseAdmin)?$is_courseAdmin:false); -//$dbTable = '`'.$_course['dbNameGlu']."document`"; $dbTable = Database::get_course_table(TABLE_DOCUMENT); $baseServDir = $_configuration['root_sys']; $baseServUrl = $_configuration['url_append']."/"; @@ -57,7 +56,7 @@ if ($is_allowedToEdit) include("hotpotatoes.lib.php"); //disable document parsing(?) - obviously deprecated $enableDocumentParsing=false; - + if(hotpotatoes_init($document_sys_path.$uploadPath)) {//if the directory doesn't exist //create the "HotPotatoes" directory @@ -82,7 +81,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) //check that the submit button was pressed when the button had the "Download" value //This should be updated to "upload" here and on the button, and it would be better to // check something else than a string displayd on a button - if (strcmp($_POST['submit'],get_lang('Download'))===0) + if (strcmp($_POST['submit'],get_lang('Download'))===0) { /** el kell tarolni <- english please */ include_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php'); @@ -90,13 +89,13 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) FILEMANAGER BASIC VARIABLES DEFINITION ======================================*/ include_once(api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php"); - + //@todo: this value should be moved to the platform admin section $maxFilledSpace = 100000000; - + //initialise $finish if (!isset($finish)) {$finish = 0;} - + //if the size is not defined, it's probably because there has been an error or no file was submitted if(!$_FILES['userFile']['size']) { @@ -118,7 +117,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) } if ($finish==0) { //generate new test folder if on first step of file upload - $filename = replace_dangerous_char(trim($_FILES['userFile']['name']),'strict'); + $filename = replace_dangerous_char(trim($_FILES['userFile']['name']),'strict'); $fld = GenerateHpFolder($document_sys_path.$uploadPath."/"); @mkdir($document_sys_path.$uploadPath."/".$fld); $doc_id = add_document($_course, '/HotPotatoes_files/'.$fld,'folder',0,$fld); @@ -126,22 +125,22 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) } else { //it is not the first step... get the filename directly from the system params - $filename = $_FILES['userFile']['name']; - } - + $filename = $_FILES['userFile']['name']; + } + /*if (treat_uploaded_file($_FILES['userFile'], $document_sys_path, $uploadPath."/".$fld, $maxFilledSpace, $unzip))*/ $allow_output_on_success = false; if (handle_uploaded_document($_course,$_FILES['userFile'],$document_sys_path,$uploadPath."/".$fld,$_user['user_id'],null,null,$maxFilledSpace,$unzip,'',$allow_output_on_success)) { - + if ($finish==2) { $checked = CheckImageName($imgparams,$filename); if ($checked) { $imgcount = $imgcount-1; } else - { + { $dialogBox .= $filename." ".get_lang('NameNotEqual'); my_delete($document_sys_path.$uploadPath."/".$fld."/".$filename); update_db_info("delete", $uploadPath."/".$fld."/".$filename); @@ -154,7 +153,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) else { //if we are (still) on the first step of the upload process if ($finish==0) - { + { $finish = 2; // get number and name of images from the files contents GetImgParams("/".$filename,$document_sys_path.$uploadPath."/".$fld,$imgparams,$imgcount); @@ -165,10 +164,10 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) } } $newComment = ""; - - $query = "UPDATE $dbTable SET comment='$newComment' WHERE path=\"".$uploadPath."/".$fld."/".$filename."\""; + + $query = "UPDATE $dbTable SET comment='$newComment' WHERE path=\"".$uploadPath."/".$fld."/".$filename."\""; /*, visibility='v' */ - + api_sql_query($query,__FILE__,__LINE__); api_item_property_update($_course, TOOL_QUIZ, $id, "QuizAdded", $_user['user_id']); } @@ -180,7 +179,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) //$dialogBox .= get_lang('NoImg'); } $finish = 0; // error - + if (api_failure::get_last_failure() == 'not_enough_space') { $dialogBox .= get_lang('NoSpace'); @@ -189,9 +188,9 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) { $dialogBox .= get_lang('ZipNoPhp'); } - + } - + /* if ($oke==1) { $enableDocumentParsing=true; $oke=0;} */ @@ -202,8 +201,8 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) { /** ok -> send to main exercises page */ header("Location: exercice.php"); exit; - } - + } + Display::display_header($nameTools,"Exercise"); $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); /* -----*/ @@ -226,7 +225,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2))) { $dialogBox.= get_lang('ImgNote_st').$imgcount.get_lang('ImgNote_en')."
"; while(list($key,$string)=each($imgparams)) - { + { $dialogBox.=$string."; "; } } @@ -274,7 +273,7 @@ else { // ok //include("exercice.php"); header("Location: exercice.php"); - } + } else { } diff --git a/main/exercice/hotspot.class.php b/main/exercice/hotspot.class.php index 377a0f2310..330b6addd3 100644 --- a/main/exercice/hotspot.class.php +++ b/main/exercice/hotspot.class.php @@ -1,35 +1,31 @@ -uploadPicture($file_info['tmp_name'], $file_info['name']); $this->resizePicture('any',350); $this->save(); - } + } } function createAnswersForm ($form) { diff --git a/main/exercice/hotspot_actionscript.as.php b/main/exercice/hotspot_actionscript.as.php index ee0f8b6dba..2bf5d26b4d 100644 --- a/main/exercice/hotspot_actionscript.as.php +++ b/main/exercice/hotspot_actionscript.as.php @@ -1,118 +1,98 @@ selectPicture(); - $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture()); - $pictureWidth = $pictureSize[0]; - $pictureHeight = $pictureSize[1]; - - $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"; - $result = api_sql_query($sql,__FILE__,__LINE__); - - // Init - $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath"; - $i = 0; - $nmbrTries = 0; - - while ($hotspot = mysql_fetch_assoc($result)) +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); +$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER); +$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; +$picturePath = $documentPath.'/images'; +$pictureName = $objQuestion->selectPicture(); +$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture()); +$pictureWidth = $pictureSize[0]; +$pictureHeight = $pictureSize[1]; + +$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"; +$result = api_sql_query($sql,__FILE__,__LINE__); + +// Init +$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath"; +$i = 0; +$nmbrTries = 0; + +while ($hotspot = mysql_fetch_assoc($result)) +{ + $output .= "&hotspot_".$hotspot['id']."=true"; + $output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']); + // Square or rectancle + if ($hotspot['hotspot_type'] == 'square' ) { - $output .= "&hotspot_".$hotspot['id']."=true"; - $output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']); - - // Square or rectancle - if ($hotspot['hotspot_type'] == 'square' ) - { - $output .= "&hotspot_".$hotspot['id']."_type=square"; - } - - // Circle or ovale - if ($hotspot['hotspot_type'] == 'circle') - { - $output .= "&hotspot_".$hotspot['id']."_type=circle"; - } - - // Polygon - if ($hotspot['hotspot_type'] == 'poly') - { - $output .= "&hotspot_".$hotspot['id']."_type=poly"; - } - - // This is a good answer, count + 1 for nmbr of clicks - if ($hotspot['hotspot_type'] > 0) - { - $nmbrTries++; - } - - $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates'].""; - - $i++; - + $output .= "&hotspot_".$hotspot['id']."_type=square"; } - - // Generate empty - $i++; - for ($i; $i <= 12; $i++) + // Circle or ovale + if ($hotspot['hotspot_type'] == 'circle') + { + $output .= "&hotspot_".$hotspot['id']."_type=circle"; + } + // Polygon + if ($hotspot['hotspot_type'] == 'poly') { - $output .= "&hotspot_".$i."=false"; + $output .= "&hotspot_".$hotspot['id']."_type=poly"; } - // Output - echo $output."&nmbrTries=".$nmbrTries."&done=done"; + // This is a good answer, count + 1 for nmbr of clicks + if ($hotspot['hotspot_type'] > 0) + { + $nmbrTries++; + } - /*echo '
';
+	$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
+	$i++;
 
-	var_dump($explode);
+}
 
-	echo '
';*/ +// Generate empty +$i++; +for ($i; $i <= 12; $i++) +{ + $output .= "&hotspot_".$i."=false"; +} +// Output +echo $output."&nmbrTries=".$nmbrTries."&done=done"; ?> \ No newline at end of file diff --git a/main/exercice/hotspot_actionscript_admin.as.php b/main/exercice/hotspot_actionscript_admin.as.php index e8551d1329..bc1a199b84 100644 --- a/main/exercice/hotspot_actionscript_admin.as.php +++ b/main/exercice/hotspot_actionscript_admin.as.php @@ -1,113 +1,106 @@ selectPicture(); - $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture()); - $pictureWidth = $pictureSize[0]; - $pictureHeight = $pictureSize[1]; +$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER); +$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; - $courseLang = $_course['language']; - $courseCode = $_course['sysCode']; - $coursePath = $_course['path']; +$picturePath = $documentPath.'/images'; +$pictureName = $objQuestion->selectPicture(); +$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture()); +$pictureWidth = $pictureSize[0]; +$pictureHeight = $pictureSize[1]; - // Query db for answers - //$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id"; - //$result = api_sql_query($sql,__FILE__,__LINE__); +$courseLang = $_course['language']; +$courseCode = $_course['sysCode']; +$coursePath = $_course['path']; - // Init - $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath"; - $i = 0; - $nmbrTries = 0; +// Query db for answers +//$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id"; +//$result = api_sql_query($sql,__FILE__,__LINE__); +// Init +$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath"; +$i = 0; +$nmbrTries = 0; - $answers=$_SESSION['tmp_answers']; - $nbrAnswers = count($answers['answer']); - for($i=1;$i <= $nbrAnswers;$i++) - { - $output .= "&hotspot_".$i."=true"; - $output .= "&hotspot_".$i."_answer=".$answers['answer'][$i]; +$answers=$_SESSION['tmp_answers']; +$nbrAnswers = count($answers['answer']); - // Square or rectancle - if ($answers['hotspot_type'][$i] == 'square' ) - { - $output .= "&hotspot_".$i."_type=square"; - } +for($i=1;$i <= $nbrAnswers;$i++) +{ + $output .= "&hotspot_".$i."=true"; + $output .= "&hotspot_".$i."_answer=".$answers['answer'][$i]; - // 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"; - } + // Square or rectancle + if ($answers['hotspot_type'][$i] == 'square' ) + { + $output .= "&hotspot_".$i."_type=square"; + } - // This is a good answer, count + 1 for nmbr of clicks - if ($answers['weighting'][$i] > 0) - { - $nmbrTries++; - } + // Circle or ovale + if ($answers['hotspot_type'][$i] == 'circle') + { + $output .= "&hotspot_".$i."_type=circle"; + } - $output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i].""; - } + // Polygon + if ($answers['hotspot_type'][$i] == 'poly') + { + $output .= "&hotspot_".$i."_type=poly"; + } - // Generate empty - $i++; - for ($i; $i <= 12; $i++) + // This is a good answer, count + 1 for nmbr of clicks + if ($answers['weighting'][$i] > 0) { - $output .= "&hotspot_".$i."=false"; + $nmbrTries++; } - // Output - echo $output."&nmbrTries=".$nmbrTries."&done=done"; + $output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i].""; +} + +// Generate empty +$i++; +for ($i; $i <= 12; $i++) +{ + $output .= "&hotspot_".$i."=false"; +} +// Output +echo $output."&nmbrTries=".$nmbrTries."&done=done"; ?> \ No newline at end of file diff --git a/main/exercice/hotspot_admin.inc.php b/main/exercice/hotspot_admin.inc.php index 7cb8e5cd01..0d2d91f644 100644 --- a/main/exercice/hotspot_admin.inc.php +++ b/main/exercice/hotspot_admin.inc.php @@ -1,36 +1,30 @@ ->>>>>>>>>>>>>>>>>>> ANSWER ADMINISTRATION <<<<<<<<<<<<<<<<<<<<*/ /** -============================================================================== - * This script allows to manage answers - * - * It is included from the script admin.php - * @author Olivier Brouckaert - * @package dokeos.exercise -============================================================================== - */ +* This script allows to manage answers. It is included from the script admin.php +* @package dokeos.exercise +* @author Toon Keppens +* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $ +*/ + // ALLOWED_TO_INCLUDE is defined in admin.php if(!defined('ALLOWED_TO_INCLUDE')) diff --git a/main/exercice/hotspot_answers.as.php b/main/exercice/hotspot_answers.as.php index c9f77be17c..1f551ea1da 100644 --- a/main/exercice/hotspot_answers.as.php +++ b/main/exercice/hotspot_answers.as.php @@ -1,129 +1,107 @@ selectPicture(); - $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture()); - $pictureWidth = $pictureSize[0]; - $pictureHeight = $pictureSize[1]; - - $courseLang = $_course['language']; - $courseCode = $_course['sysCode']; - $coursePath = $_course['path']; - - // Query db for answers - $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id"; - $result = api_sql_query($sql,__FILE__,__LINE__); - - // Init - $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath"; - $i = 0; - - while ($hotspot = mysql_fetch_array($result)) { - - $output .= "&hotspot_".$hotspot['id']."=true"; - - // Square or rectancle - if ($hotspot['hotspot_type'] == 'square' ) - { - $output .= "&hotspot_".$hotspot['id']."_type=square"; - } - - // Circle or ovale - if ($hotspot['hotspot_type'] == 'circle') - { - $output .= "&hotspot_".$hotspot['id']."_type=circle"; - } - - // Polygon - if ($hotspot['hotspot_type'] == 'poly') - { - $output .= "&hotspot_".$hotspot['id']."_type=poly"; - } - - $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates'].""; - - $i++; +include('exercise.class.php'); +include('question.class.php'); +include('answer.class.php'); +include('../inc/global.inc.php'); + +// set vars +$userId = $_user['user_id']; +$questionId = $_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'; + +$picturePath = $documentPath.'/images'; +$pictureName = $objQuestion->selectPicture(); +$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture()); +$pictureWidth = $pictureSize[0]; +$pictureHeight = $pictureSize[1]; + +$courseLang = $_course['language']; +$courseCode = $_course['sysCode']; +$coursePath = $_course['path']; + +// Query db for answers +$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id"; +$result = api_sql_query($sql,__FILE__,__LINE__); + +// Init +$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath"; +$i = 0; + +while ($hotspot = mysql_fetch_array($result)) +{ + $output .= "&hotspot_".$hotspot['id']."=true"; + // Square or rectancle + if ($hotspot['hotspot_type'] == 'square' ) + { + $output .= "&hotspot_".$hotspot['id']."_type=square"; } - // Generate empty - $i++; - for ($i; $i <= 12; $i++) + // Circle or ovale + if ($hotspot['hotspot_type'] == 'circle') { - $output .= "&hotspot_".$i."=false"; + $output .= "&hotspot_".$hotspot['id']."_type=circle"; } - // set vars - $questionId = $_GET['modifyAnswers']; - - $courseCode = $_course['sysCode']; - - // Get clicks - foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate) + // Polygon + if ($hotspot['hotspot_type'] == 'poly') { - $output2 .= $coordinate."|"; + $output .= "&hotspot_".$hotspot['id']."_type=poly"; } - //var_dump($_SESSION['exerciseResultCoordinates']); - // Output - $output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done"; + $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates'].""; + + $i++; +} - $explode = explode('&', $output); +// Generate empty +$i++; +for ($i; $i <= 12; $i++) +{ + $output .= "&hotspot_".$i."=false"; +} - /*echo '
';
+// set vars
+$questionId    = $_GET['modifyAnswers'];
+$courseCode = $_course['sysCode'];
 
-	var_dump($explode);
+// Get clicks
+foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
+{
+	$output2 .= $coordinate."|";
+}
 
-	echo '
';*/ +$output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done"; - echo $output; +$explode = explode('&', $output); +echo $output; ?> \ No newline at end of file diff --git a/main/exercice/hotspot_lang_conversion.php b/main/exercice/hotspot_lang_conversion.php index d82d0f0ed0..d4cd35b5a8 100644 --- a/main/exercice/hotspot_lang_conversion.php +++ b/main/exercice/hotspot_lang_conversion.php @@ -1,4 +1,31 @@ 1) { $explode[0] = trim($explode[0]); $explode[0] = '&' . substr($explode[0], 1, strlen($explode[0])); - + $explode[1] = trim($explode[1]); $explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1); $explode[1] = ereg_replace('"', '', $explode[1]); - + $temp[] = $explode[0] . '=' . $explode[1]; } } diff --git a/main/exercice/hotspot_save.inc.php b/main/exercice/hotspot_save.inc.php index bf1958a1d9..a80663a669 100644 --- a/main/exercice/hotspot_save.inc.php +++ b/main/exercice/hotspot_save.inc.php @@ -1,72 +1,67 @@ \ No newline at end of file diff --git a/main/exercice/hotspot_savescore.inc.php b/main/exercice/hotspot_savescore.inc.php index 55a206af65..5b905b1931 100644 --- a/main/exercice/hotspot_savescore.inc.php +++ b/main/exercice/hotspot_savescore.inc.php @@ -1,75 +1,60 @@ selectId(); - - // Save clicking order - $answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1; - - if ($_GET['answerId'] == "0") // click is NOT on a hotspot - { - $hit = 0; - $answerId = NULL; - - } - else // user clicked ON a hotspot - { - $hit = 1; - $answerId = substr($_GET['answerId'],22,2); - - // Save into session - $_SESSION['exerciseResult'][$questionId][$answerId] = $hit; - - } - - $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS); - - // Save into db - $sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (`user_id` , `course_id` , `quiz_id` , `question_id` , `answer_id` , `correct` , `coordinate` ) VALUES ('".$_user['user_id']."', '$courseCode', '$exerciseId', '$questionId', '$answerId', '$hit', '$coordinates')"; - - $result = api_sql_query($sql,__FILE__,__LINE__); - - // Save insert id into session if users changes answer. - $insert_id = mysql_insert_id(); - $_SESSION['exerciseResult'][$questionId]['ids'][$answerOrderId] = $insert_id; +include('exercise.class.php'); +include('question.class.php'); +include('answer.class.php'); +include('../inc/global.inc.php'); +include('../inc/lib/database.lib.php'); +$courseCode = $_GET['coursecode']; +$questionId = $_GET['questionId']; +$coordinates = $_GET['coord']; +$objExcercise = $_SESSION['objExercise']; +$exerciseId = $objExcercise->selectId(); +// Save clicking order +$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1; +if ($_GET['answerId'] == "0") // click is NOT on a hotspot +{ + $hit = 0; + $answerId = NULL; +} +else // user clicked ON a hotspot +{ + $hit = 1; + $answerId = substr($_GET['answerId'],22,2); + // Save into session + $_SESSION['exerciseResult'][$questionId][$answerId] = $hit; +} + +$TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS); +// Save into db +$sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (`user_id` , `course_id` , `quiz_id` , `question_id` , `answer_id` , `correct` , `coordinate` ) VALUES ('".$_user['user_id']."', '$courseCode', '$exerciseId', '$questionId', '$answerId', '$hit', '$coordinates')"; +$result = api_sql_query($sql,__FILE__,__LINE__); +// Save insert id into session if users changes answer. +$insert_id = mysql_insert_id(); +$_SESSION['exerciseResult'][$questionId]['ids'][$answerOrderId] = $insert_id; ?> \ No newline at end of file diff --git a/main/exercice/hotspot_updatescore.inc.php b/main/exercice/hotspot_updatescore.inc.php index 7f4ab4dd87..e775044ce4 100644 --- a/main/exercice/hotspot_updatescore.inc.php +++ b/main/exercice/hotspot_updatescore.inc.php @@ -1,77 +1,72 @@ selectId(); - if ($_GET['answerId'] == "0") // click is NOT on a hotspot - { - $hit = 0; - $answerId = $hotspotId; - - // remove from session - unset($_SESSION['exerciseResult'][$questionId][$answerId]); - - // Save clicking order - //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1; - //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId; - } - else // user clicked ON a hotspot - { - $hit = 1; - $answerId = $hotspotId; - - // Save into session - $_SESSION['exerciseResult'][$questionId][$answerId] = $hit; - - // Save clicking order - //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1; - //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId; - } - - $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS); - - // update db - $update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId]; - $sql = "UPDATE $TBL_TRACK_E_HOTSPOT SET `coordinate` = '".$coordinates."' WHERE `id` =$update_id LIMIT 1 ;;"; - $result = api_sql_query($sql,__FILE__,__LINE__); + +include('exercise.class.php'); +include('question.class.php'); +include('answer.class.php'); +include('../inc/global.inc.php'); + + +$courseCode = $_GET['coursecode']; +$questionId = $_GET['questionId']; +$coordinates = $_GET['coord']; +$objExcercise = $_SESSION['objExercise']; +$hotspotId = $_GET['hotspotId']; +$exerciseId = $objExcercise->selectId(); +if ($_GET['answerId'] == "0") // click is NOT on a hotspot +{ + $hit = 0; + $answerId = $hotspotId; + + // remove from session + unset($_SESSION['exerciseResult'][$questionId][$answerId]); + + // Save clicking order + //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1; + //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId; +} +else // user clicked ON a hotspot +{ + $hit = 1; + $answerId = $hotspotId; + + // Save into session + $_SESSION['exerciseResult'][$questionId][$answerId] = $hit; + + // Save clicking order + //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1; + //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId; +} + +$TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS); + +// update db +$update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId]; +$sql = "UPDATE $TBL_TRACK_E_HOTSPOT SET `coordinate` = '".$coordinates."' WHERE `id` =$update_id LIMIT 1 ;;"; +$result = api_sql_query($sql,__FILE__,__LINE__); ?> \ No newline at end of file diff --git a/main/exercice/mark_free_answer.php b/main/exercice/mark_free_answer.php index 3e95dfa5c2..03dd4e0ffd 100644 --- a/main/exercice/mark_free_answer.php +++ b/main/exercice/mark_free_answer.php @@ -1,35 +1,31 @@ - + For a full list of contributors, see documentation/credits.html - For a full list of contributors, see "credits.txt". - The full license can be read in "license.txt". + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + See "documentation/licence.html" more details. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. + Contact: + Dokeos + Rue des Palais 44 Paleizenstraat + B-1030 Brussels - Belgium + Tel. +32 (2) 211 34 56 +*/ - See the GNU General Public License for more details. - Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com -============================================================================== -*/ /** -============================================================================== -* FREE ANSWER MARKING SCRIPT -* -* This script allows a course tutor to mark a student's free answer. -* @author Yannick Warnier +* Free answer marking script +* This script allows a course tutor to mark a student's free answer. * @package dokeos.exercise +* @author Yannick Warnier +* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $ * -* @todo use the Database:: functions * @todo respect coding guidelines -============================================================================== */ /* @@ -60,8 +56,8 @@ define('FREE_ANSWER', 5); /** @todo use the Database:: functions */ -$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question'; -$TBL_EXERCICES = $_course['dbNameGlu'].'quiz'; +$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); +$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER); diff --git a/main/exercice/matching.class.php b/main/exercice/matching.class.php index 11985339d2..6ddc0c41fc 100644 --- a/main/exercice/matching.class.php +++ b/main/exercice/matching.class.php @@ -1,53 +1,49 @@ - type = MATCHING; } - + /** * function which redifines Question::createAnswersForm * @param the formvalidator instance */ - function createAnswersForm ($form) { - + function createAnswersForm ($form) { + $defaults = array(); - + $nb_matches = $nb_options = 2; if($form -> isSubmitted()) { $nb_matches = $form -> getSubmitValue('nb_matches'); - $nb_options = $form -> getSubmitValue('nb_options'); + $nb_options = $form -> getSubmitValue('nb_options'); if(isset($_POST['lessMatches'])) $nb_matches--; if(isset($_POST['moreMatches'])) @@ -77,9 +73,9 @@ class Matching extends Question { $nb_options--; if(isset($_POST['moreOptions'])) $nb_options++; - + } - else if(!empty($this -> id)) + else if(!empty($this -> id)) { $answer = new Answer($this -> id); $answer -> read(); @@ -89,7 +85,7 @@ class Matching extends Question { $nb_matches = $nb_options = 0; for($i=1 ; $i<=$answer->nbrAnswers ; $i++){ if($answer -> isCorrect($i)) - { + { $nb_matches++; $defaults['answer['.$nb_matches.']'] = $answer -> selectAnswer($i); $defaults['weighting['.$nb_matches.']'] = $answer -> selectWeighting($i); @@ -101,12 +97,12 @@ class Matching extends Question { $defaults['option['.$nb_options.']'] = $answer -> selectAnswer($i); } } - + } } else { $defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1'); - $defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2'); + $defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2'); $defaults['matches[2]'] = '2'; $defaults['option[1]'] = get_lang('DefaultMatchingOptA'); $defaults['option[2]'] = get_lang('DefaultMatchingOptB'); @@ -116,19 +112,19 @@ class Matching extends Question { { $a_matches[$i] = chr(64+$i); // fill the array with A, B, C..... } - - - - - + + + + + $form -> addElement('hidden', 'nb_matches', $nb_matches); $form -> addElement('hidden', 'nb_options', $nb_options); - - + + //////////////////////// // DISPLAY MATCHES //// - ////////////////////// - + ////////////////////// + $html='
@@ -153,34 +149,34 @@ class Matching extends Question { '; $form -> addElement ('html', $html); - - + + for($i = 1 ; $i <= $nb_matches ; ++$i) { - + $form -> addElement ('html', ''); $group = array(); $puce = FormValidator :: createElement ('text', null,null,'value="'.$i.'"'); - $puce->freeze(); + $puce->freeze(); $group[] = $puce; $group[] = FormValidator :: createElement ('text', 'answer['.$i.']',null, 'size="30"'); $group[] = FormValidator :: createElement ('select', 'matches['.$i.']',null,$a_matches); $group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="2" value="1"'); $form -> addGroup($group, null, null, ''); - + $form -> addElement ('html', ''); - + } - - $form -> addElement ('html', '
'); + + $form -> addElement ('html', ''); $group = array(); $group[] = FormValidator :: createElement ('submit', 'lessMatches', '-elem'); $group[] = FormValidator :: createElement ('submit', 'moreMatches', '+elem'); $form -> addGroup($group); - - - + + + //////////////////////// // DISPLAY OPTIONS //// ////////////////////// @@ -200,50 +196,50 @@ class Matching extends Question { '; $form -> addElement ('html', $html); - - - + + + for($i = 1 ; $i <= $nb_options ; ++$i) { $form -> addElement ('html', ''); $group = array(); $puce = FormValidator :: createElement ('text', null,null,'value="'.chr(64+$i).'"'); - $puce->freeze(); + $puce->freeze(); $group[] = $puce; $group[] = FormValidator :: createElement ('text', 'option['.$i.']',null, 'size="30"'); $form -> addGroup($group, null, null, ''); - + $form -> addElement ('html', ''); - + } - - $form -> addElement ('html', ''); + + $form -> addElement ('html', ''); $group = array(); $group[] = FormValidator :: createElement ('submit', 'lessOptions', '-elem'); $group[] = FormValidator :: createElement ('submit', 'moreOptions', '+elem'); $form -> addGroup($group); - + $form -> setDefaults($defaults); - + $form->setConstants(array('nb_matches' => $nb_matches,'nb_options' => $nb_options)); - + } - - + + /** * abstract function which creates the form to create / edit the answers of the question * @param the formvalidator instance */ function processAnswersCreation($form) { - + $nb_matches = $form -> getSubmitValue('nb_matches'); $nb_options = $form -> getSubmitValue('nb_options'); $this -> weighting = 0; $objAnswer = new Answer($this->id); - + $position = 0; - + // insert the options for($i=1 ; $i<=$nb_options ; ++$i) { @@ -251,7 +247,7 @@ class Matching extends Question { $option = $form -> getSubmitValue('option['.$i.']'); $objAnswer->createAnswer($option, 0, '', 0, $position); } - + // insert the answers for($i=1 ; $i<=$nb_matches ; ++$i) { @@ -262,12 +258,12 @@ class Matching extends Question { $this -> weighting += $weighting; $objAnswer->createAnswer($answer,$matches,'',$weighting,$position); } - + $objAnswer->save(); $this->save(); - + } - + } endif; diff --git a/main/exercice/multiple_answer.class.php b/main/exercice/multiple_answer.class.php index 540fdf2ae6..20c42b5bdd 100644 --- a/main/exercice/multiple_answer.class.php +++ b/main/exercice/multiple_answer.class.php @@ -1,52 +1,47 @@ - type = MULTIPLE_ANSWER; } - + /** * function which redifines Question::createAnswersForm * @param the formvalidator instance * @param the answers number to display */ function createAnswersForm ($form) { - + global $fck_attribute; - + $fck_attribute = array(); $fck_attribute['Width'] = '300px'; $fck_attribute['Height'] = '100px'; $fck_attribute['ToolbarSet'] = 'Small'; $fck_attribute['Config']['IMUploadPath'] = 'upload/test/'; $fck_attribute['Config']['FlashUploadPath'] = 'upload/test/'; - - $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2; + + $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2; $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); - + $html='
@@ -100,23 +95,23 @@ class MultipleAnswer extends Question { '; $form -> addElement ('html', $html); - + $defaults = array(); - if(!empty($this -> id)) + if(!empty($this -> id)) { $answer = new Answer($this -> id); - $answer -> read(); + $answer -> read(); if(count($answer->nbrAnswers)>0 && !$form->isSubmitted()) { $nb_answers = $answer->nbrAnswers; } } - + $form -> addElement('hidden', 'nb_answers'); - + for($i = 1 ; $i <= $nb_answers ; ++$i) { - + if(is_object($answer)) { $defaults['answer['.$i.']'] = $answer -> answer[$i]; @@ -124,57 +119,57 @@ class MultipleAnswer extends Question { $defaults['weighting['.$i.']'] = $answer -> weighting[$i]; $defaults['correct['.$i.']'] = $answer -> correct[$i]; } - + $form -> addElement ('html', ''); $group = array(); $puce = FormValidator :: createElement ('text', null,null,'value="1"'); - $puce->freeze(); + $puce->freeze(); $group[] = $puce; - $group[] = FormValidator :: createElement ('checkbox', 'correct['.$i.']', null, null, $i); + $group[] = FormValidator :: createElement ('checkbox', 'correct['.$i.']', null, null, $i); $group[] = FormValidator :: createElement ('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle" cols="30"'); $group[] = FormValidator :: createElement ('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle" cols="30"'); $group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="5" value="0"'); $form -> addGroup($group, null, null, ''); - + $form -> addElement ('html', ''); - + } - - $form -> addElement ('html', '
'); + + $form -> addElement ('html', ''); $group = array(); $group[] = FormValidator :: createElement ('submit', 'lessAnswers', '-answ'); $group[] = FormValidator :: createElement ('submit', 'moreAnswers', '+answ'); $form -> addGroup($group); - + $form -> setDefaults($defaults); $form->setConstants(array('nb_answers' => $nb_answers)); - - + + } - - + + /** * abstract function which creates the form to create / edit the answers of the question * @param the formvalidator instance * @param the answers number to display */ function processAnswersCreation($form) { - + $questionWeighting = $nbrGoodAnswers = 0; - + $objAnswer = new Answer($this->id); - + $nb_answers = $form -> getSubmitValue('nb_answers'); - + for($i=1 ; $i <= $nb_answers ; $i++) { $answer = trim($form -> getSubmitValue('answer['.$i.']')); $comment = trim($form -> getSubmitValue('comment['.$i.']')); $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); $goodAnswer = trim($form -> getSubmitValue('correct['.$i.']')); - - if($goodAnswer) + + if($goodAnswer) { $nbrGoodAnswers++; $weighting = abs($weighting); @@ -183,20 +178,20 @@ class MultipleAnswer extends Question { $questionWeighting += $weighting; } } - + $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i); - + } - + // saves the answers into the data base $objAnswer -> save(); - + // sets the total weighting of the question $this -> updateWeighting($questionWeighting); $this -> save(); - + } - + } endif; diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index fb7e0de926..4a1c5e61fc 100644 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1,35 +1,31 @@ - '; echo $styles; - - + + /********************* * INIT FORM *********************/ $form = new FormValidator('question_admin_form','post',$action); - - + + /********************* * FORM CREATION *********************/ - - $objQuestion -> createForm ($form); - - $objQuestion -> createAnswersForm ($form); - + + $objQuestion -> createForm ($form); + + $objQuestion -> createAnswersForm ($form); + $form->addElement('submit','submitQuestion',get_lang('Ok')); - - + + /********************** - * FORM VALIDATION + * FORM VALIDATION **********************/ if(isset($_POST['submitQuestion']) && $form->validate()) - { + { // question $objQuestion -> processCreation($form,$objExercise); - + // answers $objQuestion -> processAnswersCreation($form,$nb_answers); - + // redirect if($objQuestion -> type != HOT_SPOT) echo ''; else echo ''; } - else - { - + else + { + /****************** * FORM DISPLAY ******************/ echo '

'.$questionName.'

'; - - + + if(!empty($pictureName)){ echo ''; } - + if(!empty($msgErr)) { Display::display_normal_message($msgErr); //main API } - - + + // display the form $form->display(); - } } - ?> \ No newline at end of file diff --git a/main/exercice/question_list_admin.inc.php b/main/exercice/question_list_admin.inc.php index 3c721eb2ee..c28d745a3e 100644 --- a/main/exercice/question_list_admin.inc.php +++ b/main/exercice/question_list_admin.inc.php @@ -1,36 +1,41 @@ - -selectQuestionList(); @@ -97,12 +102,12 @@ if($nbrQuestions) $objQuestionTmp = Question :: read($id); //showQuestion($id); -?> +?> selectTitle(); ?> <?php echo get_lang('Modify'); ?> <?php echo get_lang('Delete'); ?> - + +?> - diff --git a/main/exercice/question_pool.php b/main/exercice/question_pool.php index 580f605247..34f920ff3d 100644 --- a/main/exercice/question_pool.php +++ b/main/exercice/question_pool.php @@ -1,54 +1,48 @@ -"; $posthref=""; - $newcontent = str_replace($prehref,$posthref,$newcontent); - - - if (CheckSubFolder($full_file_path.$_user['user_id'].".t.html")==0) - { $newcontent = ReplaceImgTag($newcontent); } - + $newcontent = str_replace($prehref,$posthref,$newcontent); + + + if (CheckSubFolder($full_file_path.$_user['user_id'].".t.html")==0) + { $newcontent = ReplaceImgTag($newcontent); } + } else { - //my_delete($full_file_path.$_user['user_id'].".t.html"); + //my_delete($full_file_path.$_user['user_id'].".t.html"); $newcontent = $content; } @@ -101,22 +96,22 @@ WriteFileCont($full_file_path.$_user['user_id'].".t.html",$newcontent); /* $prehref="javascript:void(0);"; $posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; - $newcontent = str_replace($prehref,$posthref,$newcontent); - + $newcontent = str_replace($prehref,$posthref,$newcontent); + $prehref="class=\"GridNum\" onclick="; $posthref="class=\"GridNum\" onMouseover="; - $newcontent = str_replace($prehref,$posthref,$newcontent); -*/ + $newcontent = str_replace($prehref,$posthref,$newcontent); +*/ $doc_url = GetFolderPath($doc_url).urlencode(GetFileName($doc_url)); // echo $documentWebPath.$doc_url.$_user['user_id'].".t.html"; // exit; -?> +?> Tests - Dokeos - @@ -131,16 +126,16 @@ if ($origin!='learnpath') { - - diff --git a/main/exercice/testheaderpage.php b/main/exercice/testheaderpage.php index 98a8993781..760c9ae2a7 100644 --- a/main/exercice/testheaderpage.php +++ b/main/exercice/testheaderpage.php @@ -1,50 +1,46 @@ "./exercice.php", "name"=> get_lang('Exercices')); Display::display_header($nameTools,"Exercise"); echo ""; - - ?> \ No newline at end of file diff --git a/main/exercice/unique_answer.class.php b/main/exercice/unique_answer.class.php index a17b521d9f..a1cfa1086b 100644 --- a/main/exercice/unique_answer.class.php +++ b/main/exercice/unique_answer.class.php @@ -1,78 +1,74 @@ - type = UNIQUE_ANSWER; } - + /** * function which redifines Question::createAnswersForm * @param the formvalidator instance * @param the answers number to display */ function createAnswersForm ($form) { - + global $fck_attribute; - + $fck_attribute = array(); $fck_attribute['Width'] = '300px'; $fck_attribute['Height'] = '100px'; $fck_attribute['ToolbarSet'] = 'Small'; $fck_attribute['Config']['IMUploadPath'] = 'upload/test/'; $fck_attribute['Config']['FlashUploadPath'] = 'upload/test/'; - - $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2; + + $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2; $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); - + $html='
@@ -99,27 +95,27 @@ class UniqueAnswer extends Question {
'; $form -> addElement ('html', $html); - + $defaults = array(); $correct = 0; - if(!empty($this -> id)) + if(!empty($this -> id)) { $answer = new Answer($this -> id); - $answer -> read(); + $answer -> read(); if(count($answer->nbrAnswers)>0 && !$form->isSubmitted()) { $nb_answers = $answer->nbrAnswers; } } - + $form -> addElement('hidden', 'nb_answers'); - + for($i = 1 ; $i <= $nb_answers ; ++$i) { - + if(is_object($answer)) { - if($answer -> correct[$i]) + if($answer -> correct[$i]) { $correct = $i; } @@ -127,60 +123,60 @@ class UniqueAnswer extends Question { $defaults['comment['.$i.']'] = $answer -> comment[$i]; $defaults['weighting['.$i.']'] = $answer -> weighting[$i]; } - + $form -> addElement ('html', ''); - + } - - $form -> addElement ('html', '
'); $group = array(); $puce = FormValidator :: createElement ('text', null,null,'value="'.$i.'"'); - $puce->freeze(); + $puce->freeze(); $group[] = $puce; - $group[] = FormValidator :: createElement ('radio', 'correct', null, null, $i); - + $group[] = FormValidator :: createElement ('radio', 'correct', null, null, $i); + $group[] = FormValidator :: createElement ('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"'); $group[] = FormValidator :: createElement ('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"'); $group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="5" value="0"'); $form -> addGroup($group, null, null, ''); - + $form -> addElement ('html', '
'); + + $form -> addElement ('html', ''); $group = array(); $group[] = FormValidator :: createElement ('submit', 'lessAnswers', '-answ'); $group[] = FormValidator :: createElement ('submit', 'moreAnswers', '+answ'); $form -> addGroup($group); - + $defaults['correct'] = $correct; $form -> setDefaults($defaults); - + $form->setConstants(array('nb_answers' => $nb_answers)); - + } - - + + /** * abstract function which creates the form to create / edit the answers of the question * @param the formvalidator instance * @param the answers number to display */ function processAnswersCreation($form) { - + $questionWeighting = $nbrGoodAnswers = 0; - + $correct = $form -> getSubmitValue('correct'); $objAnswer = new Answer($this->id); $nb_answers = $form -> getSubmitValue('nb_answers'); - + for($i=1 ; $i <= $nb_answers ; $i++) { $answer = trim($form -> getSubmitValue('answer['.$i.']')); $comment = trim($form -> getSubmitValue('comment['.$i.']')); $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); - + $goodAnswer= ($correct == $i) ? true : false; - - if($goodAnswer) + + if($goodAnswer) { $nbrGoodAnswers++; $weighting = abs($weighting); @@ -189,21 +185,18 @@ class UniqueAnswer extends Question { $questionWeighting += $weighting; } } - + $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i); - + } - + // saves the answers into the data base $objAnswer -> save(); - + // sets the total weighting of the question $this -> updateWeighting($questionWeighting); $this -> save(); - } - } - endif; ?> \ No newline at end of file