Skip to content

Conversation

@opitz
Copy link
Contributor

@opitz opitz commented Dec 12, 2025

@opitz opitz requested a review from leonstr December 12, 2025 16:23
@opitz opitz self-assigned this Dec 12, 2025
Copilot AI review requested due to automatic review settings December 12, 2025 16:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive Behat test coverage for the double marking with blind marking workflow in the coursework module. The tests verify the complete marking cycle from setup through grade release, ensuring blind marking functionality works correctly with double markers and optional moderation.

Key Changes:

  • Added 897 lines of Behat test scenarios covering double-blind marking workflows
  • Implemented 27 new Behat step definitions to support the test scenarios
  • Added helper methods for managing coursework entities (allocations, submissions, feedbacks, moderations)

Reviewed changes

Copilot reviewed 2 out of 6 changed files in this pull request and generated 5 comments.

File Description
tests/behat/double_marking_blind.feature Comprehensive test scenarios for double-blind marking workflow including setup, marker allocation, submission, marking, moderation, and grade release
tests/behat/behat_mod_coursework.php New step definitions and helper methods to support double-blind marking test scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@andrewhancox andrewhancox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how other people feel but I really don't think we should be creating any more custom behat steps unless we can possibly avoid it - if anything we should be going the other way.

@leonstr
Copy link
Contributor

leonstr commented Dec 15, 2025

I'm not sure how other people feel but I really don't think we should be creating any more custom behat steps unless we can possibly avoid it - if anything we should be going the other way.

Please could you explain further? The dev docs say Sometimes, you will need to set up data that is specific to your plugin, or perform steps that are specific to your plugin's UI. In this case it may be necessary to write new step definitions – no suggestion these should be avoided.

If we're adding custom steps where there are already steps in core that do the job then I agree we shouldn't do that.

But for setting up some specific state that's not part of the thing being tested, I prefer custom steps to painfully walking through manual clicks. They're quicker to run and quicker to read.

@andrewhancox
Copy link
Collaborator

I'm not sure how other people feel but I really don't think we should be creating any more custom behat steps unless we can possibly avoid it - if anything we should be going the other way.

Please could you explain further? The dev docs say Sometimes, you will need to set up data that is specific to your plugin, or perform steps that are specific to your plugin's UI. In this case it may be necessary to write new step definitions – no suggestion these should be avoided.

Generators are the appropriate way to do setup and add far less code, most set up done by this plugin should be happening this way.
Custom behat steps that know about the DOM are very rarely necessary and we've got way too many of them already.
I would also say that if it's hard to locate an element to fire a click event, check a value etc. (e.g. the second node of this type with this ID contained in a class on the parent but only if submitted on a wednesday...) then we should just add a data attribute that can be directly targeted (@stuartlamour likes these prefixed with behat_ for clarity).

@andrewhancox
Copy link
Collaborator

Taking mod_assign as an example, there are some generators here:
mod/assign/tests/generator/behat_mod_assign_generator.php
And one custom step here:
mod/assign/tests/behat/behat_mod_assign.php

@stuartlamour
Copy link
Contributor

stuartlamour commented Dec 15, 2025

Yep - regex to get dom elements is fragile as hell, constantly breaks and needs updating.
We own the templates/html so no reason not to just add code for behat.
As @andrewhancox said best practice is to use a naming convention for this - so prefix any ids or data attributes with behat.

e.g.
id="behat-mark"
data-behat-markstage="{{markingstage}}"
data-behat-mark="finalmark"
etc ...

depending on what is appropriate.

That should make writing tests a lot simpler.

Copilot AI review requested due to automatic review settings December 15, 2025 17:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@opitz
Copy link
Contributor Author

opitz commented Dec 17, 2025

@andrewhancox @leonstr
I have created a separate story to refactor Behat steps into generator methods here: https://ucldata.atlassian.net/browse/CTP-5564
Given the fact that this story is on my plate for too long now I like to have it approved as is for now, please.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 7 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 18, 2025 12:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@leonstr leonstr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI checks for this branch currently fail so this at least needs resolving. If any of the current Behat failures are due to bugs in Coursework then those failing scenarios should be moved to pull requests fixing these bugs.

@andrewhancox
Copy link
Collaborator

Am ok if I'm losing the popular vote here but I'm still really uncomfortable with this direction - we're doubling down on weird/bad practice.
We should not be adding more weird functions here. We should be using proper behat generators and using core functions for clicks/form completion - adding behat data attributes to Dom elements if needed.
We're accumulating more technical debt here...

If it's what we need to do in the short/medium term then fair enough but I wanted to reiterate my concerns.

@opitz opitz force-pushed the CTP-4793-behat-tests branch from eb3eff1 to 23ee7dc Compare January 7, 2026 19:11
@stuartlamour stuartlamour requested a review from Copilot January 8, 2026 08:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@opitz opitz force-pushed the CTP-4793-behat-tests branch from 23ee7dc to 72dce74 Compare January 12, 2026 10:52
@opitz opitz requested review from Copilot and leonstr January 12, 2026 10:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@opitz opitz requested a review from Copilot January 12, 2026 11:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@opitz opitz requested a review from Copilot January 12, 2026 17:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@opitz opitz force-pushed the CTP-4793-behat-tests branch from c1d88de to eab83a0 Compare January 21, 2026 18:33
Copilot AI review requested due to automatic review settings January 22, 2026 10:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@opitz
Copy link
Contributor Author

opitz commented Jan 28, 2026

@leonstr @andrewhancox any chance this can be finalised?

Copy link
Contributor

@leonstr leonstr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks.

Comment on lines +2701 to +2704
$userid = $DB->get_field_sql(
"SELECT id FROM {user} WHERE firstname = ? AND lastname = ?",
[$firstname, $lastname]
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

            $userid = $DB->get_field('user', 'id', ['firstname' => $firsname, 'lastname' => $lastname]);

I want to perform the full coursework workflow with blind marking.

Background:
And the following "roles" exist:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Background should start Given followed by Ands, i.e.:

  8     Given the following "roles" exist:
        ⋮
 83     And there is a course
        ⋮
 96     And there is a coursework

# Student has extension so late submission is in time
When I am on the "Course 1" "course" page logged in as "student1"
And I follow "Coursework 1"
When I visit the coursework page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be And not When?

And I follow "Coursework 1"
Then I should see "Submission"
And I should see "In marking"
And I should not see "Edit your submission"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use But not And.

I want to perform the full coursework workflow with blind marking.

Background:
And the following "roles" exist:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Background should start Given followed by Ands, i.e.:

  7   Background:
  8     Given the following "roles" exist:
        ⋮
 83     And there is a course   
        ⋮
 96     And there is a coursework

Then I should see "Disagreed" in row "2"
When I follow "Disagreed"
And I wait until the page is ready
Then I should see "I don't like it!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be And not Then.

| Comment | I don't like it at all! |

And I am on the "Course 1" "course" page logged in as "marker1"
And I follow "Coursework 1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When?

And I follow "Agreed" in row "1"
Then I should see "Moderation for "
And I should see "Moderator 1"
And "Save changes" "button" should not exist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use But.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants