Răsfoiți Sursa

Fixing question forms

Julio Montoya 13 ani în urmă
părinte
comite
d816379899

+ 36 - 46
main/exercice/fill_blanks.class.php

@@ -78,9 +78,7 @@ class FillBlanks extends Question
 		}
 
 		// javascript
-
-		echo '
-		<script type="text/javascript">
+		echo '<script type="text/javascript">
 			function FCKeditor_OnComplete( editorInstance )
 			{
 				if (window.attachEvent) {
@@ -90,52 +88,44 @@ class FillBlanks extends Question
 				}
 
 			}
-
-		var firstTime = true;
-		function updateBlanks()
-		{
-			if (firstTime) {
-				field = document.getElementById("answer");
-				var answer = field.value; }
-			else {
-				var oEditor = FCKeditorAPI.GetInstance(\'answer\');
-				answer =  oEditor.GetXHTML( true ) ;
-			}
-
-			var blanks = answer.match(/\[[^\]]*\]/g);
-
-			var fields = "<div class=\"row\"><div class=\"label\">'.get_lang('Weighting').'</div><div class=\"formw\"><table>";
-			if(blanks!=null){
-				for(i=0 ; i<blanks.length ; i++){
-					if(document.getElementById("weighting["+i+"]"))
-						value = document.getElementById("weighting["+i+"]").value;
-					else
-						value = "10";
-					fields += "<tr><td>"+blanks[i]+"</td><td><input style=\"margin-left: 0em;\" size=\"5\" value=\""+value+"\" type=\"text\" id=\"weighting["+i+"]\" name=\"weighting["+i+"]\" /></td></tr>";
-
-				}
-			}
-			document.getElementById("blanks_weighting").innerHTML = fields + "</table></div></div>";
-			if(firstTime){
-				firstTime = false;
+            var firstTime = true;
+            function updateBlanks() {
+                if (firstTime) {
+                    field = document.getElementById("answer");
+                    var answer = field.value; }
+                else {
+                    var oEditor = FCKeditorAPI.GetInstance(\'answer\');
+                    answer =  oEditor.GetXHTML( true ) ;
+                }
+
+                var blanks = answer.match(/\[[^\]]*\]/g);
+                var fields = "<div class=\"control-group\"><label class=\"control-label\">'.get_lang('Weighting').'</label><div class=\"controls\"><table>";
+                if(blanks!=null){
+                    for(i=0 ; i<blanks.length ; i++){
+                        if(document.getElementById("weighting["+i+"]"))
+                            value = document.getElementById("weighting["+i+"]").value;
+                        else
+                            value = "10";
+                        fields += "<tr><td>"+blanks[i]+"</td><td><input style=\"margin-left: 0em;\" size=\"5\" value=\""+value+"\" type=\"text\" id=\"weighting["+i+"]\" name=\"weighting["+i+"]\" /></td></tr>";
+
+                    }
+                }
+                document.getElementById("blanks_weighting").innerHTML = fields + "</table></div></div>";
+                if(firstTime){
+                    firstTime = false;
 			';
-
-		if(count($a_weightings)>0)
-		{
-			foreach($a_weightings as $i=>$weighting)
-			{
-				echo 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";';
-			}
-		}
-		echo '}
-		}
-		window.onload = updateBlanks;
-		</script>
-		';
-
+            if(count($a_weightings)>0) {
+                foreach($a_weightings as $i=>$weighting) {
+                    echo 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";';
+                }
+            }
+            echo '}
+            }
+            window.onload = updateBlanks;
+		</script>';
 
 		// answer
-		$form -> addElement ('html', '<br /><br /><div class="row"><div class="label"></div><div class="formw">'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank').'</div></div>');
+		$form -> addElement ('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank'));
 		$form -> addElement ('html_editor', 'answer', '<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
 
 		$form -> addRule ('answer',get_lang('GiveText'),'required');

+ 7 - 19
main/exercice/matching.class.php

@@ -89,14 +89,7 @@ class Matching extends Question {
 		$form -> addElement('hidden', 'nb_options', $nb_options);
 
 		// DISPLAY MATCHES
-		$html='
-		<div class="row">
-			<div class="label">
-			'.get_lang('Answers').' <br /> <img src="../img/fill_field.png">
-			</div>
-			<div class="formw">
-				'.get_lang('MakeCorrespond').'
-				<table class="data_table">
+		$html='<table class="data_table">
 					<tr>
 						<th width="10px">
 							'.get_lang('Number').'
@@ -110,9 +103,9 @@ class Matching extends Question {
 						<th width="50px">
 							'.get_lang('Weighting').'
 						</th>
-
 					</tr>';
-		$form -> addElement ('html', $html);
+        
+		$form -> addElement ('label', get_lang('MakeCorrespond').'<br /> <img src="../img/fill_field.png">', $html);
 		
 		if ($nb_matches < 1) {
 			$nb_matches = 1;
@@ -146,13 +139,8 @@ class Matching extends Question {
 
 		$form -> addGroup($group);
 
-		// DISPLAY OPTIONS ////
-		$html='
-		<div class="row">
-			<div class="label">
-			</div>
-			<div class="formw"><br /><br />
-				<table class="data_table">
+		// DISPLAY OPTIONS
+		$html='<table class="data_table">
 					<tr style="text-align: center;">
 						<th width="10px">
 							'.get_lang('Number').'
@@ -160,9 +148,9 @@ class Matching extends Question {
 						<th width="90%"
 							'.get_lang('Answer').'
 						</th>
-
 					</tr>';
-		$form -> addElement ('html', $html);
+		//$form -> addElement ('html', $html);
+        $form -> addElement ('label', null, $html);
 
 		if ($nb_options < 1) {
 			$nb_options = 1;

+ 2 - 8
main/exercice/multiple_answer.class.php

@@ -46,13 +46,7 @@ class MultipleAnswer extends Question {
 
 		$obj_ex = $_SESSION['objExercise'];
 
-		$html='
-		<div class="row">
-			<div class="label">
-			'.get_lang('Answers').'<br /><img src="../img/fill_field.png">
-			</div>
-			<div class="formw">
-				<table class="data_table">
+		$html='<table class="data_table">
 					<tr>
 						<th width="10px">
 							'.get_lang('Number').'
@@ -73,7 +67,7 @@ class MultipleAnswer extends Question {
 							'.get_lang('Weighting').'
 						</th>
 					</tr>';
-		$form -> addElement ('html', $html);
+		$form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
 
 		$defaults = array();
 		$correct = 0;

+ 2 - 9
main/exercice/multiple_answer_combination.class.php

@@ -44,13 +44,7 @@ class MultipleAnswerCombination extends Question {
 		$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
 		$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
 		$obj_ex = $_SESSION['objExercise'];
-		$html='
-		<div class="row">
-			<div class="label">
-			'.get_lang('Answers').'<br /><img src="../img/fill_field.png">
-			</div>
-			<div class="formw">
-				<table class="data_table">
+		$html= '<table class="data_table">
 					<tr style="text-align: center;">
 						<th width="10px">
 							'.get_lang('Number').'
@@ -66,8 +60,7 @@ class MultipleAnswerCombination extends Question {
 							$html .='<th>'.get_lang('Comment').'</th>';
 						}
 						$html .= '</tr>';
-					
-		$form -> addElement ('html', $html);
+        $form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
 
 		$defaults = array();
 		$correct = 0;

+ 3 - 17
main/exercice/multiple_answer_true_false.class.php

@@ -42,19 +42,7 @@ class MultipleAnswerTrueFalse extends Question {
 		$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
 
 		$obj_ex = $_SESSION['objExercise'];
-        
-		$html.='<div class="row">
-			     <div class="label">
-			         '.get_lang('Answers').'<br /><img src="../img/fill_field.png">
-			     </div>
-			     <div class="formw">';        
-        
-        $html2 ='<div class="row">
-                 <div class="label">               
-                 </div>
-                 <div class="formw">';
-        
-        $form -> addElement ('html', $html2);        
+                
         $form -> addElement ('html', '<table><tr>');  
         $renderer = & $form->defaultRenderer();
         $defaults = array();
@@ -77,8 +65,7 @@ class MultipleAnswerTrueFalse extends Question {
         $form -> addElement('hidden', 'options_count', 3);
                     
         $form -> addElement ('html', '</tr></table>');
-        $form -> addElement ('html', '</div></div>');
-       
+               
 		$html.='<table class="data_table">
 					<tr style="text-align: center;">
 						<th>
@@ -98,8 +85,7 @@ class MultipleAnswerTrueFalse extends Question {
         				    $html .='<th>'.get_lang('Comment').'</th>';
         				}
 				$html .= '</tr>';
-		$form -> addElement ('html', $html);
-
+        $form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
 		
 		$correct = 0;
 		if (!empty($this -> id))	{

+ 24 - 30
main/exercice/unique_answer.class.php

@@ -72,32 +72,26 @@ class UniqueAnswer extends Question {
 			$feedback_title = '<th width="350px" >'.get_lang('Scenario').'</th>';
 		}
 
-		$html='
-		<div class="row">
-			<div class="label">
-			'.get_lang('Answers').' <br /> <img src="../img/fill_field.png">
-			</div>
-			<div class="formw">
-				<table class="data_table">
-					<tr style="text-align: center;">
-						<th width="10px">
-							'.get_lang('Number').'
-						</th>
-						<th width="10px" >
-							'.get_lang('True').'
-						</th>
-						<th width="50%">
-							'.get_lang('Answer').'
-						</th>
-							'.$comment_title.'
-							'.$feedback_title.'
-						<th width="50px">
-							'.get_lang('Weighting').'
-						</th>        
-					</tr>';
-
-		$form -> addElement ('html', $html);
-
+		$html='<table class="data_table">
+                <tr style="text-align: center;">
+                    <th width="10px">
+                        '.get_lang('Number').'
+                    </th>
+                    <th width="10px" >
+                        '.get_lang('True').'
+                    </th>
+                    <th width="50%">
+                        '.get_lang('Answer').'
+                    </th>
+                        '.$comment_title.'
+                        '.$feedback_title.'
+                    <th width="50px">
+                        '.get_lang('Weighting').'
+                    </th>        
+                </tr>';
+
+        $form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
+		
 		$defaults = array();
 		$correct = 0;
 		if(!empty($this -> id)) {
@@ -219,7 +213,6 @@ class UniqueAnswer extends Question {
                 $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'lp'.$i);
                 $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'try'.$i);
                 
-
                 $form -> addGroup($group, 'scenario', 'scenario');
                 $renderer->setGroupElementTemplate('<div class="exercise_scenario_label">{label}</div><div class="exercise_scenario_element">{element}</div>','scenario');
             }
@@ -228,7 +221,8 @@ class UniqueAnswer extends Question {
         }
 
 		$form -> addElement ('html', '</table>');
-		$form -> addElement ('html', '<br />');
+		$form -> addElement ('html', '<br />');        
+        
 		$navigator_info = api_get_navigator();
 
 		global $text, $class, $show_quiz_edition;
@@ -248,8 +242,8 @@ class UniqueAnswer extends Question {
 		$renderer->setElementTemplate('{element}&nbsp;','submitQuestion');
 		$renderer->setElementTemplate('{element}&nbsp;','lessAnswers');
 		$renderer->setElementTemplate('{element}&nbsp;','moreAnswers');
-
-		$form -> addElement ('html', '</div></div>');
+        
+        $form -> addElement ('html', '</div></div>');
 
 		//We check the first radio button to be sure a radio button will be check
 		if ($correct==0) {

+ 2 - 9
main/exercice/unique_answer_no_option.class.php

@@ -73,13 +73,7 @@ class UniqueAnswerNoOption extends Question {
 			$feedback_title = '<th width="350px" >'.get_lang('Scenario').'</th>';
 		}
 
-		$html='
-		<div class="row">
-			<div class="label">
-			'.get_lang('Answers').' <br /> <img src="../img/fill_field.png">
-			</div>
-			<div class="formw">
-				<table class="data_table">
+		$html='<table class="data_table">
 					<tr style="text-align: center;">
 						<th width="10px">
 							'.get_lang('Number').'
@@ -96,8 +90,7 @@ class UniqueAnswerNoOption extends Question {
 							'.get_lang('Weighting').'
 						</th>        
 					</tr>';
-
-		$form -> addElement ('html', $html);
+        $form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
 
 		$defaults = array();
 		$correct = 0;