From 8a500168ae4a85fda1420667a9df2b5426867f04 Mon Sep 17 00:00:00 2001 From: Dragon Dionysius Date: Mon, 11 Mar 2019 23:36:34 +0100 Subject: [PATCH] fixes for linters and tests --- attempt.php | 3 ++- lang/en/studentquiz.php | 1 + renderer.php | 1 - tests/behat/run_quiz.feature | 45 ++++++++++++++++-------------------- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/attempt.php b/attempt.php index 34f9f79f..1c3ea253 100644 --- a/attempt.php +++ b/attempt.php @@ -243,7 +243,7 @@ if ($canfinish && ($hasnext || !$hasanswered)) { $html .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'finish', - 'value' => get_string('finish_button', 'studentquiz'), 'class' => 'btn btn-link')); + 'value' => get_string('abort_button', 'studentquiz'), 'class' => 'btn')); } $html .= html_writer::end_tag('div'); @@ -268,6 +268,7 @@ $html .= html_writer::end_tag('div'); // Output the comments. +$html .= html_writer::empty_tag('hr'); if ($hasanswered) { $comments = mod_studentquiz_get_comments_with_creators($question->id); diff --git a/lang/en/studentquiz.php b/lang/en/studentquiz.php index 8b85e54a..29bf3bc4 100644 --- a/lang/en/studentquiz.php +++ b/lang/en/studentquiz.php @@ -28,6 +28,7 @@ defined('MOODLE_INTERNAL') || die(); $string['add_comment'] = 'Add comment'; +$string['abort_button'] = 'Abort'; $string['after_answering_end_date'] = 'This StudentQuiz closed for answering on {$a}.'; $string['after_submission_end_date'] = 'This StudentQuiz closed for question submission on {$a}.'; $string['answeringndbeforestart'] = 'Answering deadline can not be specified before the open for answering date'; diff --git a/renderer.php b/renderer.php index 4f4d9ae2..146ded69 100755 --- a/renderer.php +++ b/renderer.php @@ -1398,7 +1398,6 @@ public function render_rate($questionid) { * @return string HTML fragment */ public function render_comment($cmid, $questionid, $comments, $userid, $anonymize = true, $ismoderator = false) { - return html_writer::div( html_writer::div( $this->comment_form($questionid, $cmid) diff --git a/tests/behat/run_quiz.feature b/tests/behat/run_quiz.feature index 42467939..2388c51c 100644 --- a/tests/behat/run_quiz.feature +++ b/tests/behat/run_quiz.feature @@ -40,11 +40,6 @@ Feature: Quizzes can be startet And the following "activities" exist: | activity | name | intro | course | idnumber | | studentquiz | StudentQuiz 1 | Quiz 1 description | C1 | studentquiz1 | - #And the following "questions" exist: - # | questioncategory | qtype | name | template | - # | Default for StudentQuiz 1 | truefalse | 1. Can next? | | - # | Default for StudentQuiz 1 | multichoice | 2. Can previous? | two_of_four | - # | Default for StudentQuiz 1 | numerical | 3. Can finish? | | And the following "questions" exist: | questioncategory | qtype | name | template | | Default for StudentQuiz 1 | truefalse | Exampe question | | @@ -63,44 +58,41 @@ Feature: Quizzes can be startet # QUESTION 1 mainly #Then I should see "Can next?" Then I should see "1" in the ".qno" "css_element" - And I should not see "Please Rate" + And I should not see "Please rate" # Can't navigate before answering question And "Previous" "button" should not exist And "Next" "button" should not exist - And "Finish" "button" should exist + And "Abort" "button" should exist + And "Finish" "button" should not exist # Must rate before go next When I set the field "True" to "1" And I press "Check" Then "Next" "button" should exist When I click on "Next" "button" - Then I should see "Please Rate" - # Must also rate when now trying to early finish - When I click on "Finish" "button" - Then I should see "Please Rate" + Then I should see "Please rate" + # Must also rate when now trying to early abort + When I click on "Abort" "button" + Then I should see "Please rate" When I click on ".rateable[data-rate='1']" "css_element" And I click on "Next" "button" # QUESTION 2 mainly - #Then I should see "Can previous?" Then I should see "2" in the ".qno" "css_element" - And I should not see "Please Rate" + And I should not see "Please rate" # Can navigate back when not answered yet And "Previous" "button" should exist And "Next" "button" should not exist - And "Finish" "button" should exist + And "Abort" "button" should exist + And "Finish" "button" should not exist When I click on "Previous" "button" - #Then I should see "Can next?" Then I should see "1" in the ".qno" "css_element" # Can navigate forth because already answered this question And I click on "Next" "button" - #Then I should see "Can previous?" Then I should see "2" in the ".qno" "css_element" # After answering can only navigate back after rating - #When I click on "One" "checkbox" - #And I click on "Two" "checkbox" When I set the field "False" to "1" And I press "Check" And I click on "Previous" "button" - Then I should see "Please Rate" + Then I should see "Please rate" When I click on ".rateable[data-rate='2']" "css_element" And I click on "Previous" "button" #Then I should see "Can next?" @@ -108,19 +100,22 @@ Feature: Quizzes can be startet And I click on "Next" "button" And I click on "Next" "button" # QUESTION 3 mainly - #Then I should see "Can finish?" Then I should see "3" in the ".qno" "css_element" - And I should not see "Please Rate" + And I should not see "Please rate" # When answered can only finish when rated And "Previous" "button" should exist And "Next" "button" should not exist - And "Finish" "button" should exist + And "Abort" "button" should exist + And "Finish" "button" should not exist # After answering can only finish after rating - #When I set the field "Answer:" to "3.14" When I set the field "True" to "1" And I press "Check" - And I click on "Finish" "button" - Then I should see "Please Rate" + Then "Previous" "button" should exist + And "Next" "button" should not exist + And "Abort" "button" should not exist + And "Finish" "button" should exist + When I click on "Finish" "button" + Then I should see "Please rate" When I click on ".rateable[data-rate='3']" "css_element" And I click on "Finish" "button" # Back to main view and check the result numbers