Browse Source

Add exercise review test BT#16144

Julio Montoya 5 years ago
parent
commit
ebffa82e01

+ 6 - 1
main/exercise/exercise_show.php

@@ -669,7 +669,12 @@ foreach ($questionList as $questionId) {
 
                 $formMark = new FormValidator('marksform_'.$questionId, 'post');
                 $formMark->addHeader(get_lang('AssignMarks'));
-                $select = $formMark->addSelect('marks', get_lang('AssignMarks'), [], ['disable_js' => true]);
+                $select = $formMark->addSelect(
+                    'marks',
+                    get_lang('AssignMarks'),
+                    [],
+                    ['disable_js' => true, 'extra_class' => 'grade_select']
+                );
                 $model = ExerciseLib::getCourseScoreModel();
                 if (empty($model)) {
                     for ($i = 0; $i <= $questionWeighting; $i++) {

+ 5 - 0
main/inc/lib/pear/HTML/QuickForm/select.php

@@ -87,6 +87,11 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
                 $attributes['data-live-search'] = '';
             }
 
+            if (isset($attributes['extra_class']) && $attributes['extra_class']) {
+                $attributes['class'] .= ' '.$attributes['extra_class'];
+                unset($attributes['extra_class']);
+            }
+
             if (isset($attributes['placeholder'])) {
                 $addBlank =  $attributes['placeholder'];
             }

+ 13 - 0
tests/behat/features/bootstrap/FeatureContext.php

@@ -414,6 +414,19 @@ class FeatureContext extends MinkContext
         ");
     }
 
+    /**
+     * @When /^(?:|I )fill in select "(?P<field>(?:[^"]|\\")*)" with option value "(?P<value>(?:[^"]|\\")*)" with class "(?P<id>(?:[^"]|\\")*)"$/
+     */
+    public function iFillInSelectWithOptionValue($field, $value, $class)
+    {
+        $this->getSession()->wait(1000);
+        $this->getSession()->executeScript("
+            var input = $('$field').filter('$class');
+            var id = input.attr('id');
+            var input = $('#'+id);            
+            input.val($value);
+        ");
+    }
 
     /**
      * @When /^wait for the page to be loaded$/

+ 10 - 1
tests/behat/features/toolExercise.feature

@@ -324,9 +324,18 @@ Feature: Exercise tool
     And I follow "Edit"
     And I follow "Results and feedback"
     Then I should see "Learner score"
-    And wait for the page to be loaded
+    And wait very long for the page to be loaded
     And I follow "Grade activity"
     Then I should see "Score for the test: 83 / 117"
+    And I press "Edit individual feedback and grade the open question"
+    And I should see "Assign a grade"
+    And I fill the only ckeditor in the page with "open question teacher answer"
+    And I fill in select "select[name=marks]" with option value "10" with class ".grade_select"
+    Then I press "Correct test"
+    And wait very long for the page to be loaded
+    And I follow "Edit"
+    Then I should see "open question teacher answer"
+    And I should see "Score for the test: 93 / 117"
 
   Scenario: Create a session "Session Exercise" and add user "acostea"
     Given I am on "/main/session/session_add.php"