[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

skala
Cristian Fasanando 17 years ago
parent 5a4ae2ce6c
commit 374af6cb2d
  1. 7
      main/exercice/exercice.php
  2. 19
      main/exercice/exercise.class.php
  3. 35
      main/exercice/question.class.php

@ -1,4 +1,4 @@
<?php // $Id: exercice.php 17605 2009-01-08 22:29:28Z cfasanando $
<?php // $Id: exercice.php 17741 2009-01-15 17:36:02Z cfasanando $
/*
==============================================================================
@ -423,10 +423,7 @@ if ($is_allowedToEdit) {
case 'enable': // enables an exercise
$objExerciseTmp->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;

@ -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();
}

@ -1,4 +1,4 @@
<?php // $Id: question.class.php 17609 2009-01-09 00:28:59Z marvil07 $
<?php // $Id: question.class.php 17741 2009-01-15 17:36:02Z cfasanando $
/*
==============================================================================
@ -28,7 +28,7 @@
* File containing the Question class.
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: question.class.php 17609 2009-01-09 00:28:59Z marvil07 $
* @version $Id: question.class.php 17741 2009-01-15 17:36:02Z cfasanando $
*/
@ -552,8 +552,11 @@ abstract class Question
*/
function save($exerciseId=0)
{
global $TBL_QUESTIONS, $TBL_EXERCICE_QUESTION, $_course;
global $_course,$_user;
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$id=$this->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']);
}
}

Loading…
Cancel
Save