Skip to content

Commit

Permalink
CTP-3783 feedback field check
Browse files Browse the repository at this point in the history
  • Loading branch information
watson8 committed Oct 21, 2024
1 parent 91874a5 commit ac9036a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
19 changes: 9 additions & 10 deletions tests/behat/behat_mod_coursework.php
Original file line number Diff line number Diff line change
Expand Up @@ -2209,13 +2209,14 @@ public function i_have_an_assessor_feedback() {
}

/**
* @Then /^I should see the grade comment (?:as ")?(\w+)?(?:" )?in the form on the page$/
* @Then /^the grade comment textarea field matches "(?P<comment_string>(?:[^"]|\\")*)"$/
* @param string $expectedvalue
*/
public function i_should_see_the_grade_comment_in_the_form_on_the_page($expectedvalue = 'New comment here') {
$commentfield = $this->find('css', '#feedback_comment');
if ($commentfield->getValue() != $expectedvalue) {
throw new ExpectationException("Expected comment $expectedvalue got " . $commentfield->getValue(), $this->getSession());
public function the_grade_comment_textarea_field_matches($expectedvalue) {
$script = "document.querySelector('textarea#id_feedbackcomment').value;";
$actual = strip_tags(behat_base::evaluate_script_in_session($this->getSession(), $script));
if ($actual != $expectedvalue) {
throw new ExpectationException("Expected comment '$expectedvalue' got '$actual'", $this->getSession());
}
}

Expand Down Expand Up @@ -2291,15 +2292,14 @@ public function i_grade_the_submission_using_the_simple_form($grade = 56, $witho

/**
* Launch the grade submission modal and complete with grade/comment.
* @When /^I grade the submission(?: as )?(\d+)? using the ajax form( with comment "(?P<comment_string>(?:[^"]|\\")*)")?$/
* @When /^I grade the submission(?: as )?(\d+)? using the ajax form(?: with comment "(?P<comment_string>(?:[^"]|\\")*)")?$/
*
* @param int $grade
* @param string $withcomment
* @param string $comment
* @throws Behat\Mink\Exception\ElementException
* @throws Behat\Mink\Exception\ElementNotFoundException
*/
public function i_grade_the_submission_using_the_ajax_form($grade = 56, $withcomment, $comment = "New comment") {
public function i_grade_the_submission_using_the_ajax_form($grade = 56, $comment = "New comment") {
// Form loaded and sent by AJAX now so wait for it to load.
$this->wait_for_pending_js();
$this->wait_for_seconds(1);
Expand All @@ -2321,8 +2321,7 @@ public function i_grade_the_submission_using_the_ajax_form($grade = 56, $withcom
* @throws coding_exception
*/
public function i_set_the_feedback_comment_to(string $comment) {
$script = '$("textarea#id_feedbackcomment").val("' . $comment . '");';
echo "\nscript $script";
$script ="document.querySelector('textarea#id_feedbackcomment').value = '$comment'";
behat_base::execute_script_in_session($this->getSession(), $script);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/behat/feedback_final_feedback_double_marking.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Feature: Adding and editing final feedback
And I wait until the page is ready
And I wait "1" seconds
And the field "Grade" matches value "58"
And the field "Comment" matches value "New comment here"
And the grade comment textarea field matches "New comment"

@javascript
Scenario: I can be both an initial assessor and the manager who agrees grades
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/feedback_multiple_assessor_feedback.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Feature: Multiple assessors simple grading form
And I expand the coursework grading row
And I click on the only interactable link with title "Edit feedback"
And I wait until the page is ready
And the field "Comment" matches value "New comment here"
And the grade comment textarea field matches "New comment here"

@javascript
Scenario: Grades can not be edited by other teachers
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/feedback_publishing_grades.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: publishing grades to the students
And I wait until the page is ready
And I wait "1" seconds
And the field "Grade" matches value "56"
And the field "Comment" matches value "New comment here"
And the grade comment textarea field matches "New comment"
And I log out

And I log in as the student
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/feedback_single_marking.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: Adding and editing single feedback
And I wait until the page is ready
And I wait "1" seconds
And the field "Grade" matches value "56"
And the field "Comment" matches value "New comment here"
And the grade comment textarea field matches "New comment"

Scenario: I should not see the feedback icon when the submission has not been finalised
And I visit the coursework page
Expand Down

0 comments on commit ac9036a

Please sign in to comment.