Browse Source

Remove ie6 fixes.

Julio Montoya 10 years ago
parent
commit
10143792d7

+ 5 - 13
main/exercice/global_multiple_answer.class.php

@@ -135,23 +135,15 @@ class GlobalMultipleAnswer extends Question
         // Affiche un message si le score n'est pas renseign�
         $form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required');
 
-        $navigator_info = api_get_navigator();
         global $text, $class;
 
-        //ie6 fix
         if ($obj_ex->edit_exercise_in_lp == true) {
-            if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
-                $form = new FormValidator();
-                $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers');
-                $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers');
-                $form->addButtonSave($text, 'submitQuestion');
-            } else {
-                $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers');
-                $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers');
-                $form->addButtonSave($text, 'submitQuestion');
-                // setting the save button here and not in the question class.php
-            }
+            $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers');
+            $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers');
+            $form->addButtonSave($text, 'submitQuestion');
+            // setting the save button here and not in the question class.php
         }
+
         $renderer->setElementTemplate('{element} ', 'lessAnswers');
         $renderer->setElementTemplate('{element} ', 'submitQuestion');
         $renderer->setElementTemplate('{element}', 'moreAnswers');

+ 36 - 37
main/exercice/matching.class.php

@@ -33,9 +33,8 @@ class Matching extends Question
     public function createAnswersForm($form)
     {
         $defaults = array();
-        $navigator_info = api_get_navigator();
-
         $nb_matches = $nb_options = 2;
+
         if ($form->isSubmitted()) {
             $nb_matches = $form->getSubmitValue('nb_matches');
             $nb_options = $form->getSubmitValue('nb_options');
@@ -129,16 +128,11 @@ class Matching extends Question
         $form->addHtml('</tbody></table>');
         $group = array();
 
-        if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
-            $group[] = $form->createElement('submit', 'lessMatches', get_lang('DelElem'), 'class="btn btn-default"');
-            $group[] = $form->createElement('submit', 'moreMatches', get_lang('AddElem'), 'class="btn btn-default"');
-        } else {
-            $renderer->setElementTemplate('<div class="form-group"><div class="col-sm-offset-2">{element}', 'lessMatches');
-            $renderer->setElementTemplate('{element}</div></div>', 'moreMatches');
+        $renderer->setElementTemplate('<div class="form-group"><div class="col-sm-offset-2">{element}', 'lessMatches');
+        $renderer->setElementTemplate('{element}</div></div>', 'moreMatches');
 
-            $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true);
-            $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true);
-        }
+        $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true);
+        $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true);
 
         $form->addGroup($group);
 
@@ -179,17 +173,10 @@ class Matching extends Question
         $group = array();
         global $text, $class;
 
-        if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
-            // setting the save button here and not in the question class.php
-            $group[] = $form->createElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
-            $group[] = $form->createElement('submit', 'lessOptions', get_lang('DelElem'), 'class="minus"');
-            $group[] = $form->createElement('submit', 'moreOptions', get_lang('AddElem'), 'class="plus"');
-        } else {
-            // setting the save button here and not in the question class.php
-            $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true);
-            $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true);
-            $group[] = $form->addButtonSave($text, 'submitQuestion', true);
-        }
+        // setting the save button here and not in the question class.php
+        $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true);
+        $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true);
+        $group[] = $form->addButtonSave($text, 'submitQuestion', true);
 
         $form->addGroup($group);
 
@@ -201,39 +188,50 @@ class Matching extends Question
             }
         }
 
-        $form->setConstants(array('nb_matches' => $nb_matches, 'nb_options' => $nb_options));
+        $form->setConstants(
+            array(
+                'nb_matches' => $nb_matches,
+                'nb_options' => $nb_options
+            )
+        );
     }
 
-
     /**
      * abstract function which creates the form to create / edit the answers of the question
      * @param FormValidator $form
      */
     public function processAnswersCreation($form)
     {
-        $nb_matches = $form -> getSubmitValue('nb_matches');
-        $nb_options = $form -> getSubmitValue('nb_options');
-        $this -> weighting = 0;
-        $objAnswer = new Answer($this->id);
-
+        $nb_matches = $form->getSubmitValue('nb_matches');
+        $nb_options = $form->getSubmitValue('nb_options');
+        $this->weighting = 0;
         $position = 0;
 
+        $objAnswer = new Answer($this->id);
+
         // insert the options
-        for($i=1 ; $i<=$nb_options; ++$i) {
+        for ($i = 1; $i <= $nb_options; ++$i) {
             $position++;
-            $option = $form -> getSubmitValue('option['.$i.']');
+            $option = $form->getSubmitValue('option['.$i.']');
             $objAnswer->createAnswer($option, 0, '', 0, $position);
         }
 
         // insert the answers
-        for($i=1 ; $i<=$nb_matches ; ++$i) {
+        for ($i = 1; $i <= $nb_matches; ++$i) {
             $position++;
-            $answer = $form -> getSubmitValue('answer['.$i.']');
-            $matches = $form -> getSubmitValue('matches['.$i.']');
-            $weighting = $form -> getSubmitValue('weighting['.$i.']');
-            $this -> weighting += $weighting;
-            $objAnswer->createAnswer($answer,$matches,'',$weighting,$position);
+            $answer = $form->getSubmitValue('answer['.$i.']');
+            $matches = $form->getSubmitValue('matches['.$i.']');
+            $weighting = $form->getSubmitValue('weighting['.$i.']');
+            $this->weighting += $weighting;
+            $objAnswer->createAnswer(
+                $answer,
+                $matches,
+                '',
+                $weighting,
+                $position
+            );
         }
+
         $objAnswer->save();
         $this->save();
     }
@@ -252,6 +250,7 @@ class Matching extends Question
                 <th>'.get_lang('ElementList').'</th>
                 <th>'.get_lang('CorrespondsTo').'</th>
               </tr>';
+
         return $header;
     }
 }

+ 7 - 29
main/exercice/multiple_answer_combination.class.php

@@ -148,38 +148,16 @@ class MultipleAnswerCombination extends Question
         //only 1 answer the all deal ...
         $form->addText('weighting[1]', get_lang('Score'), false, ['value' => 10]);
 
-        $navigator_info = api_get_navigator();
-
         global $text, $class;
         //ie6 fix
         if ($obj_ex->edit_exercise_in_lp == true) {
-            $buttonGroup = [];
-
-            if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
-                $buttonGroup[] = $form->createElement(
-                    'submit',
-                    'lessAnswers',
-                    '<i class="fa fa-minus"></i> '.get_lang('LessAnswer'),
-                    'class="btn btn-default"'
-                );
-                $buttonGroup[] = $form->createElement(
-                    'submit',
-                    'moreAnswers',
-                    '<i class="fa fa-plus"></i> '.get_lang('PlusAnswer'),
-                    'class="btn btn-default"'
-                );
-                $buttonGroup[] = $form->createElement(
-                    'submit',
-                    'submitQuestion',
-                    $text,
-                    'class="' . $class . '"'
-                );
-            } else {
-                // setting the save button here and not in the question class.php
-                $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
-                $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
-                $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
-            }
+
+            // setting the save button here and not in the question class.php
+            $buttonGroup = [
+                $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true),
+                $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true),
+                $form->addButtonSave($text, 'submitQuestion', true)
+            ];
 
             $form->addGroup($buttonGroup);
         }

+ 4 - 15
main/exercice/multiple_answer_true_false.class.php

@@ -213,24 +213,13 @@ class MultipleAnswerTrueFalse extends Question
             }
         }
 
-        $navigator_info = api_get_navigator();
-
         global $text, $class;
 
         if ($obj_ex->edit_exercise_in_lp == true) {
-            $buttonGroup = [];
-
-            //ie6 fix
-            if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
-                $buttonGroup[] = $form->addElement('submit', 'lessAnswers', '<i class="fa fa-plus"></i> '.get_lang('LessAnswer'), 'class="btn btn-default"');
-                $buttonGroup[] = $form->addElement('submit', 'moreAnswers', '<i class="fa fa-minus"></i> '.get_lang('PlusAnswer'), 'class="btn btn-default"');
-                $buttonGroup[] = $form->addElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
-            } else {
-                // setting the save button here and not in the question class.php
-                $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
-                $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
-                $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
-            }
+            // setting the save button here and not in the question class.php
+            $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
+            $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
+            $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
 
             $form->addGroup($buttonGroup);
         }

+ 7 - 6
main/exercice/result.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  *  Shows the exercise results
  *
@@ -12,8 +13,8 @@ if (empty($origin)) {
     $origin = $_REQUEST['origin'];
 }
 
-$id 	       = isset($_REQUEST['id']) 	  ? intval($_GET['id']) : null; //exe id
-$show_headers  = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
+$id = isset($_REQUEST['id']) ? intval($_GET['id']) : null; //exe id
+$show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
 
 if ($origin == 'learnpath') {
 	$show_headers = false;
@@ -35,9 +36,9 @@ if (empty($track_exercise_info)) {
     api_not_allowed($show_headers);
 }
 
-$exercise_id        = $track_exercise_info['exe_exo_id'];
-$student_id         = $track_exercise_info['exe_user_id'];
-$current_user_id    = api_get_user_id();
+$exercise_id = $track_exercise_info['exe_exo_id'];
+$student_id = $track_exercise_info['exe_user_id'];
+$current_user_id = api_get_user_id();
 
 $objExercise = new Exercise();
 
@@ -45,7 +46,7 @@ if (!empty($exercise_id)) {
     $objExercise->read($exercise_id);
 }
 
-//Only users can see their own results
+// Only users can see their own results
 if (!$is_allowedToEdit) {
     if ($student_id != $current_user_id) {
     	api_not_allowed($show_headers);

+ 12 - 20
main/exercice/unique_answer.class.php

@@ -266,26 +266,11 @@ class UniqueAnswer extends Question
         $buttonGroup = [];
         //ie6 fix
         if ($obj_ex->edit_exercise_in_lp == true) {
-            if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
-                $buttonGroup[] = $form->createElement(
-                    'submit',
-                    'lessAnswers',
-                    get_lang('LessAnswer'),
-                    'class="btn btn-primary"'
-                );
-                $buttonGroup[] = $form->createElement(
-                    'submit',
-                    'moreAnswers',
-                    get_lang('PlusAnswer'),
-                    'class="btn btn-primary"'
-                );
-                $buttonGroup[] = $form->createElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
-            } else {
-                //setting the save button here and not in the question class.php
-                $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
-                $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
-                $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
-            }
+
+            //setting the save button here and not in the question class.php
+            $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
+            $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
+            $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
 
             $form->addGroup($buttonGroup);
         }
@@ -484,6 +469,13 @@ class UniqueAnswer extends Question
                 '0@@0@@0@@0'
             )";
         Database::query($sql);
+
+        $id = Database::insert_id();
+        if ($id) {
+            $sql = "UPDATE $tbl_quiz_answer SET id = iid WHERE iid = $id";
+            Database::query($sql);
+        }
+
         if ($correct) {
             $sql = "UPDATE $tbl_quiz_question
                     SET ponderation = (ponderation + $score)

+ 4 - 14
main/exercice/unique_answer_no_option.class.php

@@ -244,8 +244,6 @@ class UniqueAnswerNoOption extends Question
         $form->addElement('html_editor', 'answer[' . $i . ']', null, array(), $editor_config);
 
         $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
-
-
         $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), $editor_config);
 
         //$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple');
@@ -255,23 +253,15 @@ class UniqueAnswerNoOption extends Question
         $form->addHTml('</tr>');
         $form->addHtml('</tbody></table>');
 
-        $navigator_info = api_get_navigator();
-
         $buttonGroup = [];
 
         global $text, $class;
         //ie6 fix
         if ($obj_ex->edit_exercise_in_lp == true) {
-            if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
-                $buttonGroup[] = $form->createElement('submit', 'moreAnswers','<i class="fa fa-plus"></i> '. get_lang('PlusAnswer'), 'class="btn btn-default"');
-                $buttonGroup[] = $form->createElement('submit', 'lessAnswers', '<i class="fa fa-minus"></i> '.get_lang('LessAnswer'), 'class="btn btn-default"');
-                $buttonGroup[] = $form->createElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
-            } else {
-                //setting the save button here and not in the question class.php
-                $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
-                $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
-                $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
-            }
+            //setting the save button here and not in the question class.php
+            $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
+            $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
+            $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
 
             $form->addGroup($buttonGroup);
         }

+ 1 - 7
main/exercice/upload_exercise.php

@@ -346,9 +346,6 @@ function lp_upload_quiz_action_handling() {
                             }
                         }
 
-                        //var_dump($answerValue);
-
-
                         if ($useCustomScore) {
                             if ($correct) {
                                 $score = $correctScore;
@@ -381,8 +378,6 @@ function lp_upload_quiz_action_handling() {
 
                         $total += $score;
                         $id++;
-
-                        //var_dump($score);
                     }
 
                     $objAnswer->save();
@@ -399,7 +394,6 @@ function lp_upload_quiz_action_handling() {
                             $questionObj->updateWeighting($total);
                             break;
                     }
-                    //var_dump($total);
 
                     $questionObj->save();
                 } else if ($detectQuestionType === FREE_ANSWER) {
@@ -410,7 +404,7 @@ function lp_upload_quiz_action_handling() {
                 }
             }
         }
-    // exit;
+
         if (isset($_SESSION['lpobject'])) {
             if ($debug > 0) {
                 error_log('New LP - SESSION[lpobject] is defined', 0);