瀏覽代碼

#4074 - Add a text at the end of a test - ref #4074

- ref #4074
Hubert Borderiou 13 年之前
父節點
當前提交
885d3aaea4

+ 39 - 7
main/exercice/exercise.class.php

@@ -6,6 +6,7 @@
  * @author Olivier Brouckaert
  * @author Julio Montoya Cleaning exercises
  * Modified by Hubert Borderiou 2011-10-21 (question category)
+ * Add text when finished : ALTER TABLE c_quiz ADD text_when_finished TEXT AFTER random_by_category
  */
 /**
  * Code
@@ -51,6 +52,7 @@ class Exercise {
 	public $propagate_neg;
 	public $review_answers; //
 	public $randomByCat;
+	public $text_when_finished; //  
 
 	 
 	/**
@@ -76,6 +78,7 @@ class Exercise {
 		$this->propagate_neg    = 0;
 		$this->review_answers	= false;
 		$this->randomByCat      = 0;	//
+		$this->text_when_finished = ""; // 
 
 		if (!empty($course_id)) {			
 			$course_info        =  api_get_course_info_by_id($course_id);
@@ -116,7 +119,8 @@ class Exercise {
 			$this->attempts 		= $object->max_attempt;
 			$this->feedbacktype 	= $object->feedback_type;
 			$this->propagate_neg    = $object->propagate_neg;
-			$this->randomByCat = $object->random_by_category; //
+			$this->randomByCat      = $object->random_by_category; //
+			$this->text_when_finished = $object->text_when_finished; // 
 		
 			$this->review_answers   = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;  
 			
@@ -237,6 +241,23 @@ class Exercise {
 		return $this->type;
 	}
 
+	/**
+	 * @author - hubert borderiou 28-11-11
+	 * @return - html text : the text to display ay the end of the test.
+	 */
+	function selectTextWhenFinished() {
+		return $this->text_when_finished;
+
+	}
+
+	/**
+	 * @author - hubert borderiou 28-11-11
+	 * @return - html text : update the text to display ay the end of the test.
+	 */  
+	function updateTextWhenFinished($in_txt) {
+		$this->text_when_finished = $in_txt;
+	}
+
 
 	/**
 	 * return 1 or 2 if randomByCat 
@@ -608,7 +629,8 @@ class Exercise {
 		$active 		= $this->active;
 		$propagate_neg  = $this->propagate_neg;
 		$review_answers = (isset($this->review_answers) && $this->review_answers) ? 1 : 0;
-		$randomByCat = $this->randomByCat; //
+		$randomByCat    = $this->randomByCat; //
+		$text_when_finished = Security::remove_XSS($this->text_when_finished, COURSEMANAGER); // 
 		
 		$session_id 	= api_get_session_id();
 		 
@@ -642,7 +664,8 @@ class Exercise {
      			    expired_time   ='".Database::escape_string($expired_time)."',
          			propagate_neg  ='".Database::escape_string($propagate_neg)."',
          			review_answers  ='".Database::escape_string($review_answers)."',
-        	        random_by_category	='".Database::escape_string($randomByCat)."',
+        	        random_by_category='".Database::escape_string($randomByCat)."',
+        	        text_when_finished = '".Database::escape_string($text_when_finished)."',
 					results_disabled='".Database::escape_string($results_disabled)."'";
 			}
 			
@@ -657,7 +680,7 @@ class Exercise {
 			}
 		} else {
 			// creates a new exercise
-			$sql="INSERT INTO $TBL_EXERCICES (c_id, start_time, end_time, title, description, sound, type, random, random_answers, active, results_disabled, max_attempt, feedback_type, expired_time, session_id, review_answers, random_by_category)
+			$sql="INSERT INTO $TBL_EXERCICES (c_id, start_time, end_time, title, description, sound, type, random, random_answers, active, results_disabled, max_attempt, feedback_type, expired_time, session_id, review_answers, random_by_category, text_when_finished)
 					VALUES(
 						".$this->course_id.",
 						'$start_time','$end_time',
@@ -674,7 +697,8 @@ class Exercise {
 						'".Database::escape_string($expired_time)."',
 						'".Database::escape_string($session_id)."',
 						'".Database::escape_string($review_answers)."',
-						'".Database::escape_string($randomByCat)."'
+						'".Database::escape_string($randomByCat)."',
+						'".Database::escape_string($text_when_finished)."'
 						)";
 			Database::query($sql);
 			$this->id = Database::insert_id();
@@ -985,9 +1009,14 @@ class Exercise {
 			}
 
 			$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'));
-								
+						
+			// add the text_when_finished textbox 
+			$form -> add_html_editor('text_when_finished', get_lang('TextWhenFinished'), false, false, $editor_config);
+											
 			$defaults = array();
 
 			if (api_get_setting('search_enabled') === 'true') {
@@ -1052,7 +1081,8 @@ class Exercise {
 				$defaults['propagate_neg'] = $this->selectPropagateNeg();
 				$defaults['review_answers'] = $this->review_answers;
 				$defaults['randomByCat'] = $this->selectRandomByCat(); //
-
+                $defaults['text_when_finished'] = $this->selectTextWhenFinished(); // 
+                
 				if (($this->start_time!='0000-00-00 00:00:00'))
 				$defaults['activate_start_date_check'] = 1;
 				if ($this->end_time!='0000-00-00 00:00:00')
@@ -1077,6 +1107,7 @@ class Exercise {
 				$defaults['exerciseFeedbackType'] = 0;
 				$defaults['results_disabled'] = 0;
 				$defaults['randomByCat'] = 0;	// 
+				$defaults['text_when_finished'] = ""; // 
 				$defaults['start_time'] = date('Y-m-d 12:00:00');
 				$defaults['end_time']   = date('Y-m-d 12:00:00',time()+84600);
 			}
@@ -1107,6 +1138,7 @@ class Exercise {
 		$this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
 		$this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
 		$this->updateRandomByCat($form->getSubmitValue('randomByCat'));			//
+		$this->updateTextWhenFinished($form->getSubmitValue('text_when_finished')); // 
 		$this->updateReviewAnswers($form->getSubmitValue('review_answers'));
 
 		if ($form->getSubmitValue('activate_start_date_check') == 1) {

+ 7 - 1
main/exercice/exercise_result.php

@@ -115,7 +115,6 @@ if (!empty($exercise_stat_info['data_tracking'])) {
 	$question_list		= explode(',', $exercise_stat_info['data_tracking']);
 }
 
-
 $safe_lp_id              = $exercise_stat_info['orig_lp_id'];
 $safe_lp_item_id         = $exercise_stat_info['orig_lp_item_id'];
 $safe_lp_item_view_id    = $exercise_stat_info['orig_lp_item_view_id'];
@@ -154,6 +153,13 @@ if ($show_results || $show_only_score) {
 
 Display :: display_confirmation_message(get_lang('Saved').'<br />',false);
 
+// Display text when test is finished #4074
+echo "<div class='normal-message'>";
+echo $objExercise->selectTextWhenFinished();
+echo "</div>";
+echo "<div class='clear'>&nbsp;</div>";
+//
+
 $counter = 1;
 // Loop over all question to show results for each of them, one by one
 if (!empty($question_list)) {

+ 1 - 0
main/inc/lib/add_course.lib.inc.php

@@ -713,6 +713,7 @@ function update_Db_course($course_db_name = null) {
         propagate_neg INT NOT NULL DEFAULT 0,
         review_answers INT NOT NULL DEFAULT 0,
         random_by_category INT NOT NULL DEFAULT 0,
+        text_when_finished TEXT default NULL,
         PRIMARY KEY (c_id, id)
         )" . $charset_clause;
     Database::query($sql);

+ 1 - 1
main/install/migrate-db-1.8.8-1.9.0-pre.sql

@@ -148,4 +148,4 @@ ALTER TABLE quiz ADD COLUMN review_answers INT NOT NULL DEFAULT 0;
 ALTER TABLE student_publication ADD COLUMN contains_file INTEGER NOT NULL DEFAULT 1;
 ALTER TABLE student_publication ADD COLUMN allow_text_assignment INTEGER NOT NULL DEFAULT 0;
 ALTER TABLE quiz ADD COLUMN random_by_category INT NOT NULL DEFAULT 0;
-
+ALTER TABLE quiz ADD text_when_finished TEXT default NULL;