123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371 |
- <?php
- /* For licensing terms, see /dokeos_license.txt */
- /**
- * Exercise class: This class allows to instantiate an object of type Exercise
- * @package dokeos.exercise
- * @author Olivier Brouckaert
- * @version $Id: exercise.class.php 22046 2009-07-14 01:45:19Z ivantcholakov $
- */
- define('ALL_ON_ONE_PAGE',1);
- define('ONE_PER_PAGE',2);
- define('EXERCISE_FEEDBACK_TYPE_END',0);
- define('EXERCISE_FEEDBACK_TYPE_DIRECT',1);
- define('EXERCISE_FEEDBACK_TYPE_EXAM',2);
- if(!class_exists('Exercise')):
- class Exercise
- {
- var $id;
- var $exercise;
- var $description;
- var $sound;
- var $type;
- var $random;
- var $random_answers;
- var $active;
- var $timeLimit;
- var $attempts;
- var $feedbacktype;
- var $end_time;
- var $start_time;
- var $questionList; // array with the list of this exercise's questions
- var $results_disabled;
- var $expired_time;
- /**
- * constructor of the class
- *
- * @author - Olivier Brouckaert
- */
- function Exercise()
- {
- $this->id=0;
- $this->exercise='';
- $this->description='';
- $this->sound='';
- $this->type=1;
- $this->random=0;
- $this->random_answers=0;
- $this->active=1;
- $this->questionList=array();
- $this->timeLimit = 0;
- $this->end_time = '0000-00-00 00:00:00';
- $this->start_time = '0000-00-00 00:00:00';
- $this->results_disabled =1;
- $this->expired_time = '0000-00-00 00:00:00';
- }
- /**
- * reads exercise informations from the data base
- *
- * @author - Olivier Brouckaert
- * @param - integer $id - exercise ID
- * @return - boolean - true if exercise exists, otherwise false
- */
- function read($id)
- {
- global $_course;
- global $_configuration;
- global $questionList;
- $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);
- $sql="SELECT title,description,sound,type,random, random_answers, active, results_disabled, max_attempt,start_time,end_time,feedback_type,expired_time FROM $TBL_EXERCICES WHERE id='".Database::escape_string($id)."'";
- $result=Database::query($sql,__FILE__,__LINE__);
- // if the exercise has been found
- if($object=Database::fetch_object($result))
- {
- $this->id=$id;
- $this->exercise=$object->title;
- $this->description=$object->description;
- $this->sound=$object->sound;
- $this->type=$object->type;
- $this->random=$object->random;
- $this->random_answers=$object->random_answers;
- $this->active=$object->active;
- $this->results_disabled =$object->results_disabled;
- $this->attempts = $object->max_attempt;
- $this->feedbacktype = $object->feedback_type;
- $this->end_time = $object->end_time;
- $this->start_time = $object->start_time;
- $this->expired_time = $object->expired_time;
- $sql="SELECT question_id, question_order FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS WHERE question_id=id AND exercice_id='".Database::escape_string($id)."' ORDER BY question_order";
- $result=Database::query($sql,__FILE__,__LINE__);
- // fills the array with the question ID for this exercise
- // the key of the array is the question position
- while($object=Database::fetch_object($result))
- {
- // makes sure that the question position is unique
- while(isset($this->questionList[$object->question_order]))
- {
- $object->question_order++;
- }
- $this->questionList[$object->question_order]=$object->question_id;
- }
- //var_dump($this->end_time,$object->start_time);
- if($this->random > 0){
- $this->questionList = $this->selectRandomList();
- }
- //overload questions list with recorded questions list
- //load questions only for exercises of type 'one question per page'
- //this is needed only is there is no questions
- //
- if($this->type == 2 && $_configuration['live_exercise_tracking']==true && $_SERVER['REQUEST_METHOD']!='POST' && defined('QUESTION_LIST_ALREADY_LOGGED'))
- {
- //if(empty($_SESSION['questionList']))
- $this->questionList = $questionList;
- }
- return true;
- }
- // exercise not found
- return false;
- }
- /**
- * returns the exercise ID
- *
- * @author - Olivier Brouckaert
- * @return - integer - exercise ID
- */
- function selectId()
- {
- return $this->id;
- }
- /**
- * returns the exercise title
- *
- * @author - Olivier Brouckaert
- * @return - string - exercise title
- */
- function selectTitle()
- {
- return $this->exercise;
- }
- /**
- * returns the number of attempts setted
- *
- * @return - numeric - exercise attempts
- */
- function selectAttempts()
- {
- return $this->attempts;
- }
- /** returns the number of FeedbackType *
- * 0=>Feedback , 1=>DirectFeedback, 2=>NoFeedback
- * @return - numeric - exercise attempts
- */
- function selectFeedbackType()
- {
- return $this->feedbacktype;
- }
- /**
- * returns the time limit
- */
- function selectTimeLimit()
- {
- return $this->timeLimit;
- }
- /**
- * returns the exercise description
- *
- * @author - Olivier Brouckaert
- * @return - string - exercise description
- */
- function selectDescription()
- {
- return $this->description;
- }
- /**
- * returns the exercise sound file
- *
- * @author - Olivier Brouckaert
- * @return - string - exercise description
- */
- function selectSound()
- {
- return $this->sound;
- }
- /**
- * returns the exercise type
- *
- * @author - Olivier Brouckaert
- * @return - integer - exercise type
- */
- function selectType()
- {
- return $this->type;
- }
- /**
- * tells if questions are selected randomly, and if so returns the draws
- *
- * @author - Carlos Vargas
- * @return - integer - results disabled exercise
- */
- function selectResultsDisabled()
- {
- return $this->results_disabled;
- }
- /**
- * tells if questions are selected randomly, and if so returns the draws
- *
- * @author - Olivier Brouckaert
- * @return - integer - 0 if not random, otherwise the draws
- */
- function isRandom()
- {
- if($this->random > 0){
- return true;
- }
- else{
- return false;
- }
- }
-
- /**
- * returns random answers status.
- *
- * @author - Juan Carlos Ra�a
- */
- function selectRandomAnswers()
- {
-
- $this->random_answers;
-
- return $this->random_answers;
- }
-
-
- /**
- * Same as isRandom() but has a name applied to values different than 0 or 1
- */
- function getShuffle()
- {
- return $this->random;
- }
- /**
- * returns the exercise status (1 = enabled ; 0 = disabled)
- *
- * @author - Olivier Brouckaert
- * @return - boolean - true if enabled, otherwise false
- */
- function selectStatus()
- {
- return $this->active;
- }
- /**
- * returns the array with the question ID list
- *
- * @author - Olivier Brouckaert
- * @return - array - question ID list
- */
- function selectQuestionList()
- {
- return $this->questionList;
- }
- /**
- * returns the number of questions in this exercise
- *
- * @author - Olivier Brouckaert
- * @return - integer - number of questions
- */
- function selectNbrQuestions()
- {
- return sizeof($this->questionList);
- }
- /**
- * selects questions randomly in the question list
- *
- * @author - Olivier Brouckaert
- * @return - array - if the exercise is not set to take questions randomly, returns the question list
- * without randomizing, otherwise, returns the list with questions selected randomly
- */
- function selectRandomList()
- {
- $nbQuestions = $this->selectNbrQuestions();
- $temp_list = $this->questionList;
- //error_log(print_r($temp_list,true));
- //error_log(count($temp_list));
- if (count($temp_list)<>0) {
- shuffle($temp_list);
- return array_combine(range(1,$nbQuestions),$temp_list);
- }
- $nbQuestions = $this->selectNbrQuestions();
- //Not a random exercise, or if there are not at least 2 questions
- if($this->random == 0 || $nbQuestions < 2)
- {
- return $this->questionList;
- }
- $randQuestionList = array();
- $alreadyChosen = array();
- for($i=0; $i < $this->random; $i++)
- {
- if($i < $nbQuestions){
- do
- {
- $rand=rand(1,$nbQuestions);
- }
- while(in_array($rand,$alreadyChosen));
- $alreadyChosen[]=$rand;
- $randQuestionList[$rand] = $this->questionList[$rand];
- }
- }
- return $randQuestionList;
- }
- /**
- * returns 'true' if the question ID is in the question list
- *
- * @author - Olivier Brouckaert
- * @param - integer $questionId - question ID
- * @return - boolean - true if in the list, otherwise false
- */
- function isInList($questionId)
- {
- if (is_array($this->questionList))
- return in_array($questionId,$this->questionList);
- else
- return false;
- }
- /**
- * changes the exercise title
- *
- * @author - Olivier Brouckaert
- * @param - string $title - exercise title
- */
- function updateTitle($title)
- {
- $this->exercise=$title;
- }
- /**
- * changes the exercise max attempts
- *
- * @param - numeric $attempts - exercise max attempts
- */
- function updateAttempts($attempts)
- {
- $this->attempts=$attempts;
- }
- /**
- * changes the exercise feedback type
- *
- * @param - numeric $attempts - exercise max attempts
- */
- function updateFeedbackType($feedback_type)
- {
- $this->feedbacktype=$feedback_type;
- }
- /**
- * changes the exercise description
- *
- * @author - Olivier Brouckaert
- * @param - string $description - exercise description
- */
- function updateDescription($description)
- {
- $this->description=$description;
- }
-
- /**
- * changes the exercise expired_time
- *
- * @author - Isaac flores
- * @param - int The expired time of the quiz
- */
- function updateExpiredTime($expired_time)
- {
- $this->expired_time = $expired_time;
- }
-
- /**
- * changes the exercise sound file
- *
- * @author - Olivier Brouckaert
- * @param - string $sound - exercise sound file
- * @param - string $delete - ask to delete the file
- */
- function updateSound($sound,$delete)
- {
- global $audioPath, $documentPath,$_course, $_user;
- $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
- $TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
- if($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video')))
- {
- $this->sound=$sound['name'];
- if(@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound))
- {
- $query="SELECT 1 FROM $TBL_DOCUMENT "
- ." WHERE path='".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'";
- $result=Database::query($query,__FILE__,__LINE__);
- if(!Database::num_rows($result))
- {
- /*$query="INSERT INTO $TBL_DOCUMENT(path,filetype) VALUES "
- ." ('".str_replace($documentPath,'',$audioPath).'/'.$this->sound."','file')";
- Database::query($query,__FILE__,__LINE__);*/
- $id = add_document($_course,str_replace($documentPath,'',$audioPath).'/'.$this->sound,'file',$sound['size'],$sound['name']);
- //$id = Database::insert_id();
- //$time = time();
- //$time = date("Y-m-d H:i:s", $time);
- // insert into the item_property table, using default visibility of "visible"
- /*$query = "INSERT INTO $TBL_ITEM_PROPERTY "
- ."(tool, ref, insert_user_id,to_group_id, insert_date, lastedit_date, lastedit_type) "
- ." VALUES "
- ."('".TOOL_DOCUMENT."', $id, $_user['user_id'], 0, '$time', '$time', 'DocumentAdded' )";
- Database::query($query,__FILE__,__LINE__);*/
- api_item_property_update($_course, TOOL_DOCUMENT, $id, 'DocumentAdded',$_user['user_id']);
- item_property_update_on_folder($_course,str_replace($documentPath,'',$audioPath),$_user['user_id']);
- }
- }
- }
- elseif($delete && is_file($audioPath.'/'.$this->sound))
- {
- $this->sound='';
- }
- }
- /**
- * changes the exercise type
- *
- * @author - Olivier Brouckaert
- * @param - integer $type - exercise type
- */
- function updateType($type)
- {
- $this->type=$type;
- }
- /**
- * sets to 0 if questions are not selected randomly
- * if questions are selected randomly, sets the draws
- *
- * @author - Olivier Brouckaert
- * @param - integer $random - 0 if not random, otherwise the draws
- */
- function setRandom($random)
- {
- $this->random=$random;
- }
- /**
- * sets to 0 if answers are not selected randomly
- * if answers are selected randomly
- * @author - Juan Carlos Ra�a
- * @param - integer $random_answers - random answers
- */
- function updateRandomAnswers($random_answers)
- {
- $this->$random_answers = $random_answers;
- }
- /**
- * enables the exercise
- *
- * @author - Olivier Brouckaert
- */
- function enable()
- {
- $this->active=1;
- }
- /**
- * disables the exercise
- *
- * @author - Olivier Brouckaert
- */
- function disable()
- {
- $this->active=0;
- }
- function disable_results()
- {
- $this->results_disabled = true;
- }
- function enable_results()
- {
- $this->results_disabled = false;
- }
- function updateResultsDisabled($results_disabled)
- {
- if ($results_disabled==1){
- $this->results_disabled = true;
- } else {
- $this->results_disabled = false;
- }
- }
- /**
- * updates the exercise in the data base
- *
- * @author - Olivier Brouckaert
- */
- function save($type_e='')
- {
- global $_course,$_user;
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
- $TBL_QUIZ_QUESTION= Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
- $id = $this->id;
- $exercise = $this->exercise;
- $description = $this->description;
- $sound = $this->sound;
- $type = $this->type;
- $attempts = $this->attempts;
- $feedbacktype = $this->feedbacktype;
- $random = $this->random;
- $random_answers = $this->random_answers;
- $active = $this->active;
- $session_id = api_get_session_id();
- $expired_time = $this->expired_time;
-
- if ($feedbacktype==1){
- $results_disabled = 1;
- } else {
- $results_disabled = intval($this->results_disabled);
- }
- $start_time = Database::escape_string($this->start_time);
- $end_time = Database::escape_string($this->end_time);
- // exercise already exists
- if($id) {
- /*
- title='".Database::escape_string(Security::remove_XSS($exercise))."',
- description='".Database::escape_string(Security::remove_XSS(api_html_entity_decode($description),COURSEMANAGERLOWSECURITY))."'";
- */
- $sql="UPDATE $TBL_EXERCICES SET
- title='".Database::escape_string($exercise)."',
- description='".Database::escape_string($description)."'";
- if ($type_e != 'simple') {
- $sql .= ", sound='".Database::escape_string($sound)."',
- type='".Database::escape_string($type)."',
- random='".Database::escape_string($random)."',
- random_answers='".Database::escape_string($random_answers)."',
- active='".Database::escape_string($active)."',
- feedback_type='".Database::escape_string($feedbacktype)."',
- start_time='$start_time',end_time='$end_time',
- max_attempt='".Database::escape_string($attempts)."',
- expired_time='".Database::escape_string($expired_time)."',
- results_disabled='".Database::escape_string($results_disabled)."'";
- }
- $sql .= " WHERE id='".Database::escape_string($id)."'";
- // echo $sql;
- Database::query($sql,__FILE__,__LINE__);
- // update into the item_property table
- api_item_property_update($_course, TOOL_QUIZ, $id,'QuizUpdated',$_user['user_id']);
- if (api_get_setting('search_enabled')=='true') {
- $this -> search_engine_edit();
- }
- } else {// creates a new exercise
- //add condition by anonymous user
- /*if (!api_is_anonymous()) {
- //is course manager
- $cond1=Database::escape_string($exercise);
- $cond2=Database::escape_string($description);
- } else {
- //is anonymous user
- $cond1=Database::escape_string(Security::remove_XSS($exercise));
- $cond2=Database::escape_string(Security::remove_XSS(api_html_entity_decode($description),COURSEMANAGERLOWSECURITY));
- }*/
- $sql="INSERT INTO $TBL_EXERCICES (start_time, end_time, title, description, sound, type, random, random_answers,active, results_disabled, max_attempt, feedback_type, expired_time, session_id)
- VALUES(
- '$start_time','$end_time',
- '".Database::escape_string($exercise)."',
- '".Database::escape_string($description)."',
- '".Database::escape_string($sound)."',
- '".Database::escape_string($type)."',
- '".Database::escape_string($random)."',
- '".Database::escape_string($random_answers)."',
- '".Database::escape_string($active)."',
- '".Database::escape_string($results_disabled)."',
- '".Database::escape_string($attempts)."',
- '".Database::escape_string($feedbacktype)."',
- '".Database::escape_string($expired_time)."',
- '".Database::escape_string($session_id)."'
- )";
- Database::query($sql,__FILE__,__LINE__);
- $this->id=Database::insert_id();
- // insert into the item_property table
- api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizAdded',$_user['user_id']);
- if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
- $this -> search_engine_save();
- }
- }
- // updates the question position
- $this->update_question_positions();
- }
- function update_question_positions() {
- // updates the question position
- $TBL_QUIZ_QUESTION= Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
- foreach($this->questionList as $position=>$questionId)
- {
- //$sql="UPDATE $TBL_QUESTIONS SET position='".Database::escape_string($position)."' WHERE id='".Database::escape_string($questionId)."'";
- $sql="UPDATE $TBL_QUIZ_QUESTION SET question_order='".Database::escape_string($position)."' " .
- "WHERE question_id='".Database::escape_string($questionId)."' and exercice_id=".Database::escape_string($this->id)."";
- Database::query($sql,__FILE__,__LINE__);
- }
- }
- /**
- * moves a question up in the list
- *
- * @author - Olivier Brouckaert
- * @author - Julio Montoya (rewrote the code)
- * @param - integer $id - question ID to move up
- */
- function moveUp($id)
- {
- // there is a bug with some version of PHP with the key and prev functions
- // the script commented was tested in dev.dokeos.com with no success
- // Instead of using prev and next this was change with arrays.
- /*
- foreach($this->questionList as $position=>$questionId)
- {
- // if question ID found
- if($questionId == $id)
- {
- // position of question in the array
- echo $pos1=$position; //1
- echo "<br>";
- prev($this->questionList);
- prev($this->questionList);
- // position of previous question in the array
- $pos2=key($this->questionList);
- //if the cursor of the array hit the end
- // then we must reset the array to get the previous key
- if($pos2===null)
- {
- end($this->questionList);
- prev($this->questionList);
- $pos2=key($this->questionList);
- }
- // error, can't move question
- if(!$pos2)
- {
- //echo 'cant move!';
- $pos2=key($this->questionList);
- reset($this->questionList);
- }
- $id2=$this->questionList[$pos2];
- // exits foreach()
- break;
- }
- $i++;
- }
- */
- $question_list =array();
- foreach($this->questionList as $position=>$questionId)
- {
- $question_list[]= $questionId;
- }
- $len=count($question_list);
- $orderlist=array_keys($this->questionList);
- for($i=0;$i<$len;$i++)
- {
- $questionId = $question_list[$i];
- if($questionId == $id)
- {
- // position of question in the array
- $pos1=$orderlist[$i];
- $pos2=$orderlist[$i-1];
- if($pos2===null)
- {
- $pos2 = $orderlist[$len-1];
- }
- // error, can't move question
- if(!$pos2)
- {
- $pos2=$orderlist[0];
- $i=0;
- }
- break;
- }
- }
- // permutes questions in the array
- $temp=$this->questionList[$pos2];
- $this->questionList[$pos2]=$this->questionList[$pos1];
- $this->questionList[$pos1]=$temp;
- }
- /**
- * moves a question down in the list
- *
- * @author - Olivier Brouckaert
- * @param - integer $id - question ID to move down
- */
- function moveDown($id)
- {
- // there is a bug with some version of PHP with the key and prev functions
- // the script commented was tested in dev.dokeos.com with no success
- // Instead of using prev and next this was change with arrays.
- /*
- foreach($this->questionList as $position=>$questionId)
- {
- // if question ID found
- if($questionId == $id)
- {
- // position of question in the array
- $pos1=$position;
- //next($this->questionList);
- // position of next question in the array
- $pos2=key($this->questionList);
- // error, can't move question
- if(!$pos2)
- {
- //echo 'cant move!';
- return;
- }
- $id2=$this->questionList[$pos2];
- // exits foreach()
- break;
- }
- }
- */
- $question_list =array();
- foreach($this->questionList as $position=>$questionId)
- {
- $question_list[]= $questionId;
- }
- $len=count($question_list);
- $orderlist=array_keys($this->questionList);
- for($i=0;$i<$len;$i++)
- {
- $questionId = $question_list[$i];
- if($questionId == $id)
- {
- $pos1=$orderlist[$i+1];
- $pos2 =$orderlist[$i];
- if(!$pos2)
- {
- //echo 'cant move!';
- }
- break;
- }
- }
- // permutes questions in the array
- $temp=$this->questionList[$pos2];
- $this->questionList[$pos2]=$this->questionList[$pos1];
- $this->questionList[$pos1]=$temp;
- }
- /**
- * adds a question into the question list
- *
- * @author - Olivier Brouckaert
- * @param - integer $questionId - question ID
- * @return - boolean - true if the question has been added, otherwise false
- */
- function addToList($questionId)
- {
- // checks if the question ID is not in the list
- if(!$this->isInList($questionId))
- {
- // selects the max position
- if(!$this->selectNbrQuestions())
- {
- $pos=1;
- }
- else
- {
- if (is_array($this->questionList))
- $pos=max(array_keys($this->questionList))+1;
- }
- $this->questionList[$pos]=$questionId;
- return true;
- }
- return false;
- }
- /**
- * removes a question from the question list
- *
- * @author - Olivier Brouckaert
- * @param - integer $questionId - question ID
- * @return - boolean - true if the question has been removed, otherwise false
- */
- function removeFromList($questionId)
- {
- // searches the position of the question ID in the list
- $pos=array_search($questionId,$this->questionList);
- // question not found
- if($pos === false)
- {
- return false;
- }
- else
- {
- // deletes the position from the array containing the wanted question ID
- unset($this->questionList[$pos]);
- return true;
- }
- }
- /**
- * deletes the exercise from the database
- * Notice : leaves the question in the data base
- *
- * @author - Olivier Brouckaert
- */
- function delete(){
- global $_course,$_user;
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $sql="UPDATE $TBL_EXERCICES SET active='-1' WHERE id='".Database::escape_string($this->id)."'";
- Database::query($sql);
- api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizDeleted',$_user['user_id']);
- if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian') ) {
- $this -> search_engine_delete();
- }
- }
- /**
- * Creates the form to create / edit an exercise
- * @param FormValidator $form the formvalidator instance (by reference)
- */
- function createForm ($form, $type='full')
- {
- global $id;
- if(empty($type)){
- $type='full';
- }
- // form title
- if (!empty($_GET['exerciseId'])) {
- $form_title = get_lang('ModifyExercise');
- } else {
- $form_title = get_lang('NewEx');
- }
- $form->addElement('header', '', $form_title);
- // title
- $form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName'),'class="input_titles" id="exercise_title"');
- //$form->applyFilter('exerciseTitle','html_filter');
- $form -> addElement('html','<div class="row">
- <div class="label"></div>
- <div class="formw" style="height:50px">
- <a href="javascript://" onclick=" return show_media()"> <span id="media_icon"> <img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" /> '.get_lang('ExerciseDescription').'</span></a>
- </div>
- </div>');
- $editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
- if(is_array($type)){
- $editor_config = array_merge($editor_config, $type);
- }
- $form -> addElement ('html','<div class="HideFCKEditor" id="HiddenFCKexerciseDescription" >');
- $form -> add_html_editor('exerciseDescription', get_lang('langExerciseDescription'), false, false, $editor_config);
- $form -> addElement ('html','</div>');
- $form -> addElement('html','<div class="row">
- <div class="label"> </div>
- <div class="formw">
- <a href="javascript://" onclick=" return advanced_parameters()"><span id="img_plus_and_minus"><div style="vertical-align:top;" ><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> '.get_lang('AdvancedParameters').'</div></span></a>
- </div>
- </div>');
- // Random questions
- $form -> addElement('html','<div id="options" style="display:none">');
- if($type=='full') {
- // feedback type
- $radios_feedback = array();
- $radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0');
- $radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2');
- $form -> addGroup($radios_feedback, null, get_lang('FeedbackType'));
- $feedback_option[0]=get_lang('ExerciseAtTheEndOfTheTest');
- $feedback_option[1]=get_lang('DirectFeedback');
- $feedback_option[2]=get_lang('NoFeedback');
- //Can't modify a DirectFeedback question
- if ($this->selectFeedbackType() != 1 ) {
- // $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'));
-
- $form -> addGroup($radios, null, get_lang('QuestionsPerPage'));
- } else {
- // if is Directfeedback but has not questions we can allow to modify the question type
- if ($this->selectNbrQuestions()== 0) {
- $form -> addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
- // test type
- $radios = array();
- $radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SimpleExercise'),'1');
- $radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
- $form -> addGroup($radios, null, get_lang('ExerciseType'));
- } else {
- //we force the options to the DirectFeedback exercisetype
- $form -> addElement('hidden', 'exerciseFeedbackType','1');
- $form -> addElement('hidden', 'exerciseType','2');
- }
- }
- $radios_results_disabled = array();
- $radios_results_disabled[] = FormValidator :: createElement ('radio', 'results_disabled', null, get_lang('Yes'),'0');
- $radios_results_disabled[] = FormValidator :: createElement ('radio', 'results_disabled', null, get_lang('No'),'1');
- $form -> addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'));
- $random = array();
- $option=array();
- $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ;
- $option = range(0,$max);
- $option[0]=get_lang('No');
- $random[] = FormValidator :: createElement ('select', 'randomQuestions',null,$option);
- $random[] = FormValidator :: createElement ('static', 'help','help','<span style="font-style: italic;">'.get_lang('RandomQuestionsHelp').'</span>');
- //$random[] = FormValidator :: createElement ('text', 'randomQuestions', null,null,'0');
- $form -> addGroup($random,null,get_lang('RandomQuestions'),'<br />');
-
- //random answers
- $radios_random_answers = array();
- $radios_random_answers[] = FormValidator :: createElement ('radio', 'randomAnswers', null, get_lang('Yes'),'1');
- $radios_random_answers[] = FormValidator :: createElement ('radio', 'randomAnswers', null, get_lang('No'),'0');
- $form -> addGroup($radios_random_answers, null, get_lang('RandomAnswers'));
-
- //Attempts
- $attempt_option=range(0,10);
- $attempt_option[0]=get_lang('Infinite');
-
- $form -> addElement('select', 'exerciseAttempts',get_lang('ExerciseAttempts'),$attempt_option);
-
- $form -> addElement('checkbox', 'enabletimelimit',get_lang('EnableTimeLimits'),null,'onclick = " return timelimit() "');
- $var= Exercise::selectTimeLimit();
- if(($this -> start_time!='0000-00-00 00:00:00')||($this -> end_time!='0000-00-00 00:00:00'))
- $form -> addElement('html','<div id="options2" style="display:block;">');
- else
- $form -> addElement('html','<div id="options2" style="display:none;">');
- //$form -> addElement('date', 'start_time', get_lang('ExeStartTime'), array('language'=>'es','format' => 'dMYHi'));
- //$form -> addElement('date', 'end_time', get_lang('ExeEndTime'), array('language'=>'es','format' => 'dMYHi'));
- $form->addElement('datepicker', 'start_time', get_lang('ExeStartTime'), array('form_name'=>'exercise_admin'));
- $form->addElement('datepicker', 'end_time', get_lang('ExeEndTime'), array('form_name'=>'exercise_admin'));
-
- //$form -> addElement('select', 'enabletimercontroltotalminutes',get_lang('ExerciseTimerControlMinutes'),$time_minutes_option);
- $form -> addElement('html','</div>');
-
- $check_option=$this -> selectType();
- // var_dump($check_option);
- if ($check_option==1 && isset($_GET['exerciseId'])) {
- $diplay = 'none';
- } else {
- $diplay = 'block';
- }
-
- $form -> addElement('html','<div id="divtimecontrol" style="display:'.$diplay.';">');
-
- //Timer control
- $time_hours_option = range(0,12);
- $time_minutes_option = range(0,59);
- $form -> addElement('checkbox', 'enabletimercontrol',get_lang('EnableTimerControl'),null,array('onclick' =>'option_time_expired()','id'=>'enabletimercontrol','onload'=>'check_load_time()'));
- $expired_date = (int)$this->selectExpiredTime();
- if(($expired_date!='0')) {
- $form -> addElement('html','<div id="timercontrol" style="display:block;">');
- } else {
- $form -> addElement('html','<div id="timercontrol" style="display:none;">');
- }
-
- $form -> addElement('text', 'enabletimercontroltotalminutes',get_lang('ExerciseTotalDurationInMinutes'),array('style' => 'width : 35px','id' => 'enabletimercontroltotalminutes'));
- $form -> addElement('html','</div>');
- //$form -> addElement('text', 'exerciseAttempts', get_lang('ExerciseAttempts').' : ',array('size'=>'2'));
-
- $form -> addElement('html','</div>'); //End advanced setting
- $form -> addElement('html','</div>');
-
- $defaults = array();
- if (api_get_setting('search_enabled') === 'true') {
- require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
- $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
- $form -> addElement ('html','<br /><div class="row">');
- $form -> addElement ('html', '<div class="label">'. get_lang('SearchFeatureDocumentLanguage') .'</div>');
- $form -> addElement ('html', '<div class="formw">'. api_get_languages_combo() .'</div>');
- $form -> addElement ('html','</div><div class="sub-form">');
- $specific_fields = get_specific_field_list();
- foreach ($specific_fields as $specific_field) {
- $form -> addElement ('text', $specific_field['code'], $specific_field['name']);
- $filter = array('course_code'=> "'". api_get_course_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''. TOOL_QUIZ .'\'');
- $values = get_specific_field_values_list($filter, array('value'));
- if ( !empty($values) ) {
- $arr_str_values = array();
- foreach ($values as $value) {
- $arr_str_values[] = $value['value'];
- }
- $defaults[$specific_field['code']] = implode(', ', $arr_str_values);
- }
- }
- $form -> addElement ('html','</div>');
- }
- }
- // submit
- isset($_GET['exerciseId'])?$text=get_lang('ModifyExercise'):$text=get_lang('ProcedToQuestions');
- $form -> addElement('html', '<br /><br />');
- $form -> addElement('style_submit_button', 'submitExercise', $text, 'class="save"');
- $form -> addRule ('exerciseTitle', get_lang('GiveExerciseName'), 'required');
- if($type=='full') {
- // rules
- $form -> addRule ('exerciseAttempts', get_lang('Numeric'), 'numeric');
- $form -> addRule ('start_time', get_lang('InvalidDate'), 'date');
- $form -> addRule ('end_time', get_lang('InvalidDate'), 'date');
- $form -> addRule(array ('start_time', 'end_time'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
- }
- // defaults
- if($type=='full') {
- if($this -> id > 0) {
- if ($this -> random > $this->selectNbrQuestions()) {
- $defaults['randomQuestions'] = $this->selectNbrQuestions();
- } else {
- $defaults['randomQuestions'] = $this -> random;
- }
- $defaults['randomAnswers'] = $this ->selectRandomAnswers();
- $defaults['exerciseType'] = $this -> selectType();
- $defaults['exerciseTitle'] = $this -> selectTitle();
- $defaults['exerciseDescription'] = $this -> selectDescription();
- $defaults['exerciseAttempts'] = $this->selectAttempts();
- $defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
- $defaults['results_disabled'] = $this->selectResultsDisabled();
- if(($this -> start_time!='0000-00-00 00:00:00')||($this -> end_time!='0000-00-00 00:00:00'))
- $defaults['enabletimelimit'] = 1;
- $defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00')? $this -> start_time : date('Y-m-d 12:00:00');
- $defaults['end_time'] = ($this->end_time!='0000-00-00 00:00:00')?$this -> end_time : date('Y-m-d 12:00:00',time()+84600);
-
- //Get expired time
- if($this -> expired_time != '0') {
- $defaults['enabletimercontrol'] = 1;
- $defaults['enabletimercontroltotalminutes'] = $this -> expired_time;
- } else {
- $defaults['enabletimercontroltotalminutes'] = 0;
- }
-
- } else {
- $defaults['exerciseType'] = 2;
- $defaults['exerciseAttempts'] = 0;
- $defaults['randomQuestions'] = 0;
- $defaults['randomAnswers'] = 0;
- $defaults['exerciseDescription'] = '';
- $defaults['exerciseFeedbackType'] = 0;
- $defaults['results_disabled'] = 0;
- $defaults['start_time'] = date('Y-m-d 12:00:00');
- $defaults['end_time'] = date('Y-m-d 12:00:00',time()+84600);
- }
- } else {
- $defaults['exerciseTitle'] = $this -> selectTitle();
- $defaults['exerciseDescription'] = $this -> selectDescription();
- }
- if (api_get_setting('search_enabled') === 'true') {
- $defaults['index_document'] = 'checked="checked"';
- }
- $form -> setDefaults($defaults);
- }
- /**
- * function which process the creation of exercises
- * @param FormValidator $form the formvalidator instance
- */
- function processCreation($form,$type='')
- {
- $this -> updateTitle($form -> getSubmitValue('exerciseTitle'));
- $this -> updateDescription($form -> getSubmitValue('exerciseDescription'));
- $this -> updateAttempts($form -> getSubmitValue('exerciseAttempts'));
- $this -> updateFeedbackType($form -> getSubmitValue('exerciseFeedbackType'));
- $this -> updateType($form -> getSubmitValue('exerciseType'));
- $this -> setRandom($form -> getSubmitValue('randomQuestions'));
- $this -> updateRandomAnswers($form -> getSubmitValue('randomAnswers'));
- $this -> updateResultsDisabled($form -> getSubmitValue('results_disabled'));
- $this -> updateExpiredTime($form -> getSubmitValue('enabletimercontroltotalminutes'));
-
- if($form -> getSubmitValue('enabletimelimit')==1) {
- $start_time = $form -> getSubmitValue('start_time');
- $this->start_time = $start_time['Y'].'-'.$start_time['F'].'-'.$start_time['d'].' '.$start_time['H'].':'.$start_time['i'].':00';
- $end_time = $form -> getSubmitValue('end_time');
- $this->end_time = $end_time['Y'].'-'.$end_time['F'].'-'.$end_time['d'].' '.$end_time['H'].':'.$end_time['i'].':00';
- } else {
- $this->start_time = '0000-00-00 00:00:00';
- $this->end_time = '0000-00-00 00:00:00';
- }
- if($form -> getSubmitValue('enabletimercontrol') == 1) {
- $expired_total_time = $form -> getSubmitValue('enabletimercontroltotalminutes');
- if ($this->expired_time == 0) {
- $this->expired_time = $expired_total_time;
- }
-
- } else {
- $this->expired_time = 0;
- }
-
- if($form -> getSubmitValue('randomAnswers') == 1) {
- $this->random_answers=1;
- } else {
- $this->random_answers=0;
- }
-
- $this -> save($type);
- }
- function search_engine_save() {
- if ($_POST['index_document'] != 1) {
- return;
- }
- $course_id = api_get_course_id();
- require_once(api_get_path(LIBRARY_PATH) . 'search/DokeosIndexer.class.php');
- require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
- require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
- $specific_fields = get_specific_field_list();
- $ic_slide = new IndexableChunk();
- $all_specific_terms = '';
- foreach ($specific_fields as $specific_field) {
- if (isset($_REQUEST[$specific_field['code']])) {
- $sterms = trim($_REQUEST[$specific_field['code']]);
- if (!empty($sterms)) {
- $all_specific_terms .= ' '. $sterms;
- $sterms = explode(',', $sterms);
- foreach ($sterms as $sterm) {
- $ic_slide->addTerm(trim($sterm), $specific_field['code']);
- add_specific_field_value($specific_field['id'], $course_id, TOOL_QUIZ, $this->id, $sterm);
- }
- }
- }
- }
- // build the chunk to index
- $ic_slide->addValue("title", $this->exercise);
- $ic_slide->addCourseId($course_id);
- $ic_slide->addToolId(TOOL_QUIZ);
- $xapian_data = array(
- SE_COURSE_ID => $course_id,
- SE_TOOL_ID => TOOL_QUIZ,
- SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
- SE_USER => (int)api_get_user_id(),
- );
- $ic_slide->xapian_data = serialize($xapian_data);
- $exercise_description = $all_specific_terms .' '. $this->description;
- $ic_slide->addValue("content", $exercise_description);
- $di = new DokeosIndexer();
- isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
- $di->connectDb(NULL, NULL, $lang);
- $di->addChunk($ic_slide);
- //index and return search engine document id
- $did = $di->index();
- if ($did) {
- // save it to db
- $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
- $sql = 'INSERT INTO %s (id, course_code, tool_id, ref_id_high_level, search_did)
- VALUES (NULL , \'%s\', \'%s\', %s, %s)';
- $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id, $did);
- Database::query($sql,__FILE__,__LINE__);
- }
- }
- function search_engine_edit() {
- // update search enchine and its values table if enabled
- if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
- $course_id = api_get_course_id();
- // actually, it consists on delete terms from db, insert new ones, create a new search engine document, and remove the old one
- // get search_did
- $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
- $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
- $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id);
- $res = Database::query($sql, __FILE__, __LINE__);
- if (Database::num_rows($res) > 0) {
- require_once(api_get_path(LIBRARY_PATH) . 'search/DokeosIndexer.class.php');
- require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
- require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
- $se_ref = Database::fetch_array($res);
- $specific_fields = get_specific_field_list();
- $ic_slide = new IndexableChunk();
- $all_specific_terms = '';
- foreach ($specific_fields as $specific_field) {
- delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id);
- if (isset($_REQUEST[$specific_field['code']])) {
- $sterms = trim($_REQUEST[$specific_field['code']]);
- $all_specific_terms .= ' '. $sterms;
- $sterms = explode(',', $sterms);
- foreach ($sterms as $sterm) {
- $ic_slide->addTerm(trim($sterm), $specific_field['code']);
- add_specific_field_value($specific_field['id'], $course_id, TOOL_QUIZ, $this->id, $sterm);
- }
- }
- }
- // build the chunk to index
- $ic_slide->addValue("title", $this->exercise);
- $ic_slide->addCourseId($course_id);
- $ic_slide->addToolId(TOOL_QUIZ);
- $xapian_data = array(
- SE_COURSE_ID => $course_id,
- SE_TOOL_ID => TOOL_QUIZ,
- SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
- SE_USER => (int)api_get_user_id(),
- );
- $ic_slide->xapian_data = serialize($xapian_data);
- $exercise_description = $all_specific_terms .' '. $this->description;
- $ic_slide->addValue("content", $exercise_description);
- $di = new DokeosIndexer();
- isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
- $di->connectDb(NULL, NULL, $lang);
- $di->remove_document((int)$se_ref['search_did']);
- $di->addChunk($ic_slide);
- //index and return search engine document id
- $did = $di->index();
- if ($did) {
- // save it to db
- $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=\'%s\'';
- $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id);
- Database::query($sql,__FILE__,__LINE__);
- //var_dump($sql);
- $sql = 'INSERT INTO %s (id, course_code, tool_id, ref_id_high_level, search_did)
- VALUES (NULL , \'%s\', \'%s\', %s, %s)';
- $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id, $did);
- Database::query($sql,__FILE__,__LINE__);
- }
- }
- }
- }
- function search_engine_delete() {
- // remove from search engine if enabled
- if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) {
- $course_id = api_get_course_id();
- $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
- $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level IS NULL LIMIT 1';
- $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id);
- $res = Database::query($sql, __FILE__, __LINE__);
- if (Database::num_rows($res) > 0) {
- $row = Database::fetch_array($res);
- require_once(api_get_path(LIBRARY_PATH) .'search/DokeosIndexer.class.php');
- $di = new DokeosIndexer();
- $di->remove_document((int)$row['search_did']);
- unset($di);
- $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
- foreach ( $this->questionList as $question_i) {
- $sql = 'SELECT type FROM %s WHERE id=%s';
- $sql = sprintf($sql, $tbl_quiz_question, $question_i);
- $qres = Database::query($sql, __FILE__, __LINE__);
- if (Database::num_rows($qres) > 0) {
- $qrow = Database::fetch_array($qres);
- $objQuestion = Question::getInstance($qrow['type']);
- $objQuestion = Question::read((int)$question_i);
- $objQuestion->search_engine_edit($this->id, FALSE, TRUE);
- unset($objQuestion);
- }
- }
- }
- $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level IS NULL LIMIT 1';
- $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id);
- Database::query($sql, __FILE__, __LINE__);
- // remove terms from db
- require_once(api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php');
- delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id);
- }
- }
- function selectExpiredTime() {
- return $this->expired_time;
- }
- }
- endif;
- ?>
|