From 7fa94503e9a2134b9f22cea30cbe0befd5f7ee27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Thu, 12 Feb 2009 21:44:00 +0100 Subject: [PATCH] [svn r18476] configure test buttons bar --- main/exercice/exercise.class.php | 8 +- main/exercice/multiple_answer.class.php | 434 +++++++------- main/exercice/question.class.php | 6 +- main/exercice/unique_answer.class.php | 754 ++++++++++++------------ main/inc/lib/fckeditor/myconfig.js | 68 ++- 5 files changed, 642 insertions(+), 628 deletions(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 2c8237fd99..7994348424 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 18422 2009-02-10 20:54:53Z juliomontoya $ +* @version $Id: exercise.class.php 18476 2009-02-12 20:44:00Z herodoto $ */ @@ -817,10 +817,10 @@ class Exercise $form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName'),'class="input_titles"'); // fck editor global $fck_attribute; - $fck_attribute = array(); + $fck_attribute = array(); + $fck_attribute['Width'] = '100%'; $fck_attribute['Height'] = '200px'; - $fck_attribute['Width'] = '50%'; - $fck_attribute['ToolbarSet'] = 'NewTest'; + $fck_attribute['ToolbarSet'] = 'TestDescription'; $fck_attribute['Config']['InDocument'] = false; $fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/'; diff --git a/main/exercice/multiple_answer.class.php b/main/exercice/multiple_answer.class.php index caa5318087..3d0a463eca 100644 --- a/main/exercice/multiple_answer.class.php +++ b/main/exercice/multiple_answer.class.php @@ -1,217 +1,217 @@ - type = MULTIPLE_ANSWER; - } - - /** - * function which redifines Question::createAnswersForm - * @param the formvalidator instance - * @param the answers number to display - */ - function createAnswersForm ($form) { - - global $fck_attribute; - - $fck_attribute = array(); - //$fck_attribute['Width'] = '348px'; - $fck_attribute['Width'] = '100%'; - $fck_attribute['Height'] = '100px'; - $fck_attribute['ToolbarSet'] = 'Test'; - $fck_attribute['Config']['IMUploadPath'] = 'upload/test/'; - $fck_attribute['Config']['FlashUploadPath'] = 'upload/test/'; - - $fck_attribute['Config']['InDocument'] = false; - $fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/'; - $fck_attribute['Config']['ToolbarStartExpanded']='false'; - - - $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2; - $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); - - $html=' -
-
- '.get_lang('Answers').' -
-
- - - - - - - - - '; - $form -> addElement ('html', $html); - - $defaults = array(); - $correct = 0; - if(!empty($this -> id)) - { - $answer = new Answer($this -> id); - $answer -> read(); - if(count($answer->nbrAnswers)>0 && !$form->isSubmitted()) - { - $nb_answers = $answer->nbrAnswers; - } - } - - $form -> addElement('hidden', 'nb_answers'); - $boxes_names = array(); - - for($i = 1 ; $i <= $nb_answers ; ++$i) - { - if(is_object($answer)) - { - $defaults['answer['.$i.']'] = $answer -> answer[$i]; - $defaults['comment['.$i.']'] = $answer -> comment[$i]; - $defaults['weighting['.$i.']'] = $answer -> weighting[$i]; - $defaults['correct['.$i.']'] = $answer -> correct[$i]; - } - - $renderer = & $form->defaultRenderer(); - $renderer->setElementTemplate(''); - - $answer_number=$form->addElement('text', null,null,'value="'.$i.'"'); - $answer_number->freeze(); - - $form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 0em;"'); - $boxes_names[] = 'correct['.$i.']'; - - $form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"'); - $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); - $form->addElement('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"'); - $form->addElement('text', 'weighting['.$i.']',null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="0"'); - $form -> addElement ('html', ''); - } - $form -> addElement ('html', '
- '.get_lang('Number').' - - '.get_lang('True').' - - '.get_lang('Answer').' - - '.get_lang('Comment').' - - '.get_lang('Weighting').' -
{error}
{element}
'); - - $form -> add_multiple_required_rule ($boxes_names , get_lang('ChooseAtLeastOneCheckbox') , 'multiple_required'); - - $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer')); - $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer')); - $renderer->setElementTemplate('{element} ','lessAnswers'); - $renderer->setElementTemplate('{element}','moreAnswers'); - $form -> addElement ('html', '
'); - - $defaults['correct'] = $correct; - $form -> setDefaults($defaults); - - $form->setConstants(array('nb_answers' => $nb_answers)); - - } - - - /** - * abstract function which creates the form to create / edit the answers of the question - * @param the formvalidator instance - * @param the answers number to display - */ - function processAnswersCreation($form) { - - $questionWeighting = $nbrGoodAnswers = 0; - - $objAnswer = new Answer($this->id); - - $nb_answers = $form -> getSubmitValue('nb_answers'); - - for($i=1 ; $i <= $nb_answers ; $i++) - { - $answer = trim($form -> getSubmitValue('answer['.$i.']')); - $comment = trim($form -> getSubmitValue('comment['.$i.']')); - $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); - $goodAnswer = trim($form -> getSubmitValue('correct['.$i.']')); - - if($goodAnswer){ - $weighting = abs($weighting); - } - else{ - $weighting = abs($weighting); - $weighting = -$weighting; - } - if($weighting > 0) - { - $questionWeighting += $weighting; - } - - $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i); - - } - - // saves the answers into the data base - $objAnswer -> save(); - - // sets the total weighting of the question - $this -> updateWeighting($questionWeighting); - $this -> save(); - - } - -} - -endif; -?> + type = MULTIPLE_ANSWER; + } + + /** + * function which redifines Question::createAnswersForm + * @param the formvalidator instance + * @param the answers number to display + */ + function createAnswersForm ($form) { + + global $fck_attribute; + + $fck_attribute = array(); + //$fck_attribute['Width'] = '348px'; + $fck_attribute['Width'] = '100%'; + $fck_attribute['Height'] = '100px'; + $fck_attribute['ToolbarSet'] = 'Answer'; + $fck_attribute['Config']['IMUploadPath'] = 'upload/test/'; + $fck_attribute['Config']['FlashUploadPath'] = 'upload/test/'; + + $fck_attribute['Config']['InDocument'] = false; + $fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/'; + $fck_attribute['Config']['ToolbarStartExpanded']='false'; + + + $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2; + $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); + + $html=' +
+
+ '.get_lang('Answers').' +
+
+ + + + + + + + + '; + $form -> addElement ('html', $html); + + $defaults = array(); + $correct = 0; + if(!empty($this -> id)) + { + $answer = new Answer($this -> id); + $answer -> read(); + if(count($answer->nbrAnswers)>0 && !$form->isSubmitted()) + { + $nb_answers = $answer->nbrAnswers; + } + } + + $form -> addElement('hidden', 'nb_answers'); + $boxes_names = array(); + + for($i = 1 ; $i <= $nb_answers ; ++$i) + { + if(is_object($answer)) + { + $defaults['answer['.$i.']'] = $answer -> answer[$i]; + $defaults['comment['.$i.']'] = $answer -> comment[$i]; + $defaults['weighting['.$i.']'] = $answer -> weighting[$i]; + $defaults['correct['.$i.']'] = $answer -> correct[$i]; + } + + $renderer = & $form->defaultRenderer(); + $renderer->setElementTemplate(''); + + $answer_number=$form->addElement('text', null,null,'value="'.$i.'"'); + $answer_number->freeze(); + + $form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 0em;"'); + $boxes_names[] = 'correct['.$i.']'; + + $form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"'); + $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); + $form->addElement('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"'); + $form->addElement('text', 'weighting['.$i.']',null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="0"'); + $form -> addElement ('html', ''); + } + $form -> addElement ('html', '
+ '.get_lang('Number').' + + '.get_lang('True').' + + '.get_lang('Answer').' + + '.get_lang('Comment').' + + '.get_lang('Weighting').' +
{error}
{element}
'); + + $form -> add_multiple_required_rule ($boxes_names , get_lang('ChooseAtLeastOneCheckbox') , 'multiple_required'); + + $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer')); + $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer')); + $renderer->setElementTemplate('{element} ','lessAnswers'); + $renderer->setElementTemplate('{element}','moreAnswers'); + $form -> addElement ('html', '
'); + + $defaults['correct'] = $correct; + $form -> setDefaults($defaults); + + $form->setConstants(array('nb_answers' => $nb_answers)); + + } + + + /** + * abstract function which creates the form to create / edit the answers of the question + * @param the formvalidator instance + * @param the answers number to display + */ + function processAnswersCreation($form) { + + $questionWeighting = $nbrGoodAnswers = 0; + + $objAnswer = new Answer($this->id); + + $nb_answers = $form -> getSubmitValue('nb_answers'); + + for($i=1 ; $i <= $nb_answers ; $i++) + { + $answer = trim($form -> getSubmitValue('answer['.$i.']')); + $comment = trim($form -> getSubmitValue('comment['.$i.']')); + $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); + $goodAnswer = trim($form -> getSubmitValue('correct['.$i.']')); + + if($goodAnswer){ + $weighting = abs($weighting); + } + else{ + $weighting = abs($weighting); + $weighting = -$weighting; + } + if($weighting > 0) + { + $questionWeighting += $weighting; + } + + $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i); + + } + + // saves the answers into the data base + $objAnswer -> save(); + + // sets the total weighting of the question + $this -> updateWeighting($questionWeighting); + $this -> save(); + + } + +} + +endif; +?> \ No newline at end of file diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index c692237f51..31acb91cda 100644 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1,4 +1,4 @@ - type = UNIQUE_ANSWER; - } - - /** - * function which redifines Question::createAnswersForm - * @param the formvalidator instance - * @param the answers number to display - */ - function createAnswersForm ($form) { - // getting the exercise list - $obj_ex =$_SESSION['objExercise']; - // multiple - global $fck_attribute; - - $fck_attribute = array(); - $fck_attribute['Width'] = '50%'; - $fck_attribute['Height'] = '125px'; - - $fck_attribute['ToolbarSet'] = 'Test'; - $fck_attribute['Config']['IMUploadPath'] = 'upload/test/'; - $fck_attribute['Config']['FlashUploadPath'] = 'upload/test/'; - $fck_attribute['Config']['InDocument'] = false; - $fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/'; - // we collapse the fckeditor toolbar - $fck_attribute['Config']['ToolbarStartExpanded']='false'; - - //this line define how many question by default appear when creating a choice question - $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4; - $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); - - /* - Types of Feedback - $feedback_option[0]=get_lang('Feedback'); - $feedback_option[1]=get_lang('DirectFeedback'); - $feedback_option[2]=get_lang('NoFeedback'); - */ - - $feedback_title=''; - $comment_title=''; - - if ($obj_ex->selectFeedbackType()==0) { - $comment_title = ''.get_lang('Comment').''; - } elseif ($obj_ex->selectFeedbackType()==1) { - $fck_attribute['Width'] = '250px'; - $fck_attribute['Height'] = '110px'; - $comment_title = ''.get_lang('Comment').''; - $feedback_title = ''.get_lang('Scenario').''; - } - - $html=' -
-
- '.get_lang('Answers').' -
-
- - - - - - '.$comment_title.' - '.$feedback_title.' - - '; - - $form -> addElement ('html', $html); - - $defaults = array(); - $correct = 0; - if(!empty($this -> id)) { - $answer = new Answer($this -> id); - $answer -> read(); - if(count($answer->nbrAnswers)>0 && !$form->isSubmitted()) - { - $nb_answers = $answer->nbrAnswers; - } - } - $form -> addElement('hidden', 'nb_answers'); - - //Feedback SELECT - $question_list=$obj_ex->selectQuestionList(); - $select_question=array(); - $select_question[0]=get_lang('SelectTargetQuestion'); - require_once('../newscorm/learnpathList.class.php'); - require_once(api_get_path(LIBRARY_PATH).'text.lib.php'); - - - foreach ($question_list as $key=>$questionid) { - $question = Question::read($questionid); - $select_question[$questionid]='Q'.$key.' :'.cut($question->selectTitle(),20); - } - $select_question[-1]=get_lang('ExitTest'); - - //LP SELECT - require_once('../newscorm/learnpathList.class.php'); - //require_once('../newscorm/learnpath.class.php'); - //require_once('../newscorm/learnpathItem.class.php'); - - $list = new LearnpathList(api_get_user_id()); - $flat_list = $list->get_flat_list(); - $select_lp_id=array(); - $select_lp_id[0]=get_lang('SelectTargetLP'); - - foreach ($flat_list as $id => $details) - { - $select_lp_id[$id] = cut($details['lp_name'],20); - } - - $temp_scenario=array(); - for($i = 1 ; $i <= $nb_answers ; ++$i) - { - $form -> addElement ('html', ''); - if(is_object($answer)) - { - if($answer -> correct[$i]) - { - $correct = $i; - } - - $defaults['answer['.$i.']'] = $answer -> answer[$i]; - $defaults['comment['.$i.']'] = $answer -> comment[$i]; - $defaults['weighting['.$i.']'] = $answer -> weighting[$i]; - - $item_list=explode('@@',$answer -> destination[$i]); - //echo '
';	print_r($item_list);
-				
-				$try = $item_list[0];
-				$lp = $item_list[1];
-				$list_dest= $item_list[2];
-				$url=$item_list[3];
-				
-				if ($try==0)
-					$try_result=0;
-				else
-					$try_result=1;
-					
-				if ($url==0)					
-					$url_result='';
-				else
-					$url_result=$url;
-				
-				$temp_scenario['url'.$i]=$url_result;
-				$temp_scenario['try'.$i]=$try_result;			
-				$temp_scenario['lp'.$i]=$lp;
-				$temp_scenario['destination'.$i]=$list_dest;							
-								
-				
-				/*$pre_list_destination=explode(';',$list_dest);
-				$list_destination=array();						
-				foreach($pre_list_destination as $value)
-				{
-					$list_destination[]=$value;		
-				}
-				$defaults['destination'.$i]=$list_destination;
-				*/
-				//$defaults['destination'.$i] = $list_destination;		
-			}
-			else
-			{
-				$temp_scenario['destination'.$i] = array('0');
-				$temp_scenario['lp'.$i] = array('0');
-				//$defaults['scenario']
-			}			
-			$defaults['scenario']=$temp_scenario;	
-				
-			$renderer = & $form->defaultRenderer();			
-			$renderer->setElementTemplate('
'); - $answer_number=$form->addElement('text', null,null,'value="'.$i.'"'); - $answer_number->freeze(); - - $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"'); - $form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"'); - $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); - - if ($obj_ex->selectFeedbackType()==0) // feedback - $form->addElement('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"'); - elseif ($obj_ex->selectFeedbackType()==1) // direct feedback - { - $form->addElement('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"'); - //Adding extra feedback fields - $group = array(); - $group['try'.$i] =&$form->createElement('checkbox', 'try'.$i,get_lang('TryAgain').': ' ); - $group['lp'.$i] =&$form->createElement('select', 'lp'.$i,get_lang('SeeTheory').': ',$select_lp_id); - $group['destination'.$i]=&$form->createElement('select', 'destination'.$i, get_lang('GoToQuestion').': ' ,$select_question); - $group['url'.$i] =&$form->createElement('text', 'url'.$i,get_lang('Other').': ',array('size'=>'25px')); - - $form -> addGroup($group, 'scenario', 'scenario'); - $renderer->setGroupElementTemplate('
{label}
{element}
','scenario'); - } - - //$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple'); - - $form->addElement('text', 'weighting['.$i.']',null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="0"'); - $form -> addElement ('html', ''); - } - - $form -> addElement ('html', '
- '.get_lang('Number').' - - '.get_lang('True').' - - '.get_lang('Answer').' - - '.get_lang('Weighting').' -
{error}
{element}
'); - - $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer')); - $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer')); - - $renderer->setElementTemplate('{element} ','lessAnswers'); - $renderer->setElementTemplate('{element}','moreAnswers'); - - $form -> addElement ('html', '
'); - - //We check the first radio button to be sure a radio button will be check - if($correct==0){ - $correct=1; - } - $defaults['correct'] = $correct; - $form -> setDefaults($defaults); - - $form->setConstants(array('nb_answers' => $nb_answers)); - - } - - - /** - * abstract function which creates the form to create / edit the answers of the question - * @param the formvalidator instance - * @param the answers number to display - */ - function processAnswersCreation($form) { - - $questionWeighting = $nbrGoodAnswers = 0; - $correct = $form -> getSubmitValue('correct'); - $objAnswer = new Answer($this->id); - $nb_answers = $form -> getSubmitValue('nb_answers'); - - for($i=1 ; $i <= $nb_answers ; $i++) - { - $answer = trim($form -> getSubmitValue('answer['.$i.']')); - $comment = trim($form -> getSubmitValue('comment['.$i.']')); - $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); - - $scenario= $form -> getSubmitValue('scenario'); - - echo '
';
-           	//$list_destination = $form -> getSubmitValue('destination'.$i);
-           	//$destination_str = $form -> getSubmitValue('destination'.$i);
-           	 
- 		    $try = $scenario['try'.$i];
-            $lp= $scenario['lp'.$i];       
- 			$destination = $scenario['destination'.$i]; 		
- 			$url = trim($scenario['url'.$i]); 			
- 			 			
- 			/*
- 			How we are going to parse the destination value
- 			
-			here we parse the destination value which is a string 
-		 	1@@3@@2;4;4;@@http://www.dokeos.com
-		 	
-		 	where: try_again@@lp_id@@selected_questions@@url	
-		 		
-			try_again = is 1 || 0
-			lp_id = id of a learning path (0 if dont select)
-			selected_questions= ids of questions 
-			url= an url			
-			*/
-			/*	
- 			$destination_str='';
- 			foreach ($list_destination as $destination_id)
- 			{
- 				$destination_str.=$destination_id.';';
- 			}*/
- 		 	 
-        	$goodAnswer= ($correct == $i) ? true : false;
-
-        	if($goodAnswer)
-        	{
-        		$nbrGoodAnswers++;
-        		$weighting = abs($weighting); 
-        		if($weighting > 0)
-                {
-                    $questionWeighting += $weighting;
-                }
-        	}
-        	
- 			if (empty($try))
- 				$try=0;
- 				
- 			if (empty($lp))
- 			{
- 				$lp=0;
- 			}
- 			
- 			if (empty($destination))
- 			{
- 				$destination=0;
- 			}
- 			
- 			
- 			
- 			if ($url=='')
- 			{
- 				$url=0;
- 			}
- 			
- 			//1@@1;2;@@2;4;4;@@http://www.dokeos.com
-			$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
-        	$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
-        	
-        }
-        
-	
-    	// saves the answers into the data base
-        $objAnswer -> save();
-
-        // sets the total weighting of the question
-        $this -> updateWeighting($questionWeighting);
-        $this -> save();
- 
-	}
-}
-endif;
-?>
+ type = UNIQUE_ANSWER;
+	}
+
+	/**
+	 * function which redifines Question::createAnswersForm
+	 * @param the formvalidator instance
+	 * @param the answers number to display
+	 */
+	function createAnswersForm ($form) {
+		// getting the exercise list	
+		$obj_ex =$_SESSION['objExercise'];
+		// multiple 
+		global $fck_attribute;
+
+		$fck_attribute = array();
+		$fck_attribute['Width'] = '50%';
+		$fck_attribute['Height'] = '125px';
+		
+		$fck_attribute['ToolbarSet'] = 'Answer';
+		$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
+		$fck_attribute['Config']['FlashUploadPath'] = 'upload/test/';
+		$fck_attribute['Config']['InDocument'] = false;		
+		$fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/';
+		// we collapse the fckeditor toolbar
+		$fck_attribute['Config']['ToolbarStartExpanded']='false';		
+		
+		//this line define how many question by default appear when creating a choice question
+		$nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4;
+		$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
+		
+		/*
+	 		Types of Feedback
+	 		$feedback_option[0]=get_lang('Feedback');
+			$feedback_option[1]=get_lang('DirectFeedback');
+			$feedback_option[2]=get_lang('NoFeedback');
+	 	*/
+	 
+		$feedback_title='';
+		$comment_title='';
+		
+		if ($obj_ex->selectFeedbackType()==0) {
+			$comment_title = ''.get_lang('Comment').'';			
+		} elseif ($obj_ex->selectFeedbackType()==1) {						
+			$fck_attribute['Width'] = '250px';
+			$fck_attribute['Height'] = '110px';			
+			$comment_title = ''.get_lang('Comment').'';
+			$feedback_title = ''.get_lang('Scenario').'';			
+		} 
+		
+		$html='
+		
+
+ '.get_lang('Answers').' +
+
+ + + + + + '.$comment_title.' + '.$feedback_title.' + + '; + + $form -> addElement ('html', $html); + + $defaults = array(); + $correct = 0; + if(!empty($this -> id)) { + $answer = new Answer($this -> id); + $answer -> read(); + if(count($answer->nbrAnswers)>0 && !$form->isSubmitted()) + { + $nb_answers = $answer->nbrAnswers; + } + } + $form -> addElement('hidden', 'nb_answers'); + + //Feedback SELECT + $question_list=$obj_ex->selectQuestionList(); + $select_question=array(); + $select_question[0]=get_lang('SelectTargetQuestion'); + require_once('../newscorm/learnpathList.class.php'); + require_once(api_get_path(LIBRARY_PATH).'text.lib.php'); + + + foreach ($question_list as $key=>$questionid) { + $question = Question::read($questionid); + $select_question[$questionid]='Q'.$key.' :'.cut($question->selectTitle(),20); + } + $select_question[-1]=get_lang('ExitTest'); + + //LP SELECT + require_once('../newscorm/learnpathList.class.php'); + //require_once('../newscorm/learnpath.class.php'); + //require_once('../newscorm/learnpathItem.class.php'); + + $list = new LearnpathList(api_get_user_id()); + $flat_list = $list->get_flat_list(); + $select_lp_id=array(); + $select_lp_id[0]=get_lang('SelectTargetLP'); + + foreach ($flat_list as $id => $details) + { + $select_lp_id[$id] = cut($details['lp_name'],20); + } + + $temp_scenario=array(); + for($i = 1 ; $i <= $nb_answers ; ++$i) + { + $form -> addElement ('html', ''); + if(is_object($answer)) + { + if($answer -> correct[$i]) + { + $correct = $i; + } + + $defaults['answer['.$i.']'] = $answer -> answer[$i]; + $defaults['comment['.$i.']'] = $answer -> comment[$i]; + $defaults['weighting['.$i.']'] = $answer -> weighting[$i]; + + $item_list=explode('@@',$answer -> destination[$i]); + //echo '
';	print_r($item_list);
+				
+				$try = $item_list[0];
+				$lp = $item_list[1];
+				$list_dest= $item_list[2];
+				$url=$item_list[3];
+				
+				if ($try==0)
+					$try_result=0;
+				else
+					$try_result=1;
+					
+				if ($url==0)					
+					$url_result='';
+				else
+					$url_result=$url;
+				
+				$temp_scenario['url'.$i]=$url_result;
+				$temp_scenario['try'.$i]=$try_result;			
+				$temp_scenario['lp'.$i]=$lp;
+				$temp_scenario['destination'.$i]=$list_dest;							
+								
+				
+				/*$pre_list_destination=explode(';',$list_dest);
+				$list_destination=array();						
+				foreach($pre_list_destination as $value)
+				{
+					$list_destination[]=$value;		
+				}
+				$defaults['destination'.$i]=$list_destination;
+				*/
+				//$defaults['destination'.$i] = $list_destination;		
+			}
+			else
+			{
+				$temp_scenario['destination'.$i] = array('0');
+				$temp_scenario['lp'.$i] = array('0');
+				//$defaults['scenario']
+			}			
+			$defaults['scenario']=$temp_scenario;	
+				
+			$renderer = & $form->defaultRenderer();			
+			$renderer->setElementTemplate('
'); + $answer_number=$form->addElement('text', null,null,'value="'.$i.'"'); + $answer_number->freeze(); + + $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"'); + $form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"'); + $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); + + if ($obj_ex->selectFeedbackType()==0) // feedback + $form->addElement('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"'); + elseif ($obj_ex->selectFeedbackType()==1) // direct feedback + { + $form->addElement('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"'); + //Adding extra feedback fields + $group = array(); + $group['try'.$i] =&$form->createElement('checkbox', 'try'.$i,get_lang('TryAgain').': ' ); + $group['lp'.$i] =&$form->createElement('select', 'lp'.$i,get_lang('SeeTheory').': ',$select_lp_id); + $group['destination'.$i]=&$form->createElement('select', 'destination'.$i, get_lang('GoToQuestion').': ' ,$select_question); + $group['url'.$i] =&$form->createElement('text', 'url'.$i,get_lang('Other').': ',array('size'=>'25px')); + + $form -> addGroup($group, 'scenario', 'scenario'); + $renderer->setGroupElementTemplate('
{label}
{element}
','scenario'); + } + + //$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple'); + + $form->addElement('text', 'weighting['.$i.']',null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="0"'); + $form -> addElement ('html', ''); + } + + $form -> addElement ('html', '
+ '.get_lang('Number').' + + '.get_lang('True').' + + '.get_lang('Answer').' + + '.get_lang('Weighting').' +
{error}
{element}
'); + + $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer')); + $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer')); + + $renderer->setElementTemplate('{element} ','lessAnswers'); + $renderer->setElementTemplate('{element}','moreAnswers'); + + $form -> addElement ('html', '
'); + + //We check the first radio button to be sure a radio button will be check + if($correct==0){ + $correct=1; + } + $defaults['correct'] = $correct; + $form -> setDefaults($defaults); + + $form->setConstants(array('nb_answers' => $nb_answers)); + + } + + + /** + * abstract function which creates the form to create / edit the answers of the question + * @param the formvalidator instance + * @param the answers number to display + */ + function processAnswersCreation($form) { + + $questionWeighting = $nbrGoodAnswers = 0; + $correct = $form -> getSubmitValue('correct'); + $objAnswer = new Answer($this->id); + $nb_answers = $form -> getSubmitValue('nb_answers'); + + for($i=1 ; $i <= $nb_answers ; $i++) + { + $answer = trim($form -> getSubmitValue('answer['.$i.']')); + $comment = trim($form -> getSubmitValue('comment['.$i.']')); + $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); + + $scenario= $form -> getSubmitValue('scenario'); + + echo '
';
+           	//$list_destination = $form -> getSubmitValue('destination'.$i);
+           	//$destination_str = $form -> getSubmitValue('destination'.$i);
+           	 
+ 		    $try = $scenario['try'.$i];
+            $lp= $scenario['lp'.$i];       
+ 			$destination = $scenario['destination'.$i]; 		
+ 			$url = trim($scenario['url'.$i]); 			
+ 			 			
+ 			/*
+ 			How we are going to parse the destination value
+ 			
+			here we parse the destination value which is a string 
+		 	1@@3@@2;4;4;@@http://www.dokeos.com
+		 	
+		 	where: try_again@@lp_id@@selected_questions@@url	
+		 		
+			try_again = is 1 || 0
+			lp_id = id of a learning path (0 if dont select)
+			selected_questions= ids of questions 
+			url= an url			
+			*/
+			/*	
+ 			$destination_str='';
+ 			foreach ($list_destination as $destination_id)
+ 			{
+ 				$destination_str.=$destination_id.';';
+ 			}*/
+ 		 	 
+        	$goodAnswer= ($correct == $i) ? true : false;
+
+        	if($goodAnswer)
+        	{
+        		$nbrGoodAnswers++;
+        		$weighting = abs($weighting); 
+        		if($weighting > 0)
+                {
+                    $questionWeighting += $weighting;
+                }
+        	}
+        	
+ 			if (empty($try))
+ 				$try=0;
+ 				
+ 			if (empty($lp))
+ 			{
+ 				$lp=0;
+ 			}
+ 			
+ 			if (empty($destination))
+ 			{
+ 				$destination=0;
+ 			}
+ 			
+ 			
+ 			
+ 			if ($url=='')
+ 			{
+ 				$url=0;
+ 			}
+ 			
+ 			//1@@1;2;@@2;4;4;@@http://www.dokeos.com
+			$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
+        	$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
+        	
+        }
+        
+	
+    	// saves the answers into the data base
+        $objAnswer -> save();
+
+        // sets the total weighting of the question
+        $this -> updateWeighting($questionWeighting);
+        $this -> save();
+ 
+	}
+}
+endif;
+?>
\ No newline at end of file
diff --git a/main/inc/lib/fckeditor/myconfig.js b/main/inc/lib/fckeditor/myconfig.js
index 8f4f367e5c..f69e925465 100644
--- a/main/inc/lib/fckeditor/myconfig.js
+++ b/main/inc/lib/fckeditor/myconfig.js
@@ -25,17 +25,8 @@
  * Editor's toolbar definitions.
  */
 
-FCKConfig.ToolbarSets["Question"] = [
-	['Source','DocProps','-','NewPage','Preview','-'],
-	['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
-	['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
-	['OrderedList','UnorderedList','-','Outdent','Indent'],
-	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
-	['Link','Unlink','Anchor'],
-	['Image','Flash','MP3','Table','Rule','Smiley','SpecialChar','UniversalKey'],
-	['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
-	'/',
-	['Style','FontFormat','FontName','FontSize'],['Attachment']
+FCKConfig.ToolbarSets["Full"] = [
+	['FitWindow','PasteWord','Link','Unlink','Anchor','-','Image','flvPlayer','Flash','EmbedMovies','MP3','YouTube','Table','Rule','-','Subscript', 'Superscript','-','OrderedList','UnorderedList','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],'/',['FontFormat','Style','FontName','FontSize','Bold','Italic','Underline','StrikeThrough','TextColor', 'BGColor','-','Source']
 ] ;
 
 FCKConfig.ToolbarSets["Middle"] = [
@@ -46,26 +37,10 @@ FCKConfig.ToolbarSets["Small"] = [
 	['Bold','Italic','Underline','StrikeThrough','Link','Unlink','Image','Flash','OrderedList','UnorderedList','Table']
 ] ;
 
-FCKConfig.ToolbarSets["Full"] = [
-	['FitWindow','PasteWord','Link','Unlink','Anchor','-','Image','flvPlayer','Flash','EmbedMovies','MP3','YouTube','Table','Rule','-','Subscript', 'Superscript','-','OrderedList','UnorderedList','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],'/',['FontFormat','Style','FontName','FontSize','Bold','Italic','Underline','StrikeThrough','TextColor', 'BGColor','-','Source']
-] ;
-
 FCKConfig.ToolbarSets["Comment"] = [
 	['Bold','Italic','Underline','StrikeThrough']
 ] ;
 
-FCKConfig.ToolbarSets["NewTest"] = [
-	['Bold','Italic','Underline','StrikeThrough','Link','Unlink','Image','Flash','MP3','OrderedList','UnorderedList','Table','Source']
-] ;
-
-FCKConfig.ToolbarSets["TestComment"] = [
-	['FontName','FontSize','TextColor','BGColor'],['Bold','Italic','Underline','StrikeThrough','Subscript', 'Superscript','Link','Unlink','Image','Flash','MP3','OrderedList','UnorderedList','Table','Source']
-] ;
-
-FCKConfig.ToolbarSets["Test"] = [
-	['Bold','Italic','Underline','StrikeThrough','Subscript','Superscript','Link','Unlink','Image','MP3','OrderedList','UnorderedList','Table']
-] ;
-
 FCKConfig.ToolbarSets["Profil"] = [
 	['FitWindow','PasteWord','Undo','Redo'],
 	['Link','Image','imgmapPopup','flvPlayer','Flash','EmbedMovies','YouTube','Table','googlemaps'],
@@ -78,6 +53,7 @@ FCKConfig.ToolbarSets["Messages"] = [
 	['Bold','Italic','Underline','OrderedList','UnorderedList','TextColor','-','Source']
 ] ;
 
+//Course introduction
 FCKConfig.ToolbarSets["Introduction"] = [
 	['NewPage','Templates','Preview','FitWindow','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat','-','Find'],
 	['Link','Unlink','Anchor'],
@@ -89,6 +65,7 @@ FCKConfig.ToolbarSets["Introduction"] = [
 	['Source']
 ] ;
 
+//Agenda
 FCKConfig.ToolbarSets["Agenda"] = [
 	['FitWindow','-','PasteWord','-','Undo','Redo','RemoveFormat'],
 	['Link','Unlink'],
@@ -111,6 +88,7 @@ FCKConfig.ToolbarSets["Agenda_Student"] = [
 	['ShowBlocks']
 ] ;
 
+//Announcements
 FCKConfig.ToolbarSets["Announcements"] = [
 	['NewPage','Preview','FitWindow','-','PasteText','-','Undo','Redo','-','SelectAll','RemoveFormat'],
 	['Link','Unlink','Anchor'],
@@ -133,6 +111,7 @@ FCKConfig.ToolbarSets["Announcements_Student"] = [
 	['ShowBlocks']
 ] ;
 
+//Blog
 FCKConfig.ToolbarSets["Blog"] = [
 	['FitWindow','-','PasteWord','-','Undo','Redo','-','RemoveFormat'],
 	['Link','Unlink','Anchor'],
@@ -175,6 +154,7 @@ FCKConfig.ToolbarSets["BlogComment_Student"] = [
 	['ShowBlocks']
 ] ;
 
+//Course Description
 FCKConfig.ToolbarSets["CourseDescription"] = [
 	['NewPage','Templates','Save','PageBreak','Preview','FitWindow','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat','-','Find'],
 	['Link','Unlink','Anchor'],
@@ -186,6 +166,7 @@ FCKConfig.ToolbarSets["CourseDescription"] = [
 	['Source']
 ] ;
 
+//Documents
 FCKConfig.ToolbarSets["Documents"] = [
 	['NewPage','Templates','Save','PageBreak','Preview','FitWindow','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat','-','Find'],
 	['Link','Unlink','Anchor'],
@@ -208,6 +189,7 @@ FCKConfig.ToolbarSets["Documents_Student"] = [
 	['ShowBlocks']
 ] ;
 
+//Forum
 FCKConfig.ToolbarSets["ForumLight"] = [
 	['Bold','Italic','Underline','StrikeThrough']
 ] ;
@@ -234,6 +216,7 @@ FCKConfig.ToolbarSets["Forum_Student"] = [
 	['ShowBlocks']
 ] ;
 
+//Glossary
 FCKConfig.ToolbarSets["Glossary"] = [
 	['NewPage','Save','FitWindow','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat','-','Find'],
 	['Link','Unlink','Anchor'],
@@ -245,6 +228,7 @@ FCKConfig.ToolbarSets["Glossary"] = [
 	['Source']
 ] ;
 
+//Learning Path
 FCKConfig.ToolbarSets["LearnPath"] = [
 	['NewPage','Templates','PageBreak','Preview','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat','-','Find'],
 	['Link','Unlink','Anchor'],
@@ -256,6 +240,7 @@ FCKConfig.ToolbarSets["LearnPath"] = [
 	['Source']
 ] ;//save, FitWindow don't run well here
 
+//Notebook
 FCKConfig.ToolbarSets["Notebook"] = [
 	['NewPage','Save','FitWindow','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat','-','Find'],
 	['Link','Unlink','Anchor'],
@@ -278,6 +263,7 @@ FCKConfig.ToolbarSets["Notebook_Student"] = [
 	['ShowBlocks']
 ] ;
 
+//Survey
 FCKConfig.ToolbarSets["Survey"] = [
 	['FitWindow'],
 	['Link','Unlink'],
@@ -289,6 +275,34 @@ FCKConfig.ToolbarSets["Survey"] = [
 	['Source']
 ] ;
 
+//Test
+FCKConfig.ToolbarSets["TestDescription"] = [
+	['NewPage','Preview','FitWindow','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat'],
+	['Link','Unlink'],
+	['Image','imgmapPopup','flvPlayer','Flash','EmbedMovies','YouTube','MP3'],
+	['Table','Rule','Smiley','SpecialChar','googlemaps'],
+	['FontName','FontSize'],
+	['Bold','Italic','Underline'],
+	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','-','OrderedList','UnorderedList','-','Outdent','Indent','-','TextColor','BGColor'],
+	['Source']
+] ;
+
+FCKConfig.ToolbarSets["QuestionDescription"] = [
+	['NewPage','Preview','FitWindow','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat'],
+	['Link','Unlink'],
+	['Image','imgmapPopup','flvPlayer','Flash','EmbedMovies','YouTube','MP3'],
+	['Table','Rule','Smiley','SpecialChar','googlemaps'],
+	['FontName','FontSize'],
+	['Bold','Italic','Underline'],
+	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','-','OrderedList','UnorderedList','-','Outdent','Indent','-','TextColor','BGColor'],
+	['Source']
+] ;
+
+FCKConfig.ToolbarSets["Answer"] = [
+	['FitWindow','Link','Unlink','Image','flvPlayer','Table','Bold','Italic','TextColor','Source']
+] ;
+
+//Wiki
 FCKConfig.ToolbarSets["Wiki"] = [
 	['NewPage','Templates','Save','PageBreak','Preview','FitWindow','-','PasteText','PasteWord','-','Undo','Redo','-','SelectAll','RemoveFormat','-','Find'],
 	['Wikilink','Link','Unlink','Anchor'],