From 374af6cb2df652dd9ac65a5beba7231eab853ce9 Mon Sep 17 00:00:00 2001 From: Cristian Fasanando Date: Thu, 15 Jan 2009 18:36:02 +0100 Subject: [PATCH] [svn r17741] Logic Changes - Added information stored in the item_property table when creating, updating and deleting a quiz or a question - see FS#3417 --- main/exercice/exercice.php | 7 ++----- main/exercice/exercise.class.php | 19 +++++++++++------ main/exercice/question.class.php | 35 ++++++++++++++++++++++---------- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index 52ebcfb6d7..4ca37cc8de 100644 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -1,4 +1,4 @@ -enable(); $objExerciseTmp->save(); - - // "WHAT'S NEW" notification: update table item_property (previously last_tooledit) - api_item_property_update($_course, TOOL_QUIZ, $exerciseId, "QuizAdded", $_user['user_id']); - + // "WHAT'S NEW" notification: update table item_property (previously last_tooledit) Display::display_confirmation_message(get_lang('VisibilityChanged')); break; diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 20b4b4a271..d967b6ca02 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -25,7 +25,7 @@ * Exercise class: This class allows to instantiate an object of type Exercise * @package dokeos.exercise * @author Olivier Brouckaert -* @version $Id: exercise.class.php 17609 2009-01-09 00:28:59Z marvil07 $ +* @version $Id: exercise.class.php 17741 2009-01-15 17:36:02Z cfasanando $ */ @@ -461,10 +461,10 @@ class Exercise */ function save() { + 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=addslashes($this->exercise); $description=addslashes($this->description); @@ -491,7 +491,10 @@ class Exercise "results_disabled='".Database::escape_string($results_disabled)."' WHERE id='".Database::escape_string($id)."'"; api_sql_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(); } @@ -514,8 +517,10 @@ class Exercise )"; api_sql_query($sql,__FILE__,__LINE__); - $this->id=mysql_insert_id(); - + $this->id=mysql_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') { $this -> search_engine_save(); } @@ -757,10 +762,12 @@ class Exercise * @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)."'"; api_sql_query($sql); - + api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizDeleted',$_user['user_id']); + if (api_get_setting('search_enabled')=='true') { $this -> search_engine_delete(); } diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index 0d9f7b98b1..7a001f7807 100644 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1,4 +1,4 @@ -id; $question=addslashes($this->question); $description=addslashes($this->description); @@ -562,8 +565,8 @@ abstract class Question $type=$this->type; $picture=addslashes($this->picture); - // question already exists - if($id) + // question already exists + if(!empty($id)) { $sql="UPDATE $TBL_QUESTIONS SET question ='".Database::escape_string($question)."', @@ -574,7 +577,9 @@ abstract class Question picture ='".Database::escape_string($picture)."' WHERE id='".Database::escape_string($id)."'"; api_sql_query($sql,__FILE__,__LINE__); - + if(!empty($exerciseId)) { + api_item_property_update($_course, TOOL_QUIZ, $id,'QuizQuestionUpdated',$_user['user_id']); + } if (api_get_setting('search_enabled')=='true') { if ($exerciseId != 0) { $this -> search_engine_edit($exerciseId); @@ -608,7 +613,9 @@ abstract class Question api_sql_query($sql,__FILE__,__LINE__); $this->id=mysql_insert_id(); - + + api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizQuestionAdded',$_user['user_id']); + // If hotspot, create first answer if ($type == HOT_SPOT || $type == HOT_SPOT_ORDER) { $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER); @@ -838,8 +845,12 @@ abstract class Question */ function delete($deleteFromEx=0) { - global $TBL_EXERCICE_QUESTION, $TBL_QUESTIONS, $TBL_REPONSES; - + global $_course,$_user; + + $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); + $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); + $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER); + $id=$this->id; // if the question must be removed from all exercises @@ -864,7 +875,8 @@ abstract class Question $sql="DELETE FROM $TBL_REPONSES WHERE question_id='".Database::escape_string($id)."'"; api_sql_query($sql,__FILE__,__LINE__); - + + api_item_property_update($_course, TOOL_QUIZ, $id,'QuizQuestionDeleted',$_user['user_id']); $this->removePicture(); // resets the object @@ -878,6 +890,7 @@ abstract class Question // disassociate question with this exercise $this -> search_engine_edit($deleteFromEx, FALSE, TRUE); } + api_item_property_update($_course, TOOL_QUIZ, $id,'QuizQuestionDeleted',$_user['user_id']); } }