Преглед на файлове

[svn r18422] If a DirectFeedback exercise is created and have questions registered, we can't edit the evaluation type or the exercise type (see FS#3612)

Julio Montoya преди 16 години
родител
ревизия
3346c11ae2
променени са 2 файла, в които са добавени 31 реда и са изтрити 12 реда
  1. 26 10
      main/exercice/exercise.class.php
  2. 5 2
      main/exercice/exercise_admin.php

+ 26 - 10
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 18235 2009-02-04 16:34:55Z juliomontoya $
+* 	@version $Id: exercise.class.php 18422 2009-02-10 20:54:53Z juliomontoya $
 */
 
 
@@ -833,15 +833,31 @@ class Exercise
 			$feedback_option[0]=get_lang('Feedback');
 			$feedback_option[1]=get_lang('DirectFeedback');
 			$feedback_option[2]=get_lang('NoFeedback');
-			
-			$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'), '<br />');
-							
+						
+			//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('SimpleExercise'),'1');
+				$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
+				$form -> addGroup($radios, null, get_lang('ExerciseType'), '<br />');							
+			} 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'), '<br />');					
+				} else {
+					//we force the options to the DirectFeedback exercisetype
+					$form -> addElement('hidden', 'exerciseFeedbackType','1');
+					$form -> addElement('hidden', 'exerciseType','2');
+				}				
+			}
+										
 			$form -> addElement('html','<div class="row">
 				<div class="label">&nbsp;</div>
 				<div class="formw">

+ 5 - 2
main/exercice/exercise_admin.php

@@ -5,7 +5,7 @@
 
 	Copyright (c) 2004-2009 Dokeos SPRL
 
-		For a full list of contributors, see "credits.txt".
+	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
@@ -99,6 +99,7 @@ if(isset($_GET['exerciseId'])) {
 	$form = new FormValidator('exercise_admin');
 	$form -> addElement ('hidden','edit','false');
 }
+
 $objExercise -> createForm ($form);
 
 
@@ -118,7 +119,9 @@ if($form -> validate()) {
 	 *********************/
 	$nameTools=get_lang('ExerciseManagement');
 	$interbreadcrumb[] = array ("url"=>"exercice.php", "name"=> get_lang('Exercices'));
-	Display::display_header($nameTools,"Exercise");
+	Display::display_header($nameTools,"Exercise");	
+	if ($objExercise->feedbacktype==1)
+		Display::display_normal_message(get_lang("DirectFeedbackCantModifyTypeQuestion"));
 	$form -> display ();
 }
 Display::display_footer();