From c56ae661af0a80afa18629bc35dd9a331f0ee8b3 Mon Sep 17 00:00:00 2001 From: watson8 <14983002+watson8@users.noreply.github.com> Date: Mon, 2 Sep 2024 13:51:09 +0100 Subject: [PATCH 01/27] CTP-3762 add missing upgrade savepoint (#10) --- db/upgrade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/db/upgrade.php b/db/upgrade.php index de358995..11960664 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -1649,6 +1649,7 @@ function xmldb_coursework_upgrade($oldversion) { if ($oldversion < 2014090200) { $DB->execute("UPDATE {coursework} SET moderationenabled = 0"); + upgrade_mod_savepoint(true, 2014090200, 'coursework'); } if ($oldversion < 2014090801) { From bf95d97280b078b756366dae8042d81b46c68d85 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:24:50 +0100 Subject: [PATCH 02/27] CTP-3560 behat indentation --- ...ion_automatic_allocations_disabled.feature | 26 +-- ...tomatic_equal_assessor_allocations.feature | 59 +++---- ...nteracting_with_manual_allocations.feature | 55 +++--- ...ic_percentage_assessor_allocations.feature | 66 ++++--- ...cation_manual_assessor_allocations.feature | 88 +++++----- ...ibility_of_all_students_capability.feature | 8 - ...n_visibility_of_allocated_students.feature | 40 ++--- ...n_visibility_of_allocated_teachers.feature | 24 +-- tests/behat/automatic_agreement.feature | 77 ++++----- ..._agreed_graders_with_blind_marking.feature | 45 +++-- ...reed_graders_without_blind_marking.feature | 46 ++--- ...ty_for_teachers_with_blind_marking.feature | 65 ++++--- ...for_teachers_without_blind_marking.feature | 55 +++--- tests/behat/deadline_extension.feature | 4 +- ...ine_extension_reason_dropdown_list.feature | 5 +- tests/behat/enrolment_triggers.feature | 29 ++-- tests/behat/factory.feature | 129 +++++++------- ...feedback_auto_release_without_cron.feature | 37 ++-- tests/behat/feedback_collisions.feature | 82 ++++----- ...dit_feedback_within_specified_time.feature | 15 +- tests/behat/feedback_files.feature | 59 ++++--- ...back_final_feedback_double_marking.feature | 100 ++++++----- tests/behat/feedback_general_feedback.feature | 109 ++++++------ ...edback_group_feedback_for_students.feature | 70 ++++---- tests/behat/feedback_group_marking.feature | 44 ++--- ...eedback_multiple_assessor_feedback.feature | 159 +++++++++-------- .../behat/feedback_publishing_grades.feature | 76 ++++---- ...feedback_restrict_feedback_editing.feature | 7 - tests/behat/feedback_rubrics.feature | 81 +++++---- tests/behat/feedback_single_marking.feature | 73 ++++---- tests/behat/feedback_zero_grades.feature | 32 ++-- tests/behat/installation_and_set_up.feature | 35 ++-- .../behat/sampling_automatic_sampling.feature | 23 +-- tests/behat/sampling_manual_sampling.feature | 89 +++++----- .../sampling_sample_range_set_rules.feature | 20 +-- ...submissions_agree_submission_terms.feature | 163 +++++++++--------- .../submissions_auto_finalisation.feature | 29 ++-- tests/behat/submissions_deadlines.feature | 42 ++--- .../submissions_early_finalisation.feature | 81 ++++----- .../submissions_file_upload_limit.feature | 25 ++- .../submissions_file_upload_types.feature | 48 +++--- .../submissions_group_submissions.feature | 72 ++++---- .../submissions_late_submissions.feature | 41 +++-- tests/behat/submissions_start_date.feature | 37 ++-- .../submissions_student_submission.feature | 58 +++---- ...ubmissions_submit_onbehalf_student.feature | 2 +- tests/behat/warnings.feature | 43 ++--- 47 files changed, 1237 insertions(+), 1336 deletions(-) delete mode 100644 tests/behat/feedback_restrict_feedback_editing.feature diff --git a/tests/behat/allocation_automatic_allocations_disabled.feature b/tests/behat/allocation_automatic_allocations_disabled.feature index 034f2cb9..8536bf9e 100644 --- a/tests/behat/allocation_automatic_allocations_disabled.feature +++ b/tests/behat/allocation_automatic_allocations_disabled.feature @@ -5,17 +5,17 @@ Feature: Automatic allocations can be disabled I want to be able to turn off automatic allocations So that I can choose the teachers manually and not have weird or inappropriate allocations - Background: - Given the managers are not allowed to grade - And there is a course - And there is a coursework - And there is a teacher - And I am logged in as a manager - And the managers are not allowed to grade - And there are no allocations in the db + Background: + Given the managers are not allowed to grade + And there is a course + And there is a coursework + And there is a teacher + And I am logged in as a manager + And the managers are not allowed to grade + And there are no allocations in the db - Scenario: Nothing happens with - Given the coursework "allocationenabled" setting is "1" in the database - And the coursework "assessorallocationstrategy" setting is "none" in the database - When there is a student - Then there should be no allocations in the db + Scenario: Nothing happens with + Given the coursework "allocationenabled" setting is "1" in the database + And the coursework "assessorallocationstrategy" setting is "none" in the database + When there is a student + Then there should be no allocations in the db diff --git a/tests/behat/allocation_automatic_equal_assessor_allocations.feature b/tests/behat/allocation_automatic_equal_assessor_allocations.feature index 7a3a8461..7dc68dc8 100644 --- a/tests/behat/allocation_automatic_equal_assessor_allocations.feature +++ b/tests/behat/allocation_automatic_equal_assessor_allocations.feature @@ -6,35 +6,30 @@ Feature: Automatic equal assessor allocations So that the marking is fairly distributed and the interface is less cluttered for teachers, and they don't mark to many or too few. - Background: - Given the managers are not allowed to grade - And there is a course - And there is a coursework - And the coursework "allocationenabled" setting is "1" in the database - And the coursework "numberofmarkers" setting is "1" in the database - And there is a student - And there is a teacher - And teachers hava a capability to administer grades - And I am logged in as a manager - And there are no allocations in the db - - Scenario: Automatic allocations should work - When I visit the allocations page - And I save everything - And I log out - And I log in as the teacher - And I visit the coursework page - Then I should see the student's name on the page - - Scenario: Automatic allocations of non-manually allocated should work - When I visit the allocations page - And I save everything - And I log out - And I log in as the teacher - And I visit the coursework page - Then I should see the student's name on the page - - - - - + Background: + Given the managers are not allowed to grade + And there is a course + And there is a coursework + And the coursework "allocationenabled" setting is "1" in the database + And the coursework "numberofmarkers" setting is "1" in the database + And there is a student + And there is a teacher + And teachers hava a capability to administer grades + And I am logged in as a manager + And there are no allocations in the db + + Scenario: Automatic allocations should work + When I visit the allocations page + And I save everything + And I log out + And I log in as the teacher + And I visit the coursework page + Then I should see the student's name on the page + + Scenario: Automatic allocations of non-manually allocated should work + When I visit the allocations page + And I save everything + And I log out + And I log in as the teacher + And I visit the coursework page + Then I should see the student's name on the page diff --git a/tests/behat/allocation_automatic_interacting_with_manual_allocations.feature b/tests/behat/allocation_automatic_interacting_with_manual_allocations.feature index 2e976845..2516b80a 100644 --- a/tests/behat/allocation_automatic_interacting_with_manual_allocations.feature +++ b/tests/behat/allocation_automatic_interacting_with_manual_allocations.feature @@ -5,33 +5,32 @@ Feature: Automatically allocations interacting with manually allocated students I want to be able to reallocate all of the non manual students So that if the number of students or teachers has changed, I can make sure everything remains balanced - Background: - Given there is a course - And there is a coursework - And the coursework "allocationenabled" setting is "1" in the database - And the coursework "numberofmarkers" setting is "1" in the database - And the managers are not allowed to grade - And there is a student - And there is a teacher - And I am logged in as a manager + Background: + Given there is a course + And there is a coursework + And the coursework "allocationenabled" setting is "1" in the database + And the coursework "numberofmarkers" setting is "1" in the database + And the managers are not allowed to grade + And there is a student + And there is a teacher + And I am logged in as a manager - Scenario: Automatic allocations should not alter the manual allocations - Given there is another teacher - And there are no allocations in the db - When I visit the allocations page - And I manually allocate the student to the teacher - And I set the allocation strategy to 100 percent for the other teacher - And I save everything - When I visit the allocations page - Then I should see the student allocated to the teacher for the first assessor - - @javascript - Scenario: Automatic allocations should wipe the older automatic allocations - Given the student is allocated to the teacher - And there is another teacher - When I visit the allocations page - And I set the allocation strategy to 100 percent for the other teacher - And I press "Apply" - When I visit the allocations page - Then I should see the student allocated to the other teacher for the first assessor + Scenario: Automatic allocations should not alter the manual allocations + Given there is another teacher + And there are no allocations in the db + When I visit the allocations page + And I manually allocate the student to the teacher + And I set the allocation strategy to 100 percent for the other teacher + And I save everything + When I visit the allocations page + Then I should see the student allocated to the teacher for the first assessor + @javascript + Scenario: Automatic allocations should wipe the older automatic allocations + Given the student is allocated to the teacher + And there is another teacher + When I visit the allocations page + And I set the allocation strategy to 100 percent for the other teacher + And I press "Apply" + When I visit the allocations page + Then I should see the student allocated to the other teacher for the first assessor diff --git a/tests/behat/allocation_automatic_percentage_assessor_allocations.feature b/tests/behat/allocation_automatic_percentage_assessor_allocations.feature index a470fe8d..06a13fe8 100644 --- a/tests/behat/allocation_automatic_percentage_assessor_allocations.feature +++ b/tests/behat/allocation_automatic_percentage_assessor_allocations.feature @@ -6,38 +6,34 @@ Feature: Automatic percentage assessor allocations So that the marking is fairly distributed and the interface is less cluttered for teachers, and they don't mark to many or too few. - Background: - Given there is a course - And there is a coursework - And the coursework "allocationenabled" setting is "1" in the database - And the coursework "numberofmarkers" setting is "1" in the database - And the managers are not allowed to grade - And there is a student - And there is a teacher - And I am logged in as a manager - And there are no allocations in the db - - @javascript - Scenario: Automatic percentage allocations should allocate to the right teacher - Given there is another teacher - And there are no allocations in the db - When I visit the allocations page - And I set the allocation strategy to 100 percent for the other teacher - And I press "Apply" - When I visit the allocations page - Then I should see the student allocated to the other teacher for the first assessor - - Scenario: percentage allocations should not allocate to the wrong teacher - Given there is another teacher - And there are no allocations in the db - When I visit the allocations page - And I set the allocation strategy to 100 percent for the other teacher - And I save everything - And I log out - And I log in as the teacher - And I visit the coursework page - Then I should not see the student's name on the page - - - - + Background: + Given there is a course + And there is a coursework + And the coursework "allocationenabled" setting is "1" in the database + And the coursework "numberofmarkers" setting is "1" in the database + And the managers are not allowed to grade + And there is a student + And there is a teacher + And I am logged in as a manager + And there are no allocations in the db + + @javascript + Scenario: Automatic percentage allocations should allocate to the right teacher + Given there is another teacher + And there are no allocations in the db + When I visit the allocations page + And I set the allocation strategy to 100 percent for the other teacher + And I press "Apply" + When I visit the allocations page + Then I should see the student allocated to the other teacher for the first assessor + + Scenario: percentage allocations should not allocate to the wrong teacher + Given there is another teacher + And there are no allocations in the db + When I visit the allocations page + And I set the allocation strategy to 100 percent for the other teacher + And I save everything + And I log out + And I log in as the teacher + And I visit the coursework page + Then I should not see the student's name on the page diff --git a/tests/behat/allocation_manual_assessor_allocations.feature b/tests/behat/allocation_manual_assessor_allocations.feature index 250814ef..13acf308 100644 --- a/tests/behat/allocation_manual_assessor_allocations.feature +++ b/tests/behat/allocation_manual_assessor_allocations.feature @@ -5,51 +5,51 @@ Feature: Manually assessor allocations As a course leader I want to be able to manually allocate students to assessors - Background: - Given there is a course - And there is a coursework - And the coursework "allocationenabled" setting is "1" in the database - And the coursework "assessorallocationstrategy" setting is "none" in the database - And the coursework "numberofmarkers" setting is "2" in the database - And there is a student - And there is a teacher - And I am logged in as a manager + Background: + Given there is a course + And there is a coursework + And the coursework "allocationenabled" setting is "1" in the database + And the coursework "assessorallocationstrategy" setting is "none" in the database + And the coursework "numberofmarkers" setting is "2" in the database + And there is a student + And there is a teacher + And I am logged in as a manager - Scenario: Teachers do not see students who are allocated to other teachers - Given there is another teacher - And there are no allocations in the db - When I visit the allocations page - And I manually allocate the student to the other teacher - And I log out - And I log in as the teacher - And I visit the coursework page - Then I should not see the student's name on the page + Scenario: Teachers do not see students who are allocated to other teachers + Given there is another teacher + And there are no allocations in the db + When I visit the allocations page + And I manually allocate the student to the other teacher + And I log out + And I log in as the teacher + And I visit the coursework page + Then I should not see the student's name on the page - Scenario: auto allocations should not alter the manual allocations - Given there is another teacher - And there are no allocations in the db - When I visit the allocations page - And I manually allocate the student to the teacher - And I set the allocation strategy to 100 percent for the other teacher - And I save everything - And I visit the allocations page - Then I should see the student allocated to the teacher for the first assessor + Scenario: auto allocations should not alter the manual allocations + Given there is another teacher + And there are no allocations in the db + When I visit the allocations page + And I manually allocate the student to the teacher + And I set the allocation strategy to 100 percent for the other teacher + And I save everything + And I visit the allocations page + Then I should see the student allocated to the teacher for the first assessor - Scenario: allocating multiple teachers - Given there is another teacher - When I visit the allocations page - And I manually allocate the student to the teacher - And I save everything - And I visit the allocations page - And I manually allocate the student to the other teacher for the second assessment - And I save everything - And I visit the allocations page - Then I should see that the student has two allcations + Scenario: allocating multiple teachers + Given there is another teacher + When I visit the allocations page + And I manually allocate the student to the teacher + And I save everything + And I visit the allocations page + And I manually allocate the student to the other teacher for the second assessment + And I save everything + And I visit the allocations page + Then I should see that the student has two allcations - Scenario: Allocations work for more than one student - Given there is another student - When I visit the allocations page - And I manually allocate the student to the teacher - And I manually allocate the other student to the teacher - And I save everything - Then I should see that both students are allocated to the teacher + Scenario: Allocations work for more than one student + Given there is another student + When I visit the allocations page + And I manually allocate the student to the teacher + And I manually allocate the other student to the teacher + And I save everything + Then I should see that both students are allocated to the teacher diff --git a/tests/behat/allocation_visibility_of_all_students_capability.feature b/tests/behat/allocation_visibility_of_all_students_capability.feature index 15551950..cc5d6444 100644 --- a/tests/behat/allocation_visibility_of_all_students_capability.feature +++ b/tests/behat/allocation_visibility_of_all_students_capability.feature @@ -38,11 +38,3 @@ Feature: View of all students: allocated and non allocated students And I visit the coursework page And I click show all students button Then I should see another student's name on the page - - - - - - - - diff --git a/tests/behat/allocation_visibility_of_allocated_students.feature b/tests/behat/allocation_visibility_of_allocated_students.feature index dc4481d1..a47afbe6 100644 --- a/tests/behat/allocation_visibility_of_allocated_students.feature +++ b/tests/behat/allocation_visibility_of_allocated_students.feature @@ -5,25 +5,25 @@ Feature: Visibility of allocated students As a course leader I want teachers to only see the students who have been allocated to them - Background: - Given there is a course - And there is a coursework - And the coursework "allocationenabled" setting is "1" in the database - And the coursework "assessorallocationstrategy" setting is "none" in the database - And there is a student - And there is a teacher + Background: + Given there is a course + And there is a coursework + And the coursework "allocationenabled" setting is "1" in the database + And the coursework "assessorallocationstrategy" setting is "none" in the database + And there is a student + And there is a teacher - Scenario: Teachers do not see students who are unallocated - Given I log in as the teacher - And I visit the coursework page - Then I should not see the student's name on the page + Scenario: Teachers do not see students who are unallocated + Given I log in as the teacher + And I visit the coursework page + Then I should not see the student's name on the page - Scenario: I can allocate a student manually and the teacher will see them - Given I am logged in as a manager - When I visit the allocations page - And I manually allocate the student to the teacher - And I save everything - And I log out - And I log in as the teacher - And I visit the coursework page - Then I should see the student's name on the page \ No newline at end of file + Scenario: I can allocate a student manually and the teacher will see them + Given I am logged in as a manager + When I visit the allocations page + And I manually allocate the student to the teacher + And I save everything + And I log out + And I log in as the teacher + And I visit the coursework page + Then I should see the student's name on the page diff --git a/tests/behat/allocation_visibility_of_allocated_teachers.feature b/tests/behat/allocation_visibility_of_allocated_teachers.feature index 6ac591d8..832fba3a 100644 --- a/tests/behat/allocation_visibility_of_allocated_teachers.feature +++ b/tests/behat/allocation_visibility_of_allocated_teachers.feature @@ -5,16 +5,16 @@ Feature: Visibility of allocated teachers I want to know who is allocated to mark each submission So that I do not accidentally mark the wrong stuff - Background: - Given there is a course - And there is a coursework - And there is a student + Background: + Given there is a course + And there is a coursework + And there is a student - Scenario: I should see the name of the allocated teacher in the assessor feedback cell - Given there is a teacher - And the coursework is set to single marker - And the coursework has assessor allocations enabled - And the student is manually allocated to the teacher - When I log in as a manager - And I visit the coursework page - Then I should see the name of the teacher in the assessor feedback cell + Scenario: I should see the name of the allocated teacher in the assessor feedback cell + Given there is a teacher + And the coursework is set to single marker + And the coursework has assessor allocations enabled + And the student is manually allocated to the teacher + When I log in as a manager + And I visit the coursework page + Then I should see the name of the teacher in the assessor feedback cell diff --git a/tests/behat/automatic_agreement.feature b/tests/behat/automatic_agreement.feature index c33b0c71..5ecae93e 100644 --- a/tests/behat/automatic_agreement.feature +++ b/tests/behat/automatic_agreement.feature @@ -5,48 +5,35 @@ Feature: Automatic agreement for simple grades I can add an automatic agreement for double marking when both simple grades are adjacent within a specified range, so that the highest grade is chosen for all cases apart from the fail grades. - Background: - Given there is a course - And there is a coursework - And the coursework "numberofmarkers" setting is "2" in the database - And there is a teacher - And there is another teacher - And there is a student - And the student has a submission - And the submission is finalised - And the coursework deadline has passed - - Scenario: Only one grade in the submissions - And the coursework "automaticagreementstrategy" setting is "none" in the database - Given I am logged in as a teacher - And I visit the coursework page - And I click on the new feedback button for assessor 1 - When I grade the submission as 56 using the simple form - Then I should not see the final grade on the multiple marker page - - Scenario: Simple grades within 10% boundaries takes higher mark as a final grade - Given the coursework "automaticagreementstrategy" setting is "percentage_distance" in the database - Given the coursework "automaticagreementrange" setting is "10" in the database - And I am logged in as a teacher - And I visit the coursework page - And I click on the new feedback button for assessor 1 - And I grade the submission as 67 using the simple form - And I log out - And I log in as the other teacher - And I visit the coursework page - And I click on the new feedback button for assessor 2 - And I grade the submission as 63 using the simple form - Then I should see the final grade as 67 on the multiple marker page - - - - - - - - - - - - - + Background: + Given there is a course + And there is a coursework + And the coursework "numberofmarkers" setting is "2" in the database + And there is a teacher + And there is another teacher + And there is a student + And the student has a submission + And the submission is finalised + And the coursework deadline has passed + + Scenario: Only one grade in the submissions + And the coursework "automaticagreementstrategy" setting is "none" in the database + Given I am logged in as a teacher + And I visit the coursework page + And I click on the new feedback button for assessor 1 + When I grade the submission as 56 using the simple form + Then I should not see the final grade on the multiple marker page + + Scenario: Simple grades within 10% boundaries takes higher mark as a final grade + Given the coursework "automaticagreementstrategy" setting is "percentage_distance" in the database + Given the coursework "automaticagreementrange" setting is "10" in the database + And I am logged in as a teacher + And I visit the coursework page + And I click on the new feedback button for assessor 1 + And I grade the submission as 67 using the simple form + And I log out + And I log in as the other teacher + And I visit the coursework page + And I click on the new feedback button for assessor 2 + And I grade the submission as 63 using the simple form + Then I should see the final grade as 67 on the multiple marker page diff --git a/tests/behat/blind_marking_visibiilty_for_agreed_graders_with_blind_marking.feature b/tests/behat/blind_marking_visibiilty_for_agreed_graders_with_blind_marking.feature index 3107d88c..c34228ee 100644 --- a/tests/behat/blind_marking_visibiilty_for_agreed_graders_with_blind_marking.feature +++ b/tests/behat/blind_marking_visibiilty_for_agreed_graders_with_blind_marking.feature @@ -6,28 +6,27 @@ Feature: visibility of agreed graders with blind marking teachers before the agreement phase So that we are not influenced by one another or confused over what to do - Background: - Given there is a course - And there is a coursework - And blind marking is enabled - And teachers have the add agreed grade capability - And there is a teacher - And there is another teacher - And the coursework "numberofmarkers" setting is "2" in the database - And there is a student - And the student has a submission - And the submission is finalised + Background: + Given there is a course + And there is a coursework + And blind marking is enabled + And teachers have the add agreed grade capability + And there is a teacher + And there is another teacher + And the coursework "numberofmarkers" setting is "2" in the database + And there is a student + And the student has a submission + And the submission is finalised - Scenario: agreed graders cannot see other feedbacks before they have done their own - Given I am logged in as the other teacher - And there is feedback for the submission from the teacher - When I visit the coursework page - Then I should not see the grade from the teacher in the assessor table - - Scenario: agreed graders can view the feedback of the other assessors when all done - Given there are feedbacks from both teachers - And I am logged in as the other teacher - And I visit the coursework page - When I click on the view icon for the first initial assessor's grade - Then I should see the first initial assessors grade and comment + Scenario: agreed graders cannot see other feedbacks before they have done their own + Given I am logged in as the other teacher + And there is feedback for the submission from the teacher + When I visit the coursework page + Then I should not see the grade from the teacher in the assessor table + Scenario: agreed graders can view the feedback of the other assessors when all done + Given there are feedbacks from both teachers + And I am logged in as the other teacher + And I visit the coursework page + When I click on the view icon for the first initial assessor's grade + Then I should see the first initial assessors grade and comment diff --git a/tests/behat/blind_marking_visibiilty_for_agreed_graders_without_blind_marking.feature b/tests/behat/blind_marking_visibiilty_for_agreed_graders_without_blind_marking.feature index 3b0606d8..6a02ce43 100644 --- a/tests/behat/blind_marking_visibiilty_for_agreed_graders_without_blind_marking.feature +++ b/tests/behat/blind_marking_visibiilty_for_agreed_graders_without_blind_marking.feature @@ -6,28 +6,28 @@ Feature: visibility of agreed graders without blind marking teachers before the agreement phase So that we are not influenced by one another or confused over what to do - Background: - Given there is a course - And there is a coursework - And there is a teacher - And there is another teacher - And the coursework "numberofmarkers" setting is "2" in the database - And there is a student - And the student has a submission - And the submission is finalised + Background: + Given there is a course + And there is a coursework + And there is a teacher + And there is another teacher + And the coursework "numberofmarkers" setting is "2" in the database + And there is a student + And the student has a submission + And the submission is finalised - Scenario: agreed graders can see other feedbacks before they have done their own - Given teachers have the add agreed grade capability - And the coursework "viewinitialgradeenabled" setting is "1" in the database - And I am logged in as the other teacher - And there is feedback for the submission from the teacher - When I visit the coursework page - Then I should see the grade from the teacher in the assessor table + Scenario: agreed graders can see other feedbacks before they have done their own + Given teachers have the add agreed grade capability + And the coursework "viewinitialgradeenabled" setting is "1" in the database + And I am logged in as the other teacher + And there is feedback for the submission from the teacher + When I visit the coursework page + Then I should see the grade from the teacher in the assessor table - Scenario: agreed graders can view the feedback of the other assessors when all done - Given there are feedbacks from both teachers - And teachers have the add agreed grade capability - And I am logged in as the other teacher - And I visit the coursework page - When I click on the view icon for the first initial assessor's grade - Then I should see the first initial assessors grade and comment \ No newline at end of file + Scenario: agreed graders can view the feedback of the other assessors when all done + Given there are feedbacks from both teachers + And teachers have the add agreed grade capability + And I am logged in as the other teacher + And I visit the coursework page + When I click on the view icon for the first initial assessor's grade + Then I should see the first initial assessors grade and comment diff --git a/tests/behat/blind_marking_visibility_for_teachers_with_blind_marking.feature b/tests/behat/blind_marking_visibility_for_teachers_with_blind_marking.feature index 2577ebc2..46a036e0 100644 --- a/tests/behat/blind_marking_visibility_for_teachers_with_blind_marking.feature +++ b/tests/behat/blind_marking_visibility_for_teachers_with_blind_marking.feature @@ -5,37 +5,34 @@ Feature: Visibility for teachers with blind marking I want to be able to prevent teachers from seeing each others' marks So that I can be sure that they are not influenced by each other and the marking is fair - Background: - Given there is a course - And there is a coursework - And blind marking is enabled - - Scenario: The student names are hidden from teachers in the user cells - Given I am logged in as a teacher - And there is a student - When I visit the coursework page - Then I should not see the student's name in the user cell - - Scenario: The user names are hidden from teachers in the group cells - Given I am logged in as a teacher - And there is a student - And group submissions are enabled - And the student is a member of a group - And the group is part of a grouping for the coursework - When I visit the coursework page - Then I should not see the student's name in the group cell - - Scenario: Teachers cannot see other initial grades before final grading happens - Given the coursework "numberofmarkers" setting is "2" in the database - And there is a teacher - And there is another teacher - And there is a student - And the student has a submission - And the submission is finalised - And there are feedbacks from both teachers - And I am logged in as the other teacher - When I visit the coursework page - Then I should not see the grade from the teacher in the assessor table - - - + Background: + Given there is a course + And there is a coursework + And blind marking is enabled + + Scenario: The student names are hidden from teachers in the user cells + Given I am logged in as a teacher + And there is a student + When I visit the coursework page + Then I should not see the student's name in the user cell + + Scenario: The user names are hidden from teachers in the group cells + Given I am logged in as a teacher + And there is a student + And group submissions are enabled + And the student is a member of a group + And the group is part of a grouping for the coursework + When I visit the coursework page + Then I should not see the student's name in the group cell + + Scenario: Teachers cannot see other initial grades before final grading happens + Given the coursework "numberofmarkers" setting is "2" in the database + And there is a teacher + And there is another teacher + And there is a student + And the student has a submission + And the submission is finalised + And there are feedbacks from both teachers + And I am logged in as the other teacher + When I visit the coursework page + Then I should not see the grade from the teacher in the assessor table diff --git a/tests/behat/blind_marking_visibility_for_teachers_without_blind_marking.feature b/tests/behat/blind_marking_visibility_for_teachers_without_blind_marking.feature index b5f94c43..b3fdc266 100644 --- a/tests/behat/blind_marking_visibility_for_teachers_without_blind_marking.feature +++ b/tests/behat/blind_marking_visibility_for_teachers_without_blind_marking.feature @@ -5,35 +5,34 @@ Feature: visibility for teachers without blind marking I want to be able to prevent teachers from seeing each others' marks So that I can be sure that they are not influenced by each other and the marking is fair - Background: - Given there is a course - And there is a coursework + Background: + Given there is a course + And there is a coursework - Scenario: The student names are normally visible to teachers in the user cells - Given I am logged in as a teacher - And there is a student - When I visit the coursework page - Then I should see the student's name in the user cell + Scenario: The student names are normally visible to teachers in the user cells + Given I am logged in as a teacher + And there is a student + When I visit the coursework page + Then I should see the student's name in the user cell Scenario: The user names are visible from teachers in the group cells - Given I am logged in as a teacher - And there is a student - And group submissions are enabled - And the student is a member of a group - And the group is part of a grouping for the coursework - When I visit the coursework page - Then I should see the student's name in the group cell - - Scenario: Teachers can see other grades - Given the coursework "numberofmarkers" setting is "2" in the database - And the coursework "viewinitialgradeenabled" setting is "1" in the database - And there is a teacher - And there is another teacher - And there is a student - And the student has a submission - And the submission is finalised - And there are feedbacks from both teachers - And I am logged in as the other teacher - When I visit the coursework page - Then I should see the grade from the teacher in the assessor table + Given I am logged in as a teacher + And there is a student + And group submissions are enabled + And the student is a member of a group + And the group is part of a grouping for the coursework + When I visit the coursework page + Then I should see the student's name in the group cell + Scenario: Teachers can see other grades + Given the coursework "numberofmarkers" setting is "2" in the database + And the coursework "viewinitialgradeenabled" setting is "1" in the database + And there is a teacher + And there is another teacher + And there is a student + And the student has a submission + And the submission is finalised + And there are feedbacks from both teachers + And I am logged in as the other teacher + When I visit the coursework page + Then I should see the grade from the teacher in the assessor table diff --git a/tests/behat/deadline_extension.feature b/tests/behat/deadline_extension.feature index 7f30c8b0..e35c0a0a 100644 --- a/tests/behat/deadline_extension.feature +++ b/tests/behat/deadline_extension.feature @@ -28,7 +28,7 @@ Feature: Deadlines extensions for submissions Scenario: The teacher can add a deadline extension to an individual submission Given the coursework deadline has passed And I log in as a manager - And I am on the coursework page + And I visit the coursework page When I add a new extension for the student Then I should be on the coursework page And I should see the extended deadline in the student row @@ -37,7 +37,7 @@ Feature: Deadlines extensions for submissions Given the coursework deadline has passed And there is an extension for the student which has expired And I log in as a manager - And I am on the coursework page + And I visit the coursework page When I edit the extension for the student Then I should be on the coursework page And I should see the extended deadline in the student row diff --git a/tests/behat/deadline_extension_reason_dropdown_list.feature b/tests/behat/deadline_extension_reason_dropdown_list.feature index 50db3908..84987d2f 100644 --- a/tests/behat/deadline_extension_reason_dropdown_list.feature +++ b/tests/behat/deadline_extension_reason_dropdown_list.feature @@ -15,7 +15,7 @@ Feature: Deadline extension reasons dropdown list Given the coursework deadline has passed And there are some extension reasons configured at site level And I log in as a manager - And I am on the coursework page + And I visit the coursework page When I add a new extension for the student Then I should be on the coursework page When I click on the edit extension icon for the student @@ -27,11 +27,10 @@ Feature: Deadline extension reasons dropdown list And there are some extension reasons configured at site level And there is an extension for the student which has expired And I log in as a manager - And I am on the coursework page + And I visit the coursework page When I edit the extension for the student Then I should be on the coursework page And I should see the new extended deadline in the student row When I click on the edit extension icon for the student Then I should see the new deadline reason in the dropdown And I should see the new extra deadline information in the deadline extension form - diff --git a/tests/behat/enrolment_triggers.feature b/tests/behat/enrolment_triggers.feature index 1a61d77d..3799958b 100644 --- a/tests/behat/enrolment_triggers.feature +++ b/tests/behat/enrolment_triggers.feature @@ -5,31 +5,30 @@ Feature: the students should be auto allocated on enrolment I want the students to be reallocated when they or their assessors are added or removed from the course So that they always have a configured allocation for an appropriate assessor - Background: - Given there is a course - And there is a coursework - And there is a teacher - And the coursework "allocationenabled" setting is "1" in the database - And there are no allocations in the db - - Scenario: new students should be allocated when they join + Background: + Given there is a course + And there is a coursework + And there is a teacher + And the coursework "allocationenabled" setting is "1" in the database + And there are no allocations in the db + + Scenario: new students should be allocated when they join pending - Scenario: exisitng manual allocations should not be reallocated when a tutor joins + Scenario: exisitng manual allocations should not be reallocated when a tutor joins pending - Scenario: existing auto allocations should not be reallocated when a tutor joins + Scenario: existing auto allocations should not be reallocated when a tutor joins pending - Scenario: exisitng graded allocations should not be reallocated when a tutor joins + Scenario: exisitng graded allocations should not be reallocated when a tutor joins pending - Scenario: exisitng manual allocations should not be reallocated when a tutor leaves + Scenario: exisitng manual allocations should not be reallocated when a tutor leaves pending - Scenario: existing auto allocations should not be reallocated when a tutor leaves + Scenario: existing auto allocations should not be reallocated when a tutor leaves pending - Scenario: exisitng graded allocations should not be reallocated when a tutor leaves + Scenario: exisitng graded allocations should not be reallocated when a tutor leaves pending - diff --git a/tests/behat/factory.feature b/tests/behat/factory.feature index 8c8f9356..cb5b314e 100644 --- a/tests/behat/factory.feature +++ b/tests/behat/factory.feature @@ -5,83 +5,80 @@ Feature: Testing that the factories for behat steps work. If any tests fail, fix I want to be able to use a factory to generate the scenario context So that my tests are easier to write and run faster - @javascript - Scenario: Making a coursework - Given there is a course - And I am logged in as a teacher - And there is a coursework - When I visit the coursework page - Then I should see the title of the coursework on the page + @javascript + Scenario: Making a coursework + Given there is a course + And I am logged in as a teacher + And there is a coursework + When I visit the coursework page + Then I should see the title of the coursework on the page - Scenario: the submission factory works properly and shows the file on the page - Given there is a course - And there is a coursework - And I am logged in as a student - And I have a submission - When I visit the coursework page - Then I should see the file on the page + Scenario: the submission factory works properly and shows the file on the page + Given there is a course + And there is a coursework + And I am logged in as a student + And I have a submission + When I visit the coursework page + Then I should see the file on the page - @javascript - Scenario: the submission factory works properly and shows the file in the upload area - Given there is a course - And there is a coursework - And I am logged in as a student - And I have a submission - When I visit the coursework page - And I click on the edit submission button - Then I should see "1" elements in "Upload a file" filemanager + @javascript + Scenario: the submission factory works properly and shows the file in the upload area + Given there is a course + And there is a coursework + And I am logged in as a student + And I have a submission + When I visit the coursework page + And I click on the edit submission button + Then I should see "1" elements in "Upload a file" filemanager - Scenario: Making a coursework sets the defaults correctly - Given there is a course - And I am logged in as an editing teacher - When I visit the course page - And I turn editing mode on - When I add a "Coursework" to section "3" and I fill the form with: + Scenario: Making a coursework sets the defaults correctly + Given there is a course + And I am logged in as an editing teacher + When I visit the course page + And I turn editing mode on + When I add a "coursework" activity to course "C1" section "3" and I fill the form with: | name | Test coursework | | Description | Test coursework description | - Then the coursework general feedback should be disabled + Then the coursework general feedback should be disabled - Scenario: The coursework settings can be changed - Given there is a course - And I am logged in as an editing teacher - And there is a coursework - And the coursework "blindmarking" setting is "1" in the database - When I visit the coursework settings page - Then the field "blindmarking" matches value "1" + Scenario: The coursework settings can be changed + Given there is a course + And I am logged in as an editing teacher + And there is a coursework + And the coursework "blindmarking" setting is "1" in the database + When I visit the coursework settings page + Then the field "blindmarking" matches value "1" - Scenario: disabling general feedback alters the db setting (checkboxes bug is fixed - 0 was being interpreted as 1) - Given there is a course - And I am logged in as an editing teacher - When I visit the course page - And I turn editing mode on - When I add a "Coursework" to section "3" and I fill the form with: + Scenario: disabling general feedback alters the db setting (checkboxes bug is fixed - 0 was being interpreted as 1) + Given there is a course + And I am logged in as an editing teacher + When I visit the course page + And I turn editing mode on + When I add a "coursework" activity to course "C1" section "3" and I fill the form with: | name | Test coursework | | Description | Test coursework description | | blindmarking | 0 | - Then the coursework "blindmarking" setting should be "0" in the database + Then the coursework "blindmarking" setting should be "0" in the database - Scenario: logged in as a teacher works - Given there is a course - And I am logged in as a teacher - When I visit the course page - Then I should be on the course page - - Scenario: logged in as a manager works - Given there is a course - And I am logged in as a manager - When I visit the course page - Then I should be on the course page - - Scenario: logged in as a manager works when a student has been created - Given there is a course - And there is a student - Then I am logged in as a manager - - Scenario: Making a setting NULL - Given there is a course - And there is a coursework - And the coursework "individualfeedback" setting is "NULL" in the database - Then the coursework "blindmarking" setting should be "0" in the database + Scenario: logged in as a teacher works + Given there is a course + And I am logged in as a teacher + When I visit the course page + Then I should be on the course page + Scenario: logged in as a manager works + Given there is a course + And I am logged in as a manager + When I visit the course page + Then I should be on the course page + Scenario: logged in as a manager works when a student has been created + Given there is a course + And there is a student + Then I am logged in as a manager + Scenario: Making a setting NULL + Given there is a course + And there is a coursework + And the coursework "individualfeedback" setting is "NULL" in the database + Then the coursework "blindmarking" setting should be "0" in the database diff --git a/tests/behat/feedback_auto_release_without_cron.feature b/tests/behat/feedback_auto_release_without_cron.feature index 5c7bc465..73791ba9 100644 --- a/tests/behat/feedback_auto_release_without_cron.feature +++ b/tests/behat/feedback_auto_release_without_cron.feature @@ -1,3 +1,4 @@ +@mod @mod_coursework Feature: Auto releasing the student feedback without cron As a student @@ -5,23 +6,23 @@ Feature: Auto releasing the student feedback without cron for automatic release passes So that I get the feedback I need and don't think the system is broken - Background: - Given there is a course - And there is a coursework - And the coursework is set to single marker - And there is a student - And the student has a submission - And there is a teacher - And there is feedback for the submission from the teacher + Background: + Given there is a course + And there is a coursework + And the coursework is set to single marker + And there is a student + And the student has a submission + And there is a teacher + And there is feedback for the submission from the teacher - Scenario: auto release happens after the deadline without the cron running - Given the coursework individual feedback release date has passed - When I log in as a student - And I visit the coursework page - Then I should see "Released to students" + Scenario: auto release happens after the deadline without the cron running + Given the coursework individual feedback release date has passed + When I log in as a student + And I visit the coursework page + Then I should see "Released to students" - Scenario: auto release does not happen before the deadline without the cron running - Given the coursework individual feedback release date has not passed - When I log in as a student - And I visit the coursework page - Then I should not see "Released to students" \ No newline at end of file + Scenario: auto release does not happen before the deadline without the cron running + Given the coursework individual feedback release date has not passed + When I log in as a student + And I visit the coursework page + Then I should not see "Released to students" diff --git a/tests/behat/feedback_collisions.feature b/tests/behat/feedback_collisions.feature index 5911ab87..83130de6 100644 --- a/tests/behat/feedback_collisions.feature +++ b/tests/behat/feedback_collisions.feature @@ -1,3 +1,4 @@ +@mod @mod_coursework @mod_coursework_feedback_collisions @javascript Feature: Collisions: two people try to create feedback at the same time As a teacher @@ -5,47 +6,46 @@ Feature: Collisions: two people try to create feedback at the same time teacher has already done so So that I do not get a surprise when the grades I have awarded disappear - Background: - Given there is a course - And there is a coursework - And there is a student - And the student has a submission - And the submission is finalised + Background: + Given there is a course + And there is a coursework + And there is a student + And the student has a submission + And the submission is finalised - Scenario: Single marker: If I submit feedback and it's already been given then the form should reload with a warning - Given there is a teacher - And there is another teacher - And I am logged in as the other teacher - And the coursework is set to single marker - When I visit the coursework page - And I click the new single final feedback button for the student - And I have an assessor feedback - When I grade the submission using the simple form - Then I should be on the create feedback page - And I should see "has already submitted" - Then I should see the grade comment in the form on the page - And I should see the grade in the form on the page + Scenario: Single marker: If I submit feedback and it's already been given then the form should reload with a warning + Given there is a teacher + And there is another teacher + And I am logged in as the other teacher + And the coursework is set to single marker + When I visit the coursework page + And I click the new single final feedback button for the student + And I have an assessor feedback + When I grade the submission using the simple form + Then I should be on the create feedback page + And I should see "has already submitted" + Then I should see the grade comment in the form on the page + And I should see the grade in the form on the page - Scenario: Multiple marker: If I submit feedback and it's already been given then it should be given a new stage_identifier - Given there is a teacher - And there is another teacher - And I am logged in as the other teacher - And the coursework is set to double marker - When I visit the coursework page - And I click on the new feedback button for assessor 1 - And I have an assessor feedback - When I grade the submission using the simple form - Then I should be on the coursework page - - Scenario: Multiple marker: If I submit feedback and it's already been given by all teachers then it should fail - Given there is a teacher - And there is another teacher - And I am logged in as a manager - And the coursework is set to double marker - When I visit the coursework page - And I click on the new feedback button for assessor 1 - And I have an assessor feedback - And there is final feedback from the other teacher - When I grade the submission using the simple form - Then I should be on the create feedback page + Scenario: Multiple marker: If I submit feedback and it's already been given then it should be given a new stage_identifier + Given there is a teacher + And there is another teacher + And I am logged in as the other teacher + And the coursework is set to double marker + When I visit the coursework page + And I click on the new feedback button for assessor 1 + And I have an assessor feedback + When I grade the submission using the simple form + Then I should be on the coursework page + Scenario: Multiple marker: If I submit feedback and it's already been given by all teachers then it should fail + Given there is a teacher + And there is another teacher + And I am logged in as a manager + And the coursework is set to double marker + When I visit the coursework page + And I click on the new feedback button for assessor 1 + And I have an assessor feedback + And there is final feedback from the other teacher + When I grade the submission using the simple form + Then I should be on the create feedback page diff --git a/tests/behat/feedback_edit_feedback_within_specified_time.feature b/tests/behat/feedback_edit_feedback_within_specified_time.feature index eba2ce97..a797184a 100644 --- a/tests/behat/feedback_edit_feedback_within_specified_time.feature +++ b/tests/behat/feedback_edit_feedback_within_specified_time.feature @@ -1,11 +1,11 @@ - +@mod @mod_coursework Feature: Allow markers to edit their marking but only during specific marking stages As an initial marker I want to be able to edit my initial marking if I have made a mistake. So that if the marking stage is at final agreed grading there is a time window for initial marks edition to happen - Background: + Background: Given there is a course And there is a coursework And the coursework "allocationenabled" setting is "1" in the database @@ -17,23 +17,19 @@ Feature: Allow markers to edit their marking but only during specific marking st And the student has a submission And the submission is finalised - - Scenario: Edit own initial feedback before delayed time Given there are feedbacks from both teachers And I log in as the teacher And I visit the coursework page Then I should see the edit feedback button for the teacher's feedback - - @javascript + @javascript Scenario: Edit own initial feedback after delayed time Given there are feedbacks from both teachers And I wait "35" seconds And I log in as the teacher And I visit the coursework page - Then I should not see the edit feedback button for the teacher's feedback - + Then I should not see the edit feedback button for the teacher's feedback Scenario: Automatic agreement before delayed time Given the coursework "automaticagreementstrategy" setting is "percentage_distance" in the database @@ -50,7 +46,6 @@ Feature: Allow markers to edit their marking but only during specific marking st And I visit the coursework page Then I should not see the final grade on the multiple marker page - @javascript Scenario: Automatic agreement after delayed time Given the coursework "automaticagreementstrategy" setting is "percentage_distance" in the database @@ -64,6 +59,6 @@ Feature: Allow markers to edit their marking but only during specific marking st And I visit the coursework page And I click on the new feedback button for assessor 2 And I grade the submission as 63 without comments using the simple form - And I wait "50" seconds + And I wait "50" seconds And I visit the coursework page Then I should see the final grade as 67 on the multiple marker page diff --git a/tests/behat/feedback_files.feature b/tests/behat/feedback_files.feature index fe2bd721..989c846c 100644 --- a/tests/behat/feedback_files.feature +++ b/tests/behat/feedback_files.feature @@ -1,38 +1,37 @@ +@_file_upload Feature: Adding feedback files As a teacher I want to be able to add feedback files So that I can provide users with rich, detailed feedback - Background: - Given there is a course - And there is a coursework - And the coursework "numberofmarkers" setting is "1" in the database - And there is a student - And the student has a submission - And the submission is finalised - - @javascript - Scenario: I can upload any file type, regardless of the coursework file types - Given the coursework "filetypes" setting is "pdf" in the database - And I am logged in as a teacher - When I visit the coursework page - And I click the new single final feedback button for the student - And I upload "mod/coursework/tests/files_for_uploading/Test_image.png" file to "Upload a file" filemanager - Then I should see "1" elements in "Upload a file" filemanager - - @javascript - Scenario: Students see all the feedback files - Given I am logged in as a manager - When I visit the coursework page - And I click the new single final feedback button for the student - And I upload "mod/coursework/tests/files_for_uploading/Test_image.png" file to "Upload a file" filemanager - When I upload "mod/coursework/tests/files_for_uploading/Test_document_two.docx" file to "Upload a file" filemanager - And I press "Save changes" - And I publish the grades - And I log out - And I log in as a student - And I visit the coursework page - Then I should see two feedback files on the page + Background: + Given there is a course + And there is a coursework + And the coursework "numberofmarkers" setting is "1" in the database + And there is a student + And the student has a submission + And the submission is finalised + @javascript + Scenario: I can upload any file type, regardless of the coursework file types + Given the coursework "filetypes" setting is "pdf" in the database + And I am logged in as a teacher + When I visit the coursework page + And I click the new single final feedback button for the student + And I upload "mod/coursework/tests/files_for_uploading/Test_image.png" file to "Upload a file" filemanager + Then I should see "1" elements in "Upload a file" filemanager + @javascript + Scenario: Students see all the feedback files + Given I am logged in as a manager + When I visit the coursework page + And I click the new single final feedback button for the student + And I upload "mod/coursework/tests/files_for_uploading/Test_image.png" file to "Upload a file" filemanager + When I upload "mod/coursework/tests/files_for_uploading/Test_document_two.docx" file to "Upload a file" filemanager + And I press "Save changes" + And I publish the grades + And I log out + And I log in as a student + And I visit the coursework page + Then I should see two feedback files on the page diff --git a/tests/behat/feedback_final_feedback_double_marking.feature b/tests/behat/feedback_final_feedback_double_marking.feature index ad807395..e040c80d 100644 --- a/tests/behat/feedback_final_feedback_double_marking.feature +++ b/tests/behat/feedback_final_feedback_double_marking.feature @@ -5,54 +5,52 @@ Feature: Adding and editing final feedback As a course leader I want to be able to edit the final grade via a form - Background: - Given there is a course - And there is a coursework - And there is a teacher - And there is another teacher - And the coursework "numberofmarkers" setting is "2" in the database - And there is a student - And the student has a submission - And the submission is finalised - - Scenario: Setting the final feedback grade - Given there are feedbacks from both teachers - And I am logged in as a manager - And I visit the coursework page - When I click the new multiple final feedback button for the student - When I grade the submission using the simple form - Then I should be on the coursework page - And I should see the final grade on the multiple marker page - - Scenario: Setting the final feedback comment - Given there are feedbacks from both teachers - And I am logged in as a manager - And I visit the coursework page - When I click the new multiple final feedback button for the student - When I grade the submission using the simple form - Then I should be on the coursework page - When I click the edit final feedback button - Then I should see the grade comment in the form on the page - And I should see the grade in the form on the page - - Scenario: I can be both an initial assessor and the manager who agrees grades - And managers do not have the manage capability - Given I am logged in as a manager - And there are feedbacks from both me and another teacher - And I visit the coursework page - When I click the new multiple final feedback button for the student - And I grade the submission using the simple form - Then I should be on the coursework page - - Scenario: Editing final feedback from others - And managers do not have the manage capability - Given I am logged in as a manager - And there are feedbacks from both me and another teacher - And there is final feedback from the other teacher - When I visit the coursework page - When I click the edit final feedback button - And I should see the other teacher's final grade in the form on the page - And I grade the submission using the simple form - Then I should be on the coursework page - - + Background: + Given there is a course + And there is a coursework + And there is a teacher + And there is another teacher + And the coursework "numberofmarkers" setting is "2" in the database + And there is a student + And the student has a submission + And the submission is finalised + + Scenario: Setting the final feedback grade + Given there are feedbacks from both teachers + And I am logged in as a manager + And I visit the coursework page + When I click the new multiple final feedback button for the student + When I grade the submission using the simple form + Then I should be on the coursework page + And I should see the final grade on the multiple marker page + + Scenario: Setting the final feedback comment + Given there are feedbacks from both teachers + And I am logged in as a manager + And I visit the coursework page + When I click the new multiple final feedback button for the student + When I grade the submission using the simple form + Then I should be on the coursework page + When I click the edit final feedback button + Then I should see the grade comment in the form on the page + And I should see the grade in the form on the page + + Scenario: I can be both an initial assessor and the manager who agrees grades + And managers do not have the manage capability + Given I am logged in as a manager + And there are feedbacks from both me and another teacher + And I visit the coursework page + When I click the new multiple final feedback button for the student + And I grade the submission using the simple form + Then I should be on the coursework page + + Scenario: Editing final feedback from others + And managers do not have the manage capability + Given I am logged in as a manager + And there are feedbacks from both me and another teacher + And there is final feedback from the other teacher + When I visit the coursework page + When I click the edit final feedback button + And I should see the other teacher's final grade in the form on the page + And I grade the submission using the simple form + Then I should be on the coursework page diff --git a/tests/behat/feedback_general_feedback.feature b/tests/behat/feedback_general_feedback.feature index 52923edb..fbe6567e 100644 --- a/tests/behat/feedback_general_feedback.feature +++ b/tests/behat/feedback_general_feedback.feature @@ -5,59 +5,56 @@ Feature: general feedback I want to be able to provide some general feedback for all of the students before their individual feedback is released So that they can prepare effectively for upcoming exams or assignments - Scenario: enabling general feedback shows the place for managers to enter feedback - Given there is a course - And there is a coursework - And the coursework general feedback is enabled - And I am logged in as an manager - When I visit the coursework page - Then I should see "Add general feedback" - - Scenario: disabling general feedback does not hide the place for managers to enter feedback - Given there is a course - And there is a coursework - And the coursework general feedback is disabled - And I am logged in as an manager - When I visit the coursework page - Then I should see "Add general feedback" - - Scenario: enabling general feedback shows students the feedback deadline - Given there is a course - And there is a coursework - And the coursework general feedback is enabled - And I am logged in as a student - And I have a submission - When I visit the coursework page - And I should see "General feedback deadline" - - Scenario: enabling general feedback shows students the feedback when the deadline has passed - Given there is a course - And there is a coursework - And the coursework general feedback is enabled - And there is some general feedback - And the general feedback deadline has passed - And I am logged in as a student - And I have a submission - When I visit the coursework page - Then I should see "General feedback" - - Scenario: disabling general feedback hides the feedback from students - Given there is a course - And there is a coursework - And the coursework general feedback is disabled - And I am logged in as a student - When I visit the coursework page - Then I should not see "General feedback:" - And I should not see "General feedback deadline" - - Scenario: Users without permission cannot add or edit general feedback - Given there is a course - And there is a coursework - And the coursework general feedback is enabled - And I am logged in as an editing teacher - When I visit the coursework page - Then I should not see "Edit general feedback" - And I should not see "Add general feedback" - - - + Scenario: enabling general feedback shows the place for managers to enter feedback + Given there is a course + And there is a coursework + And the coursework general feedback is enabled + And I am logged in as an manager + When I visit the coursework page + Then I should see "Add general feedback" + + Scenario: disabling general feedback does not hide the place for managers to enter feedback + Given there is a course + And there is a coursework + And the coursework general feedback is disabled + And I am logged in as an manager + When I visit the coursework page + Then I should see "Add general feedback" + + Scenario: enabling general feedback shows students the feedback deadline + Given there is a course + And there is a coursework + And the coursework general feedback is enabled + And I am logged in as a student + And I have a submission + When I visit the coursework page + And I should see "General feedback deadline" + + Scenario: enabling general feedback shows students the feedback when the deadline has passed + Given there is a course + And there is a coursework + And the coursework general feedback is enabled + And there is some general feedback + And the general feedback deadline has passed + And I am logged in as a student + And I have a submission + When I visit the coursework page + Then I should see "General feedback" + + Scenario: disabling general feedback hides the feedback from students + Given there is a course + And there is a coursework + And the coursework general feedback is disabled + And I am logged in as a student + When I visit the coursework page + Then I should not see "General feedback:" + And I should not see "General feedback deadline" + + Scenario: Users without permission cannot add or edit general feedback + Given there is a course + And there is a coursework + And the coursework general feedback is enabled + And I am logged in as an editing teacher + When I visit the coursework page + Then I should not see "Edit general feedback" + And I should not see "Add general feedback" diff --git a/tests/behat/feedback_group_feedback_for_students.feature b/tests/behat/feedback_group_feedback_for_students.feature index 857585e4..30a3fa2a 100644 --- a/tests/behat/feedback_group_feedback_for_students.feature +++ b/tests/behat/feedback_group_feedback_for_students.feature @@ -5,42 +5,42 @@ Feature: Students see feedback on group assignments I want to be able to see the feedaback for the group assignment even if I did not submit it So that I know what my marks are and can improve my work - Background: - Given there is a course - And there is a coursework - And the coursework "use_groups" setting is "1" in the database - And the coursework is set to double marker - And there is a manager - And there is a student - And the student is a member of a group - And there is another student - And the other student is a member of the group - And the group has a submission - And the submission is finalised - And there is final feedback - And the grades have been published + Background: + Given there is a course + And there is a coursework + And the coursework "use_groups" setting is "1" in the database + And the coursework is set to double marker + And there is a manager + And there is a student + And the student is a member of a group + And there is another student + And the other student is a member of the group + And the group has a submission + And the submission is finalised + And there is final feedback + And the grades have been published - Scenario: I can see the published grade when someone else submitted - Given I am logged in as the other student - When I visit the coursework page - Then I should see the grade for the group submission - And I should see the feedback for the group submission + Scenario: I can see the published grade when someone else submitted + Given I am logged in as the other student + When I visit the coursework page + Then I should see the grade for the group submission + And I should see the feedback for the group submission - Scenario: I can see the published grade when I submitted - Given I am logged in as the student - When I visit the coursework page - Then I should see the grade for the group submission - And I should see the feedback for the group submission + Scenario: I can see the published grade when I submitted + Given I am logged in as the student + When I visit the coursework page + Then I should see the grade for the group submission + And I should see the feedback for the group submission - @broken - Scenario: I can see the published grade in the gradebook when someone else submitted - Given I am logged in as the other student - And I visit the coursework page - When I visit the gradebook page - Then I should see the grade in the gradebook + @broken + Scenario: I can see the published grade in the gradebook when someone else submitted + Given I am logged in as the other student + And I visit the coursework page + When I visit the gradebook page + Then I should see the grade in the gradebook - @broken - Scenario: I can see the published grade in the gradebook when I submitted - Given I am logged in as the student - When I visit the gradebook page - Then I should see the grade in the gradebook + @broken + Scenario: I can see the published grade in the gradebook when I submitted + Given I am logged in as the student + When I visit the gradebook page + Then I should see the grade in the gradebook diff --git a/tests/behat/feedback_group_marking.feature b/tests/behat/feedback_group_marking.feature index d788c225..90c6d074 100644 --- a/tests/behat/feedback_group_marking.feature +++ b/tests/behat/feedback_group_marking.feature @@ -6,26 +6,26 @@ Feature: Marking the group submissions applies the grades to the whole group So that the marks are awarded to all of the group members and they can see their feedback and grades - Background: - Given there is a course - And there is a coursework - And there is a teacher - And there is another teacher - And the coursework "numberofmarkers" setting is "2" in the database - And the coursework "use_groups" setting is "1" in the database - And there is a student - And the student is a member of a group - And there is another student - And the other student is a member of the group - And the group has a submission - And the submission is finalised - And there are feedbacks from both teachers - And I am logged in as a manager + Background: + Given there is a course + And there is a coursework + And there is a teacher + And there is another teacher + And the coursework "numberofmarkers" setting is "2" in the database + And the coursework "use_groups" setting is "1" in the database + And there is a student + And the student is a member of a group + And there is another student + And the other student is a member of the group + And the group has a submission + And the submission is finalised + And there are feedbacks from both teachers + And I am logged in as a manager - Scenario: grading the submission makes the grades show up for both students in the interface - Given I am on the coursework page - When I click the new final feedback button for the group - And show me the page - And I grade the submission using the simple form - Then I should be on the coursework page - And I should see the final grade for the group in the grading interface + Scenario: grading the submission makes the grades show up for both students in the interface + Given I visit the coursework page + When I click the new final feedback button for the group + And show me the page + And I grade the submission using the simple form + Then I should be on the coursework page + And I should see the final grade for the group in the grading interface diff --git a/tests/behat/feedback_multiple_assessor_feedback.feature b/tests/behat/feedback_multiple_assessor_feedback.feature index 017c779c..165c0110 100644 --- a/tests/behat/feedback_multiple_assessor_feedback.feature +++ b/tests/behat/feedback_multiple_assessor_feedback.feature @@ -5,95 +5,92 @@ Feature: Multiple assessors simple grading form I want there to be a simple grading form So that I can give students a grade and a feedback comment without any frustrating extra work - Background: - Given there is a course - And the following "permission overrides" exist: + Background: + Given there is a course + And the following "permission overrides" exist: | capability | permission | role | contextlevel | reference | | mod/coursework:editinitialgrade | Allow | teacher | Course | C1 | - And there is a coursework - And the coursework "numberofmarkers" setting is "2" in the database - And the coursework "allocationenabled" setting is "0" in the database - And there is a student - And the student has a submission + And there is a coursework + And the coursework "numberofmarkers" setting is "2" in the database + And the coursework "allocationenabled" setting is "0" in the database + And there is a student + And the student has a submission - Scenario: Grades can be saved - Given I am logged in as a teacher - And the submission is finalised - And I visit the coursework page - And I click on the new feedback button for assessor 1 - When I grade the submission using the simple form - Then I should see the grade on the page + Scenario: Grades can be saved + Given I am logged in as a teacher + And the submission is finalised + And I visit the coursework page + And I click on the new feedback button for assessor 1 + When I grade the submission using the simple form + Then I should see the grade on the page - Scenario: Grade comments can be saved - Given I am logged in as a teacher - And the submission is finalised - And I visit the coursework page - And I click on the new feedback button for assessor 1 - When I grade the submission using the simple form - And I visit the edit feedback page - Then I should see the grade comment in the form on the page + Scenario: Grade comments can be saved + Given I am logged in as a teacher + And the submission is finalised + And I visit the coursework page + And I click on the new feedback button for assessor 1 + When I grade the submission using the simple form + And I visit the edit feedback page + Then I should see the grade comment in the form on the page - @javascript - Scenario: Grade files can be saved - Given I am logged in as a teacher - And the submission is finalised - And I visit the coursework page - And I click on the new feedback button for assessor 1 - When I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I press "Save and finalise" - And I click on the edit feedback icon - Then I should be on the edit feedback page - Then I should see "1" elements in "Upload a file" filemanager + @javascript + Scenario: Grade files can be saved + Given I am logged in as a teacher + And the submission is finalised + And I visit the coursework page + And I click on the new feedback button for assessor 1 + When I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I press "Save and finalise" + And I click on the edit feedback icon + Then I should be on the edit feedback page + Then I should see "1" elements in "Upload a file" filemanager - Scenario: Grade comments can be edited - Given I am logged in as a teacher - And the submission is finalised - And I have an assessor feedback - And I visit the coursework page - And I click on the edit feedback icon - Then I should see the grade comment in the form on the page + Scenario: Grade comments can be edited + Given I am logged in as a teacher + And the submission is finalised + And I have an assessor feedback + And I visit the coursework page + And I click on the edit feedback icon + Then I should see the grade comment in the form on the page - Scenario: Grades can not be edited by other teachers - Given there is a teacher - And there is another teacher - And there is feedback for the submission from the teacher - And I am logged in as the other teacher - And the submission is finalised - When I visit the coursework page - Then show me the page - Then I should not see the edit feedback button for the teacher's feedback + Scenario: Grades can not be edited by other teachers + Given there is a teacher + And there is another teacher + And there is feedback for the submission from the teacher + And I am logged in as the other teacher + And the submission is finalised + When I visit the coursework page + Then show me the page + Then I should not see the edit feedback button for the teacher's feedback - @javascript - Scenario: Grade files can be edited and more are added - Given I am logged in as a teacher - And the submission is finalised - And I visit the coursework page - And I click on the new feedback button for assessor 1 - And I wait "1" seconds - When I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I press "Save and finalise" - And I click on the edit feedback icon - And I wait "2" seconds - And I upload "mod/coursework/tests/files_for_uploading/Test_document_two.docx" file to "Upload a file" filemanager - Then I should see "2" elements in "Upload a file" filemanager - - When I press "Save and finalise" - And I click on the edit feedback icon - And I wait "1" seconds - Then I should see "2" elements in "Upload a file" filemanager - - Scenario: I should not see the feedback icon when the submisison has not been finalised - Given I am logged in as a teacher - And I visit the coursework page - Then I should not see a link to add feedback - - Scenario: managers can grade the initial stages - Given I am logged in as a manager - And the submission is finalised - And I visit the coursework page - And I click on the new feedback button for assessor 1 - When I grade the submission using the simple form - Then I should see the grade on the page + @javascript @_file_upload + Scenario: Grade files can be edited and more are added + Given I am logged in as a teacher + And the submission is finalised + And I visit the coursework page + And I click on the new feedback button for assessor 1 + And I wait "1" seconds + When I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I press "Save and finalise" + And I click on the edit feedback icon + And I wait "2" seconds + And I upload "mod/coursework/tests/files_for_uploading/Test_document_two.docx" file to "Upload a file" filemanager + Then I should see "2" elements in "Upload a file" filemanager + When I press "Save and finalise" + And I click on the edit feedback icon + And I wait "1" seconds + Then I should see "2" elements in "Upload a file" filemanager + Scenario: I should not see the feedback icon when the submisison has not been finalised + Given I am logged in as a teacher + And I visit the coursework page + Then I should not see a link to add feedback + Scenario: managers can grade the initial stages + Given I am logged in as a manager + And the submission is finalised + And I visit the coursework page + And I click on the new feedback button for assessor 1 + When I grade the submission using the simple form + Then I should see the grade on the page diff --git a/tests/behat/feedback_publishing_grades.feature b/tests/behat/feedback_publishing_grades.feature index 432b8703..cb5e17a7 100644 --- a/tests/behat/feedback_publishing_grades.feature +++ b/tests/behat/feedback_publishing_grades.feature @@ -5,44 +5,44 @@ Feature: publishing grades to the students As a manager I want to be able to publish the grades when I am ready to - Background: - Given there is a course - And there is a coursework - And the coursework "numberofmarkers" setting is "1" in the database - And the coursework "blindmarking" setting is "0" in the database - And the coursework "moderationenabled" setting is "0" in the database - And there is a student - And the student has a submission - And the submission is finalised + Background: + Given there is a course + And there is a coursework + And the coursework "numberofmarkers" setting is "1" in the database + And the coursework "blindmarking" setting is "0" in the database + And the coursework "moderationenabled" setting is "0" in the database + And there is a student + And the student has a submission + And the submission is finalised - Scenario: Not publishing with double marking hides feedback from the student - Given there is a teacher - And there is another teacher - And the coursework "numberofmarkers" setting is "2" in the database - And there are feedbacks from both teachers - And I am logged in as a manager - When I visit the coursework page - And I click the new multiple final feedback button for the student - And I grade the submission using the simple form - And I log out - And I log in as the student - And I visit the coursework page - Then I should not see the final grade on the student page - And I should not see the grade comment on the student page + Scenario: Not publishing with double marking hides feedback from the student + Given there is a teacher + And there is another teacher + And the coursework "numberofmarkers" setting is "2" in the database + And there are feedbacks from both teachers + And I am logged in as a manager + When I visit the coursework page + And I click the new multiple final feedback button for the student + And I grade the submission using the simple form + And I log out + And I log in as the student + And I visit the coursework page + Then I should not see the final grade on the student page + And I should not see the grade comment on the student page - Scenario: Deliberate publishing with double marking shows feedback to the student - Given there is a teacher - And there is another teacher - And the coursework "numberofmarkers" setting is "2" in the database - And there are feedbacks from both teachers - And I am logged in as a manager + Scenario: Deliberate publishing with double marking shows feedback to the student + Given there is a teacher + And there is another teacher + And the coursework "numberofmarkers" setting is "2" in the database + And there are feedbacks from both teachers + And I am logged in as a manager - When I visit the coursework page - And I click the new multiple final feedback button for the student - And I grade the submission using the simple form - And I press the publish button - And I log out - And I log in as the student - And I visit the coursework page - Then I should see the final grade on the student page - And I should see the grade comment on the student page \ No newline at end of file + When I visit the coursework page + And I click the new multiple final feedback button for the student + And I grade the submission using the simple form + And I press the publish button + And I log out + And I log in as the student + And I visit the coursework page + Then I should see the final grade on the student page + And I should see the grade comment on the student page diff --git a/tests/behat/feedback_restrict_feedback_editing.feature b/tests/behat/feedback_restrict_feedback_editing.feature deleted file mode 100644 index 9187cc93..00000000 --- a/tests/behat/feedback_restrict_feedback_editing.feature +++ /dev/null @@ -1,7 +0,0 @@ -Feature: Resticting the editing of feedback by the assessors who added it - - As a course leader - I want to be sure that assessor cannot modify their feedback after they have left it - So that I can be sure that the grades are fair and no later changes happened due to - later finding out about other people's grades - diff --git a/tests/behat/feedback_rubrics.feature b/tests/behat/feedback_rubrics.feature index 30fcac22..8ed8381d 100644 --- a/tests/behat/feedback_rubrics.feature +++ b/tests/behat/feedback_rubrics.feature @@ -6,48 +6,47 @@ Feature: Adding feedback using the built in Moodle rubrics in a standardised way So that I can grade the work faster, give more consistent responses and make the process more fair - Background: - Given there is a course - And there is a coursework - And the coursework "numberofmarkers" setting is "1" in the database - And there is a student - And the student has a submission - And the submission is finalised - And I am logged in as a teacher + Background: + Given there is a course + And there is a coursework + And the coursework "numberofmarkers" setting is "1" in the database + And there is a student + And the student has a submission + And the submission is finalised + And I am logged in as a teacher - Scenario: I should be able to add feedback using a simple rubric - Given there is a rubric defined for the coursework - Given I visit the coursework page - When I click the new single final feedback button for the student - And I grade by filling the rubric with: + Scenario: I should be able to add feedback using a simple rubric + Given there is a rubric defined for the coursework + Given I visit the coursework page + When I click the new single final feedback button for the student + And I grade by filling the rubric with: | first criterion | 1 | Very good | - And I fill in the rest of the form after the rubric and submit it - And I log out - And I log in as a manager - And I visit the coursework page - And I publish the grades - And I log out - And I log in as a student - And I visit the coursework page - Then I should see the rubric grade on the page - And I should see the grade comment on the student page + And I fill in the rest of the form after the rubric and submit it + And I log out + And I log in as a manager + And I visit the coursework page + And I publish the grades + And I log out + And I log in as a student + And I visit the coursework page + Then I should see the rubric grade on the page + And I should see the grade comment on the student page - @broken - Scenario: I should see the rubric grade show up in the gradebook - Given there is a rubric defined for the coursework - Given I visit the coursework page - When I click the new single final feedback button for the student - And I grade by filling the rubric with: + @broken + Scenario: I should see the rubric grade show up in the gradebook + Given there is a rubric defined for the coursework + Given I visit the coursework page + When I click the new single final feedback button for the student + And I grade by filling the rubric with: | first criterion | 1 | Very good | - And I fill in the rest of the form after the rubric and submit it - And I log out - And I log in as a manager - And I visit the coursework page - And I publish the grades - And I log out - And I log in as a student - When I visit the gradebook page - Then I should see the rubric grade in the gradebook - When I visit the coursework page - And I should see the grade comment on the student page - + And I fill in the rest of the form after the rubric and submit it + And I log out + And I log in as a manager + And I visit the coursework page + And I publish the grades + And I log out + And I log in as a student + When I visit the gradebook page + Then I should see the rubric grade in the gradebook + When I visit the coursework page + And I should see the grade comment on the student page diff --git a/tests/behat/feedback_single_marking.feature b/tests/behat/feedback_single_marking.feature index e985c733..60649a43 100644 --- a/tests/behat/feedback_single_marking.feature +++ b/tests/behat/feedback_single_marking.feature @@ -5,44 +5,43 @@ Feature: Adding and editing single feedback As a course leader I want to be able to edit the final grade via a form - Background: - Given there is a course - And there is a coursework - And the coursework "numberofmarkers" setting is "1" in the database - And there is a student - And there is a teacher - And the student has a submission - And the teacher has a capability to edit their own initial feedbacks - And I log in as the teacher + Background: + Given there is a course + And there is a coursework + And the coursework "numberofmarkers" setting is "1" in the database + And there is a student + And there is a teacher + And the student has a submission + And the teacher has a capability to edit their own initial feedbacks + And I log in as the teacher - Scenario: Setting the final feedback grade - Given the submission is finalised - And the coursework deadline has passed - And I visit the coursework page - When I click the new single final feedback button for the student - When I grade the submission using the simple form - Then I should be on the coursework page - And I should see the final grade on the single marker page + Scenario: Setting the final feedback grade + Given the submission is finalised + And the coursework deadline has passed + And I visit the coursework page + When I click the new single final feedback button for the student + When I grade the submission using the simple form + Then I should be on the coursework page + And I should see the final grade on the single marker page - Scenario: Setting the final feedback comment - Given the submission is finalised - And I visit the coursework page - When I click the new single final feedback button for the student - When I grade the submission using the simple form - Then I should be on the coursework page - When I click the edit final feedback button - Then I should see the grade comment in the form on the page - And I should see the grade in the form on the page + Scenario: Setting the final feedback comment + Given the submission is finalised + And I visit the coursework page + When I click the new single final feedback button for the student + When I grade the submission using the simple form + Then I should be on the coursework page + When I click the edit final feedback button + Then I should see the grade comment in the form on the page + And I should see the grade in the form on the page - Scenario: I should not see the feedback icon when the submisison has not been finalised - And I visit the coursework page - Then I should not see a link to add feedback - - Scenario: Editing someone elses grade - Given the submission is finalised - And there is feedback for the submission from the teacher - And I visit the coursework page - When I click the edit final feedback button - Then I should see the grade comment as "Blah" in the form on the page - And I should see the other teacher's grade in the form on the page + Scenario: I should not see the feedback icon when the submisison has not been finalised + And I visit the coursework page + Then I should not see a link to add feedback + Scenario: Editing someone elses grade + Given the submission is finalised + And there is feedback for the submission from the teacher + And I visit the coursework page + When I click the edit final feedback button + Then I should see the grade comment as "Blah" in the form on the page + And I should see the other teacher's grade in the form on the page diff --git a/tests/behat/feedback_zero_grades.feature b/tests/behat/feedback_zero_grades.feature index 5c66ebfd..f5a0f70c 100644 --- a/tests/behat/feedback_zero_grades.feature +++ b/tests/behat/feedback_zero_grades.feature @@ -1,3 +1,4 @@ +@mod @mod_coursework Feature: Zero grades should show up just like the others As a teacher @@ -5,20 +6,19 @@ Feature: Zero grades should show up just like the others So that in case there is no work submitted or the work is truly and irredeemably useless, the student will know - Background: - Given there is a course - And there is a coursework - And there is a student - And the student has a submission - And the submission is finalised - - Scenario: Single maker final feedback - Given the coursework "grade" setting is "9" in the database - Given I am logged in as a teacher - And the coursework "numberofmarkers" setting is "1" in the database - When I visit the coursework page - And I click the new single final feedback button for the student - And I grade the submission as 0 using the simple form - Then I should be on the coursework page - And I should see the final grade as 0 on the single marker page + Background: + Given there is a course + And there is a coursework + And there is a student + And the student has a submission + And the submission is finalised + Scenario: Single maker final feedback + Given the coursework "grade" setting is "9" in the database + Given I am logged in as a teacher + And the coursework "numberofmarkers" setting is "1" in the database + When I visit the coursework page + And I click the new single final feedback button for the student + And I grade the submission as 0 using the simple form + Then I should be on the coursework page + And I should see the final grade as 0 on the single marker page diff --git a/tests/behat/installation_and_set_up.feature b/tests/behat/installation_and_set_up.feature index 4ea75f2d..f5341016 100644 --- a/tests/behat/installation_and_set_up.feature +++ b/tests/behat/installation_and_set_up.feature @@ -5,27 +5,24 @@ Feature: Installing the coursework module and making sure it works As an admin I need to be able to successfully install the module in a course and add an instance - @javascript - Scenario: I can add a new instance of the coursework module to a course - Given there is a course - And I am logged in as an editing teacher - And I visit the course page - And I turn editing mode on - When I add a "Coursework" to section "3" and I fill the form with: + @javascript + Scenario: I can add a new instance of the coursework module to a course + Given there is a course + And I am logged in as an editing teacher + And I visit the course page + And I turn editing mode on + When I add a "coursework" activity to course "C1" section "3" and I fill the form with: | name | Test coursework | | Description | Test coursework description | - Then I should be on the course page + Then I should be on the course page - Scenario: The module can be used with course completion enabled - Given there is a course - And I am logged in as an editing teacher - And the course has completion enabled - When I visit the course page - And I turn editing mode on - When I add a "Coursework" to section "3" and I fill the form with: + Scenario: The module can be used with course completion enabled + Given there is a course + And I am logged in as an editing teacher + And the course has completion enabled + When I visit the course page + And I turn editing mode on + When I add a "coursework" activity to course "C1" section "3" and I fill the form with: | name | Test coursework | | Description | Test coursework description | - Then I should be on the course page - - - + Then I should be on the course page diff --git a/tests/behat/sampling_automatic_sampling.feature b/tests/behat/sampling_automatic_sampling.feature index 44774e15..299fbd89 100644 --- a/tests/behat/sampling_automatic_sampling.feature +++ b/tests/behat/sampling_automatic_sampling.feature @@ -1,3 +1,4 @@ +@mod @mod_coursework Feature: Automatic sampling using total number of students in stage 1 and 2 As a course administrator setting up a coursework instance for a large group of students @@ -17,19 +18,17 @@ Feature: Automatic sampling using total number of students in stage 1 and 2 Scenario: Automatically allocating a total for stage 2 based on stage 1 Given the coursework "numberofmarkers" setting is "2" in the database And the coursework "samplingenabled" setting is "1" in the database - And I am on the allocations page + And I visit the allocations page When I enable automatic sampling for stage 2 And I enable total rule for stage 2 And I select 50% of total students in stage 1 And I save sampling strategy - Then a student or another student should be automatically included in sample for stage 2 - - + Then a student or another student should be automatically included in sample for stage 2 Scenario: Automatically allocating a total for stage 3 based on stage 2 Given the coursework "numberofmarkers" setting is "3" in the database And the coursework "samplingenabled" setting is "1" in the database - And I am on the allocations page + And I visit the allocations page When I enable automatic sampling for stage 2 And I enable total rule for stage 2 And I select 100% of total students in stage 1 @@ -39,24 +38,12 @@ Feature: Automatic sampling using total number of students in stage 1 and 2 And I save sampling strategy Then a student or another student should be automatically included in sample for stage 3 - - Scenario: Automatically allocating a total for stage 3 based on stage 1 Given the coursework "numberofmarkers" setting is "3" in the database And the coursework "samplingenabled" setting is "1" in the database - And I am on the allocations page + And I visit the allocations page When I enable automatic sampling for stage 3 And I enable total rule for stage 3 And I select 50% of total students in stage 1 And I save sampling strategy Then a student or another student should be automatically included in sample for stage 3 - - - - - - - - - - diff --git a/tests/behat/sampling_manual_sampling.feature b/tests/behat/sampling_manual_sampling.feature index a84b1955..5a7c3cb2 100644 --- a/tests/behat/sampling_manual_sampling.feature +++ b/tests/behat/sampling_manual_sampling.feature @@ -5,49 +5,46 @@ Feature: Manual sampling I can manually select the submissions to be included in the sample for a single feedback stage So I can select correct sample of students for double marking - Background: - Given there is a course - And I am logged in as a manager - And the manager has a capability to allocate students in samplings - And there is a coursework - And the coursework allocation option is disabled - And the coursework has sampling enabled - And the coursework is set to double marker - And there is a student - And there is a teacher - And the teacher has a capability to mark submissions - And there is another teacher - And the student has a submission - And there is feedback for the submission from the other teacher - And the submission deadline has passed - And the submission is finalised - - - Scenario: Manual sampling should include student when selected - When I visit the allocations page - And I select a student as a part of the sample for the second stage - And I save everything - And I log out - And I log in as the teacher - And I visit the coursework page - Then I should be able to add the second grade for this student - - - Scenario: Manual sampling should not include student when not selected - When I visit the allocations page - And I deselect a student as a part of the sample for the second stage - And I save everything - And I log out - And I log in as the teacher - And I visit the coursework page - Then I should not be able to add the second grade for this student - - - Scenario: Single grade should go to the gradebook column when only first stage is in sample - When I visit the allocations page - And I deselect a student as a part of the sample for the second stage - And I save everything - And I log out - And I log in as the teacher - And I visit the coursework page - Then I should see the grade given by the initial teacher in the provisional grade column + Background: + Given there is a course + And I am logged in as a manager + And the manager has a capability to allocate students in samplings + And there is a coursework + And the coursework allocation option is disabled + And the coursework has sampling enabled + And the coursework is set to double marker + And there is a student + And there is a teacher + And the teacher has a capability to mark submissions + And there is another teacher + And the student has a submission + And there is feedback for the submission from the other teacher + And the submission deadline has passed + And the submission is finalised + + Scenario: Manual sampling should include student when selected + When I visit the allocations page + And I select a student as a part of the sample for the second stage + And I save everything + And I log out + And I log in as the teacher + And I visit the coursework page + Then I should be able to add the second grade for this student + + Scenario: Manual sampling should not include student when not selected + When I visit the allocations page + And I deselect a student as a part of the sample for the second stage + And I save everything + And I log out + And I log in as the teacher + And I visit the coursework page + Then I should not be able to add the second grade for this student + + Scenario: Single grade should go to the gradebook column when only first stage is in sample + When I visit the allocations page + And I deselect a student as a part of the sample for the second stage + And I save everything + And I log out + And I log in as the teacher + And I visit the coursework page + Then I should see the grade given by the initial teacher in the provisional grade column diff --git a/tests/behat/sampling_sample_range_set_rules.feature b/tests/behat/sampling_sample_range_set_rules.feature index 53ba5026..71714f77 100644 --- a/tests/behat/sampling_sample_range_set_rules.feature +++ b/tests/behat/sampling_sample_range_set_rules.feature @@ -1,3 +1,4 @@ +@mod @mod_coursework Feature: Automatic sample based on range set grades using marking of students in stage 1 and 2 As a manager, I want to be able to automatically allocate assessors to students @@ -26,10 +27,9 @@ Feature: Automatic sample based on range set grades using marking of students in And I grade the submission as 45 using the simple form And I log out - Scenario: Automatically allocating a set of students within specified grade rule range in stage 2 based on stage 1 grades Given I am logged in as a manager - And I am on the allocations page + And I visit the allocations page And I enable automatic sampling for stage 2 And show me the page And I enable grade range rule 1 for stage 2 @@ -50,11 +50,9 @@ Feature: Automatic sample based on range set grades using marking of students in #Then a student should be automatically included in sample for stage 2 #And another student should be automatically included in sample for stage 2 - - Scenario: Automatically allocating a set of students within specified percentage rule range in stage 3 based on stage 2 grades Given I am logged in as a manager - And I am on the allocations page + And I visit the allocations page And I enable automatic sampling for stage 2 And I enable total rule for stage 2 And I select 100% of total students in stage 1 @@ -66,7 +64,7 @@ Feature: Automatic sample based on range set grades using marking of students in And I grade the submission as 40 using the simple form And I log out And I am logged in as a manager - And I am on the allocations page + And I visit the allocations page When I enable automatic sampling for stage 3 And I enable grade range rule 1 for stage 3 And I select limit type for grade range rule 1 in stage 3 as "percentage" @@ -75,13 +73,3 @@ Feature: Automatic sample based on range set grades using marking of students in And I save sampling strategy Then a student should be automatically included in sample for stage 3 And another student should not be automatically included in sample for stage 3 - - - - - - - - - - diff --git a/tests/behat/submissions_agree_submission_terms.feature b/tests/behat/submissions_agree_submission_terms.feature index 35ede8d9..b94f931e 100644 --- a/tests/behat/submissions_agree_submission_terms.feature +++ b/tests/behat/submissions_agree_submission_terms.feature @@ -1,96 +1,95 @@ -@mod @mod_coursework +@mod @mod_coursework @_file_upload Feature: Students must agree to terms before submitting anything As a manger I want to be able to force students to agree to terms and conditions So that we are legally protected in case of disputes over plagiarism and the students can't cheat - Background: - Given there is a course - And there is a coursework - And I am logged in as a student + Background: + Given there is a course + And there is a coursework + And I am logged in as a student - Scenario: I see the terms when the site has the option enabled - Given the sitewide "coursework_agree_terms" setting is "1" - And the sitewide "coursework_agree_terms_text" setting is "Some text" - When I visit the coursework page - And I click on the new submission button - Then I should be on the new submission page - And I should see "Some text" + Scenario: I see the terms when the site has the option enabled + Given the sitewide "coursework_agree_terms" setting is "1" + And the sitewide "coursework_agree_terms_text" setting is "Some text" + When I visit the coursework page + And I click on the new submission button + Then I should be on the new submission page + And I should see "Some text" - Scenario: I do not see the terms when the site has the option disabled - Given the sitewide "coursework_agree_terms" setting is "0" - And the sitewide "coursework_agree_terms_text" setting is "Some text" - When I visit the coursework page - And I click on the new submission button - Then I should be on the new submission page - And I should not see "Some text" + Scenario: I do not see the terms when the site has the option disabled + Given the sitewide "coursework_agree_terms" setting is "0" + And the sitewide "coursework_agree_terms_text" setting is "Some text" + When I visit the coursework page + And I click on the new submission button + Then I should be on the new submission page + And I should not see "Some text" - @javascript - Scenario: The submission is saved when the agree terms checkbox is checked during create - Given the sitewide "coursework_agree_terms" setting is "1" - And the sitewide "coursework_agree_terms_text" setting is "Some text" - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I set the field "termsagreed" to "1" - And I press "Submit" - Then I should be on the coursework page + @javascript + Scenario: The submission is saved when the agree terms checkbox is checked during create + Given the sitewide "coursework_agree_terms" setting is "1" + And the sitewide "coursework_agree_terms_text" setting is "Some text" + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I set the field "termsagreed" to "1" + And I press "Submit" + Then I should be on the coursework page - @javascript - Scenario: The submission is not saved when the agree terms checkbox is not checked during create - Given the sitewide "coursework_agree_terms" setting is "1" - And the sitewide "coursework_agree_terms_text" setting is "Some text" - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I press "Submit" - Then I should be on the create submission page + @javascript + Scenario: The submission is not saved when the agree terms checkbox is not checked during create + Given the sitewide "coursework_agree_terms" setting is "1" + And the sitewide "coursework_agree_terms_text" setting is "Some text" + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I press "Submit" + Then I should be on the create submission page - @javascript - Scenario: The submission is saved when the agree terms checkbox is checked during update - Given the sitewide "coursework_agree_terms" setting is "1" - And the sitewide "coursework_agree_terms_text" setting is "Some text" - And the student has a submission - When I visit the coursework page - And I click on the edit submission button - And I set the field "termsagreed" to "1" - And I press "Submit" - Then I should be on the coursework page + @javascript + Scenario: The submission is saved when the agree terms checkbox is checked during update + Given the sitewide "coursework_agree_terms" setting is "1" + And the sitewide "coursework_agree_terms_text" setting is "Some text" + And the student has a submission + When I visit the coursework page + And I click on the edit submission button + And I set the field "termsagreed" to "1" + And I press "Submit" + Then I should be on the coursework page - @javascript - Scenario: The submission is not saved when the agree terms checkbox is not checked during update - Given the sitewide "coursework_agree_terms" setting is "1" - And the sitewide "coursework_agree_terms_text" setting is "Some text" - And the student has a submission - When I visit the coursework page - And I click on the edit submission button - And I press "Submit" - Then I should be on the update submission page + @javascript + Scenario: The submission is not saved when the agree terms checkbox is not checked during update + Given the sitewide "coursework_agree_terms" setting is "1" + And the sitewide "coursework_agree_terms_text" setting is "Some text" + And the student has a submission + When I visit the coursework page + And I click on the edit submission button + And I press "Submit" + Then I should be on the update submission page - @javascript - Scenario: The file should not be saved if the agree terms are skipped on create - Given the sitewide "coursework_agree_terms" setting is "1" - And the sitewide "coursework_agree_terms_text" setting is "Some text" - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I press "Submit" - Then I should be on the create submission page - When I visit the coursework page - Then I should not see the file on the page - - @javascript - Scenario: The file should not be saved if the agree terms are skipped on update - Given the sitewide "coursework_agree_terms" setting is "1" - And the sitewide "coursework_agree_terms_text" setting is "Some text" - And the coursework "maxfiles" setting is "2" in the database - And the student has a submission - When I visit the coursework page - And I click on the edit submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I press "Submit" - Then I should be on the update submission page - When I visit the coursework page - Then I should see 1 file on the page + @javascript + Scenario: The file should not be saved if the agree terms are skipped on create + Given the sitewide "coursework_agree_terms" setting is "1" + And the sitewide "coursework_agree_terms_text" setting is "Some text" + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I press "Submit" + Then I should be on the create submission page + When I visit the coursework page + Then I should not see the file on the page + @javascript + Scenario: The file should not be saved if the agree terms are skipped on update + Given the sitewide "coursework_agree_terms" setting is "1" + And the sitewide "coursework_agree_terms_text" setting is "Some text" + And the coursework "maxfiles" setting is "2" in the database + And the student has a submission + When I visit the coursework page + And I click on the edit submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I press "Submit" + Then I should be on the update submission page + When I visit the coursework page + Then I should see 1 file on the page diff --git a/tests/behat/submissions_auto_finalisation.feature b/tests/behat/submissions_auto_finalisation.feature index b8edc44b..18b19cc8 100644 --- a/tests/behat/submissions_auto_finalisation.feature +++ b/tests/behat/submissions_auto_finalisation.feature @@ -1,3 +1,4 @@ +@mod @mod_coursework Feature: Auto finalising before cron runs As a teacher @@ -5,19 +6,19 @@ Feature: Auto finalising before cron runs wait for the cron to run So that I can start marking immediately - Background: - Given there is a course - And there is a coursework - And there is a student - And the student has a submission + Background: + Given there is a course + And there is a coursework + And there is a student + And the student has a submission - Scenario: Teacher visits the page and sees the submission is finalised when the deadline has passed - Given I am logged in as a teacher - And the coursework deadline has passed - When I visit the coursework page - Then I should see "Ready to grade" + Scenario: Teacher visits the page and sees the submission is finalised when the deadline has passed + Given I am logged in as a teacher + And the coursework deadline has passed + When I visit the coursework page + Then I should see "Ready to grade" - Scenario: Teacher visits the page and sees the submission is not finalised when the deadline has not passed - Given I am logged in as a teacher - When I visit the coursework page - Then I should not see "Ready to grade" + Scenario: Teacher visits the page and sees the submission is not finalised when the deadline has not passed + Given I am logged in as a teacher + When I visit the coursework page + Then I should not see "Ready to grade" diff --git a/tests/behat/submissions_deadlines.feature b/tests/behat/submissions_deadlines.feature index 934338fa..930ead3e 100644 --- a/tests/behat/submissions_deadlines.feature +++ b/tests/behat/submissions_deadlines.feature @@ -5,28 +5,28 @@ Feature: Deadlines for submissions I want to set deadlines that are viible to the student So that they know when they are expected to submut, and can be sent automatic reminders - Background: - Given there is a course - And I am logged in as a teacher - And there is a coursework + Background: + Given there is a course + And I am logged in as a teacher + And there is a coursework - Scenario: the general feedback deadline should be visible if enabled and set - Given the coursework "generalfeedback" setting is "777777" in the database - And the coursework general feedback is enabled - When I visit the coursework page - Then I should see the date when the general feedback will be released + Scenario: the general feedback deadline should be visible if enabled and set + Given the coursework "generalfeedback" setting is "777777" in the database + And the coursework general feedback is enabled + When I visit the coursework page + Then I should see the date when the general feedback will be released - Scenario: the individual feedback deadline should not be visible if not enabled - Given the coursework "individualfeedback" setting is "0" in the database - When I visit the coursework page - Then I should not see the date when the individual feedback will be released + Scenario: the individual feedback deadline should not be visible if not enabled + Given the coursework "individualfeedback" setting is "0" in the database + When I visit the coursework page + Then I should not see the date when the individual feedback will be released - Scenario: the individual feedback deadline should be visible if enabled - Given the coursework "individualfeedback" setting is "777777" in the database - When I visit the coursework page - Then I should see the date when the individual feedback will be released + Scenario: the individual feedback deadline should be visible if enabled + Given the coursework "individualfeedback" setting is "777777" in the database + When I visit the coursework page + Then I should see the date when the individual feedback will be released - Scenario: the general feedback deadline should be visible if not enabled - Given the coursework "individualfeedback" setting is "7777777" in the database - When I visit the coursework page - Then I should see the date when the individual feedback will be released \ No newline at end of file + Scenario: the general feedback deadline should be visible if not enabled + Given the coursework "individualfeedback" setting is "7777777" in the database + When I visit the coursework page + Then I should see the date when the individual feedback will be released diff --git a/tests/behat/submissions_early_finalisation.feature b/tests/behat/submissions_early_finalisation.feature index 5e2ad2b8..05ac7c8e 100644 --- a/tests/behat/submissions_early_finalisation.feature +++ b/tests/behat/submissions_early_finalisation.feature @@ -1,3 +1,4 @@ +@mod @mod_coursework Feature: Early finalisation of student submissions As a teacher @@ -5,47 +6,47 @@ Feature: Early finalisation of student submissions So that there is a way to know when something is ready to mark before the deadline is due and I can plan my grading work more effectively - Background: - Given there is a course - And there is a coursework - And the coursework "allowearlyfinalisation" setting is "1" in the database - And I am logged in as a student + Background: + Given there is a course + And there is a coursework + And the coursework "allowearlyfinalisation" setting is "1" in the database + And I am logged in as a student - @javascript - Scenario: I upload a file and finalise it immediately - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I save and finalise the submission - And I visit the coursework page - Then I should see the file on the page - And I should not see the edit submission button - And I should not see the finalise submission button + @javascript @_file_upload + Scenario: I upload a file and finalise it immediately + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I save and finalise the submission + And I visit the coursework page + Then I should see the file on the page + And I should not see the edit submission button + And I should not see the finalise submission button - @broken @javascript - Scenario: I upload a file and save it - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I save the submission - And I visit the coursework page - And I click on the finalise submission button - And I agree to the confirm message - Then I should be on the coursework page - And I should not see the finalise submission button + @broken @javascript @_file_upload + Scenario: I upload a file and save it + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I save the submission + And I visit the coursework page + And I click on the finalise submission button + And I agree to the confirm message + Then I should be on the coursework page + And I should not see the finalise submission button - @javascript - Scenario: I should not see the early finalisation button on the student page when the option is disabled - Given the coursework "allowearlyfinalisation" setting is "0" in the database - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I save the submission - And I visit the coursework page - Then I should not see the finalise button + @javascript @_file_upload + Scenario: I should not see the early finalisation button on the student page when the option is disabled + Given the coursework "allowearlyfinalisation" setting is "0" in the database + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I save the submission + And I visit the coursework page + Then I should not see the finalise button - Scenario: I should not see the early finalisation button on the student submission form - Given the coursework "allowearlyfinalisation" setting is "0" in the database - When I visit the coursework page - And I click on the new submission button - Then I should not see the save and finalise button \ No newline at end of file + Scenario: I should not see the early finalisation button on the student submission form + Given the coursework "allowearlyfinalisation" setting is "0" in the database + When I visit the coursework page + And I click on the new submission button + Then I should not see the save and finalise button diff --git a/tests/behat/submissions_file_upload_limit.feature b/tests/behat/submissions_file_upload_limit.feature index 50ae4ffb..38770dcf 100644 --- a/tests/behat/submissions_file_upload_limit.feature +++ b/tests/behat/submissions_file_upload_limit.feature @@ -5,18 +5,17 @@ Feature: File upload limits I want to be able to limit the number of files that a student can upload So that they must submit a specific number - Background: - Given there is a course - And there is a coursework - And I am logged in as a student + Background: + Given there is a course + And there is a coursework + And I am logged in as a student - @javascript - Scenario: I am prevented from uploading more files than specified - Given the coursework "maxfiles" setting is "2" in the database - - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I upload "mod/coursework/tests/files_for_uploading/Test_document_two.docx" file to "Upload a file" filemanager - Then the file upload button should not be visible + @javascript @_file_upload + Scenario: I am prevented from uploading more files than specified + Given the coursework "maxfiles" setting is "2" in the database + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I upload "mod/coursework/tests/files_for_uploading/Test_document_two.docx" file to "Upload a file" filemanager + Then the file upload button should not be visible diff --git a/tests/behat/submissions_file_upload_types.feature b/tests/behat/submissions_file_upload_types.feature index 04315233..061ba499 100644 --- a/tests/behat/submissions_file_upload_types.feature +++ b/tests/behat/submissions_file_upload_types.feature @@ -5,33 +5,33 @@ Feature: Restricting the types of files that students can upload I want to be able to restrict what file types the students can upload So that tutors marking the work have a consistent experence and don't waste time - Background: - Given there is a course - And there is a coursework - And I am logged in as a student + Background: + Given there is a course + And there is a coursework + And I am logged in as a student - @javascript - Scenario: I can upload anything when the settings are empty - Given the coursework "filetypes" setting is "" in the database + @javascript @_file_upload + Scenario: I can upload anything when the settings are empty + Given the coursework "filetypes" setting is "" in the database - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_image.png" file to "Upload a file" filemanager - Then I should see "1" elements in "Upload a file" filemanager + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_image.png" file to "Upload a file" filemanager + Then I should see "1" elements in "Upload a file" filemanager # Wrong file type throws an exception with a backtrace. Can't find out how to expect this. -# @javascript -# Scenario: I can not upload other file types when the settings are restrictive -# Given the coursework "filetypes" setting is "doc" in the database +# @javascript @_file_upload +# Scenario: I can not upload other file types when the settings are restrictive +# Given the coursework "filetypes" setting is "doc" in the database # -# When I visit the coursework page -# And I upload "mod/coursework/tests/files_for_uploading/Test_image.png" file to "Upload a file" filemanager -# Then I should see "0" elements in "Upload a file" filemanager +# When I visit the coursework page +# And I upload "mod/coursework/tests/files_for_uploading/Test_image.png" file to "Upload a file" filemanager +# Then I should see "0" elements in "Upload a file" filemanager - @javascript - Scenario: I can upload allowed file types when the settings are restrictive - Given the coursework "filetypes" setting is "docx" in the database - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - Then I should see "1" elements in "Upload a file" filemanager \ No newline at end of file + @javascript @_file_upload + Scenario: I can upload allowed file types when the settings are restrictive + Given the coursework "filetypes" setting is "docx" in the database + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + Then I should see "1" elements in "Upload a file" filemanager diff --git a/tests/behat/submissions_group_submissions.feature b/tests/behat/submissions_group_submissions.feature index 1e81afba..dc438526 100644 --- a/tests/behat/submissions_group_submissions.feature +++ b/tests/behat/submissions_group_submissions.feature @@ -5,44 +5,44 @@ Feature: Students are able to submit one piece of work on behalf of the group I want to be able to submit a single piece of work on behalf of the other people in my group So that they and the tutor can see it and mark it - Background: - Given there is a course - And there is a coursework - And the coursework "use_groups" setting is "1" in the database - And I am logged in as a student - And the student is a member of a group - And there is another student - And the other student is a member of the group + Background: + Given there is a course + And there is a coursework + And the coursework "use_groups" setting is "1" in the database + And I am logged in as a student + And the student is a member of a group + And there is another student + And the other student is a member of the group - @javascript - Scenario: I can submit a file and it appears for the others to see - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I press "Submit" - And I log out - And I log in as the other student - And I visit the coursework page - Then I should see the file on the page + @javascript @_file_upload + Scenario: I can submit a file and it appears for the others to see + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I press "Submit" + And I log out + And I log in as the other student + And I visit the coursework page + Then I should see the file on the page - @javascript - Scenario: I can resubmit the work when someone else has submitted it - Given the coursework "maxfiles" setting is "2" in the database - And I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I press "Submit" - And I log out - And I log in as the other student - And I visit the coursework page - Then I should see that the submission was made by the student + @javascript @_file_upload + Scenario: I can resubmit the work when someone else has submitted it + Given the coursework "maxfiles" setting is "2" in the database + And I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I press "Submit" + And I log out + And I log in as the other student + And I visit the coursework page + Then I should see that the submission was made by the student - When I click on the edit submission button - Then I should see "1" elements in "Upload a file" filemanager + When I click on the edit submission button + Then I should see "1" elements in "Upload a file" filemanager - When I upload "mod/coursework/tests/files_for_uploading/Test_document_two.docx" file to "Upload a file" filemanager + When I upload "mod/coursework/tests/files_for_uploading/Test_document_two.docx" file to "Upload a file" filemanager - And I press "Submit" - Then I should be on the coursework page - And I should see both the submission files on the page - And I should see that the submission was made by the other student + And I press "Submit" + Then I should be on the coursework page + And I should see both the submission files on the page + And I should see that the submission was made by the other student diff --git a/tests/behat/submissions_late_submissions.feature b/tests/behat/submissions_late_submissions.feature index 16d1fe76..f13ffb5c 100644 --- a/tests/behat/submissions_late_submissions.feature +++ b/tests/behat/submissions_late_submissions.feature @@ -1,29 +1,28 @@ +@mod @mod_coursework Feature: Late submissions As a teacher I want to be able to allow stuents to submit work past the deadline So that they can still get some credit even if their grades get capped - Background: - Given there is a course - And there is a coursework - And I am logged in as a student - - Scenario: not allowed to submit late if the setting does not allow it - Given the coursework "allowlatesubmissions" setting is "0" in the database - And the submission deadline has passed - When I visit the coursework page - Then I should not see the new submission button - - @javascript - Scenario: allowed to submit late if the setting allows it - Given the coursework "allowlatesubmissions" setting is "1" in the database - And the submission deadline has passed - When I visit the coursework page - Then I should see the new submission button - When I visit the new submission page - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I press "Submit" - Then I should be on the coursework page + Background: + Given there is a course + And there is a coursework + And I am logged in as a student + Scenario: not allowed to submit late if the setting does not allow it + Given the coursework "allowlatesubmissions" setting is "0" in the database + And the submission deadline has passed + When I visit the coursework page + Then I should not see the new submission button + @javascript @_file_upload + Scenario: allowed to submit late if the setting allows it + Given the coursework "allowlatesubmissions" setting is "1" in the database + And the submission deadline has passed + When I visit the coursework page + Then I should see the new submission button + When I visit the new submission page + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I press "Submit" + Then I should be on the coursework page diff --git a/tests/behat/submissions_start_date.feature b/tests/behat/submissions_start_date.feature index e8ca422d..2619ab90 100644 --- a/tests/behat/submissions_start_date.feature +++ b/tests/behat/submissions_start_date.feature @@ -1,27 +1,28 @@ +@mod @mod_coursework Feature: Start date As a teacher I want to be able to restrict the start date of the coursework So that students will not begin to work on it until the right time - Background: - Given there is a course - And there is a coursework + Background: + Given there is a course + And there is a coursework - Scenario: The student can submit when the start date is disabled - Given the coursework start date is disabled - When I log in as a student - And I visit the coursework page - Then I should see the new submission button + Scenario: The student can submit when the start date is disabled + Given the coursework start date is disabled + When I log in as a student + And I visit the coursework page + Then I should see the new submission button - Scenario: The student can not submit when the start date is in the future - Given the coursework start date is in the future - When I log in as a student - And I visit the coursework page - Then I should not see the new submission button + Scenario: The student can not submit when the start date is in the future + Given the coursework start date is in the future + When I log in as a student + And I visit the coursework page + Then I should not see the new submission button - Scenario: The student can submit when the start date is in the past - Given the coursework start date is in the past - When I log in as a student - And I visit the coursework page - Then I should see the new submission button \ No newline at end of file + Scenario: The student can submit when the start date is in the past + Given the coursework start date is in the past + When I log in as a student + And I visit the coursework page + Then I should see the new submission button diff --git a/tests/behat/submissions_student_submission.feature b/tests/behat/submissions_student_submission.feature index 01bcb082..963e5a1d 100644 --- a/tests/behat/submissions_student_submission.feature +++ b/tests/behat/submissions_student_submission.feature @@ -5,35 +5,29 @@ Feature: Students can submit files As a student who has completed some work I want to be able to upload it as a file to the coursework instance - Background: - Given there is a course - And there is a coursework - And I am logged in as a student - - @javascript - Scenario: I upload a file and see it on the coursework page as read only - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I save the submission - Then I should be on the coursework page - And I should see the file on the page - And I should see the edit submission button - - @javascript - Scenario: I upload a file and save it and I see it when I come back - When I visit the coursework page - And I click on the new submission button - And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager - And I save the submission - Then I should be on the coursework page - When I visit the course page - And I visit the coursework page - And I click on the edit submission button - Then I should see "1" elements in "Upload a file" filemanager - - - - - - + Background: + Given there is a course + And there is a coursework + And I am logged in as a student + + @javascript @_file_upload + Scenario: I upload a file and see it on the coursework page as read only + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I save the submission + Then I should be on the coursework page + And I should see the file on the page + And I should see the edit submission button + + @javascript @_file_upload + Scenario: I upload a file and save it and I see it when I come back + When I visit the coursework page + And I click on the new submission button + And I upload "mod/coursework/tests/files_for_uploading/Test_document.docx" file to "Upload a file" filemanager + And I save the submission + Then I should be on the coursework page + When I visit the course page + And I visit the coursework page + And I click on the edit submission button + Then I should see "1" elements in "Upload a file" filemanager diff --git a/tests/behat/submissions_submit_onbehalf_student.feature b/tests/behat/submissions_submit_onbehalf_student.feature index 8aee7f49..6922ed43 100644 --- a/tests/behat/submissions_submit_onbehalf_student.feature +++ b/tests/behat/submissions_submit_onbehalf_student.feature @@ -11,7 +11,7 @@ Feature: User can submit on behalf of a student And there is a student And I am logged in as a manager - @javascript + @javascript @_file_upload Scenario: As a teacher, I upload a file and see it on the coursework page as read only When I visit the coursework page And I click on the new submission button for the student diff --git a/tests/behat/warnings.feature b/tests/behat/warnings.feature index 3769f3ec..d13f3286 100644 --- a/tests/behat/warnings.feature +++ b/tests/behat/warnings.feature @@ -1,30 +1,31 @@ +@mod @mod_coursework@mod @mod_coursework Feature: warnings when settings are not right As a manager I want to know when there are issues with the setup of the coursework instance So that I can take corrective action before stuff goes wrong - Background: - Given there is a course - And there is a coursework + Background: + Given there is a course + And there is a coursework - Scenario: managers see a warning about there being too few teachers - Given there is a teacher - And the coursework "numberofmarkers" setting is "3" in the database - And I am logged in as a manager - When I visit the coursework page - Then I should see "There are only" + Scenario: managers see a warning about there being too few teachers + Given there is a teacher + And the coursework "numberofmarkers" setting is "3" in the database + And I am logged in as a manager + When I visit the coursework page + Then I should see "There are only" - Scenario: Teachers do not see the warnign about too few teachers - Given there is a teacher - And the coursework "numberofmarkers" setting is "3" in the database - And I am logged in as a teacher - When I visit the coursework page - Then I should not see "There are only" + Scenario: Teachers do not see the warning about too few teachers + Given there is a teacher + And the coursework "numberofmarkers" setting is "3" in the database + And I am logged in as a teacher + When I visit the coursework page + Then I should not see "There are only" - Scenario: There is no warning when there are enough teachers - Given there is a teacher - And the coursework "numberofmarkers" setting is "1" in the database - And I am logged in as a manager - When I visit the coursework page - Then I should not see "There are only" + Scenario: There is no warning when there are enough teachers + Given there is a teacher + And the coursework "numberofmarkers" setting is "1" in the database + And I am logged in as a manager + When I visit the coursework page + Then I should not see "There are only" From aa3285d916924fe79280413d41a8b599edf1d338 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:36:45 +0100 Subject: [PATCH 03/27] CTP-3690 comma multi-line array --- actions/allocate.php | 4 +- actions/feedbacks/edit.php | 2 +- actions/feedbacks/show.php | 2 +- actions/feedbacks/update.php | 2 +- actions/personal_deadline.php | 2 +- actions/plagiarism_flagging/create.php | 2 +- actions/plagiarism_flagging/edit.php | 2 +- actions/plagiarism_flagging/new.php | 2 +- actions/plagiarism_flagging/update.php | 2 +- actions/set_personal_deadlines.php | 2 +- backup/moodle2/backup_coursework_stepslib.php | 26 ++--- classes/allocation/strategy/base.php | 2 +- classes/allocation/strategy/percentages.php | 4 +- classes/auto_grader/average_grade.php | 2 +- classes/auto_grader/percentage_distance.php | 2 +- classes/calendar.php | 4 +- .../deadline_extensions_controller.php | 12 +-- .../personal_deadlines_controller.php | 4 +- .../plagiarism_flagging_controller.php | 4 +- .../controllers/submissions_controller.php | 12 +-- classes/cron.php | 2 +- .../csv/cells/assessorfeedback_cell.php | 2 +- .../export/csv/cells/assessorgrade_cell.php | 2 +- .../export/csv/cells/otherassessors_cell.php | 2 +- classes/export/grading_sheet.php | 2 +- classes/export/import.php | 2 +- classes/forms/advance_plugins_form.php | 2 +- classes/forms/assessor_feedback_mform.php | 4 +- classes/framework/test/table_base_test.php | 14 +-- classes/grading_table_row_base.php | 2 +- classes/models/course_module.php | 2 +- classes/models/moderation_set_rule.php | 2 +- classes/models/personal_deadline.php | 2 +- classes/models/sample_set_rule.php | 2 +- .../minimum_range_grade_percent.php | 6 +- .../minimum_range_grade_raw.php | 6 +- .../range_grade_percent.php | 4 +- .../moderation_set_rule/range_grade_raw.php | 4 +- .../range_total_percent.php | 2 +- classes/personal_deadline/table/builder.php | 4 +- classes/plagiarism_helpers/turnitin.php | 2 +- classes/privacy/provider.php | 26 ++--- .../cells/moderation_agreement_cell.php | 8 +- .../cells/multiple_agreed_grade_cell.php | 2 +- .../cells/plagiarism_flag_cell.php | 6 +- .../cells/single_assessor_feedback_cell.php | 2 +- classes/sample_set_rule/sample_base.php | 2 +- classes/sampling_set_widget.php | 4 +- classes/stages/base.php | 6 +- classes/warnings.php | 2 +- db/access.php | 102 +++++++++--------- db/caches.php | 4 +- db/events.php | 2 +- db/log.php | 2 +- db/tasks.php | 8 +- lib.php | 6 +- mod_form.php | 4 +- renderers/grading_report_renderer.php | 4 +- renderers/object_renderer.php | 10 +- view.php | 4 +- 60 files changed, 184 insertions(+), 184 deletions(-) diff --git a/actions/allocate.php b/actions/allocate.php index 1b9fc262..01ac806c 100644 --- a/actions/allocate.php +++ b/actions/allocate.php @@ -98,7 +98,7 @@ 'name' => 'mod_coursework', 'fullpath' => '/mod/coursework/module.js', 'requires' => array('base', - 'node-base') + 'node-base'), ); $PAGE->requires->js_init_call('M.mod_coursework.init_allocate_page', array('wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid), @@ -215,7 +215,7 @@ // Spacer so that we can float the headers next to each other. $attributes = array( - 'class' => 'coursework_spacer' + 'class' => 'coursework_spacer', ); echo html_writer::start_tag('div', $attributes); echo html_writer::end_tag('div'); diff --git a/actions/feedbacks/edit.php b/actions/feedbacks/edit.php index 57ebd485..397d7d1b 100644 --- a/actions/feedbacks/edit.php +++ b/actions/feedbacks/edit.php @@ -29,7 +29,7 @@ $params = array( 'feedbackid' => $feedbackid, - 'ajax' => $ajax + 'ajax' => $ajax, ); $controller = new mod_coursework\controllers\feedback_controller($params); $controller->edit_feedback(); diff --git a/actions/feedbacks/show.php b/actions/feedbacks/show.php index b74fd868..a3ee41ef 100644 --- a/actions/feedbacks/show.php +++ b/actions/feedbacks/show.php @@ -29,7 +29,7 @@ $params = array( 'feedbackid' => $feedbackid, - 'ajax' => $ajax + 'ajax' => $ajax, ); $controller = new mod_coursework\controllers\feedback_controller($params); diff --git a/actions/feedbacks/update.php b/actions/feedbacks/update.php index ab1bafad..4524d49b 100644 --- a/actions/feedbacks/update.php +++ b/actions/feedbacks/update.php @@ -39,7 +39,7 @@ 'finalised' => $finalised, 'remove' => $remove, 'confirm' => $confirm, - 'ajax' => $ajax + 'ajax' => $ajax, ); if ($ajax) { diff --git a/actions/personal_deadline.php b/actions/personal_deadline.php index e4ed63cc..63508468 100644 --- a/actions/personal_deadline.php +++ b/actions/personal_deadline.php @@ -46,7 +46,7 @@ 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, 'setpersonaldeadlinespage' => $setpersonaldeadlinespage, - 'multipleuserdeadlines' => $multipleuserdeadlines + 'multipleuserdeadlines' => $multipleuserdeadlines, ); if ($selectedtype != 'unfinalise') { diff --git a/actions/plagiarism_flagging/create.php b/actions/plagiarism_flagging/create.php index 1afc831c..12eb39fe 100644 --- a/actions/plagiarism_flagging/create.php +++ b/actions/plagiarism_flagging/create.php @@ -31,7 +31,7 @@ $submissionid = required_param('submissionid', PARAM_INT); $params = array( - 'submissionid' => $submissionid + 'submissionid' => $submissionid, ); $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); diff --git a/actions/plagiarism_flagging/edit.php b/actions/plagiarism_flagging/edit.php index be4b7507..deb30313 100644 --- a/actions/plagiarism_flagging/edit.php +++ b/actions/plagiarism_flagging/edit.php @@ -27,7 +27,7 @@ $flagid = optional_param('flagid', 0, PARAM_INT); $params = array( - 'flagid' => $flagid + 'flagid' => $flagid, ); $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); diff --git a/actions/plagiarism_flagging/new.php b/actions/plagiarism_flagging/new.php index d1b3a388..a4b01cb1 100644 --- a/actions/plagiarism_flagging/new.php +++ b/actions/plagiarism_flagging/new.php @@ -27,7 +27,7 @@ $submissionid = required_param('submissionid', PARAM_INT); $params = array( - 'submissionid' => $submissionid + 'submissionid' => $submissionid, ); $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); diff --git a/actions/plagiarism_flagging/update.php b/actions/plagiarism_flagging/update.php index 903d7245..33d2825f 100644 --- a/actions/plagiarism_flagging/update.php +++ b/actions/plagiarism_flagging/update.php @@ -31,7 +31,7 @@ $flagid = required_param('flagid', PARAM_INT); $params = array( - 'flagid' => $flagid + 'flagid' => $flagid, ); $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); diff --git a/actions/set_personal_deadlines.php b/actions/set_personal_deadlines.php index c6d42bf4..2e946a07 100644 --- a/actions/set_personal_deadlines.php +++ b/actions/set_personal_deadlines.php @@ -59,7 +59,7 @@ 'name' => 'mod_coursework', 'fullpath' => '/mod/coursework/module.js', 'requires' => array('base', - 'node-base') + 'node-base'), ); $PAGE->requires->js_init_call('M.mod_coursework.init_personal_deadlines_page', [], diff --git a/backup/moodle2/backup_coursework_stepslib.php b/backup/moodle2/backup_coursework_stepslib.php index 104b12e9..960553cf 100644 --- a/backup/moodle2/backup_coursework_stepslib.php +++ b/backup/moodle2/backup_coursework_stepslib.php @@ -105,7 +105,7 @@ protected function define_structure() { 'draftfeedbackenabled', 'processenrol', 'processunenrol', - 'plagiarismflagenabled' + 'plagiarismflagenabled', )); $sample_strategies = new backup_nested_element('coursework_sample_set_rules'); @@ -140,7 +140,7 @@ protected function define_structure() { "createdby", "timecreated", "lastmodifiedby", - "timemodified" + "timemodified", )); $moderation_agreements = new backup_nested_element('coursework_mod_agreements'); @@ -154,7 +154,7 @@ protected function define_structure() { "timemodified", "lasteditedby", "modcomment", - "modecommentformat" + "modecommentformat", )); $feedbacks = new backup_nested_element('coursework_feedbacks'); @@ -176,7 +176,7 @@ protected function define_structure() { "entry_id", "markernumber", "stage_identifier", - "finalised" + "finalised", )); $submissions = new backup_nested_element('coursework_submissions'); @@ -198,7 +198,7 @@ protected function define_structure() { 'allocatablegroup', "firstpublished", "lastpublished", - "timesubmitted" + "timesubmitted", )); $reminders = new backup_nested_element('coursework_reminders'); @@ -207,7 +207,7 @@ protected function define_structure() { "userid", "coursework_id", "remindernumber", - "extension" + "extension", )); $pairs = new backup_nested_element('coursework_allocation_pairs'); @@ -223,7 +223,7 @@ protected function define_structure() { "allocatableid", "allocatabletype", 'allocatableuser', - 'allocatablegroup' + 'allocatablegroup', )); $modsetrules = new backup_nested_element('coursework_mod_set_rules'); @@ -235,7 +235,7 @@ protected function define_structure() { "ruleorder", "upperlimit", "lowerlimit", - "minimum" + "minimum", )); $allocation_configs = new backup_nested_element('coursework_allocation_configs'); @@ -246,7 +246,7 @@ protected function define_structure() { "allocationstrategy", "assessorid", "value", - "purpose" + "purpose", )); $modsetmembers = new backup_nested_element('coursework_mod_set_members'); @@ -258,7 +258,7 @@ protected function define_structure() { "allocatabletype", 'allocatableuser', 'allocatablegroup', - "stage_identifier" + "stage_identifier", )); $extensions = new backup_nested_element('coursework_extensions'); @@ -274,7 +274,7 @@ protected function define_structure() { "pre_defined_reason", "createdbyid", "extra_information_text", - "extra_information_format" + "extra_information_format", )); $personal_deadlines = new backup_nested_element('coursework_person_deadlines'); @@ -290,7 +290,7 @@ protected function define_structure() { "createdbyid", "timecreated", "timemodified", - "lastmodifiedbyid" + "lastmodifiedbyid", )); $sample_members = new backup_nested_element('coursework_sample_set_mbrs'); @@ -303,7 +303,7 @@ protected function define_structure() { 'allocatableuser', 'allocatablegroup', "stage_identifier", - "selectiontype" + "selectiontype", )); // A coursework instance has submissions. diff --git a/classes/allocation/strategy/base.php b/classes/allocation/strategy/base.php index 4069fa15..92210f76 100644 --- a/classes/allocation/strategy/base.php +++ b/classes/allocation/strategy/base.php @@ -146,7 +146,7 @@ protected final function get_existing_config_data($type = 'assessor', $reset = f $params = array( 'courseworkid' => $this->coursework->id, 'allocationstrategy' => $this->get_name(), - 'purpose' => $type + 'purpose' => $type, ); $this->settings[$type] = $DB->get_records('coursework_allocation_config', $params); diff --git a/classes/allocation/strategy/percentages.php b/classes/allocation/strategy/percentages.php index a6fc2064..90b7f098 100644 --- a/classes/allocation/strategy/percentages.php +++ b/classes/allocation/strategy/percentages.php @@ -104,7 +104,7 @@ public function add_form_elements($strategypurpose = 'assessor') { $attributes = array( 'name' => 'assessorstrategy'.$this->get_name().'['.$teacher->id.']', - 'size' => 3 + 'size' => 3, ); if ($currentsetting) { $attributes['value'] = $currentsetting->value; @@ -159,7 +159,7 @@ public function save_allocation_strategy_options() { 'courseworkid' => $this->coursework->id, 'allocationstrategy' => $this->get_name(), 'assessorid' => $teacherid, - 'purpose' => 'assessor' + 'purpose' => 'assessor', ); $DB->delete_records('coursework_allocation_config', $params); continue; diff --git a/classes/auto_grader/average_grade.php b/classes/auto_grader/average_grade.php index 149f166b..46114cd3 100644 --- a/classes/auto_grader/average_grade.php +++ b/classes/auto_grader/average_grade.php @@ -135,7 +135,7 @@ private function create_final_feedback() { feedback::create(array( 'stage_identifier' => 'final_agreed_1', 'submissionid' => $this->get_allocatable()->get_submission($this->get_coursework())->id(), - 'grade' => $this->automatic_grade() + 'grade' => $this->automatic_grade(), )); } diff --git a/classes/auto_grader/percentage_distance.php b/classes/auto_grader/percentage_distance.php index 92575b51..4f59a389 100644 --- a/classes/auto_grader/percentage_distance.php +++ b/classes/auto_grader/percentage_distance.php @@ -133,7 +133,7 @@ private function create_final_feedback() { feedback::create(array( 'stage_identifier' => 'final_agreed_1', 'submissionid' => $this->get_allocatable()->get_submission($this->get_coursework())->id(), - 'grade' => $this->automatic_grade() + 'grade' => $this->automatic_grade(), )); } diff --git a/classes/calendar.php b/classes/calendar.php index 6d52af5c..1ebcefb1 100644 --- a/classes/calendar.php +++ b/classes/calendar.php @@ -58,12 +58,12 @@ public static function coursework_event(object $coursework, string $eventtype, ? if ($cm->showdescription) { $event->description = array( 'text' => $intro, - 'format' => $coursework->introformat + 'format' => $coursework->introformat, ); } else { $event->description = array( 'text' => '', - 'format' => $coursework->introformat + 'format' => $coursework->introformat, ); } diff --git a/classes/controllers/deadline_extensions_controller.php b/classes/controllers/deadline_extensions_controller.php index 7612db02..bf0d86d5 100644 --- a/classes/controllers/deadline_extensions_controller.php +++ b/classes/controllers/deadline_extensions_controller.php @@ -210,13 +210,13 @@ public function ajax_submit_mitigation($data_params) { $response = [ 'error' => 0, 'data' => $data_params, - 'content' => $content + 'content' => $content, ]; echo json_encode($response); } else { $response = [ 'error' => 1, - 'messages' => $errors + 'messages' => $errors, ]; echo json_encode($response); @@ -246,7 +246,7 @@ public function submission_exists($data) { return $DB->record_exists('coursework_submissions', array( 'courseworkid' => $data['courseworkid'], 'allocatableid' => $data['allocatableid'], - 'allocatabletype' => $data['allocatabletype'] + 'allocatabletype' => $data['allocatabletype'], )); } @@ -322,13 +322,13 @@ public function ajax_edit_mitigation($data_params) { ]; $response = [ 'error' => 0, - 'data' => $deadline_extension_transform + 'data' => $deadline_extension_transform, ]; } } else { $response = [ 'error' => 1, - 'message' => 'ID can not be lower than 1!' + 'message' => 'ID can not be lower than 1!', ]; } echo json_encode($response); @@ -373,7 +373,7 @@ public function ajax_new_mitigation($data_params) { $response = [ 'error' => 0, - 'data' => $deadline_extension_transform + 'data' => $deadline_extension_transform, ]; echo json_encode($response); diff --git a/classes/controllers/personal_deadlines_controller.php b/classes/controllers/personal_deadlines_controller.php index c34d6385..6774813b 100644 --- a/classes/controllers/personal_deadlines_controller.php +++ b/classes/controllers/personal_deadlines_controller.php @@ -179,7 +179,7 @@ public function insert_update($time) { if (!$this->validated($time)) { return [ 'error' => 1, - 'message' => 'The new deadline you chose has already passed. Please select appropriate deadline' + 'message' => 'The new deadline you chose has already passed. Please select appropriate deadline', ]; } $this->coursework = coursework::find(['id' => $this->params['courseworkid']]); @@ -243,7 +243,7 @@ public function insert_update($time) { return [ 'error' => 0, 'time' => $date, - 'timestamp' => $timestamp + 'timestamp' => $timestamp, ]; } diff --git a/classes/controllers/plagiarism_flagging_controller.php b/classes/controllers/plagiarism_flagging_controller.php index 30e2bf50..c08c6abd 100644 --- a/classes/controllers/plagiarism_flagging_controller.php +++ b/classes/controllers/plagiarism_flagging_controller.php @@ -181,8 +181,8 @@ protected function update_plagiarism_flag() { 'submissionid' => $plagiarismflag->submissionid, 'flagid' => $flagid, 'oldstatus' => $oldstatus, - 'newstatus' => $plagiarismflag->status - ) + 'newstatus' => $plagiarismflag->status, + ), ); $event = \mod_coursework\event\coursework_plagiarism_flag_updated::create($params); diff --git a/classes/controllers/submissions_controller.php b/classes/controllers/submissions_controller.php index 467111d8..b2320ea2 100644 --- a/classes/controllers/submissions_controller.php +++ b/classes/controllers/submissions_controller.php @@ -77,7 +77,7 @@ protected function new_submission() { $submit_form = new student_submission_form($path, array( 'coursework' => $this->coursework, - 'submission' => $submission + 'submission' => $submission, )); if ($submit_form->is_submitted()) { $validation = $submit_form->validate_defined_fields(); @@ -152,8 +152,8 @@ protected function create_submission() { 'context' => $context, 'objectid' => $submission->id, 'other' => array( - 'courseworkid' => $this->coursework->id - ) + 'courseworkid' => $this->coursework->id, + ), ); $event = assessable_submitted::create($params); $event->trigger(); @@ -213,7 +213,7 @@ protected function edit_submission() { $submit_form = new student_submission_form($path, array( 'coursework' => $this->coursework, - 'submission' => $submission + 'submission' => $submission, )); if ($submit_form->is_submitted()) { $validation = $submit_form->validate_defined_fields(); @@ -273,8 +273,8 @@ protected function update_submission() { 'context' => $context, 'objectid' => $submission->id, 'other' => array( - 'courseworkid' => $this->coursework->id - ) + 'courseworkid' => $this->coursework->id, + ), ); $event = assessable_submitted::create($params); $event->trigger(); diff --git a/classes/cron.php b/classes/cron.php index 57a7f363..894cfa51 100644 --- a/classes/cron.php +++ b/classes/cron.php @@ -71,7 +71,7 @@ private static function send_reminders_to_students() { $counts = array( 'emails' => 0, - 'users' => 0 + 'users' => 0, ); $userswhoneedreminding = []; diff --git a/classes/export/csv/cells/assessorfeedback_cell.php b/classes/export/csv/cells/assessorfeedback_cell.php index 86bf9aaf..e3062990 100644 --- a/classes/export/csv/cells/assessorfeedback_cell.php +++ b/classes/export/csv/cells/assessorfeedback_cell.php @@ -137,7 +137,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo 'courseworkid' => $this->coursework->id, 'allocatableid' => $submission->allocatableid, 'allocatabletype' => $submission->allocatabletype, - 'stage_identifier' => $stage_identifier + 'stage_identifier' => $stage_identifier, ); if (!has_capability('mod/coursework:administergrades', $modulecontext) diff --git a/classes/export/csv/cells/assessorgrade_cell.php b/classes/export/csv/cells/assessorgrade_cell.php index 3c2a83b8..081148f0 100644 --- a/classes/export/csv/cells/assessorgrade_cell.php +++ b/classes/export/csv/cells/assessorgrade_cell.php @@ -217,7 +217,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo 'courseworkid' => $this->coursework->id, 'allocatableid' => $submission->allocatableid, 'allocatabletype' => $submission->allocatabletype, - 'stage_identifier' => $stage_identifier + 'stage_identifier' => $stage_identifier, ); if (!has_capability('mod/coursework:administergrades', $PAGE->context) diff --git a/classes/export/csv/cells/otherassessors_cell.php b/classes/export/csv/cells/otherassessors_cell.php index 008def5a..66caf981 100644 --- a/classes/export/csv/cells/otherassessors_cell.php +++ b/classes/export/csv/cells/otherassessors_cell.php @@ -48,7 +48,7 @@ public function get_cell($submission, $student, $stage_identifier) { $params = array( 'submissionid' => $submission->id, 'assessorid' => $USER->id, - 'stageidentifier' => $stage_identifier + 'stageidentifier' => $stage_identifier, ); $sql = "SELECT * FROM {coursework_feedbacks} diff --git a/classes/export/grading_sheet.php b/classes/export/grading_sheet.php index d3ce543d..1c8ea7aa 100644 --- a/classes/export/grading_sheet.php +++ b/classes/export/grading_sheet.php @@ -32,7 +32,7 @@ class grading_sheet extends csv { public function get_submissions($groupid = null, $selected_submission_ids = '') { global $PAGE, $USER; $params = array( - 'courseworkid' => $this->coursework->id + 'courseworkid' => $this->coursework->id, ); $submissions = submission::find_all($params); diff --git a/classes/export/import.php b/classes/export/import.php index bc8e10e7..5a8c87a5 100644 --- a/classes/export/import.php +++ b/classes/export/import.php @@ -706,7 +706,7 @@ public function get_stage_identifier($submissionid, $cell_identifier) { array('courseworkid' => $this->coursework->id, 'allocatableid' => $submission->allocatableid, 'allocatabletype' => $submission->allocatabletype, - 'assessorid' => $USER->id + 'assessorid' => $USER->id, )); $stage_identifier = $dbrecord->stage_identifier; } diff --git a/classes/forms/advance_plugins_form.php b/classes/forms/advance_plugins_form.php index 9c2d4932..75c8a343 100644 --- a/classes/forms/advance_plugins_form.php +++ b/classes/forms/advance_plugins_form.php @@ -53,7 +53,7 @@ public function definition() { $file_manager_options = array( 'subdirs' => false, 'accepted_types' => '*', - 'return_types' => FILE_INTERNAL + 'return_types' => FILE_INTERNAL, ); $this->_form->addElement('filemanager', 'file_element', diff --git a/classes/forms/assessor_feedback_mform.php b/classes/forms/assessor_feedback_mform.php index fb419e14..911c1c16 100644 --- a/classes/forms/assessor_feedback_mform.php +++ b/classes/forms/assessor_feedback_mform.php @@ -108,7 +108,7 @@ public function definition() { $file_manager_options = array( 'subdirs' => false, 'accepted_types' => '*', - 'return_types' => FILE_INTERNAL + 'return_types' => FILE_INTERNAL, ); $uploadfilestring = get_string('uploadafile'); @@ -235,7 +235,7 @@ public function get_file_options() { 'areamaxbytes' => $filemanager->getAreamaxbytes(), 'target' => 'id_' . $filemanager->getName(), 'context' => $PAGE->context, - 'itemid' => $filemanager->getValue() + 'itemid' => $filemanager->getValue(), ]; $fm = new \form_filemanager($params); $options = $fm->options; diff --git a/classes/framework/test/table_base_test.php b/classes/framework/test/table_base_test.php index 2f16324e..14f9dd5f 100644 --- a/classes/framework/test/table_base_test.php +++ b/classes/framework/test/table_base_test.php @@ -52,7 +52,7 @@ public function test_find_when_true_with_id() { $generator = testing_util::get_data_generator(); $params = array( - 'username' => 'freddo' + 'username' => 'freddo', ); $user = $generator->create_user($params); @@ -63,7 +63,7 @@ public function test_find_when_true_with_other_param() { $generator = testing_util::get_data_generator(); $params = array( - 'username' => 'freddo' + 'username' => 'freddo', ); $user = $generator->create_user($params); @@ -74,7 +74,7 @@ public function test_find_when_true_with_entire_db_object() { $generator = testing_util::get_data_generator(); $params = array( - 'username' => 'freddo' + 'username' => 'freddo', ); $user = $generator->create_user($params); @@ -83,7 +83,7 @@ public function test_find_when_true_with_entire_db_object() { public function test_find_when_false() { $params = array( - 'username' => 'freddo' + 'username' => 'freddo', ); $this->assertFalse(framework_user_table::find($params)); } @@ -96,7 +96,7 @@ public function test_exists_when_true() { $generator = testing_util::get_data_generator(); $params = array( - 'username' => 'freddo' + 'username' => 'freddo', ); $generator->create_user($params); @@ -105,7 +105,7 @@ public function test_exists_when_true() { public function test_exists_when_false() { $params = array( - 'username' => 'freddo' + 'username' => 'freddo', ); $this->assertFalse(framework_user_table::exists($params)); } @@ -114,7 +114,7 @@ public function test_find_when_given_a_db_record() { $generator = testing_util::get_data_generator(); $params = array( - 'username' => 'freddo' + 'username' => 'freddo', ); $user = $generator->create_user($params); $this->assertEquals($user->id, framework_user_table::find($user)->id); diff --git a/classes/grading_table_row_base.php b/classes/grading_table_row_base.php index 51532886..1752b4ee 100644 --- a/classes/grading_table_row_base.php +++ b/classes/grading_table_row_base.php @@ -257,7 +257,7 @@ public function get_plagiarism_flag() { $submission = $this->get_submission(); $params = array( - 'submissionid' => $submission->id + 'submissionid' => $submission->id, ); return plagiarism_flag::find($params); diff --git a/classes/models/course_module.php b/classes/models/course_module.php index ed0aeccb..392ffb0d 100644 --- a/classes/models/course_module.php +++ b/classes/models/course_module.php @@ -57,7 +57,7 @@ class course_module extends table_base { public static function fill_pool($array) { self::$pool = [ 'id' => [], - 'course-module-instance' => [] + 'course-module-instance' => [], ]; foreach ($array as $record) { $object = new self($record); diff --git a/classes/models/moderation_set_rule.php b/classes/models/moderation_set_rule.php index 11d44550..15ab01d2 100644 --- a/classes/models/moderation_set_rule.php +++ b/classes/models/moderation_set_rule.php @@ -96,7 +96,7 @@ abstract class moderation_set_rule extends table_base implements renderable { 'ruleorder', 'upperlimit', 'lowerlimit', - 'minimum' + 'minimum', ); /** diff --git a/classes/models/personal_deadline.php b/classes/models/personal_deadline.php index b02713bd..00025a09 100644 --- a/classes/models/personal_deadline.php +++ b/classes/models/personal_deadline.php @@ -112,7 +112,7 @@ protected static function get_cache_array($coursework_id) { global $DB; $records = $DB->get_records(static::$table_name, ['courseworkid' => $coursework_id]); $result = [ - 'allocatableid-allocatabletype' => [] + 'allocatableid-allocatabletype' => [], ]; if ($records) { foreach ($records as $record) { diff --git a/classes/models/sample_set_rule.php b/classes/models/sample_set_rule.php index 465bbe23..a3411d1c 100644 --- a/classes/models/sample_set_rule.php +++ b/classes/models/sample_set_rule.php @@ -96,7 +96,7 @@ abstract class sample_set_rule extends table_base implements renderable { 'ruleorder', 'upperlimit', 'lowerlimit', - 'minimum' + 'minimum', ); /** diff --git a/classes/moderation_set_rule/minimum_range_grade_percent.php b/classes/moderation_set_rule/minimum_range_grade_percent.php index 888b48b3..6551a877 100644 --- a/classes/moderation_set_rule/minimum_range_grade_percent.php +++ b/classes/moderation_set_rule/minimum_range_grade_percent.php @@ -128,7 +128,7 @@ public function get_form_elements() { $html .= get_string('upperlimit', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_'.self::get_name().'_upperlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); @@ -137,7 +137,7 @@ public function get_form_elements() { $html .= get_string('lowerlimit', 'mod_coursework').' '; $attributes = array( 'name' => self::get_name().'_lowerlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); @@ -146,7 +146,7 @@ public function get_form_elements() { $html .= get_string('modsetminimum', 'mod_coursework').' '; $attributes = array( 'name' => self::get_name().'_minimum', - 'size' => 4 + 'size' => 4, ); $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); diff --git a/classes/moderation_set_rule/minimum_range_grade_raw.php b/classes/moderation_set_rule/minimum_range_grade_raw.php index 76985030..42598297 100644 --- a/classes/moderation_set_rule/minimum_range_grade_raw.php +++ b/classes/moderation_set_rule/minimum_range_grade_raw.php @@ -122,7 +122,7 @@ public function get_form_elements() { $html .= get_string('upperlimit', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_minimum_range_grade_raw_upperlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); @@ -131,7 +131,7 @@ public function get_form_elements() { $html .= get_string('lowerlimit', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_minimum_range_grade_raw_lowerlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); @@ -140,7 +140,7 @@ public function get_form_elements() { $html .= get_string('modsetminimum', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_minimum_range_grade_raw_minimum', - 'size' => 4 + 'size' => 4, ); $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); diff --git a/classes/moderation_set_rule/range_grade_percent.php b/classes/moderation_set_rule/range_grade_percent.php index 25cfff42..73e14808 100644 --- a/classes/moderation_set_rule/range_grade_percent.php +++ b/classes/moderation_set_rule/range_grade_percent.php @@ -119,7 +119,7 @@ public function get_form_elements() { $html .= get_string('upperlimit', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_range_grade_percent_upperlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes).'%'; $html .= html_writer::end_tag('p'); @@ -128,7 +128,7 @@ public function get_form_elements() { $html .= get_string('lowerlimit', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_range_grade_percent_lowerlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes).'%'; $html .= html_writer::end_tag('p'); diff --git a/classes/moderation_set_rule/range_grade_raw.php b/classes/moderation_set_rule/range_grade_raw.php index 7e4502cf..f6913c03 100644 --- a/classes/moderation_set_rule/range_grade_raw.php +++ b/classes/moderation_set_rule/range_grade_raw.php @@ -110,7 +110,7 @@ public function get_form_elements() { $html .= get_string('upperlimit', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_range_grade_raw_upperlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); @@ -119,7 +119,7 @@ public function get_form_elements() { $html .= get_string('lowerlimit', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_range_grade_raw_lowerlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); diff --git a/classes/moderation_set_rule/range_total_percent.php b/classes/moderation_set_rule/range_total_percent.php index 825ed812..eb0563d7 100644 --- a/classes/moderation_set_rule/range_total_percent.php +++ b/classes/moderation_set_rule/range_total_percent.php @@ -127,7 +127,7 @@ public function get_form_elements() { $html .= get_string('upperlimit', 'mod_coursework').' '; $attributes = array( 'name' => 'rule_range_total_percent_upperlimit', - 'size' => 3 + 'size' => 3, ); $html .= html_writer::empty_tag('input', $attributes).'%'; $html .= html_writer::end_tag('p'); diff --git a/classes/personal_deadline/table/builder.php b/classes/personal_deadline/table/builder.php index ec6d52e2..6610bee2 100644 --- a/classes/personal_deadline/table/builder.php +++ b/classes/personal_deadline/table/builder.php @@ -112,7 +112,7 @@ public function get_options() { */ public function get_allocatable_cell() { $items = array( - 'coursework' => $this->coursework + 'coursework' => $this->coursework, ); if ($this->coursework->is_configured_to_have_group_submissions()) { @@ -126,7 +126,7 @@ public function get_allocatable_cell() { */ public function get_personal_deadline_cell() { $items = array( - 'coursework' => $this->coursework + 'coursework' => $this->coursework, ); return new personal_deadline_cell($items); diff --git a/classes/plagiarism_helpers/turnitin.php b/classes/plagiarism_helpers/turnitin.php index ec2c23b8..2ba1c168 100644 --- a/classes/plagiarism_helpers/turnitin.php +++ b/classes/plagiarism_helpers/turnitin.php @@ -50,7 +50,7 @@ public function enabled() { $params = array( 'cm' => $this->get_coursework()->get_course_module()->id, 'name' => 'use_turnitin', - 'value' => 1 + 'value' => 1, ); if ($DB->record_exists('plagiarism_turnitin_config', $params)) { return true; diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index acc79b7a..5680ed20 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -54,7 +54,7 @@ public static function get_metadata(collection $collection) : collection { 'timemodified' => 'timemodified', 'grade' => 'privacy:metadata:grade', 'submissionid' => 'privacy:metadata:submissionid', - 'feedbackcomment' => 'privacy:metadata:feedbackcomment' + 'feedbackcomment' => 'privacy:metadata:feedbackcomment', ]; $submissions = [ 'authorid' => 'privacy:metadata:authorid', @@ -62,7 +62,7 @@ public static function get_metadata(collection $collection) : collection { 'timecreated' => 'privacy:metadata:timecreated', 'timemodified' => 'timemodified', 'createdby' => 'createdby', - 'timesubmitted' => 'timesubmitted' + 'timesubmitted' => 'timesubmitted', ]; $extensions = [ 'allocatableid' => 'privacy:metadata:allocatableid', @@ -70,27 +70,27 @@ public static function get_metadata(collection $collection) : collection { 'extra_information_text' => 'privacy:metadata:extra_information_text', 'extended_deadline' => 'privacy:metadata:extended_deadline', 'allocatableuser' => 'privacy:metadata:userid', - 'allocatablegroup' => 'privacy:metadata:groupid' + 'allocatablegroup' => 'privacy:metadata:groupid', ]; $persondeadlines = [ 'allocatableid' => 'privacy:metadata:allocatableid', 'createdbyid' => 'privacy:metadata:createdbyid', 'personal_deadline' => 'privacy:metadata:personal_deadline', 'allocatableuser' => 'privacy:metadata:userid', - 'allocatablegroup' => 'privacy:metadata:groupid' + 'allocatablegroup' => 'privacy:metadata:groupid', ]; $modagreements = [ 'moderatorid' => 'privacy:metadata:moderatorid', 'agreement' => 'privacy:metadata:agreement', 'modcomment' => 'privacy:metadata:modcomment', 'timecreated' => 'privacy:metadata:timecreated', - 'timemodified' => 'timemodified' + 'timemodified' => 'timemodified', ]; $plagiarismflags = [ 'createdby' => 'privacy:metadata:createdby', 'comment' => 'privacy:metadata:comment', 'timecreated' => 'privacy:metadata:timecreated', - 'timemodified' => 'timemodified' + 'timemodified' => 'timemodified', ]; $collection->add_database_table('coursework_feedbacks', $feedbacks, 'privacy:metadata:feedbacks'); $collection->add_database_table('coursework_submissions', $submissions, 'privacy:metadata:submissions'); @@ -113,7 +113,7 @@ public static function get_users_in_context(userlist $userlist) { $params = [ 'modulename' => 'coursework', 'contextid' => $context->id, - 'contextlevel' => CONTEXT_MODULE + 'contextlevel' => CONTEXT_MODULE, ]; $sql = "SELECT cwf.assessorid FROM {context} ctx @@ -192,7 +192,7 @@ public static function get_contexts_for_userid(int $userid) : contextlist { 'allocatableuser' => $userid, 'allocatablegroup' => $userid, 'moderatorid' => $userid, - 'createdby' => $userid + 'createdby' => $userid, ]; $sql = "SELECT ctx.id FROM {course_modules} cm @@ -445,7 +445,7 @@ protected static function export_coursework_submission(\stdClass $submission, \c 'timemodified' => transform::datetime($submission->timemodified), 'timesubmitted' => transform::datetime($submission->timesubmitted), 'createdby' => $submission->createdby, - 'finalised' => transform::yesno($submission->finalised) + 'finalised' => transform::yesno($submission->finalised), ]; writer::with_context($context) ->export_data(array_merge($currentpath, [get_string('privacy:submissionpath', 'mod_coursework')]), $submissionData); @@ -503,7 +503,7 @@ protected static function format_submissions_feedback(\stdClass $feedback) { 'grade' => $feedback->grade, 'feedbackcomment' => $feedback->feedbackcomment, 'stage_identifier' => $feedback->stage_identifier, - 'finalised' => transform::yesno($feedback->finalised) + 'finalised' => transform::yesno($feedback->finalised), ]; return $feedbackData; } @@ -523,7 +523,7 @@ protected static function export_coursework_extension_data($extension, $context, $extensionData = [ 'extended_deadline' => transform::datetime($extension->extended_deadline), 'extra_information_text' => $extension->extra_information_text, - 'createdbyid' => $extension->createdbyid + 'createdbyid' => $extension->createdbyid, ]; writer::with_context($context) ->export_data(array_merge($path, [get_string('privacy:extensionpath', 'mod_coursework')]), (object) $extensionData); @@ -545,7 +545,7 @@ protected static function export_person_deadline_data($personDeadline, $context, 'personal_deadline' => transform::datetime($personDeadline->personal_deadline), 'timecreated' => transform::datetime($personDeadline->timecreated), 'timemodified' => transform::datetime($personDeadline->timemodified), - 'createdbyid' => $personDeadline->createdbyid + 'createdbyid' => $personDeadline->createdbyid, ]; writer::with_context($context) ->export_data(array_merge($path, [get_string('privacy:person_deadlines', 'mod_coursework')]), (object) $personDeadlineData); @@ -577,7 +577,7 @@ protected static function export_plagiarism_flags_data($plagiarism, $context, $p 'status' => $status, 'timecreated' => transform::datetime($plagiarism->timecreated), 'timemodified' => transform::datetime($plagiarism->timemodified), - 'createdby' => $plagiarism->createdby + 'createdby' => $plagiarism->createdby, ]; writer::with_context($context) diff --git a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php index 53aca8a7..07b72e25 100644 --- a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php +++ b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php @@ -78,7 +78,7 @@ public function get_table_cell($rowobject) { 'submissionid' => $rowobject->get_submission()->id, 'moderatorid' => $USER->id, 'stage_identifier' => $this->stage->identifier(), - 'feedbackid' => $rowobject->get_single_feedback()->id + 'feedbackid' => $rowobject->get_single_feedback()->id, ); // allow moderations if feedback exists $new_moderation = moderation::build($moderation_params); @@ -166,7 +166,7 @@ private function new_moderation_button($rowobject, $assessor) { 'submission' => $rowobject->get_submission(), 'assessor' => $assessor, 'stage' => $this->stage, - 'feedbackid' => $feedback->id + 'feedbackid' => $feedback->id, ); $link = $this->get_router()->get_path('new moderations', $moderation_params); @@ -191,7 +191,7 @@ private function edit_moderation_button($rowobject) { $feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1'); $feedback_params = array( - 'moderation' => $this->stage->get_moderation_for_feedback($feedback) + 'moderation' => $this->stage->get_moderation_for_feedback($feedback), ); $link = $this->get_router()->get_path('edit moderation', $feedback_params); @@ -218,7 +218,7 @@ private function show_moderation_button($rowobject) { $feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1'); $moderation_params = array( - 'moderation' => $this->stage->get_moderation_for_feedback($feedback) + 'moderation' => $this->stage->get_moderation_for_feedback($feedback), ); $linktitle = get_string('viewmoderation', 'mod_coursework'); diff --git a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php index 8654576a..3b01688b 100644 --- a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php +++ b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php @@ -92,7 +92,7 @@ public function get_content($rowobject) { if ($existing_feedback && $ability->can('edit', $existing_feedback)) { $feedback_route_params = array( - 'feedback' => $finalfeedback + 'feedback' => $finalfeedback, ); $link = $this->get_router()->get_path('ajax edit feedback', $feedback_route_params); diff --git a/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php b/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php index f4b22698..019e6ddd 100644 --- a/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php +++ b/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php @@ -51,7 +51,7 @@ public function get_table_cell($rowobject) { if ($rowobject->has_submission() && $rowobject->get_submission()->finalised) { $plagiarism_flag_params = array( - 'submissionid' => $rowobject->get_submission()->id + 'submissionid' => $rowobject->get_submission()->id, ); $plagiarism_flag = plagiarism_flag::find($plagiarism_flag_params); @@ -111,7 +111,7 @@ private function new_flag_plagiarism_button($row_object) { $title = get_string('flagplagiarism', 'coursework'); $feedback_params = array( - 'submission' => $row_object->get_submission() + 'submission' => $row_object->get_submission(), ); $link = $this->get_router()->get_path('new plagiarism flag', $feedback_params); @@ -134,7 +134,7 @@ private function edit_flag_plagiarism_button($row_object) { $title = get_string('editflagplagiarism', 'coursework'); $feedback_params = array( - 'flag' => $row_object->get_plagiarism_flag() + 'flag' => $row_object->get_plagiarism_flag(), ); $link = $this->get_router()->get_path('edit plagiarism flag', $feedback_params); diff --git a/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php b/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php index 1573f4e2..88875297 100644 --- a/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php +++ b/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php @@ -167,7 +167,7 @@ private function edit_feedback_button($rowobject) { global $OUTPUT; $feedback_params = array( - 'feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable()) + 'feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable()), ); $link = $this->get_router()->get_path('edit feedback', $feedback_params); diff --git a/classes/sample_set_rule/sample_base.php b/classes/sample_set_rule/sample_base.php index e4a25d12..308f6775 100644 --- a/classes/sample_set_rule/sample_base.php +++ b/classes/sample_set_rule/sample_base.php @@ -87,7 +87,7 @@ abstract class sample_base { 'ruleorder', 'upperlimit', 'lowerlimit', - 'minimum' + 'minimum', ); function __construct($coursework) { diff --git a/classes/sampling_set_widget.php b/classes/sampling_set_widget.php index f1d7bbc2..7ef9ca6e 100644 --- a/classes/sampling_set_widget.php +++ b/classes/sampling_set_widget.php @@ -126,7 +126,7 @@ public function get_potential_rule_class_names() { if (!$fullclassname::allow_multiple()) { $params = array( 'courseworkid' => $this->coursework->id, - 'rulename' => $rulename + 'rulename' => $rulename, ); $alreadygotone = $DB->record_exists('coursework_mod_set_rules', $params); if ($alreadygotone) { @@ -174,7 +174,7 @@ public function get_add_rule_form_elements() { $attributes = array( 'class' => 'rule-config', 'id' => 'rule-config-'.$shortname, - 'style' => 'display:none' // Always hide, so they only get revealed by clicking the radio buttons. + 'style' => 'display:none', // Always hide, so they only get revealed by clicking the radio buttons. ); $html .= html_writer::start_tag('div', $attributes); /* @var models\moderation_set_rule $instance */ diff --git a/classes/stages/base.php b/classes/stages/base.php index e81b86c0..c867db19 100644 --- a/classes/stages/base.php +++ b/classes/stages/base.php @@ -66,7 +66,7 @@ abstract class base { * @var array */ private static $self_cache = [ - 'user_is_assessor' => [] + 'user_is_assessor' => [], ]; /** @@ -552,7 +552,7 @@ public function remove_allocatable_from_sampling($allocatable) { 'courseworkid' => $this->coursework->id, 'allocatableid' => $allocatable->id(), 'allocatabletype' => $allocatable->type(), - 'stage_identifier' => $this->stage_identifier + 'stage_identifier' => $this->stage_identifier, ); $DB->delete_records('coursework_sample_set_mbrs', $params); } @@ -719,7 +719,7 @@ public function get_feedback_for_submission($submission) { */ public function get_moderation_for_feedback($feedback) { $moderation_params = array( - 'feedbackid' => $feedback->id + 'feedbackid' => $feedback->id, ); return moderation::find($moderation_params); } diff --git a/classes/warnings.php b/classes/warnings.php index 21576ab3..b05f450c 100644 --- a/classes/warnings.php +++ b/classes/warnings.php @@ -371,7 +371,7 @@ private function students_who_are_not_in_any_group($student_sql, $student_params $params = array_merge($student_params, array( - 'courseid' => $this->coursework->get_course()->id + 'courseid' => $this->coursework->get_course()->id, )); $students = $DB->get_records_sql($sql, $params); return $students; diff --git a/db/access.php b/db/access.php index 07e8c4b2..ea402cb1 100644 --- a/db/access.php +++ b/db/access.php @@ -60,9 +60,9 @@ 'contextlevel' => CONTEXT_COURSE, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ), - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ), 'mod/coursework:view' => array( @@ -73,8 +73,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:submit' => array( @@ -82,8 +82,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'student' => CAP_ALLOW - ) + 'student' => CAP_ALLOW, + ), ), 'mod/coursework:submitonbehalfof' => array( @@ -91,8 +91,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:addinitialgrade' => array( @@ -102,8 +102,8 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:editinitialgrade' => array( @@ -111,8 +111,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:addagreedgrade' => array( @@ -120,8 +120,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:editagreedgrade' => array( @@ -129,8 +129,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:publish' => array( @@ -138,8 +138,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:viewanonymous' => array( @@ -147,8 +147,8 @@ 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:revertfinalised' => array( @@ -156,8 +156,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:allocate' => array( @@ -165,8 +165,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:viewallgradesatalltimes' => array( @@ -174,8 +174,8 @@ 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:administergrades' => array( @@ -183,8 +183,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:grantextensions' => array( @@ -192,8 +192,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:canexportfinalgrades' => array( @@ -201,8 +201,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:viewextensions' => array( @@ -213,7 +213,7 @@ 'manager' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - ) + ), ), 'mod/coursework:grade' => array( @@ -224,7 +224,7 @@ 'manager' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - ) + ), ), 'mod/coursework:addgeneralfeedback' => array( 'riskbitmask' => RISK_MANAGETRUST | RISK_PERSONAL, @@ -232,7 +232,7 @@ 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( 'manager' => CAP_ALLOW, - ) + ), ), 'mod/coursework:viewallstudents' => array( @@ -242,8 +242,8 @@ 'legacy' => array( 'manager' => CAP_ALLOW, 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW - ) + 'editingteacher' => CAP_ALLOW, + ), ), 'mod/coursework:addallocatedagreedgrade' => array( @@ -251,8 +251,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:editallocatedagreedgrade' => array( @@ -260,8 +260,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:editpersonaldeadline' => array( @@ -269,8 +269,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:moderate' => array( @@ -278,8 +278,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:receivesubmissionnotifications' => array( @@ -287,8 +287,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/coursework:addplagiarismflag' => array( @@ -298,8 +298,8 @@ 'legacy' => array( 'manager' => CAP_ALLOW, 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW - ) + 'editingteacher' => CAP_ALLOW, + ), ), 'mod/coursework:updateplagiarismflag' => array( @@ -307,8 +307,8 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), ); diff --git a/db/caches.php b/db/caches.php index b097c831..5870f333 100644 --- a/db/caches.php +++ b/db/caches.php @@ -22,6 +22,6 @@ $definitions = array( 'courseworkdata' => array( - 'mode' => cache_store::MODE_APPLICATION - ) + 'mode' => cache_store::MODE_APPLICATION, + ), ); diff --git a/db/events.php b/db/events.php index 31627dd3..58ea29ae 100644 --- a/db/events.php +++ b/db/events.php @@ -35,7 +35,7 @@ array( 'eventname' => '\mod_coursework\event\coursework_deadline_changed', 'callback' => 'mod_coursework_observer::coursework_deadline_changed', - 'schedule' => 'cron' + 'schedule' => 'cron', ), array( 'eventname' => '\core\event\course_module_updated', diff --git a/db/log.php b/db/log.php index cd5cd1a1..864ae951 100644 --- a/db/log.php +++ b/db/log.php @@ -39,5 +39,5 @@ array('module' => 'coursework', 'action' => 'add', 'mtable' => 'coursework', 'field' => 'name'), array('module' => 'coursework', 'action' => 'update', 'mtable' => 'coursework', 'field' => 'name'), array('module' => 'coursework', 'action' => 'view', 'mtable' => 'coursework', 'field' => 'name'), - array('module' => 'coursework', 'action' => 'view all', 'mtable' => 'coursework', 'field' => 'name') + array('module' => 'coursework', 'action' => 'view all', 'mtable' => 'coursework', 'field' => 'name'), ); diff --git a/db/tasks.php b/db/tasks.php index 8ab3a22e..fda40ee2 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -33,7 +33,7 @@ 'hour' => '0', 'day' => '*', 'month' => '*', - 'dayofweek' => '*' + 'dayofweek' => '*', ), array( 'classname' => 'mod_coursework\task\enrol_task', @@ -42,7 +42,7 @@ 'hour' => '*', 'day' => '*', 'month' => '*', - 'dayofweek' => '*' + 'dayofweek' => '*', ), array( 'classname' => 'mod_coursework\task\unenrol_task', @@ -51,6 +51,6 @@ 'hour' => '*', 'day' => '*', 'month' => '*', - 'dayofweek' => '*' - ) + 'dayofweek' => '*', + ), ); diff --git a/lib.php b/lib.php index 8784f020..1fb5062a 100644 --- a/lib.php +++ b/lib.php @@ -479,7 +479,7 @@ function coursework_update_instance($coursework) { 'oldindividualdeadline' => $oldindividualdeadline, 'newindividualdeadline' => $coursework->individualfeedback, 'userfrom' => $USER->id, - ) + ), ); $event = \mod_coursework\event\coursework_deadline_changed::create($params); @@ -927,7 +927,7 @@ function coursework_seconds_to_string($seconds) { 60 => array(get_string('minute', 'mod_coursework'), get_string('minutes', 'mod_coursework')), 1 => array(get_string('second', 'mod_coursework'), - get_string('seconds', 'mod_coursework')) + get_string('seconds', 'mod_coursework')), ); $result = []; @@ -966,7 +966,7 @@ function coursework_get_current_max_feedbacks($courseworkid) { GROUP BY feedbacks.submissionid) AS feedbackcounts "; $params = array( - 'courseworkid' => $courseworkid + 'courseworkid' => $courseworkid, ); $max = $DB->get_field_sql($sql, $params); diff --git a/mod_form.php b/mod_form.php index 19201e1e..a2caea1b 100644 --- a/mod_form.php +++ b/mod_form.php @@ -51,7 +51,7 @@ public function definition() { 'fullpath' => '/mod/coursework/mod_form.js', 'requires' => array( 'node', - 'ajax' + 'ajax', )); $PAGE->requires->js_init_call('M.mod_coursework.init', [], true, $module); @@ -824,7 +824,7 @@ protected function add_number_of_initial_assessors_field() { // Don't want to give the option for 0! 1 => 1, 2 => 2, - 3 => 3 + 3 => 3, ); // Remove all options lower than the current maximum number of feedbacks that any student has. $currentmaxfeedbacks = coursework_get_current_max_feedbacks($courseworkid); diff --git a/renderers/grading_report_renderer.php b/renderers/grading_report_renderer.php index ae5ff26b..ea532009 100644 --- a/renderers/grading_report_renderer.php +++ b/renderers/grading_report_renderer.php @@ -86,13 +86,13 @@ private function generate_lang_element() { 'download_submitted_files' => get_string('download_submitted_files', 'mod_coursework'), 'exportfinalgrades' => get_string('exportfinalgrades', 'mod_coursework'), 'exportgradingsheets' => get_string('exportgradingsheets', 'mod_coursework'), - 'loadingpagination' => get_string('loadingpagination', 'mod_coursework') + 'loadingpagination' => get_string('loadingpagination', 'mod_coursework'), ]; $result = html_writer::empty_tag('input', array( 'name' => '', 'type' => 'hidden', 'data-lang' => json_encode($lang_messages), - 'id' => 'element_lang_messages' + 'id' => 'element_lang_messages', )); $result = html_writer::div($result); diff --git a/renderers/object_renderer.php b/renderers/object_renderer.php index 22bfe18c..ae12d656 100644 --- a/renderers/object_renderer.php +++ b/renderers/object_renderer.php @@ -328,7 +328,7 @@ protected function render_mod_coursework_assessor_feedback_row(mod_coursework_as $new_feedback_params = array( 'submission' => $feedbackrow->get_submission(), 'assessor' => $feedbackrow->get_assessor(), - 'stage' => $feedbackrow->get_stage() + 'stage' => $feedbackrow->get_stage(), ); $link = $this->get_router()->get_path('new feedback', $new_feedback_params); $iconlink = $this->output->action_icon($link, $icon, null, array('class' => "new_feedback")); @@ -1038,7 +1038,7 @@ protected function make_moderation_set_rule_row(moderation_set_rule $rule) { $attributes = array( 'type' => 'submit', 'name' => 'delete-mod-set-rule[' . $rule->id . ']', - 'value' => $linktitle + 'value' => $linktitle, ); $controlscell->text .= html_writer::empty_tag('input', $attributes); $row->cells[] = $controlscell; @@ -1073,7 +1073,7 @@ protected function get_allocation_strategy_form_elements($coursework) { $attributes = array( 'class' => 'assessor-strategy-options', - 'id' => 'assessor-strategy-' . $classname + 'id' => 'assessor-strategy-' . $classname, ); // Hide this if it's not currently selected. $strategytype = 'assessorallocationstrategy'; @@ -1166,7 +1166,7 @@ protected function render_file_plagiarism_information($file, $coursework) { 'cmid' => $coursework->get_coursemodule_id(), 'course' => $coursework->get_course(), 'coursework' => $coursework->id, - 'modname' => 'coursework' + 'modname' => 'coursework', ); $plagiarsmlinks = plagiarism_get_links($plagiarism_links_params); @@ -1473,7 +1473,7 @@ private function render_personal_deadline_table_row($personal_deadline_row) { 'allocatableid' => $personal_deadline_row->get_allocatable()->id(), 'allocatabletype' => $personal_deadline_row->get_allocatable()->type(), 'courseworkid' => $personal_deadline_row->get_coursework()->id, - 'setpersonaldeadlinespage' => '1' + 'setpersonaldeadlinespage' => '1', ); $allocatable_cell_helper = $personal_deadline_row->get_allocatable_cell(); diff --git a/view.php b/view.php index 51bb866e..90805981 100644 --- a/view.php +++ b/view.php @@ -47,7 +47,7 @@ 'fullpath' => '/mod/coursework/module.js', 'requires' => array('base', 'node-base'), - 'strings' => [] + 'strings' => [], ); $PAGE->requires->yui_module('moodle-core-notification', 'notification_init'); @@ -481,7 +481,7 @@ // work. if ($filehash) { $params = array( - 'pathnamehash' => $filehash + 'pathnamehash' => $filehash, ); $file = $DB->get_record('files', $params); $file->timemodified = time(); From 2adde4de38cab7b52722539340486a7bcd980bff Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:44:49 +0100 Subject: [PATCH 04/27] CTP-3690 indentation --- actions/upload_grading_sheet.php | 2 +- .../backup_coursework_activity_task.class.php | 30 ++-- classes/ability.php | 14 +- classes/allocation/manager.php | 24 +-- classes/allocation/table/cell/builder.php | 18 +- classes/allocation/table/processor.php | 28 +-- classes/assessor_feedback_row.php | 2 +- .../personal_deadlines_controller.php | 64 ++++--- .../controllers/submissions_controller.php | 28 +-- classes/cron.php | 12 +- classes/export/csv.php | 78 ++++---- .../csv/cells/assessorfeedback_cell.php | 2 +- .../export/csv/cells/assessorgrade_cell.php | 8 +- classes/export/csv/cells/cell_base.php | 2 +- .../csv/cells/moderationagreement_cell.php | 12 +- .../export/csv/cells/otherassessors_cell.php | 8 +- classes/export/csv/cells/singlegrade_cell.php | 4 +- .../export/csv/cells/submissiontime_cell.php | 2 +- classes/export/grading_sheet.php | 110 ++++++------ classes/export/import.php | 126 ++++++------- classes/file_importer.php | 2 +- classes/forms/deadline_extension_form.php | 2 +- classes/forms/student_submission_form.php | 2 +- classes/forms/upload_allocations_form.php | 2 +- classes/grading_table_row_base.php | 2 +- classes/models/moderation.php | 6 +- classes/models/outstanding_marking.php | 12 +- .../grading_report/cells/_user_cell.php | 20 +-- .../cells/moderation_agreement_cell.php | 2 +- .../cells/multiple_agreed_grade_cell.php | 14 +- .../grading_report/cells/user_cell.php | 28 +-- classes/sample_set_rule/range_sample_type.php | 68 +++---- classes/sample_set_rule/total_sample_type.php | 14 +- classes/warnings.php | 52 +++--- db/upgrade.php | 2 +- lib.php | 168 +++++++++--------- mod_form.php | 40 ++--- renderers/object_renderer.php | 34 ++-- settings.php | 2 +- view.php | 2 +- 40 files changed, 523 insertions(+), 525 deletions(-) diff --git a/actions/upload_grading_sheet.php b/actions/upload_grading_sheet.php index 9a43230f..1dbae1e1 100644 --- a/actions/upload_grading_sheet.php +++ b/actions/upload_grading_sheet.php @@ -69,7 +69,7 @@ $csvimport = new \mod_coursework\export\import($coursework, false, false); - // $csv_cells = $csvimport->csv_columns(); //all columns from spreadsheet + // $csv_cells = $csvimport->csv_columns(); //all columns from spreadsheet $procsessingresults = $csvimport->validate_csv($content, $data->encoding, $data->delimiter_name, $csv_cells); diff --git a/backup/moodle2/backup_coursework_activity_task.class.php b/backup/moodle2/backup_coursework_activity_task.class.php index 78a19a15..c3654be1 100644 --- a/backup/moodle2/backup_coursework_activity_task.class.php +++ b/backup/moodle2/backup_coursework_activity_task.class.php @@ -24,25 +24,25 @@ class backup_coursework_activity_task extends backup_activity_task { - static public function encode_content_links($content) { - global $CFG; + static public function encode_content_links($content) { + global $CFG; - $base = preg_quote($CFG->wwwroot, "/"); + $base = preg_quote($CFG->wwwroot, "/"); - // These have to be picked up by the restore code COURSEWORK... are arbitrary - $search = "/(".$base."\/mod\/coursework\/index.php\?id\=)([0-9]+)/"; - $content = preg_replace($search, '$@COURSEWORKINDEX*$2@$', $content); + // These have to be picked up by the restore code COURSEWORK... are arbitrary + $search = "/(".$base."\/mod\/coursework\/index.php\?id\=)([0-9]+)/"; + $content = preg_replace($search, '$@COURSEWORKINDEX*$2@$', $content); - $search = "/(".$base."\/mod\/coursework\/view.php\?id\=)([0-9]+)/"; - $content = preg_replace($search, '$@COURSEWORKBYID*$2@$', $content); + $search = "/(".$base."\/mod\/coursework\/view.php\?id\=)([0-9]+)/"; + $content = preg_replace($search, '$@COURSEWORKBYID*$2@$', $content); - return $content; - } + return $content; + } - protected function define_my_settings() { - } + protected function define_my_settings() { + } - protected function define_my_steps() { - $this->add_step(new backup_coursework_activity_structure_step('coursework_structure', 'coursework.xml')); - } + protected function define_my_steps() { + $this->add_step(new backup_coursework_activity_structure_step('coursework_structure', 'coursework.xml')); + } } diff --git a/classes/ability.php b/classes/ability.php index c24ad60e..681e8a98 100644 --- a/classes/ability.php +++ b/classes/ability.php @@ -152,7 +152,7 @@ function (coursework $coursework) { // New feedback $this->prevent_new_feedback_with_no_submission(); - $this->prevent_new_feedback_when_submission_not_finalised(); + $this->prevent_new_feedback_when_submission_not_finalised(); $this->prevent_new_feedback_when_prerequisite_stages_have_no_feedback(); $this->prevent_new_feedback_with_empty_stage(); $this->prevent_new_feedback_when_allocatable_already_has_feedback_for_this_stage(); @@ -163,7 +163,7 @@ function (coursework $coursework) { $this->prevent_new_feedback_when_not_assessor_for_stage(); $this->prevent_new_feedback_from_non_allocated_assessors(); $this->allow_new_feedback_by_allocated_assessor(); - $this->allow_new_feedback_from_any_assessor_when_allocation_is_disabled_for_stage_or_instance(); + $this->allow_new_feedback_from_any_assessor_when_allocation_is_disabled_for_stage_or_instance(); $this->allow_new_feedback_if_agreed_feedback_and_user_can_add_agreed_feedback(); // Create feedback @@ -230,7 +230,7 @@ function (coursework $coursework) { // Plagiarism flagging rules for Plagiarism Alert // New - // $this->prevent_new_plagiarism_flag_if_already_exists(); + // $this->prevent_new_plagiarism_flag_if_already_exists(); $this->allow_new_plagiarism_flag_with_capability(); // Edit @@ -425,7 +425,7 @@ function (submission $submission) { } protected function allow_show_submission_to_graders_after_feedback_release() { -// Show to graders after release + // Show to graders after release $this->allow('show', 'mod_coursework\models\submission', function (submission $submission) { @@ -485,8 +485,8 @@ function (submission $submission) { // take into account courseworks with personal deadlines if ($submission->get_coursework()->personal_deadlines_enabled()) { $deadline_passed = (bool)$submission->submission_personal_deadline() < time(); - } else { - $deadline_passed = $submission->get_coursework()->deadline_has_passed(); + } else { + $deadline_passed = $submission->get_coursework()->deadline_has_passed(); } $ok_to_submit_late = $submission->get_coursework()->allow_late_submissions(); $coursework = $submission->get_coursework(); @@ -1202,7 +1202,7 @@ private function allow_show_grading_table_row_if_user_can_grant_extension_and_no 'mod_coursework\grading_table_row_base', function (grading_table_row_base $row) { - return (!$row->get_coursework()->allocation_enabled() && has_capability('mod/coursework:grantextensions', + return (!$row->get_coursework()->allocation_enabled() && has_capability('mod/coursework:grantextensions', $row->get_coursework() ->get_context())); diff --git a/classes/allocation/manager.php b/classes/allocation/manager.php index e25b57af..b4dd472f 100644 --- a/classes/allocation/manager.php +++ b/classes/allocation/manager.php @@ -344,18 +344,18 @@ public function auto_generate_sample_set() { // Save sample set if (!empty($auto_sample_set)) { - foreach ($auto_sample_set as $allocatable) { - $sample = new \stdClass(); - $sample->courseworkid = $this->coursework->id; - $sample->allocatableid = $allocatable->id; - $sample->allocatabletype = ($this->coursework->is_configured_to_have_group_submissions()) ? "group" : "user"; - $sample->stage_identifier = "assessor_{$stage_number}"; - $sample->selectiontype = "automatic"; - - // If this a manually selected allocatable check to see if the allocatable is already in the table - $DB->insert_record("coursework_sample_set_mbrs", $sample); - - } + foreach ($auto_sample_set as $allocatable) { + $sample = new \stdClass(); + $sample->courseworkid = $this->coursework->id; + $sample->allocatableid = $allocatable->id; + $sample->allocatabletype = ($this->coursework->is_configured_to_have_group_submissions()) ? "group" : "user"; + $sample->stage_identifier = "assessor_{$stage_number}"; + $sample->selectiontype = "automatic"; + + // If this a manually selected allocatable check to see if the allocatable is already in the table + $DB->insert_record("coursework_sample_set_mbrs", $sample); + + } } } } diff --git a/classes/allocation/table/cell/builder.php b/classes/allocation/table/cell/builder.php index 859cb3e6..6ffeb3a3 100644 --- a/classes/allocation/table/cell/builder.php +++ b/classes/allocation/table/cell/builder.php @@ -191,9 +191,9 @@ private function prepare_allocation_table_cell() { } $contents .= '
'; - if ($this->coursework->allocation_enabled()) { - $assessor_dropdown = $this->get_potential_marker_dropdown(); - } + if ($this->coursework->allocation_enabled()) { + $assessor_dropdown = $this->get_potential_marker_dropdown(); + } $assessor_name = ''; if ($this->has_feedback()) { $class .= ' has-assessor-feedback '; @@ -210,7 +210,7 @@ private function prepare_allocation_table_cell() { } if ($assessor_name) { - if ($this->get_stage()->uses_sampling() && !$this->get_feedback() && !$this->has_automatic_sampling()) { + if ($this->get_stage()->uses_sampling() && !$this->get_feedback() && !$this->has_automatic_sampling()) { $contents .= '
'; } $contents .= "{$assessor_name}"; @@ -437,15 +437,15 @@ private function has_final_feedback() { [$this->allocatable->id(), $this->allocatable->type()] ); if ($submission) { - $feedbacks = isset(feedback::$pool[$this->coursework->id]['submissionid'][$submission->id]) ? + $feedbacks = isset(feedback::$pool[$this->coursework->id]['submissionid'][$submission->id]) ? feedback::$pool[$this->coursework->id]['submissionid'][$submission->id] : []; - foreach ($feedbacks as $feedback) { - if ($feedback->stage_identifier == 'final_agreed_1') { - return true; + foreach ($feedbacks as $feedback) { + if ($feedback->stage_identifier == 'final_agreed_1') { + return true; + } } } - } return false; } diff --git a/classes/allocation/table/processor.php b/classes/allocation/table/processor.php index 7b6c5f85..fd329886 100644 --- a/classes/allocation/table/processor.php +++ b/classes/allocation/table/processor.php @@ -87,19 +87,19 @@ private function get_row($allocatable) { private function clean_data($raw_data) { // Data looks like this: -// $example_data = array( -// 4543 => array( // Student id -// 'assessor_1' => array( -// 'allocation_id' => 43, -// 'assessor_id' => 232, -// ), -// 'moderator_1' => array( -// 'allocation_id' => 46, -// 'assessor_id' => 235, -// 'in_set' => 1, -// ) -// ) -// ); + // $example_data = array( + // 4543 => array( // Student id + // 'assessor_1' => array( + // 'allocation_id' => 43, + // 'assessor_id' => 232, + // ), + // 'moderator_1' => array( + // 'allocation_id' => 46, + // 'assessor_id' => 235, + // 'in_set' => 1, + // ) + // ) + // ); $clean_data = []; foreach ($raw_data as $allocatable_id => $datarrays) { @@ -117,7 +117,7 @@ private function clean_data($raw_data) { $clean_data[$allocatable_id][$stage->identifier()] = $stage_data; } } - /* if (array_key_exists('moderator', $datarrays)) { + /* if (array_key_exists('moderator', $datarrays)) { $moderator_data = $datarrays['moderator']; $clean_data[$allocatable_id]['moderator'] = $moderator_data; }*/ diff --git a/classes/assessor_feedback_row.php b/classes/assessor_feedback_row.php index d24932d6..be98e9b5 100644 --- a/classes/assessor_feedback_row.php +++ b/classes/assessor_feedback_row.php @@ -128,7 +128,7 @@ public function get_graded_by() { * @return string */ public function get_graders_name() { - return $this->get_graded_by()->profile_link(); + return $this->get_graded_by()->profile_link(); } /** diff --git a/classes/controllers/personal_deadlines_controller.php b/classes/controllers/personal_deadlines_controller.php index 6774813b..be1a73ec 100644 --- a/classes/controllers/personal_deadlines_controller.php +++ b/classes/controllers/personal_deadlines_controller.php @@ -84,36 +84,34 @@ protected function new_personal_deadline() { $this->personal_deadline->update_attributes($data); } } else { - - $allocatables = unserialize($data->allocatableid); - - foreach ($allocatables as $allocatableid) { - $data->allocatableid = $allocatableid; - $data->id = ''; - //$data->id = ''; - $findparams = array( - 'allocatableid' => $allocatableid, - 'allocatabletype' => $data->allocatabletype, - 'courseworkid' => $data->courseworkid, - ); - $this->personal_deadline = personal_deadline::find_or_build($findparams); - - if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist - // add new - $data->createdbyid = $USER->id; - $this->personal_deadline = personal_deadline::build($data); - $this->personal_deadline->save(); - - } else { - // update - $data->id = $this->personal_deadline->id; - $data->lastmodifiedbyid = $USER->id; - $data->timemodified = time(); - $this->personal_deadline->update_attributes($data); - } - + $allocatables = unserialize($data->allocatableid); + foreach ($allocatables as $allocatableid) { + $data->allocatableid = $allocatableid; + $data->id = ''; + //$data->id = ''; + $findparams = array( + 'allocatableid' => $allocatableid, + 'allocatabletype' => $data->allocatabletype, + 'courseworkid' => $data->courseworkid, + ); + $this->personal_deadline = personal_deadline::find_or_build($findparams); + + if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist + // add new + $data->createdbyid = $USER->id; + $this->personal_deadline = personal_deadline::build($data); + $this->personal_deadline->save(); + + } else { + // update + $data->id = $this->personal_deadline->id; + $data->lastmodifiedbyid = $USER->id; + $data->timemodified = time(); + $this->personal_deadline->update_attributes($data); } + } + } redirect($coursework_page_url); } @@ -141,12 +139,12 @@ protected function set_default_current_deadline() { $params['allocatableid'] = $this->params['allocatableid']; - // If the allocatableid is an array then the current page will probably be setting multiple the personal deadlines - // of multiple allocatable ids in which case set the personal deadline to the coursework default - if (is_array($this->params['allocatableid']) || !$this->get_personal_deadline()) { // if no personal deadline then use coursework deadline - $this->personal_deadline->personal_deadline = $this->coursework->deadline; + // If the allocatableid is an array then the current page will probably be setting multiple the personal deadlines + // of multiple allocatable ids in which case set the personal deadline to the coursework default + if (is_array($this->params['allocatableid']) || !$this->get_personal_deadline()) { // if no personal deadline then use coursework deadline + $this->personal_deadline->personal_deadline = $this->coursework->deadline; - } + } return $params; } diff --git a/classes/controllers/submissions_controller.php b/classes/controllers/submissions_controller.php index b2320ea2..60b73b53 100644 --- a/classes/controllers/submissions_controller.php +++ b/classes/controllers/submissions_controller.php @@ -116,14 +116,14 @@ protected function create_submission() { $submission->authorid = $submission->get_author_id(); // Create new function to get the author id depending on whether the current user is submitting on behalf $submission->timesubmitted = time(); - // Automatically finalise any submissions that's past the deadline/personal deadline and doesn't have valid extension + // Automatically finalise any submissions that's past the deadline/personal deadline and doesn't have valid extension if ($this->coursework->personal_deadlines_enabled()) { // Check is submission has a valid personal deadline or a valid extension - if (!$this->has_valid_personal_deadline($submission) && !$this->has_valid_extension($submission)) { - $submission->finalised = 1; - } + if (!$this->has_valid_personal_deadline($submission) && !$this->has_valid_extension($submission)) { + $submission->finalised = 1; + } } else if ($this->coursework->deadline_has_passed() && !$this->has_valid_extension($submission)) { - $submission->finalised = 1; + $submission->finalised = 1; } $ability = new ability(user::find($USER), $this->coursework); @@ -167,7 +167,7 @@ protected function create_submission() { } } - if ($submission->finalised) { + if ($submission->finalised) { if (!$submission->get_coursework()->has_deadline()) { $userids = explode(',', $submission->get_coursework()->get_submission_notification_users()); @@ -221,11 +221,11 @@ protected function edit_submission() { $submit_form->set_data($submission); - if ($validation != true) { + if ($validation != true) { $this->get_page_renderer()->edit_submission_page($submit_form, $submission); return true; - } - } + } + } /** * @@ -399,11 +399,11 @@ protected function check_coursework_is_open($coursework) { */ private function exception_if_late($submission) { $could_have_submitted = has_capability('mod/coursework:submit', $this->coursework->get_context()); - if ($this->coursework->personal_deadlines_enabled()) { - $deadline_has_passed = !$this->has_valid_personal_deadline($submission); - } else { - $deadline_has_passed = $this->coursework->deadline_has_passed(); - } + if ($this->coursework->personal_deadlines_enabled()) { + $deadline_has_passed = !$this->has_valid_personal_deadline($submission); + } else { + $deadline_has_passed = $this->coursework->deadline_has_passed(); + } if ($could_have_submitted && $deadline_has_passed && !$this->has_valid_extension($submission) && !$this->coursework->allow_late_submissions()) { throw new late_submission($this->coursework); diff --git a/classes/cron.php b/classes/cron.php index 894cfa51..b04ee7df 100644 --- a/classes/cron.php +++ b/classes/cron.php @@ -51,7 +51,7 @@ public static function run() { echo "Starting coursework cron functions...\n"; self::finalise_any_submissions_where_the_deadline_has_passed(); self::send_reminders_to_students(); - // self::send_first_reminders_to_admins(); #90211934 + // self::send_first_reminders_to_admins(); #90211934 self::autorelease_feedbacks_where_the_release_date_has_passed(); return true; } @@ -109,7 +109,7 @@ private static function send_reminders_to_students() { if ($individual_extension) { // check if 1st reminder is due to be sent but has not been sent yet - if ($coursework->due_to_send_first_reminders($individual_extension->extended_deadline) && + if ($coursework->due_to_send_first_reminders($individual_extension->extended_deadline) && $student->has_not_been_sent_reminder($coursework, 1, $individual_extension->extended_deadline)) { $student->deadline = $individual_extension->extended_deadline; $student->extension = $individual_extension->extended_deadline; @@ -117,15 +117,15 @@ private static function send_reminders_to_students() { $student->nextremindernumber = 1; $userswhoneedreminding[$student->id().'_'.$coursework->id] = $student; - // check if 2nd reminder is due to be sent but has not been sent yet - } else if ($coursework->due_to_send_second_reminders($individual_extension->extended_deadline) && + // check if 2nd reminder is due to be sent but has not been sent yet + } else if ($coursework->due_to_send_second_reminders($individual_extension->extended_deadline) && $student->has_not_been_sent_reminder($coursework, 2, $individual_extension->extended_deadline)) { $student->deadline = $individual_extension->extended_deadline; $student->extension = $individual_extension->extended_deadline; $student->coursework_id = $coursework->id; $student->nextremindernumber = 2; $userswhoneedreminding[$student->id().'_'.$coursework->id] = $student; - } + } } else if ($deadline > time()) { // coursework or personal deadline hasn't passed // check if 1st reminder is due to be sent but has not been sent yet @@ -386,7 +386,7 @@ private static function autorelease_feedbacks_where_the_release_date_has_passed( global $DB; echo 'Auto releasing feedbacks for courseworks where the release date have passed...'; - $sql = "SELECT * + $sql = "SELECT * FROM {coursework} c JOIN {coursework_submissions} cs ON c.id = cs.courseworkid diff --git a/classes/export/csv.php b/classes/export/csv.php index c0db544a..704f9498 100644 --- a/classes/export/csv.php +++ b/classes/export/csv.php @@ -128,11 +128,11 @@ public function add_cells_to_array($submission, $student, $csv_cells) { } } else if ($csv_cell != 'stages' && $csv_cell != 'moderationagreement' && $csv_cell != 'otherassessors') { $cell = $cell->get_cell($submission, $student, false); - if (is_array($cell)) { - $row = array_merge($row, $cell); - } else { - $row[] = $cell; - } + if (is_array($cell)) { + $row = array_merge($row, $cell); + } else { + $row[] = $cell; + } } else { $stages = $cell->get_cell($submission, $student, false); @@ -147,50 +147,50 @@ public function add_cells_to_array($submission, $student, $csv_cells) { * create headers for CSV * @param $csv_headers */ - public function add_headers($csv_headers) { - $headers = []; - foreach ($csv_headers as $header) { - if (substr($header, 0, 8) == 'assessor') { - $stage = (substr($header, -1)); - $header = substr($header, 0, -1); + public function add_headers($csv_headers) { + $headers = []; + foreach ($csv_headers as $header) { + if (substr($header, 0, 8) == 'assessor') { + $stage = (substr($header, -1)); + $header = substr($header, 0, -1); + } + $class = "mod_coursework\\export\\csv\\cells\\".$header."_cell"; + $cell = new $class($this->coursework); + if (substr($header, 0, 8) == 'assessor') { + $head = $cell->get_header($stage); + if (is_array($head)) { + $headers = array_merge($headers, $head); + } else { + $headers[$header.$stage] = $head; } - $class = "mod_coursework\\export\\csv\\cells\\".$header."_cell"; - $cell = new $class($this->coursework); - if (substr($header, 0, 8) == 'assessor') { - $head = $cell->get_header($stage); - if (is_array($head)) { - $headers = array_merge($headers, $head); - } else { - $headers[$header.$stage] = $head; - } - - } else if ($header != 'stages' && $header != 'moderationagreement' && $header != 'otherassessors' ) { - $head = $cell->get_header(false); - if (is_array($head)) { - $headers = array_merge($headers, $head); - } else { - $headers[$header] = $head; - } + + } else if ($header != 'stages' && $header != 'moderationagreement' && $header != 'otherassessors' ) { + $head = $cell->get_header(false); + if (is_array($head)) { + $headers = array_merge($headers, $head); } else { - $array_headers = $cell->get_header(false); - $headers = array_merge($headers, $array_headers); + $headers[$header] = $head; } + } else { + $array_headers = $cell->get_header(false); + $headers = array_merge($headers, $array_headers); } + } - $this->csvexport->add_data($headers); + $this->csvexport->add_data($headers); - } + } /** * Add filename to the CSV * @param $filename * @return string */ - public function add_filename($filename) { + public function add_filename($filename) { - $filename = clean_filename($filename); - return $this->csvexport->filename = $filename.'.csv'; - } + $filename = clean_filename($filename); + return $this->csvexport->filename = $filename.'.csv'; + } /** * Function to sort array in order of submission's lastname @@ -264,9 +264,9 @@ public function other_assessors_cells() { $increment = 2; } - for ($i = 1; $i < $this->coursework->get_max_markers(); $i++) { - $cells = $cells + $increment; // one for grade, one for feedback - } + for ($i = 1; $i < $this->coursework->get_max_markers(); $i++) { + $cells = $cells + $increment; // one for grade, one for feedback + } return $cells; diff --git a/classes/export/csv/cells/assessorfeedback_cell.php b/classes/export/csv/cells/assessorfeedback_cell.php index e3062990..d1be9117 100644 --- a/classes/export/csv/cells/assessorfeedback_cell.php +++ b/classes/export/csv/cells/assessorfeedback_cell.php @@ -125,7 +125,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } if (!$this->coursework->allocation_enabled() && !empty($feedback)) { - // Was this user the one who last graded this submission if not then user cannot grade + // Was this user the one who last graded this submission if not then user cannot grade if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $modulecontext) ) return get_string('nopermissiontogradesubmission', 'coursework'); diff --git a/classes/export/csv/cells/assessorgrade_cell.php b/classes/export/csv/cells/assessorgrade_cell.php index 081148f0..ef991bbb 100644 --- a/classes/export/csv/cells/assessorgrade_cell.php +++ b/classes/export/csv/cells/assessorgrade_cell.php @@ -205,7 +205,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } if (!$this->coursework->allocation_enabled() && !empty($feedback)) { - // Was this user the one who last graded this submission if not then user cannot grade + // Was this user the one who last graded this submission if not then user cannot grade if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context)) return get_string('nopermissiontogradesubmission', 'coursework'); @@ -246,9 +246,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } else if (has_any_capability($agreedgradecap, $PAGE->context)) { - // If you have the add agreed or edit agreed grades capabilities then you may have the grades on your export sheet - // We will return true as we will ignore them - return true; + // If you have the add agreed or edit agreed grades capabilities then you may have the grades on your export sheet + // We will return true as we will ignore them + return true; } else { return get_string('nopermissiontoimportgrade', 'coursework'); diff --git a/classes/export/csv/cells/cell_base.php b/classes/export/csv/cells/cell_base.php index 563f8484..ff72d309 100644 --- a/classes/export/csv/cells/cell_base.php +++ b/classes/export/csv/cells/cell_base.php @@ -230,7 +230,7 @@ public function get_stage_identifier_for_assessor($submission, $student) { } else if ($this->coursework->get_max_markers() > 1) { // get existing feedback - $sql = "SELECT * FROM {coursework_feedbacks} + $sql = "SELECT * FROM {coursework_feedbacks} WHERE submissionid= $submission->id AND assessorid = $USER->id AND stage_identifier <> 'final_agreed_1'"; diff --git a/classes/export/csv/cells/moderationagreement_cell.php b/classes/export/csv/cells/moderationagreement_cell.php index a989a1e2..12795ed6 100644 --- a/classes/export/csv/cells/moderationagreement_cell.php +++ b/classes/export/csv/cells/moderationagreement_cell.php @@ -62,12 +62,12 @@ public function get_cell($submission, $student, $stage_identifier) { $data[] = $this->get_assessor_name($moderation_agreement->moderatorid); $data[] = $this->get_assessor_username($moderation_agreement->moderatorid); $data[] = userdate($moderation_agreement->timemodified, $this->dateformat); - } else { - $data[] = ''; - $data[] = ''; - $data[] = ''; - $data[] = ''; - } + } else { + $data[] = ''; + $data[] = ''; + $data[] = ''; + $data[] = ''; + } return $data; } diff --git a/classes/export/csv/cells/otherassessors_cell.php b/classes/export/csv/cells/otherassessors_cell.php index 66caf981..5b6bffda 100644 --- a/classes/export/csv/cells/otherassessors_cell.php +++ b/classes/export/csv/cells/otherassessors_cell.php @@ -42,8 +42,8 @@ public function get_cell($submission, $student, $stage_identifier) { global $DB, $USER; // find out current user stage identifier - // $stage_identifier = - // retrieve all feedbacks without currents user feedback + // $stage_identifier = + // retrieve all feedbacks without currents user feedback $params = array( 'submissionid' => $submission->id, @@ -59,7 +59,7 @@ public function get_cell($submission, $student, $stage_identifier) { $feedbacks = $DB->get_records_sql($sql, $params); $gradedata = []; - // $stage_identifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student); + // $stage_identifier = ($this->coursework->get_max_markers() == 1) ? "assessor_1" : $this->get_stage_identifier_for_assessor($submission, $student); foreach ($feedbacks as $feedback) { $grade = $submission->get_assessor_feedback_by_stage($feedback->stage_identifier); @@ -146,7 +146,7 @@ public function get_header($stage) { } $fields['otherassessorfeedback' . $i] = get_string('otherassessorfeedback', 'coursework', $i); } - return $fields; + return $fields; } } diff --git a/classes/export/csv/cells/singlegrade_cell.php b/classes/export/csv/cells/singlegrade_cell.php index 22c2d721..d56da8f4 100644 --- a/classes/export/csv/cells/singlegrade_cell.php +++ b/classes/export/csv/cells/singlegrade_cell.php @@ -160,7 +160,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo $feedback = feedback::find($feedback_params); if (!$this->coursework->allocation_enabled() && !empty($feedback)) { - // Was this user the one who last graded this submission if not then user cannot grade + // Was this user the one who last graded this submission if not then user cannot grade if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context) && !has_capability('mod/coursework:administergrades', $PAGE->context)) return get_string('nopermissiontoeditgrade', 'coursework'); @@ -253,7 +253,7 @@ function get_rubrics($coursework, $csv_cells) { // Find out the position of singlegrade $position = array_search('singlegrade', $csv_cells); // Get all data from the position of the singlegrade to the length of rubricheaders - // $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders); + // $csv_cells = array_splice($csv_cells,5, 1, $rubricheaders); $start_cells = array_slice($csv_cells, 0, $position, true); $end_cells = array_slice($csv_cells, $position + 1, count($csv_cells), true); diff --git a/classes/export/csv/cells/submissiontime_cell.php b/classes/export/csv/cells/submissiontime_cell.php index a7452bdf..205c186d 100644 --- a/classes/export/csv/cells/submissiontime_cell.php +++ b/classes/export/csv/cells/submissiontime_cell.php @@ -34,7 +34,7 @@ class submissiontime_cell extends cell_base { * @return string */ public function get_cell($submission, $student, $stage_identifier) { - return $this->submission_time($submission); + return $this->submission_time($submission); } /** diff --git a/classes/export/grading_sheet.php b/classes/export/grading_sheet.php index 1c8ea7aa..e3166847 100644 --- a/classes/export/grading_sheet.php +++ b/classes/export/grading_sheet.php @@ -35,7 +35,7 @@ public function get_submissions($groupid = null, $selected_submission_ids = '') 'courseworkid' => $this->coursework->id, ); - $submissions = submission::find_all($params); + $submissions = submission::find_all($params); // remove unfinalised submissions foreach ($submissions as $submission) { @@ -55,44 +55,44 @@ public function get_submissions($groupid = null, $selected_submission_ids = '') /** * @var submission[] $submissions */ - foreach ($submissions as $submission) { - $stage_identifiers = []; - // remove all submissions that a user is not supposed to see - - // double marking not allocated - $stages = $this->coursework->get_max_markers(); - if ($stages > 1 && !$this->coursework->allocation_enabled() && !has_capability('mod/coursework:addagreedgrade', $PAGE->context)) { - // if samplings enabled, work out how many per submission - if ($this->coursework->sampling_enabled()) { - $stage_identifiers[] = 'assessor_1'; // always have at least one assessor - // check how many other assessors for this submission - $in_sample = $submission->get_submissions_in_sample(); - foreach ($in_sample as $i) { - $stage_identifiers[] = $i->stage_identifier; - } - } else { // if sampling not enabled, everyone is marked in all stages - for ($i = 1; $i <= $stages; $i++) { - $stage_identifiers[] = 'assessor_' . $i; - } - } - // check if any of the submissions still requires marking - for ($i = 0; $i < count($stage_identifiers); $i++) { - $feedback = $submission->get_assessor_feedback_by_stage($stage_identifiers[$i]); - // if no feedback or feedback belongs to current user don't remove submission - if (!$feedback || $feedback->assessorid == $USER->id) { - break; - } else if ($i + 1 < count($stage_identifiers)) { - continue; - } - // if the last submission was already marked remove it from the array - unset($submissions[$submission->id]); - } - } - - // TODO - decide if already marked submissions should be displayed in single marking - // if not marked by a user than dont display it as it would allow them to edit it?? - // || $submission->get_state() == submission::FINAL_GRADED - if (!$ability->can('show', $submission) + foreach ($submissions as $submission) { + $stage_identifiers = []; + // remove all submissions that a user is not supposed to see + + // double marking not allocated + $stages = $this->coursework->get_max_markers(); + if ($stages > 1 && !$this->coursework->allocation_enabled() && !has_capability('mod/coursework:addagreedgrade', $PAGE->context)) { + // if samplings enabled, work out how many per submission + if ($this->coursework->sampling_enabled()) { + $stage_identifiers[] = 'assessor_1'; // always have at least one assessor + // check how many other assessors for this submission + $in_sample = $submission->get_submissions_in_sample(); + foreach ($in_sample as $i) { + $stage_identifiers[] = $i->stage_identifier; + } + } else { // if sampling not enabled, everyone is marked in all stages + for ($i = 1; $i <= $stages; $i++) { + $stage_identifiers[] = 'assessor_' . $i; + } + } + // check if any of the submissions still requires marking + for ($i = 0; $i < count($stage_identifiers); $i++) { + $feedback = $submission->get_assessor_feedback_by_stage($stage_identifiers[$i]); + // if no feedback or feedback belongs to current user don't remove submission + if (!$feedback || $feedback->assessorid == $USER->id) { + break; + } else if ($i + 1 < count($stage_identifiers)) { + continue; + } + // if the last submission was already marked remove it from the array + unset($submissions[$submission->id]); + } + } + + // TODO - decide if already marked submissions should be displayed in single marking + // if not marked by a user than dont display it as it would allow them to edit it?? + // || $submission->get_state() == submission::FINAL_GRADED + if (!$ability->can('show', $submission) || ($stages == 1 && !has_capability('mod/coursework:addinitialgrade', $PAGE->context)) || ($this->coursework->allocation_enabled() && !$this->coursework ->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) @@ -105,12 +105,12 @@ public function get_submissions($groupid = null, $selected_submission_ids = '') && (has_capability('mod/coursework:addagreedgrade', $PAGE->context) || has_capability('mod/coursework:editagreedgrade', $PAGE->context))) || ((has_capability('mod/coursework:addagreedgrade', $PAGE->context) && $submission->get_state() < submission::FULLY_GRADED )) - ) { - unset($submissions[$submission->id]); - continue; - } - } - } + ) { + unset($submissions[$submission->id]); + continue; + } + } + } return $submissions; } @@ -166,15 +166,15 @@ public static function cells_array($coursework) { // based on capabilities decide what view display - singlegrade or multiplegrade if ((has_capability('mod/coursework:addagreedgrade', $PAGE->context) || has_capability('mod/coursework:administergrades', $PAGE->context)) && $coursework->get_max_markers() > 1 ) { - for ($i = 1; $i <= $coursework->get_max_markers(); $i++) { - // extra column with allocated assessor name - if ($coursework->allocation_enabled() && $coursework->get_max_markers() > 1 + for ($i = 1; $i <= $coursework->get_max_markers(); $i++) { + // extra column with allocated assessor name + if ($coursework->allocation_enabled() && $coursework->get_max_markers() > 1 && (has_capability('mod/coursework:addinitialgrade', $PAGE->context) || has_capability('mod/coursework:editinitialgrade', $PAGE->context))) { - $csv_cells[] = 'assessor' . $i; - } - $csv_cells[] = 'assessorgrade'.$i; - $csv_cells[] = 'assessorfeedback'.$i; + $csv_cells[] = 'assessor' . $i; + } + $csv_cells[] = 'assessorgrade'.$i; + $csv_cells[] = 'assessorfeedback'.$i; } $csv_cells[] = 'agreedgrade'; $csv_cells[] = 'agreedfeedback'; @@ -192,9 +192,9 @@ public static function cells_array($coursework) { } else if (has_capability('mod/coursework:addinitialgrade', $PAGE->context) || has_capability('mod/coursework:administergrades', $PAGE->context)) { - // if (!$coursework->is_using_rubric()) { + // if (!$coursework->is_using_rubric()) { $csv_cells[] = 'singlegrade'; - /* } else { + /* } else { $criterias = $coursework->get_rubric_criteria(); @@ -204,7 +204,7 @@ public static function cells_array($coursework) { } } - */ + */ $csv_cells[] = 'feedbackcomments'; } diff --git a/classes/export/import.php b/classes/export/import.php index 5a8c87a5..437ecad8 100644 --- a/classes/export/import.php +++ b/classes/export/import.php @@ -141,15 +141,15 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) { $result = $cell->validate_cell($value, $submissionid, $stage_identifier, $uploadedgradecells); } - if ($result !== true) { - $errors[$s] = $result; - break; // Go to next line on error - } else if ($cells[$i] == "singlegrade" || $cells[$i] == "assessorgrade" || $cells[$i] == "agreedgrade" && !empty($value)) { + if ($result !== true) { + $errors[$s] = $result; + break; // Go to next line on error + } else if ($cells[$i] == "singlegrade" || $cells[$i] == "assessorgrade" || $cells[$i] == "agreedgrade" && !empty($value)) { - $uploadedgradecells[] = $stage_identifier; + $uploadedgradecells[] = $stage_identifier; - } - $i++; + } + $i++; } $s++; } @@ -203,10 +203,10 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) { unset($csvheader[$position + $offset]); unset($linefromimportedcsv[$position + $offset]); -// if ($type == 'agreedgrade' && $this->coursework->finalstagegrading == 0) { + // if ($type == 'agreedgrade' && $this->coursework->finalstagegrading == 0) { array_splice($csvheader, $position + $offset, 0, array_keys($headers)); array_splice($linefromimportedcsv, $position + $offset, 0, array('')); -// } + // } $offset = $offset + count($headers) - 1; $expectedsize = (int)count($csvheader); $actualsize = (int)count($linefromimportedcsv); @@ -344,9 +344,9 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces foreach ($csvline as $k => $v) { if (substr($k, 0, 13) == 'assessorgrade' || substr($k, 0, 11) == 'singlegrade') { - $stages[$k] = $this->get_stage_identifier($csvline['submissionid'], $k); + $stages[$k] = $this->get_stage_identifier($csvline['submissionid'], $k); } else if (substr($k, 0, 11) == 'agreedgrade') { - $stages[$k] = 'final_agreed_1'; + $stages[$k] = 'final_agreed_1'; } } } @@ -362,7 +362,7 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces foreach ($stages as $k => $stage) { - // When allocation is enabled + // When allocation is enabled if (has_capability('mod/coursework:administergrades', $PAGE->context) && $coursework->allocation_enabled() && $stage != 'final_agreed_1' && $coursework->has_multiple_markers() == true) { $rubricoffset += 1; if ($a == 1) $rubricoffsetstart += 1; @@ -436,62 +436,62 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces $rubricoffset = $rubricoffset + $numberofrubrics + 1; } - $arrayvalues = array_filter($rubricdata); + $arrayvalues = array_filter($rubricdata); - if (!empty($arrayvalues)) { + if (!empty($arrayvalues)) { - //for ( $critidx < $numberofrubrics; ) { - $critidx = 0; - // This assumes that the data in the csv is in the correct criteria order.....it should be - foreach ($criterias as $c) { - $criteriagrade = []; + //for ( $critidx < $numberofrubrics; ) { + $critidx = 0; + // This assumes that the data in the csv is in the correct criteria order.....it should be + foreach ($criterias as $c) { + $criteriagrade = []; - // We need to get the levelid for the value that the criteria has been given + // We need to get the levelid for the value that the criteria has been given - $levelid = $this->get_value_rubric_levelid($c, $rubricdata[$critidx]); + $levelid = $this->get_value_rubric_levelid($c, $rubricdata[$critidx]); - $criteriagrade['levelid'] = $levelid; - $criteriagrade['remark'] = $rubricdata[$critidx + 1]; + $criteriagrade['levelid'] = $levelid; + $criteriagrade['remark'] = $rubricdata[$critidx + 1]; - $criteriagradedata['criteria'][$c['id']] = $criteriagrade; + $criteriagradedata['criteria'][$c['id']] = $criteriagrade; - $critidx = $critidx + 2; + $critidx = $critidx + 2; - } - } else { - $criteriagradedata = false; } + } else { + $criteriagradedata = false; + } - // Need to decide where the grade instance submit and get grade should be put as in order + // Need to decide where the grade instance submit and get grade should be put as in order - // Pass the criteria data into the csvline position for the grade data so we can generate a grade - $csvline[$gradepointer] = $criteriagradedata; + // Pass the criteria data into the csvline position for the grade data so we can generate a grade + $csvline[$gradepointer] = $criteriagradedata; - // In case there is another rubric to be extracted from the csv set the new value of the rubric offset + // In case there is another rubric to be extracted from the csv set the new value of the rubric offset - } else if ($coursework->is_using_rubric() && ($stage == 'final_agreed_1' && $this->coursework->finalstagegrading == 1)) { + } else if ($coursework->is_using_rubric() && ($stage == 'final_agreed_1' && $this->coursework->finalstagegrading == 1)) { - if (!isset($numberofrubrics)) { + if (!isset($numberofrubrics)) { - $criterias = $this->coursework->get_rubric_criteria(); + $criterias = $this->coursework->get_rubric_criteria(); - $numberofrubrics = count($criterias) * 2; + $numberofrubrics = count($criterias) * 2; - } - $stagemultiplier = $numberofstages - 1; + } + $stagemultiplier = $numberofstages - 1; - // The calculation below finds the position of the agreed grades in the uploaded csv + // The calculation below finds the position of the agreed grades in the uploaded csv - $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); + $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); - if ($coursework->allocation_enabled()) $rubricoffset += 1; + if ($coursework->allocation_enabled()) $rubricoffset += 1; - $gradearrvalue = array_slice($line, $rubricoffset, 2); + $gradearrvalue = array_slice($line, $rubricoffset, 2); - $csvline[$gradepointer] = $gradearrvalue[0]; - $csvline[$feedbackpointer] = $gradearrvalue[1]; + $csvline[$gradepointer] = $gradearrvalue[0]; + $csvline[$feedbackpointer] = $gradearrvalue[1]; - } + } // don't create/update feedback if grade is empty if (!empty($csvline[$gradepointer])) { @@ -566,7 +566,7 @@ public function add_grade($submissionid, $grade, $feedback, $stage_identifier, $ // workout markernumber if ($stage_identifier == 'assessor_1') { - // assessor_1 is always marker 1 + // assessor_1 is always marker 1 $markernumber = 1; } else { // get all feedbacks and add 1 @@ -670,9 +670,9 @@ public function edit_grade($cwfeedbackid, $grade, $feedback, $uses_rubric=false) $update = $DB->update_record('coursework_feedbacks', $edit_grade); // if record updated and coursework has automatic grading enabled update agreedgrade - if ($update && $this->coursework->automaticagreement_enabled()) { - $this->auto_agreement($cwfeedbackid); - } + if ($update && $this->coursework->automaticagreement_enabled()) { + $this->auto_agreement($cwfeedbackid); + } } return $update; @@ -741,19 +741,19 @@ public function get_stage_identifier($submissionid, $cell_identifier) { 'stage_identifier' => 'assessor_1')); // no sample or no feedback for sample yet if (!$in_sample || ($in_sample && !$feedback)) { - $stage_identifier = 'assessor_1'; + $stage_identifier = 'assessor_1'; } else { // find out which sample wasn't graded yet - $samples = $submission->get_submissions_in_sample(); - foreach ($samples as $sample) { - $feedback = $DB->record_exists('coursework_feedbacks', array('submissionid' => $submissionid, + $samples = $submission->get_submissions_in_sample(); + foreach ($samples as $sample) { + $feedback = $DB->record_exists('coursework_feedbacks', array('submissionid' => $submissionid, 'stage_identifier' => $sample->stage_identifier)); - // if feedback doesn't exist, we'll use this stage identifier for a new feedback - if (!$feedback) { - $stage_identifier = $sample->stage_identifier; - break; - } - } - } + // if feedback doesn't exist, we'll use this stage identifier for a new feedback + if (!$feedback) { + $stage_identifier = $sample->stage_identifier; + break; + } + } + } } } @@ -791,9 +791,9 @@ public function auto_agreement($cwfeedbackid) { $auto_grader->create_auto_grade_if_rules_match(); } - public function remove_other_assessors_grade($csv_cells, &$line) { + public function remove_other_assessors_grade($csv_cells, &$line) { - $otherassessors = false; + $otherassessors = false; if (in_array('otherassessors', $csv_cells)) { // find position of otherassesors so we know from which key to unset @@ -820,7 +820,7 @@ public function remove_other_assessors_grade($csv_cells, &$line) { } - return $csv_cells; + return $csv_cells; } } diff --git a/classes/file_importer.php b/classes/file_importer.php index d41f4b5c..b73413ee 100644 --- a/classes/file_importer.php +++ b/classes/file_importer.php @@ -177,7 +177,7 @@ public function import_zip_files($coursework, $feedbackstage, $overwritecurrent) $results[$filename] = get_string('feedbacksubmissionpublished', 'mod_coursework'); } - } else { + } else { $results[$filename] = get_string('feedbacknotfound', 'mod_coursework'); } } diff --git a/classes/forms/deadline_extension_form.php b/classes/forms/deadline_extension_form.php index b6083172..5ea0553d 100644 --- a/classes/forms/deadline_extension_form.php +++ b/classes/forms/deadline_extension_form.php @@ -124,7 +124,7 @@ public function personal_deadline() { 'courseworkid' => $courseworkid, ); - return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); + return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); } } diff --git a/classes/forms/student_submission_form.php b/classes/forms/student_submission_form.php index ff5bca7f..3c4695ac 100644 --- a/classes/forms/student_submission_form.php +++ b/classes/forms/student_submission_form.php @@ -183,7 +183,7 @@ public function handle() { $mailer = new mailer($coursework); if (!empty($notifyuser)) $mailer->send_submission_notification($notifyuser); - } + } } } diff --git a/classes/forms/upload_allocations_form.php b/classes/forms/upload_allocations_form.php index 795d2847..be524829 100644 --- a/classes/forms/upload_allocations_form.php +++ b/classes/forms/upload_allocations_form.php @@ -39,7 +39,7 @@ function definition() { $mform->addElement('filepicker', 'allocationsdata', get_string('allocationsfile', 'coursework'), null, array( 'accepted_types' => '*.csv')); $mform->addRule('allocationsdata', null, 'required'); - // $mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework')); + // $mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework')); $mform->addElement('hidden', 'cmid', $this->cmid); $mform->setType('cmid', PARAM_RAW); diff --git a/classes/grading_table_row_base.php b/classes/grading_table_row_base.php index 1752b4ee..6c9a71c1 100644 --- a/classes/grading_table_row_base.php +++ b/classes/grading_table_row_base.php @@ -255,7 +255,7 @@ public function get_submission() { */ public function get_plagiarism_flag() { - $submission = $this->get_submission(); + $submission = $this->get_submission(); $params = array( 'submissionid' => $submission->id, ); diff --git a/classes/models/moderation.php b/classes/models/moderation.php index ca7808cd..db962a11 100644 --- a/classes/models/moderation.php +++ b/classes/models/moderation.php @@ -48,7 +48,7 @@ class moderation extends table_base { /** * @var int */ - public $feedbackid; + public $feedbackid; /** * @var int @@ -113,8 +113,8 @@ public function get_agreement() { * @return bool|submission */ public function get_submission() { - $feedback = $this->get_feedback(); - $this->submission = submission::find($feedback->submissionid); + $feedback = $this->get_feedback(); + $this->submission = submission::find($feedback->submissionid); return $this->submission; } diff --git a/classes/models/outstanding_marking.php b/classes/models/outstanding_marking.php index f6bc8fac..2d7d8a93 100644 --- a/classes/models/outstanding_marking.php +++ b/classes/models/outstanding_marking.php @@ -73,13 +73,13 @@ public function get_to_grade_agreed_count($cwkrecord, $userid) { //AGREED GRADE INFORMATION - if ($this->should_get_to_mark_agreed_grade_info($coursework->id, $userid) && $coursework->has_multiple_markers()) { - if (!$coursework->sampling_enabled()) { - $agreedsubmissions = $this->get_to_grade_agreed_grade_submissions($coursework->id, $coursework->get_max_markers()); - } else { - $agreedsubmissions = $this->get_to_grade_agreed_grade_sampled_submissions($coursework->id); - } + if ($this->should_get_to_mark_agreed_grade_info($coursework->id, $userid) && $coursework->has_multiple_markers()) { + if (!$coursework->sampling_enabled()) { + $agreedsubmissions = $this->get_to_grade_agreed_grade_submissions($coursework->id, $coursework->get_max_markers()); + } else { + $agreedsubmissions = $this->get_to_grade_agreed_grade_sampled_submissions($coursework->id); } + } return (!empty($agreedsubmissions)) ? count($agreedsubmissions) : 0; } diff --git a/classes/render_helpers/grading_report/cells/_user_cell.php b/classes/render_helpers/grading_report/cells/_user_cell.php index def69931..213a3428 100644 --- a/classes/render_helpers/grading_report/cells/_user_cell.php +++ b/classes/render_helpers/grading_report/cells/_user_cell.php @@ -48,7 +48,7 @@ public function get_table_cell($rowobject) { */ $user = $rowobject->get_allocatable(); - /* if ($rowobject->can_view_username()) { + /* if ($rowobject->can_view_username()) { $content .= $OUTPUT->user_picture($user->get_raw_record()); } else { $renderer = $PAGE->get_renderer('core'); @@ -69,28 +69,28 @@ public function get_table_cell($rowobject) { */ public function get_table_header($options = []) { - $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); + $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); //adding this line so that the sortable heading function will make a sortable link unique to the table // If tablename is set $tablename = (!empty($options['tablename'])) ? $options['tablename'] : ''; - // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous - if ($viewanonymous || !$this->coursework->blindmarking) { - $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), + // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous + if ($viewanonymous || !$this->coursework->blindmarking) { + $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), 'firstname', $options['sorthow'], $options['sortby'], $tablename); - $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'), + $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'), 'lastname', $options['sorthow'], $options['sortby'], $tablename); - } else { // otherwise display header without sorting - $sort_by_first_name = get_string('firstname'); - $sort_by_last_name =get_string('lastname'); - } + } else { // otherwise display header without sorting + $sort_by_first_name = get_string('firstname'); + $sort_by_last_name =get_string('lastname'); + } if ($this->fullname_format() == 'lf') { $sort_by_name = $sort_by_last_name . ' / ' . $sort_by_first_name; diff --git a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php index 07b72e25..1ab3ac31 100644 --- a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php +++ b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php @@ -162,7 +162,7 @@ private function new_moderation_button($rowobject, $assessor) { // moderation only done for single marking courseworks $feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1'); - $moderation_params = array( + $moderation_params = array( 'submission' => $rowobject->get_submission(), 'assessor' => $assessor, 'stage' => $this->stage, diff --git a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php index 3b01688b..d0dc6ed4 100644 --- a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php +++ b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php @@ -79,8 +79,8 @@ public function get_content($rowobject) { if ($finalfeedback !== false) { $grade_judge = new grade_judge($this->coursework); $content .= $grade_judge->grade_to_display($finalfeedback->get_grade()); - // $content .= html_writer::empty_tag('br'); - // $content .= ' by: ' . $finalfeedback->get_assesor_username(); + // $content .= html_writer::empty_tag('br'); + // $content .= ' by: ' . $finalfeedback->get_assesor_username(); } // Edit/new link @@ -150,13 +150,13 @@ public function get_content($rowobject) { if ($finalfeedback !== false) { $content .= html_writer::empty_tag('br'); - if ((!$this->coursework->sampling_enabled() || $rowobject->get_submission()->sampled_feedback_exists()) && ($finalfeedback->get_feedbacks_assessorid() == 0 + if ((!$this->coursework->sampling_enabled() || $rowobject->get_submission()->sampled_feedback_exists()) && ($finalfeedback->get_feedbacks_assessorid() == 0 && $finalfeedback->timecreated == $finalfeedback->timemodified) || $finalfeedback->lasteditedbyuser == 0) { // if the grade was automatically agreed - $content .= "(".get_string('automaticagreement', 'coursework').")"; - } else { - $content .= ' by: ' . $finalfeedback->get_assesor_username(); - } + $content .= "(".get_string('automaticagreement', 'coursework').")"; + } else { + $content .= ' by: ' . $finalfeedback->get_assesor_username(); + } } return $content; } diff --git a/classes/render_helpers/grading_report/cells/user_cell.php b/classes/render_helpers/grading_report/cells/user_cell.php index 6eddeab0..acf601fd 100644 --- a/classes/render_helpers/grading_report/cells/user_cell.php +++ b/classes/render_helpers/grading_report/cells/user_cell.php @@ -43,7 +43,7 @@ public function get_table_cell($rowobject) { $content = ''; - /* if ($rowobject->can_view_username()) { + /* if ($rowobject->can_view_username()) { $content .= $OUTPUT->user_picture($user->get_raw_record()); } else { $renderer = $PAGE->get_renderer('core'); @@ -56,7 +56,7 @@ public function get_table_cell($rowobject) { $content .= ' ' . $rowobject->get_user_name(true); $content .= "
".$rowobject->get_email(); $user = $rowobject->get_allocatable(); -/* + /* $candidatenumber = $user->candidate_number(); if (!empty($candidatenumber)) { @@ -65,7 +65,7 @@ public function get_table_cell($rowobject) { } -*/ + */ return $this->get_new_cell_with_class($content); } @@ -76,35 +76,35 @@ public function get_table_cell($rowobject) { */ public function get_table_header($options = []) { - $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); + $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->coursework->get_context()); //adding this line so that the sortable heading function will make a sortable link unique to the table // If tablename is set $tablename = (!empty($options['tablename'])) ? $options['tablename'] : ''; - // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous - if ($viewanonymous || !$this->coursework->blindmarking) { - $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), + // allow to sort users only if CW is not set to blind marking or a user has capability to view anonymous + if ($viewanonymous || !$this->coursework->blindmarking) { + $sort_by_first_name = $this->helper_sortable_heading(get_string('firstname'), 'firstname', $options['sorthow'], $options['sortby'], $tablename); - $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'), + $sort_by_last_name = $this->helper_sortable_heading(get_string('lastname'), 'lastname', $options['sorthow'], $options['sortby'], $tablename); - $sort_by_email = $this->helper_sortable_heading(get_string('email', 'mod_coursework'), + $sort_by_email = $this->helper_sortable_heading(get_string('email', 'mod_coursework'), 'email', $options['sorthow'], $options['sortby'], $tablename); - } else { // otherwise display header without sorting - $sort_by_first_name = get_string('firstname'); - $sort_by_last_name = get_string('lastname'); - $sort_by_email = get_string('email', 'mod_coursework'); - } + } else { // otherwise display header without sorting + $sort_by_first_name = get_string('firstname'); + $sort_by_last_name = get_string('lastname'); + $sort_by_email = get_string('email', 'mod_coursework'); + } if ($this->fullname_format() == 'lf') { $sort_by_first_name = ' / ' . $sort_by_first_name; diff --git a/classes/sample_set_rule/range_sample_type.php b/classes/sample_set_rule/range_sample_type.php index 303fc868..bfb5f8f9 100644 --- a/classes/sample_set_rule/range_sample_type.php +++ b/classes/sample_set_rule/range_sample_type.php @@ -105,7 +105,7 @@ public function range_elements($assessor_number, $sequence, $dbrecord=false) { if ($dbrecord) { $selected_type = array($dbrecord->ruletype => get_string($dbrecord->ruletype, 'mod_coursework')); - $selected_to = ($dbrecord->ruletype == 'scale') ? array($dbrecord->upperlimit => $scale[$dbrecord->upperlimit]) : array($dbrecord->upperlimit => $dbrecord->upperlimit); + $selected_to = ($dbrecord->ruletype == 'scale') ? array($dbrecord->upperlimit => $scale[$dbrecord->upperlimit]) : array($dbrecord->upperlimit => $dbrecord->upperlimit); $selected_from = ($dbrecord->ruletype == 'scale') ? array($dbrecord->lowerlimit => $scale[$dbrecord->lowerlimit]) : array($dbrecord->lowerlimit => $dbrecord->lowerlimit); @@ -337,23 +337,23 @@ public function save_form_data($assessor_number=0, &$order=0) { $sample_plugin = $DB->get_record('coursework_sample_set_plugin', array('rulename' => 'range_sample_type')); - if ($sample_rules) { - foreach ($sample_rules as $i => $val) { + if ($sample_rules) { + foreach ($sample_rules as $i => $val) { - $dbrecord = new \stdClass(); + $dbrecord = new \stdClass(); - $dbrecord->ruletype = $sample_type[$i]; - $dbrecord->lowerlimit = $sample_from[$i]; - $dbrecord->upperlimit = $sample_to[$i]; - $dbrecord->sample_set_plugin_id = $sample_plugin->id; - $dbrecord->courseworkid = $this->coursework->id; - $dbrecord->ruleorder = $order; - $dbrecord->stage_identifier = "assessor_{$assessor_number}"; + $dbrecord->ruletype = $sample_type[$i]; + $dbrecord->lowerlimit = $sample_from[$i]; + $dbrecord->upperlimit = $sample_to[$i]; + $dbrecord->sample_set_plugin_id = $sample_plugin->id; + $dbrecord->courseworkid = $this->coursework->id; + $dbrecord->ruleorder = $order; + $dbrecord->stage_identifier = "assessor_{$assessor_number}"; - $DB->insert_record("coursework_sample_set_rules", $dbrecord); - $order++; - } + $DB->insert_record("coursework_sample_set_rules", $dbrecord); + $order++; } + } } @@ -404,35 +404,35 @@ private function rationalise($ruletype, $limit1, $limit2) { $limits[0] = ($limit1>$limit2) ? $limit2 : $limit1; $limits[1] = ($limit1>$limit2) ? $limit1 : $limit2; - if ($ruletype == 'scale') { - ++$limits[0]; - ++$limits[1]; - } - - if ($ruletype == 'percentage') { - if ($this->coursework->grade > 0) { - $limits[0] = $this->coursework->grade * $limits[0] / 100; - $limits[1] = $this->coursework->grade * $limits[1] / 100; - } else { - $scale = $DB->get_record("scale", array('id' => abs($this->coursework->grade))); + if ($ruletype == 'scale') { + ++$limits[0]; + ++$limits[1]; + } - if ($scale) { + if ($ruletype == 'percentage') { + if ($this->coursework->grade > 0) { + $limits[0] = $this->coursework->grade * $limits[0] / 100; + $limits[1] = $this->coursework->grade * $limits[1] / 100; + } else { + $scale = $DB->get_record("scale", array('id' => abs($this->coursework->grade))); - $coursework_scale = explode(",", $scale->scale); + if ($scale) { - $number_of_items = count($coursework_scale); + $coursework_scale = explode(",", $scale->scale); - $weighting = 100 / $number_of_items; // shall we round it???? + $number_of_items = count($coursework_scale); - $limits[0] = ceil($limits[0]/$weighting); // element of array - $limits[1] = ceil($limits[1]/$weighting); // element of array + $weighting = 100 / $number_of_items; // shall we round it???? - // Note we have to add one as the values are not stored in there element positions + $limits[0] = ceil($limits[0]/$weighting); // element of array + $limits[1] = ceil($limits[1]/$weighting); // element of array - } + // Note we have to add one as the values are not stored in there element positions } + } + } return $limits; } @@ -453,7 +453,7 @@ private function get_allocatables_in_range($stage, $limit1, $limit2) { // Note as things stand limit1 and limit2 can not be params as the type of the grade field (varchar) //means the values are cast as strings - return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, + return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage)); } diff --git a/classes/sample_set_rule/total_sample_type.php b/classes/sample_set_rule/total_sample_type.php index f1993680..38bb27a4 100644 --- a/classes/sample_set_rule/total_sample_type.php +++ b/classes/sample_set_rule/total_sample_type.php @@ -219,15 +219,15 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample if (!is_array($array_keys)) $array_keys = array($array_keys); //use the allocatables array to get other ungraded allocatables - foreach ($array_keys as $id) { + foreach ($array_keys as $id) { - if (!isset($published[$id]) && !isset($finalised[$id]) - && !isset($auto_sample_set[$id]) && !isset($manual_sample_set[$id]) - ) - $auto_sample_set[$id] = $allocatables[$id]; + if (!isset($published[$id]) && !isset($finalised[$id]) + && !isset($auto_sample_set[$id]) && !isset($manual_sample_set[$id]) + ) + $auto_sample_set[$id] = $allocatables[$id]; - if (count($auto_sample_set) == $total_to_return) break; - } + if (count($auto_sample_set) == $total_to_return) break; + } } diff --git a/classes/warnings.php b/classes/warnings.php index b05f450c..5f86c68b 100644 --- a/classes/warnings.php +++ b/classes/warnings.php @@ -224,41 +224,41 @@ public function manual_allocation_not_completed() { for ($i = 1; $i <= $coursework_stages; $i++) { $assessor = 'assessor_'.$i; - if ($coursework->samplingenabled == 0 || $assessor == 'assessor_1') { - $allocatables = $coursework->get_allocatables(); + if ($coursework->samplingenabled == 0 || $assessor == 'assessor_1') { + $allocatables = $coursework->get_allocatables(); - foreach ($allocatables as $allocatable) { + foreach ($allocatables as $allocatable) { - $params = array('courseworkid' => $coursework->id, - 'stageidentifier' => $assessor, - 'allocatableid' => $allocatable->id); + $params = array('courseworkid' => $coursework->id, + 'stageidentifier' => $assessor, + 'allocatableid' => $allocatable->id); - $existing_allocations = $this->check_existing_allocations($params); + $existing_allocations = $this->check_existing_allocations($params); - if ($existing_allocations == false) { - return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework')); - } - } - } else { + if ($existing_allocations == false) { + return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework')); + } + } + } else { - $params = array('courseworkid' => $coursework->id); - $sql = "SELECT id, stage_identifier, allocatableid + $params = array('courseworkid' => $coursework->id); + $sql = "SELECT id, stage_identifier, allocatableid FROM {coursework_sample_set_mbrs} WHERE courseworkid = :courseworkid"; - $stage_identifiers = $DB->get_records_sql($sql, $params); - foreach ($stage_identifiers as $stage_identifier) { - $params = array('courseworkid' => $coursework->id, - 'stageidentifier' => $stage_identifier->stage_identifier, - 'allocatableid' => $stage_identifier->allocatableid); + $stage_identifiers = $DB->get_records_sql($sql, $params); + foreach ($stage_identifiers as $stage_identifier) { + $params = array('courseworkid' => $coursework->id, + 'stageidentifier' => $stage_identifier->stage_identifier, + 'allocatableid' => $stage_identifier->allocatableid); - $existing_allocations = $this->check_existing_allocations($params); + $existing_allocations = $this->check_existing_allocations($params); - if ($existing_allocations == false) { - return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework')); - } - } - } + if ($existing_allocations == false) { + return $this->alert_div(get_string('assessors_no_allocated_warning', 'mod_coursework')); + } + } + } } return ''; } @@ -275,7 +275,7 @@ public function check_existing_allocations($params) { AND stage_identifier = :stageidentifier AND allocatableid = :allocatableid"; - return $existing_allocations = $DB->get_records_sql($sql, $params); + return $existing_allocations = $DB->get_records_sql($sql, $params); } diff --git a/db/upgrade.php b/db/upgrade.php index 11960664..b41f65c1 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -2496,7 +2496,7 @@ function xmldb_coursework_upgrade($oldversion) { $cwk->renamefiles = ($cwk->blindmarking == 1 || $courseworkhassubmissions) ? 1 : 0; $DB->update_record('coursework', $cwk); - } + } // Coursework savepoint reached. upgrade_mod_savepoint(true, 2019121403, 'coursework'); diff --git a/lib.php b/lib.php index 1fb5062a..5dc3b10d 100644 --- a/lib.php +++ b/lib.php @@ -276,21 +276,21 @@ function mod_coursework_core_calendar_provide_event_action(calendar_event $event if ($marker) { // For markers // Check how many submissions to mark - $outstandingmarking = new outstanding_marking(); + $outstandingmarking = new outstanding_marking(); - if ($event->eventtype == 'initialgradingdue') { - // Initial grades - $togradeinitialcount = $outstandingmarking->get_to_grade_initial_count($dbcoursework, $user->id()); - $name = ($coursework->has_multiple_markers()) ? get_string('initialgrade', 'coursework') : get_string('grade', 'mod_coursework'); - $itemcount = $togradeinitialcount; + if ($event->eventtype == 'initialgradingdue') { + // Initial grades + $togradeinitialcount = $outstandingmarking->get_to_grade_initial_count($dbcoursework, $user->id()); + $name = ($coursework->has_multiple_markers()) ? get_string('initialgrade', 'coursework') : get_string('grade', 'mod_coursework'); + $itemcount = $togradeinitialcount; - } else if ($event->eventtype == 'agreedgradingdue') { - // Agreed grades - $togradeagreedcount = $outstandingmarking->get_to_grade_agreed_count($dbcoursework, $user->id()); - $name = get_string('agreedgrade', 'coursework'); - $itemcount = $togradeagreedcount; + } else if ($event->eventtype == 'agreedgradingdue') { + // Agreed grades + $togradeagreedcount = $outstandingmarking->get_to_grade_agreed_count($dbcoursework, $user->id()); + $name = get_string('agreedgrade', 'coursework'); + $itemcount = $togradeagreedcount; - } + } $submission_url = new \moodle_url('/mod/coursework/view.php', array('id' => $cm->id)); @@ -517,45 +517,45 @@ function coursework_update_instance($coursework) { * * @param $coursework */ - function coursework_update_events($coursework, $eventtype) { - global $DB; - - $event = ""; - $eventid = $DB->get_record('event', array('modulename' => 'coursework', 'instance' => $coursework->id, 'eventtype' => $eventtype)); - - if ($eventid) { - $event = calendar_event::load($eventid->id); - } - - // Update/create event for coursework deadline [due] - if ($eventtype == 'due') { - $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->deadline); - if ($event) { - $event->update($data); //update if event exists - } else { - calendar_event::create($data); // Create new event as it doesn't exist - } - } - - // Update/create event for coursework initialmarking deadline [initialgradingdue] - if ($eventtype == 'initialgradingdue') { - $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->initialmarkingdeadline); - if ($event) { - $event->update($data); //update if event exists - } else { - calendar_event::create($data); // Create new event as it doesn't exist - } - } - - // Update/create event for coursework agreedgrademarking deadline [agreedgradingdue] - if ($eventtype == 'agreedgradingdue') { - $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->agreedgrademarkingdeadline); - if ($event) { - $event->update($data); //update if event exists - } else { - calendar_event::create($data); // Create new event as it doesn't exist - } - } +function coursework_update_events($coursework, $eventtype) { + global $DB; + + $event = ""; + $eventid = $DB->get_record('event', array('modulename' => 'coursework', 'instance' => $coursework->id, 'eventtype' => $eventtype)); + + if ($eventid) { + $event = calendar_event::load($eventid->id); + } + + // Update/create event for coursework deadline [due] + if ($eventtype == 'due') { + $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->deadline); + if ($event) { + $event->update($data); //update if event exists + } else { + calendar_event::create($data); // Create new event as it doesn't exist + } + } + + // Update/create event for coursework initialmarking deadline [initialgradingdue] + if ($eventtype == 'initialgradingdue') { + $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->initialmarkingdeadline); + if ($event) { + $event->update($data); //update if event exists + } else { + calendar_event::create($data); // Create new event as it doesn't exist + } + } + + // Update/create event for coursework agreedgrademarking deadline [agreedgradingdue] + if ($eventtype == 'agreedgradingdue') { + $data = \mod_coursework\calendar::coursework_event($coursework, $eventtype, $coursework->agreedgrademarkingdeadline); + if ($event) { + $event->update($data); //update if event exists + } else { + calendar_event::create($data); // Create new event as it doesn't exist + } + } } /** @@ -837,7 +837,7 @@ function coursework_extend_settings_navigation(settings_navigation $settings, na function coursework_role_assigned_event_handler($roleassignment) { global $DB; -// return true; // Until we fix the auto allocator. The stuff below causes an infinite loop. + // return true; // Until we fix the auto allocator. The stuff below causes an infinite loop. $courseworkids = coursework_get_coursework_ids_from_context_id($roleassignment->contextid); @@ -992,7 +992,7 @@ function coursework_send_deadline_changed_emails($eventdata) { // No need to send emails if none of the deadlines have changed. - // echo 'Starting to send Coursework deadline changed emails...'; + // echo 'Starting to send Coursework deadline changed emails...'; $counter = 0; $coursework = coursework::find($eventdata->other['courseworkid']); @@ -1074,7 +1074,7 @@ function coursework_send_deadline_changed_emails($eventdata) { message_send($messagedata); } - // echo 'Sent '.$counter.' messages.'; + // echo 'Sent '.$counter.' messages.'; return true; } @@ -1286,39 +1286,39 @@ function course_group_member_removed($event_data) { } } else { // find all individual students in the group - $students = get_enrolled_users($coursework->get_context(), 'mod/coursework:submit', $groupid); - if ($students) { - foreach ($students as $student) { - if (can_delete_allocation($coursework->id(), $student->id)) { - $DB->delete_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id(), 'assessorid' => $removeduserid, 'allocatableid' => $student->id, 'stage_identifier' => 'assessor_1')); - } - } - } else { - continue; - } + $students = get_enrolled_users($coursework->get_context(), 'mod/coursework:submit', $groupid); + if ($students) { + foreach ($students as $student) { + if (can_delete_allocation($coursework->id(), $student->id)) { + $DB->delete_records('coursework_allocation_pairs', array('courseworkid' => $coursework->id(), 'assessorid' => $removeduserid, 'allocatableid' => $student->id, 'stage_identifier' => 'assessor_1')); + } + } + } else { + continue; + } } // check if there are any other assessor in the group, at this point the removed member should no longer be in the group $assessors_in_group = get_enrolled_users($coursework->get_context(), 'mod/coursework:addinitialgrade', $groupid); - if ($assessors_in_group) { // if another assessor found, assign all allocatables in this group to the other assessor - if ($coursework->is_configured_to_have_group_submissions()) {// yes - assign the assessor to a allocatable group - $stage_1->make_auto_allocation_if_necessary(group::find($groupid)); - } else { - $allocatables = $coursework->get_allocatables(); - if ($allocatables) { - // yes - assign this assessor to every allocatable student in the appropriate course group - foreach ($allocatables as $allocatable) { - // process students allocations - $stage_1->make_auto_allocation_if_necessary($allocatable); - } - } else {// no - do nothing, return true - continue; - } - } - } else { - continue; - } + if ($assessors_in_group) { // if another assessor found, assign all allocatables in this group to the other assessor + if ($coursework->is_configured_to_have_group_submissions()) {// yes - assign the assessor to a allocatable group + $stage_1->make_auto_allocation_if_necessary(group::find($groupid)); + } else { + $allocatables = $coursework->get_allocatables(); + if ($allocatables) { + // yes - assign this assessor to every allocatable student in the appropriate course group + foreach ($allocatables as $allocatable) { + // process students allocations + $stage_1->make_auto_allocation_if_necessary($allocatable); + } + } else {// no - do nothing, return true + continue; + } + } + } else { + continue; + } } else if ($student) { if ($coursework->is_configured_to_have_group_submissions()) { // check if student was the only student member in the group @@ -1385,7 +1385,7 @@ function can_delete_allocation($courseworkid, $allocatableid) { * @param $course_module_id * @return string */ - function plagiarism_similarity_information($course_module) { +function plagiarism_similarity_information($course_module) { $html = ''; ob_start(); @@ -1451,7 +1451,7 @@ function coursework_personal_deadline_passed($courseworkid) { WHERE courseworkid = :courseworkid AND personal_deadline < :now"; - return $DB->record_exists_sql($sql, array('courseworkid' => $courseworkid, 'now' => time())); + return $DB->record_exists_sql($sql, array('courseworkid' => $courseworkid, 'now' => time())); } diff --git a/mod_form.php b/mod_form.php index a2caea1b..d584ca28 100644 --- a/mod_form.php +++ b/mod_form.php @@ -69,13 +69,13 @@ public function definition() { $this->add_submission_deadline_field(); $this->add_personal_deadline_field(); - // if (coursework_is_ulcc_digest_coursework_plugin_installed()) { + // if (coursework_is_ulcc_digest_coursework_plugin_installed()) { $this->add_marking_deadline_field(); $this->add_initial_marking_deadline_field(); $this->add_agreed_grade_marking_deadline_field(); $this->add_relative_initial_marking_deadline_field(); $this->add_relative_agreed_grade_marking_deadline_field(); - // } + // } $this->add_allow_early_finalisation_field(); $this->add_allow_late_submissions_field(); @@ -191,11 +191,11 @@ public function validation($data, $files) { $errors = []; - if ($data['startdate'] != 0 && !empty($data['deadline']) && $data['startdate'] > $data['deadline']) { - $errors['startdate'] = get_string('must_be_before_dealdine', 'mod_coursework'); - } + if ($data['startdate'] != 0 && !empty($data['deadline']) && $data['startdate'] > $data['deadline']) { + $errors['startdate'] = get_string('must_be_before_dealdine', 'mod_coursework'); + } - if ($data['individualfeedback'] != 0 && !empty($data['deadline']) && $data['individualfeedback'] < $data['deadline']) { + if ($data['individualfeedback'] != 0 && !empty($data['deadline']) && $data['individualfeedback'] < $data['deadline']) { $errors['individualfeedback'] = get_string('must_be_after_dealdine', 'mod_coursework'); } @@ -262,7 +262,7 @@ function get_data() { } if ($this->forceblindmarking() == 1) { - $data->blindmarking = $CFG->coursework_blindmarking; + $data->blindmarking = $CFG->coursework_blindmarking; } if ($data->numberofmarkers > 1) { @@ -522,7 +522,7 @@ protected function add_agreed_grade_marking_deadline_field() { array('optional' => true, 'disabled' => $disabled) ); - // $moodle_form->disabledIf('agreedgrademarkingdeadline', 'numberofmarkers', 'eq', '1'); + // $moodle_form->disabledIf('agreedgrademarkingdeadline', 'numberofmarkers', 'eq', '1'); if (!empty($CFG->coursework_agreed_marking_deadline)) $moodle_form->setDefault('agreedgrademarkingdeadline', $default_timestamp); $moodle_form->addHelpButton('agreedgrademarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework'); @@ -715,7 +715,7 @@ protected function add_max_file_size_field() { get_string('maximumsize', 'coursework'), $choices); $moodle_form->setDefault('maxbytes', $CFG->coursework_maxbytes); - /* $moodle_form->addElement('static', + /* $moodle_form->addElement('static', 'maxbyteslabel', '', get_string('maximumsizelabel', 'coursework'));*/ @@ -1039,7 +1039,7 @@ protected function add_individual_feedback_release_date_field() { $moodle_form->disabledIf('individualfeedback', 'forceautorelease', 'eq', 1); } $moodle_form->disabledIf('individualfeedback', 'deadline[enabled]', 'notchecked'); -// $moodle_form->addRule(array('individualfeedback', 'deadline'), get_string('must_be_after_dealdine', 'mod_coursework'), 'compare', 'gt'); + // $moodle_form->addRule(array('individualfeedback', 'deadline'), get_string('must_be_after_dealdine', 'mod_coursework'), 'compare', 'gt'); } /** @@ -1112,16 +1112,16 @@ protected function add_tweaks_to_standard_grading_form_elements() { $moodle_form->disabledIf('finalstagegrading', 'feedbackexists', 'eq', 1); // Don't think this belongs here... -// $options = array(0 => get_string('no'), 1 => get_string('yes')); -// $moodle_form->addElement('select', 'automaticagreement', get_string('automaticagreement', 'mod_coursework'), $options); -// $moodle_form->addHelpButton('automaticagreement', 'automaticagreement', 'mod_coursework'); -// $moodle_form->setDefault('automaticagreement',0); -// $moodle_form->disabledIf('automaticagreement', 'numberofmarkers', 'eq', '1'); -// -// $moodle_form->addElement('text', 'automaticagreementrange', get_string('automaticagreementrange', 'mod_coursework'), array('size' => 3)); -// $moodle_form->addHelpButton('automaticagreementrange', 'automaticagreementrange', 'mod_coursework'); -// $moodle_form->setDefault('automaticagreementrange',0); -// $moodle_form->disabledIf('automaticagreementrange', 'automaticagreement', 'eq', '0'); + // $options = array(0 => get_string('no'), 1 => get_string('yes')); + // $moodle_form->addElement('select', 'automaticagreement', get_string('automaticagreement', 'mod_coursework'), $options); + // $moodle_form->addHelpButton('automaticagreement', 'automaticagreement', 'mod_coursework'); + // $moodle_form->setDefault('automaticagreement',0); + // $moodle_form->disabledIf('automaticagreement', 'numberofmarkers', 'eq', '1'); + // + // $moodle_form->addElement('text', 'automaticagreementrange', get_string('automaticagreementrange', 'mod_coursework'), array('size' => 3)); + // $moodle_form->addHelpButton('automaticagreementrange', 'automaticagreementrange', 'mod_coursework'); + // $moodle_form->setDefault('automaticagreementrange',0); + // $moodle_form->disabledIf('automaticagreementrange', 'automaticagreement', 'eq', '0'); } diff --git a/renderers/object_renderer.php b/renderers/object_renderer.php index ae12d656..f7e6f71f 100644 --- a/renderers/object_renderer.php +++ b/renderers/object_renderer.php @@ -791,10 +791,10 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin $comma = ""; - for ($i = 0; $i <= $samplingwidget->get_coursework()->grade; $i++) { - $scale .= $comma.$i; - $comma = ","; - } + for ($i = 0; $i <= $samplingwidget->get_coursework()->grade; $i++) { + $scale .= $comma.$i; + $comma = ","; + } } else { $grade_scale = \grade_scale::fetch(array('id' => abs($samplingwidget->get_coursework()->grade))); $scale = $grade_scale->scale; @@ -1100,7 +1100,7 @@ protected function get_sampling_strategy_form_elements($coursework, $assessor_nu //$fullclasspaths = glob($classdir . '/*.php'); foreach ($sampleplugins as $plugin) { - /* if (strpos($fullclassname, 'base') !== false) { + /* if (strpos($fullclassname, 'base') !== false) { continue; }*/ preg_match('/([^\/]+).php/', $classdir."/".$plugin->rulename.".php", $matches); @@ -1792,22 +1792,22 @@ public function get_submissions_for_assessor($coursework, $submissions) { } else if (is_siteadmin($USER) || !$coursework->allocation_enabled() || has_any_capability(array('mod/coursework:administergrades'), $coursework->get_context())) { - foreach ($submissions as $sub) { - $submission = submission::find($sub); - $gradeblesub[$submission->id] = $submission; - } + foreach ($submissions as $sub) { + $submission = submission::find($sub); + $gradeblesub[$submission->id] = $submission; + } - } else { - foreach ($submissions as $sub) { - $submission = submission::find($sub); - if ($coursework->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) || (has_capability('mod/coursework:addagreedgrade', $coursework->get_context())) - && !empty($submission) && (($submission->all_inital_graded() && !$submission->get_coursework()->sampling_enabled()) - || ($submission->get_coursework()->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1))) { + } else { + foreach ($submissions as $sub) { + $submission = submission::find($sub); + if ($coursework->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) || (has_capability('mod/coursework:addagreedgrade', $coursework->get_context())) + && !empty($submission) && (($submission->all_inital_graded() && !$submission->get_coursework()->sampling_enabled()) + || ($submission->get_coursework()->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1))) { - $gradeblesub[$submission->id] = $submission; - } + $gradeblesub[$submission->id] = $submission; } } + } return $gradeblesub; } diff --git a/settings.php b/settings.php index b6ec8765..996c28b1 100644 --- a/settings.php +++ b/settings.php @@ -169,7 +169,7 @@ get_string('maximum_extension_deadline_desc', 'coursework'), 18, PARAM_INT, 2)); - // Default per page + // Default per page $options = array('3' => '3', '10' => '10', '20' => '20', '30' => '30', '40' => '40', '50' => '50', '100' => '100'); diff --git a/view.php b/view.php index 90805981..af5a7c82 100644 --- a/view.php +++ b/view.php @@ -339,7 +339,7 @@ if ($download_grading_sheet) { - $csv_cells = \mod_coursework\export\grading_sheet::cells_array($coursework); + $csv_cells = \mod_coursework\export\grading_sheet::cells_array($coursework); $timestamp = date('d_m_y @ H-i'); $filename = get_string('gradingsheetfor', 'coursework'). $coursework->name .' '.$timestamp; From 4f2d22c2496c19929ada1c859c99fbe969907c94 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:47:43 +0100 Subject: [PATCH 05/27] CTP-3690 boilerplate comment --- classes/event/assessable_uploaded.php | 1 + classes/forms/upload_allocations_form.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/event/assessable_uploaded.php b/classes/event/assessable_uploaded.php index 7b3a4cc9..fe25b149 100644 --- a/classes/event/assessable_uploaded.php +++ b/classes/event/assessable_uploaded.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * @package mod_coursework * @copyright 2017 University of London Computer Centre {@link ulcc.ac.uk} diff --git a/classes/forms/upload_allocations_form.php b/classes/forms/upload_allocations_form.php index be524829..8b97e771 100644 --- a/classes/forms/upload_allocations_form.php +++ b/classes/forms/upload_allocations_form.php @@ -1,5 +1,4 @@ Date: Tue, 3 Sep 2024 09:51:02 +0100 Subject: [PATCH 06/27] CTP-3690 closing brace line --- classes/allocation/upload.php | 28 +++++++++++++++++++++------- classes/export/import.php | 4 +++- classes/router.php | 3 ++- renderable.php | 3 ++- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/classes/allocation/upload.php b/classes/allocation/upload.php index 3e73df61..625c993a 100644 --- a/classes/allocation/upload.php +++ b/classes/allocation/upload.php @@ -92,13 +92,17 @@ public function validate_csv($content, $encoding, $delimeter) { $cells = $csv_cells; $assessorsinfile = []; - if (count($line) != count($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;} + if (count($line) != count($csv_cells)) { + $errors = get_string('incorrectfileformat', 'coursework'); break; + } foreach ($line as $keynum => $value) { // validate allocatable (user or group) if ($cells[$keynum] == 'allocatable') { // check if allocatable exists in the file - if (empty($value)) {$errors[$s] = get_string($allocatabletype .'namemissing', 'coursework'); break;} + if (empty($value)) { + $errors[$s] = get_string($allocatabletype .'namemissing', 'coursework'); break; + } if ($allocatabletype == 'user') { // get user id @@ -112,9 +116,13 @@ public function validate_csv($content, $encoding, $delimeter) { } // check if allocatable exists in this coursework - if (!$allocatable || !in_array($allocatable->id, $allocatables)) {$errors[$s] = get_string($allocatabletype .'notincoursework', 'coursework'); break;} + if (!$allocatable || !in_array($allocatable->id, $allocatables)) { + $errors[$s] = get_string($allocatabletype .'notincoursework', 'coursework'); break; + } // duplicate user or group - if ($allocatable && in_array($allocatable->id, $allocatablesinfile)) {$errors[$s] = get_string('duplicate'. $allocatabletype, 'coursework'); break;} + if ($allocatable && in_array($allocatable->id, $allocatablesinfile)) { + $errors[$s] = get_string('duplicate'. $allocatabletype, 'coursework'); break; + } $allocatablesinfile[] = $allocatable->id; } @@ -122,11 +130,15 @@ public function validate_csv($content, $encoding, $delimeter) { // in initial stage if (substr($cells[$keynum], 0, 8) == 'assessor') { // skip empty assessors fields - if (empty($value)) { continue;} + if (empty($value)) { + continue; + } $assessor = $DB->get_record('user', array($assessor_identifier => $value)); - if (!$assessor ||!in_array($assessor->id, $assessors)) {$errors[$s] = get_string('assessornotincoursework', 'coursework', $keynum ); continue;} + if (!$assessor ||!in_array($assessor->id, $assessors)) { + $errors[$s] = get_string('assessornotincoursework', 'coursework', $keynum ); continue; + } // check if current assessor is not already allocated for this allocatable in different stage // or is not already in the file in previous stage @@ -200,7 +212,9 @@ public function process_csv($content, $encoding, $delimiter, $processingresults) $cells = $csv_cells; - if (count($line) != count($csv_cells)) {$errors = get_string('incorrectfileformat', 'coursework'); break;} + if (count($line) != count($csv_cells)) { + $errors = get_string('incorrectfileformat', 'coursework'); break; + } foreach ($line as $keynum => $value) { diff --git a/classes/export/import.php b/classes/export/import.php index 437ecad8..b4a162af 100644 --- a/classes/export/import.php +++ b/classes/export/import.php @@ -90,7 +90,9 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) { $submissionid = false; // if the csv headers count is different than expected return error - if ((!$this->coursework->is_using_rubric() && count($line) != count($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($cells, $line))) {$errors = get_string('incorrectfileformat', 'coursework'); break;} + if ((!$this->coursework->is_using_rubric() && count($line) != count($cells)) || ($this->coursework->is_using_rubric() && !$this->rubric_count_correct($cells, $line))) { + $errors = get_string('incorrectfileformat', 'coursework'); break; + } $offset = 0; diff --git a/classes/router.php b/classes/router.php index 8077e876..6ff4682e 100644 --- a/classes/router.php +++ b/classes/router.php @@ -46,7 +46,8 @@ class router { /** * Singleton. */ - private function __construct() {} + private function __construct() { + } /** * Singleton accessor. diff --git a/renderable.php b/renderable.php index 374f2fb2..55b68cab 100644 --- a/renderable.php +++ b/renderable.php @@ -76,7 +76,8 @@ class mod_coursework_assessor_feedback_table extends mod_coursework_renderable { /** * @mixin \mod_coursework\models\coursework */ -class mod_coursework_coursework extends mod_coursework_renderable { } +class mod_coursework_coursework extends mod_coursework_renderable { +} /** * @mixin \mod_coursework\grading_table_row_multi From f956d789f251c6d541017a6094a6b09ae977e996 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:53:33 +0100 Subject: [PATCH 07/27] CTP-3690 operator spacing --- classes/export/import.php | 8 ++++---- classes/forms/assessor_feedback_mform.php | 2 +- .../render_helpers/grading_report/cells/_user_cell.php | 2 +- classes/sample_set_rule/range_sample_type.php | 10 +++++----- mod_form.php | 2 +- renderers/object_renderer.php | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/classes/export/import.php b/classes/export/import.php index b4a162af..c9518b97 100644 --- a/classes/export/import.php +++ b/classes/export/import.php @@ -137,7 +137,7 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) { $result = $cell->validate_cell($rubriclinedata, $submissionid, $stage_identifier, $uploadedgradecells); $z = $z + count($rubricheaders) - 1; - $offset = $offset + count($rubricheaders)-1; + $offset = $offset + count($rubricheaders) - 1; } else { $result = $cell->validate_cell($value, $submissionid, $stage_identifier, $uploadedgradecells); @@ -409,7 +409,7 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces $criteriacount = 0; - $numberofrubrics = count($criterias) * 2; + $numberofrubrics = count($criterias) * 2; // If the stage is final agrade we need to make sure the offset is set to the position of the //agreed grades in the csv, this is needed as some users will only have agreed grade capability @@ -808,13 +808,13 @@ public function remove_other_assessors_grade($csv_cells, &$line) { $criterias = $this->coursework->get_rubric_criteria(); - $startposition = $singlegradeposition+ ((count($criterias) * 2) + 1); + $startposition = $singlegradeposition + ((count($criterias) * 2) + 1); } else { $startposition = array_search('otherassessors', $csv_cells); } - for ($i = $startposition; $i < $startposition+$othercells; $i++) { + for ($i = $startposition; $i < $startposition + $othercells; $i++) { unset($line[$i]); } $csv_cells = array_values($csv_cells); diff --git a/classes/forms/assessor_feedback_mform.php b/classes/forms/assessor_feedback_mform.php index 911c1c16..d27d5f43 100644 --- a/classes/forms/assessor_feedback_mform.php +++ b/classes/forms/assessor_feedback_mform.php @@ -88,7 +88,7 @@ public function definition() { $grademenu = make_grades_menu($coursework->grade); - if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading ==0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) { + if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) { $this->_grading_controller = $coursework->get_advanced_grading_active_controller(); $this->_grading_instance = $this->_grading_controller->get_or_create_instance(0, $feedback->assessorid, $feedback->id); $mform->addElement('grading', 'advancedgrading', get_string('grade', 'mod_coursework'), array('gradinginstance' => $this->_grading_instance)); diff --git a/classes/render_helpers/grading_report/cells/_user_cell.php b/classes/render_helpers/grading_report/cells/_user_cell.php index 213a3428..be96b582 100644 --- a/classes/render_helpers/grading_report/cells/_user_cell.php +++ b/classes/render_helpers/grading_report/cells/_user_cell.php @@ -89,7 +89,7 @@ public function get_table_header($options = []) { $tablename); } else { // otherwise display header without sorting $sort_by_first_name = get_string('firstname'); - $sort_by_last_name =get_string('lastname'); + $sort_by_last_name = get_string('lastname'); } if ($this->fullname_format() == 'lf') { diff --git a/classes/sample_set_rule/range_sample_type.php b/classes/sample_set_rule/range_sample_type.php index bfb5f8f9..b028905c 100644 --- a/classes/sample_set_rule/range_sample_type.php +++ b/classes/sample_set_rule/range_sample_type.php @@ -379,7 +379,7 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample $limit = $this->rationalise($ri->ruletype, $ri->lowerlimit, $ri->upperlimit); // all allocatables that are within specified range based on previous stage - $previous_stage = $stage_number-1; + $previous_stage = $stage_number - 1; $allocatables_in_range = $this->get_allocatables_in_range("assessor_".$previous_stage, $limit[0], $limit[1]); $finalised = $this->finalised_submissions(); @@ -401,8 +401,8 @@ private function rationalise($ruletype, $limit1, $limit2) { $limits = []; - $limits[0] = ($limit1>$limit2) ? $limit2 : $limit1; - $limits[1] = ($limit1>$limit2) ? $limit1 : $limit2; + $limits[0] = ($limit1 > $limit2) ? $limit2 : $limit1; + $limits[1] = ($limit1 > $limit2) ? $limit1 : $limit2; if ($ruletype == 'scale') { ++$limits[0]; @@ -424,8 +424,8 @@ private function rationalise($ruletype, $limit1, $limit2) { $weighting = 100 / $number_of_items; // shall we round it???? - $limits[0] = ceil($limits[0]/$weighting); // element of array - $limits[1] = ceil($limits[1]/$weighting); // element of array + $limits[0] = ceil($limits[0] / $weighting); // element of array + $limits[1] = ceil($limits[1] / $weighting); // element of array // Note we have to add one as the values are not stored in there element positions diff --git a/mod_form.php b/mod_form.php index d584ca28..c832214d 100644 --- a/mod_form.php +++ b/mod_form.php @@ -484,7 +484,7 @@ protected function add_agreed_grade_marking_deadline_field() { $moodle_form =& $this->_form; - $default_timestamp =strtotime('today'); + $default_timestamp = strtotime('today'); $disabled = true; $submission_deadline_timestamp = strtotime('today'); diff --git a/renderers/object_renderer.php b/renderers/object_renderer.php index f7e6f71f..04398a37 100644 --- a/renderers/object_renderer.php +++ b/renderers/object_renderer.php @@ -145,7 +145,7 @@ public function render_feedback(feedback $feedback) { } // Rubric stuff if it's there - if ($coursework->is_using_advanced_grading() && ($coursework->finalstagegrading ==0 || ($coursework->finalstagegrading ==1 && $feedback->stage_identifier != 'final_agreed_1'))) { + if ($coursework->is_using_advanced_grading() && ($coursework->finalstagegrading == 0 || ($coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1'))) { $table_row = new html_table_row(); $left_cell = new html_table_cell(); $right_cell = new html_table_cell(); @@ -1626,7 +1626,7 @@ public function get_allocatables_count_per_assessor($coursework) { if ($coursework->assessor_has_any_allocation_for_student($allocatable) || has_capability('mod/coursework:addagreedgrade', $coursework->get_context()) && !empty($submission) && (($submission->all_inital_graded() && !$coursework->sampling_enabled()) - || ($coursework->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() >1 ))) { + || ($coursework->sampling_enabled() && $submission->all_inital_graded() && $submission->max_number_of_feedbacks() > 1 ))) { $participant ++; } } From 0ea1a67aa9c007a82b93e949906faa9e6bc445c4 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:54:42 +0100 Subject: [PATCH 08/27] CTP-3690 method declaration --- backup/moodle2/backup_coursework_activity_task.class.php | 2 +- backup/moodle2/restore_coursework_activity_task.class.php | 4 ++-- classes/allocation/strategy/base.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backup/moodle2/backup_coursework_activity_task.class.php b/backup/moodle2/backup_coursework_activity_task.class.php index c3654be1..13ecfa76 100644 --- a/backup/moodle2/backup_coursework_activity_task.class.php +++ b/backup/moodle2/backup_coursework_activity_task.class.php @@ -24,7 +24,7 @@ class backup_coursework_activity_task extends backup_activity_task { - static public function encode_content_links($content) { + public static function encode_content_links($content) { global $CFG; $base = preg_quote($CFG->wwwroot, "/"); diff --git a/backup/moodle2/restore_coursework_activity_task.class.php b/backup/moodle2/restore_coursework_activity_task.class.php index ef1f4528..17f4c554 100644 --- a/backup/moodle2/restore_coursework_activity_task.class.php +++ b/backup/moodle2/restore_coursework_activity_task.class.php @@ -32,7 +32,7 @@ class restore_coursework_activity_task extends restore_activity_task { * * @return array of restore_decode_rule */ - static public function define_decode_rules() { + public static function define_decode_rules() { $rules = []; $rules[] = new restore_decode_rule('COURSEWORKBYID', @@ -52,7 +52,7 @@ static public function define_decode_rules() { * * @return array */ - static public function define_decode_contents() { + public static function define_decode_contents() { $contents = []; $contents[] = new restore_decode_content('coursework', array('intro'), 'assign'); diff --git a/classes/allocation/strategy/base.php b/classes/allocation/strategy/base.php index 92210f76..bd162c24 100644 --- a/classes/allocation/strategy/base.php +++ b/classes/allocation/strategy/base.php @@ -138,7 +138,7 @@ abstract public function save_allocation_strategy_options(); * @param bool $reset we cache this stuff, so reset = true will wipe the cache * @return \stdClass[] */ - protected final function get_existing_config_data($type = 'assessor', $reset = false) { + final protected function get_existing_config_data($type = 'assessor', $reset = false) { global $DB; From 6f8377a315add26ad532fad8663137b33c823034 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:03:49 +0100 Subject: [PATCH 09/27] CTP-3690 inline control structures --- classes/allocation/manager.php | 8 +++- .../controllers/submissions_controller.php | 4 +- .../export/csv/cells/agreedfeedback_cell.php | 20 +++++++--- classes/export/csv/cells/agreedgrade_cell.php | 27 +++++++++---- .../csv/cells/assessorfeedback_cell.php | 31 +++++++++++---- .../export/csv/cells/assessorgrade_cell.php | 39 ++++++++++++++----- .../csv/cells/moderationagreement_cell.php | 8 +++- .../export/csv/cells/otherassessors_cell.php | 4 +- classes/export/csv/cells/singlegrade_cell.php | 30 ++++++++++---- classes/export/import.php | 27 +++++++++---- classes/forms/student_submission_form.php | 4 +- classes/forms/upload_feedback_form.php | 12 ++++-- classes/grading_report.php | 12 ++++-- classes/sample_set_rule/range_sample_type.php | 5 ++- classes/sample_set_rule/total_sample_type.php | 28 +++++++++---- classes/stages/base.php | 4 +- mod_form.php | 24 +++++++++--- renderers/object_renderer.php | 8 +++- 18 files changed, 218 insertions(+), 77 deletions(-) diff --git a/classes/allocation/manager.php b/classes/allocation/manager.php index b4dd472f..96adfde9 100644 --- a/classes/allocation/manager.php +++ b/classes/allocation/manager.php @@ -297,7 +297,9 @@ public function auto_generate_sample_set() { // Remove any allocatables that have a status of final agreed as these can not be sampled foreach ($final_agreed_allocatables as $faa) { - if (isset($allocatables[$faa->allocatableid])) unset($allocatables[$faa->allocatableid]); + if (isset($allocatables[$faa->allocatableid])) { + unset($allocatables[$faa->allocatableid]); + } } for ($stage_number = 2; $stage_number <= $this->get_coursework()->get_max_markers(); $stage_number++) { @@ -328,7 +330,9 @@ public function auto_generate_sample_set() { // In both arrays foreach ($auto_with_feedback as $k => $v) { - if (!isset($manual_sample_set[$k])) $manual_sample_set[$k] = $v; + if (!isset($manual_sample_set[$k])) { + $manual_sample_set[$k] = $v; + } } $auto_sample_set = []; diff --git a/classes/controllers/submissions_controller.php b/classes/controllers/submissions_controller.php index 60b73b53..9d9dac90 100644 --- a/classes/controllers/submissions_controller.php +++ b/classes/controllers/submissions_controller.php @@ -176,7 +176,9 @@ protected function create_submission() { foreach ($userids as $u) { $notifyuser = $DB->get_record('user', array('id' => trim($u))); - if (!empty($notifyuser)) $mailer->send_submission_notification($notifyuser); + if (!empty($notifyuser)) { + $mailer->send_submission_notification($notifyuser); + } } } diff --git a/classes/export/csv/cells/agreedfeedback_cell.php b/classes/export/csv/cells/agreedfeedback_cell.php index 05ca1d9c..9e2f3ea1 100644 --- a/classes/export/csv/cells/agreedfeedback_cell.php +++ b/classes/export/csv/cells/agreedfeedback_cell.php @@ -66,13 +66,19 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo $submission = \mod_coursework\models\submission::find($subdbrecord); // Is the submission in question ready to grade? - if (!$submission->all_inital_graded() && !empty($value)) return get_string('submissionnotreadyforagreedgrade', 'coursework'); + if (!$submission->all_inital_graded() && !empty($value)) { + return get_string('submissionnotreadyforagreedgrade', 'coursework'); + } // Has the submission been published if yes then no further grades are allowed - if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text(); + if ($submission->get_state() >= submission::PUBLISHED) { + return $submission->get_status_text(); + } // If you have administer grades you can grade anything - if (has_capability('mod/coursework:administergrades', $PAGE->context)) return true; + if (has_capability('mod/coursework:administergrades', $PAGE->context)) { + return true; + } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( @@ -94,10 +100,14 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo $new_feedback = feedback::build($feedback_params); // This is a new feedback check it against the new ability checks - if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $new_feedback)) return get_string('nopermissiontogradesubmission', 'coursework'); + if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $new_feedback)) { + return get_string('nopermissiontogradesubmission', 'coursework'); + } } else { // This is a new feedback check it against the edit ability checks - if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); + if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) { + return get_string('nopermissiontoeditgrade', 'coursework'); + } } } else { diff --git a/classes/export/csv/cells/agreedgrade_cell.php b/classes/export/csv/cells/agreedgrade_cell.php index 1deae83e..93e9a2a8 100644 --- a/classes/export/csv/cells/agreedgrade_cell.php +++ b/classes/export/csv/cells/agreedgrade_cell.php @@ -80,7 +80,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade'); - if (empty($value)) return true; + if (empty($value)) { + return true; + } if (has_any_capability($agreedgradecap, $PAGE->context) || has_capability('mod/coursework:administergrades', $PAGE->context)) { @@ -146,19 +148,26 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } - if (!empty($errormsg)) return $errormsg; + if (!empty($errormsg)) { + return $errormsg; + } $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); $submission = \mod_coursework\models\submission::find($subdbrecord); // Is the submission in question ready to grade? - if (!$submission->all_inital_graded() && !empty($value) && count($uploadedgradecells) < $submission->max_number_of_feedbacks()) return get_string('submissionnotreadyforagreedgrade', 'coursework'); + if (!$submission->all_inital_graded() && !empty($value) && count($uploadedgradecells) < $submission->max_number_of_feedbacks()) { return get_string('submissionnotreadyforagreedgrade', 'coursework'); + } // Has the submission been published if yes then no further grades are allowed - if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text(); + if ($submission->get_state() >= submission::PUBLISHED) { + return $submission->get_status_text(); + } // If you have administer grades you can grade anything - if (has_capability('mod/coursework:administergrades', $PAGE->context)) return true; + if (has_capability('mod/coursework:administergrades', $PAGE->context)) { + return true; + } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( @@ -181,10 +190,14 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo $new_feedback = feedback::build($feedback_params); // This is a new feedback check it against the new ability checks - if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $new_feedback)) return get_string('nopermissiontogradesubmission', 'coursework'); + if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !has_capability('mod/coursework:addallocatedagreedgrade', $PAGE->context) && !$ability->can('new', $new_feedback)) { + return get_string('nopermissiontogradesubmission', 'coursework'); + } } else { // This is a new feedback check it against the edit ability checks - if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); + if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) { + return get_string('nopermissiontoeditgrade', 'coursework'); + } } } else { diff --git a/classes/export/csv/cells/assessorfeedback_cell.php b/classes/export/csv/cells/assessorfeedback_cell.php index d1be9117..2a424812 100644 --- a/classes/export/csv/cells/assessorfeedback_cell.php +++ b/classes/export/csv/cells/assessorfeedback_cell.php @@ -95,13 +95,19 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo || has_capability('mod/coursework:administergrades', $modulecontext)) { // Is the submission in question ready to grade? - if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde', 'coursework'); + if (!$submission->ready_to_grade()) { + return get_string('submissionnotreadytograde', 'coursework'); + } // Has the submission been published if yes then no further grades are allowed - if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text(); + if ($submission->get_state() >= submission::PUBLISHED) { + return $submission->get_status_text(); + } // If you have administer grades you can grade anything - if (has_capability('mod/coursework:administergrades', $modulecontext)) return true; + if (has_capability('mod/coursework:administergrades', $modulecontext)) { + return true; + } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( @@ -115,19 +121,24 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo //does a feedback exist for this stage if (!empty($feedback)) { // This is a new feedback check it against the new ability checks - if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$ability->can('new', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); + if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$ability->can('new', $feedback)) { + return get_string('nopermissiontoeditgrade', 'coursework'); + } } else { // This is a new feedback check it against the edit ability checks - if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); + if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$ability->can('edit', $feedback)) { + return get_string('nopermissiontoeditgrade', 'coursework'); + } } if (!$this->coursework->allocation_enabled() && !empty($feedback)) { // Was this user the one who last graded this submission if not then user cannot grade - if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $modulecontext) ) + if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $modulecontext) ) { return get_string('nopermissiontogradesubmission', 'coursework'); + } } @@ -141,7 +152,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo ); if (!has_capability('mod/coursework:administergrades', $modulecontext) - && !$DB->get_record('coursework_allocation_pairs', $allocation_params)) return get_string('nopermissiontogradesubmission', 'coursework'); + && !$DB->get_record('coursework_allocation_pairs', $allocation_params)) { + return get_string('nopermissiontogradesubmission', 'coursework'); + } } // Check for coursework without allocations - with/without samplings @@ -159,7 +172,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo // Check how many assessors for this coursework $assessors = $this->coursework->get_max_markers(); } - if ($assessors == $feedbacks) return get_string('gradealreadyexists', 'coursework'); + if ($assessors == $feedbacks) { + return get_string('gradealreadyexists', 'coursework'); + } } } else if (has_any_capability($agreedgradecap, $modulecontext)) { diff --git a/classes/export/csv/cells/assessorgrade_cell.php b/classes/export/csv/cells/assessorgrade_cell.php index ef991bbb..ae30eb1b 100644 --- a/classes/export/csv/cells/assessorgrade_cell.php +++ b/classes/export/csv/cells/assessorgrade_cell.php @@ -106,7 +106,9 @@ public function get_header($stage) { public function validate_cell($value, $submissionid, $stage_identifier='', $uploadedgradecells = []) { global $DB, $PAGE, $USER; - if (empty($value)) return true; + if (empty($value)) { + return true; + } $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade'); $initialgradecap = array('mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade'); @@ -172,16 +174,24 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } - if (!empty($errormsg)) return $errormsg; + if (!empty($errormsg)) { + return $errormsg; + } // Is the submission in question ready to grade? - if (!$submission->ready_to_grade()) return get_string('submissionnotreadytograde', 'coursework'); + if (!$submission->ready_to_grade()) { + return get_string('submissionnotreadytograde', 'coursework'); + } // Has the submission been published if yes then no further grades are allowed - if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text(); + if ($submission->get_state() >= submission::PUBLISHED) { + return $submission->get_status_text(); + } // If you have administer grades you can grade anything - if (has_capability('mod/coursework:administergrades', $PAGE->context)) return true; + if (has_capability('mod/coursework:administergrades', $PAGE->context)) { + return true; + } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( @@ -195,19 +205,24 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo //does a feedback exist for this stage if (!empty($feedback)) { // This is a new feedback check it against the new ability checks - if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('new', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); + if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('new', $feedback)) { + return get_string('nopermissiontoeditgrade', 'coursework'); + } } else { // This is a new feedback check it against the edit ability checks - if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); + if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$ability->can('edit', $feedback)) { + return get_string('nopermissiontoeditgrade', 'coursework'); + } } if (!$this->coursework->allocation_enabled() && !empty($feedback)) { // Was this user the one who last graded this submission if not then user cannot grade - if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context)) + if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context)) { return get_string('nopermissiontogradesubmission', 'coursework'); + } } @@ -222,7 +237,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$DB->get_record('coursework_allocation_pairs', $allocation_params) - ) return get_string('nopermissiontogradesubmission', 'coursework'); + ) { + return get_string('nopermissiontogradesubmission', 'coursework'); + } } // Check for coursework without allocations - with/without samplings @@ -241,7 +258,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo // Check how many assessors for this coursework $assessors = $this->coursework->get_max_markers(); } - if ($assessors == $feedbacks) return get_string('gradealreadyexists', 'coursework'); + if ($assessors == $feedbacks) { + return get_string('gradealreadyexists', 'coursework'); + } } } else if (has_any_capability($agreedgradecap, $PAGE->context)) { diff --git a/classes/export/csv/cells/moderationagreement_cell.php b/classes/export/csv/cells/moderationagreement_cell.php index 12795ed6..421606f9 100644 --- a/classes/export/csv/cells/moderationagreement_cell.php +++ b/classes/export/csv/cells/moderationagreement_cell.php @@ -53,9 +53,13 @@ public function get_cell($submission, $student, $stage_identifier) { } } $feedback = $submission->get_assessor_feedback_by_stage('assessor_1'); - if ($feedback) $moderation = moderation::find(array('feedbackid' => $feedback->id)); + if ($feedback) { + $moderation = moderation::find(array('feedbackid' => $feedback->id)); + } - if ($moderation) $moderation_agreement = $moderation->get_moderator_agreement($feedback); + if ($moderation) { + $moderation_agreement = $moderation->get_moderator_agreement($feedback); + } if ($moderation_agreement) { $data[] = $moderation_agreement->agreement; diff --git a/classes/export/csv/cells/otherassessors_cell.php b/classes/export/csv/cells/otherassessors_cell.php index 5b6bffda..3e946a3f 100644 --- a/classes/export/csv/cells/otherassessors_cell.php +++ b/classes/export/csv/cells/otherassessors_cell.php @@ -66,7 +66,9 @@ public function get_cell($submission, $student, $stage_identifier) { if ($grade) { // skip if you are allocated but someone else graded it $allocation = $submission->get_assessor_allocation_by_stage($feedback->stage_identifier); - if ($allocation && $allocation->assessorid == $USER->id) continue; + if ($allocation && $allocation->assessorid == $USER->id) { + continue; + } $ability = new ability(user::find($USER), $this->coursework); if ((($ability->can('show', $feedback) || has_capability('mod/coursework:addallocatedagreedgrade', $submission->get_coursework()->get_context())) && (!$submission->any_editable_feedback_exists() && count($submission->get_assessor_feedbacks()) <= $submission->max_number_of_feedbacks())) || is_siteadmin($USER->id)) { diff --git a/classes/export/csv/cells/singlegrade_cell.php b/classes/export/csv/cells/singlegrade_cell.php index d56da8f4..f6837623 100644 --- a/classes/export/csv/cells/singlegrade_cell.php +++ b/classes/export/csv/cells/singlegrade_cell.php @@ -133,24 +133,33 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } - if (!empty($errormsg)) return $errormsg; + if (!empty($errormsg)) { + return $errormsg; + } $dbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); $submission = \mod_coursework\models\submission::find($dbrecord); // Is this submission ready to be graded - if (!$submission->ready_to_grade() && $submission->get_state() < \mod_coursework\models\submission::FULLY_GRADED) return get_string('submissionnotreadytograde', 'coursework'); + if (!$submission->ready_to_grade() && $submission->get_state() < \mod_coursework\models\submission::FULLY_GRADED) { + return get_string('submissionnotreadytograde', 'coursework'); + } // If you have administer grades you can grade anything - if (has_capability('mod/coursework:administergrades', $PAGE->context)) return true; + if (has_capability('mod/coursework:administergrades', $PAGE->context)) { + return true; + } // Is the current user an assessor at any of this submissions grading stages or do they have administer grades - if ($this->coursework->allocation_enabled() && !$this->coursework->is_assessor($USER) && !has_capability('mod/coursework:administergrades', $PAGE->context)) + if ($this->coursework->allocation_enabled() && !$this->coursework->is_assessor($USER) && !has_capability('mod/coursework:administergrades', $PAGE->context)) { return get_string('nopermissiontogradesubmission', 'coursework'); + } // Has the submission been published if yes then no further grades are allowed - if ($submission->get_state() >= submission::PUBLISHED) return $submission->get_status_text(); + if ($submission->get_state() >= submission::PUBLISHED) { + return $submission->get_status_text(); + } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). $feedback_params = array( @@ -161,8 +170,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo if (!$this->coursework->allocation_enabled() && !empty($feedback)) { // Was this user the one who last graded this submission if not then user cannot grade - if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context) && !has_capability('mod/coursework:administergrades', $PAGE->context)) + if ($feedback->assessorid != $USER->id || !has_capability('mod/coursework:editinitialgrade', $PAGE->context) && !has_capability('mod/coursework:administergrades', $PAGE->context)) { return get_string('nopermissiontoeditgrade', 'coursework'); + } } @@ -187,10 +197,14 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo $new_feedback = feedback::build($feedback_params); // This is a new feedback check it against the new ability checks - if (!$ability->can('new', $new_feedback)) return get_string('nopermissiontogradesubmission', 'coursework'); + if (!$ability->can('new', $new_feedback)) { + return get_string('nopermissiontogradesubmission', 'coursework'); + } } else { // This is a new feedback check it against the edit ability checks - if (!$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); + if (!$ability->can('edit', $feedback)) { + return get_string('nopermissiontoeditgrade', 'coursework'); + } } } else { diff --git a/classes/export/import.php b/classes/export/import.php index c9518b97..f2836c42 100644 --- a/classes/export/import.php +++ b/classes/export/import.php @@ -117,7 +117,9 @@ public function validate_csv($content, $encoding, $delimeter, $csv_cells) { $submissionid = $value; } - if (empty($submissionid)) $errors[$s][] = get_string('emptysubmissionid', 'coursework'); + if (empty($submissionid)) { + $errors[$s][] = get_string('emptysubmissionid', 'coursework'); + } // Offsets the position of that we extract the data from $line based on data that has been extracted before @@ -166,7 +168,8 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) { $types = array("singlegrade", "assessorgrade"); - if ($this->coursework->finalstagegrading == 0 ) $types[] = "agreedgrade"; + if ($this->coursework->finalstagegrading == 0 ) { $types[] = "agreedgrade"; + } foreach ($types as $type) { @@ -181,7 +184,9 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) { if (strpos($ch, $type) !== false) { - if (empty($typepositions)) $typepositions = []; + if (empty($typepositions)) { + $typepositions = []; + } $typefound = true; $typepositions[] = $i; @@ -323,7 +328,9 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces } // Save the value into the csvline with the relevant pointer - if (isset($cells[$i])) $csvline[$cells[$i]] = $value; + if (isset($cells[$i])) { + $csvline[$cells[$i]] = $value; + } $i++; } @@ -367,7 +374,9 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces // When allocation is enabled if (has_capability('mod/coursework:administergrades', $PAGE->context) && $coursework->allocation_enabled() && $stage != 'final_agreed_1' && $coursework->has_multiple_markers() == true) { $rubricoffset += 1; - if ($a == 1) $rubricoffsetstart += 1; + if ($a == 1) { + $rubricoffsetstart += 1; + } } // check for initial grade capability otherwise ignore it if ($stage != 'final_agreed_1' && (!has_capability('mod/coursework:addinitialgrade', $PAGE->context)) && @@ -420,7 +429,9 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); - if ($coursework->allocation_enabled()) $rubricoffset += 1; + if ($coursework->allocation_enabled()) { + $rubricoffset += 1; + } $rubricdata = array_slice($line, $rubricoffset, $numberofrubrics); $feedbackdata = array_slice($line, $rubricoffset + $numberofrubrics, 1); @@ -486,7 +497,9 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces $rubricoffset = $rubricoffsetstart + $stagemultiplier + ($numberofrubrics * $stagemultiplier); - if ($coursework->allocation_enabled()) $rubricoffset += 1; + if ($coursework->allocation_enabled()) { + $rubricoffset += 1; + } $gradearrvalue = array_slice($line, $rubricoffset, 2); diff --git a/classes/forms/student_submission_form.php b/classes/forms/student_submission_form.php index 3c4695ac..ea366b41 100644 --- a/classes/forms/student_submission_form.php +++ b/classes/forms/student_submission_form.php @@ -182,7 +182,9 @@ public function handle() { $notifyuser = $DB->get_record('user', array('id' => trim($u))); $mailer = new mailer($coursework); - if (!empty($notifyuser)) $mailer->send_submission_notification($notifyuser); + if (!empty($notifyuser)) { + $mailer->send_submission_notification($notifyuser); + } } } diff --git a/classes/forms/upload_feedback_form.php b/classes/forms/upload_feedback_form.php index 7f49a791..eb8b410c 100644 --- a/classes/forms/upload_feedback_form.php +++ b/classes/forms/upload_feedback_form.php @@ -55,12 +55,18 @@ function definition() { } else if (has_capability('mod/coursework:administergrades', $this->coursework->get_context())) { $options['assessor_1'] = get_string('assessorupload', 'coursework', '1'); - if ($this->coursework->get_max_markers() >= 2) $options['assessor_2'] = get_string('assessorupload', 'coursework', '2'); - if ($this->coursework->get_max_markers() >= 3) $options['assessor_3'] = get_string('assessorupload', 'coursework', '3'); + if ($this->coursework->get_max_markers() >= 2) { + $options['assessor_2'] = get_string('assessorupload', 'coursework', '2'); + } + if ($this->coursework->get_max_markers() >= 3) { + $options['assessor_3'] = get_string('assessorupload', 'coursework', '3'); + } } $capability = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', 'mod/coursework:administergrades'); - if (has_any_capability($capability, $this->coursework->get_context())) $options['final_agreed_1'] = get_string('finalagreed', 'coursework'); + if (has_any_capability($capability, $this->coursework->get_context())) { + $options['final_agreed_1'] = get_string('finalagreed', 'coursework'); + } $mform->addElement('select', 'feedbackstage', get_string('feedbackstage', 'coursework'), $options); } else { diff --git a/classes/grading_report.php b/classes/grading_report.php index b806f21b..b98c7351 100644 --- a/classes/grading_report.php +++ b/classes/grading_report.php @@ -362,9 +362,13 @@ public function get_table_rows_for_page($rowcount = false) { // handle 'Group mode' - unset groups/individuals thaat are not in the chosen group if (!empty($options['group']) && $options['group'] != -1) { if ($this->coursework->is_configured_to_have_group_submissions()) { - if ($options['group'] != $participant->id) continue; + if ($options['group'] != $participant->id) { + continue; + } } else { - if (!$this->coursework->student_in_group($participant->id, $options['group']))continue; + if (!$this->coursework->student_in_group($participant->id, $options['group'])) { + continue; + } } } @@ -383,7 +387,9 @@ public function get_table_rows_for_page($rowcount = false) { $rows[$participant->id()] = $row; $participantsfound++; - if (!empty($rowcount) && $participantsfound >= $rowcount) break; + if (!empty($rowcount) && $participantsfound >= $rowcount) { + break; + } } diff --git a/classes/sample_set_rule/range_sample_type.php b/classes/sample_set_rule/range_sample_type.php index b028905c..359e41a9 100644 --- a/classes/sample_set_rule/range_sample_type.php +++ b/classes/sample_set_rule/range_sample_type.php @@ -388,8 +388,9 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample foreach ($allocatables_in_range as $awf) { if (!isset($published[$awf->allocatableid]) && !isset($finalised[$awf->allocatableid]) && !isset($auto_sample_set[$awf->allocatableid]) && !isset($manual_sample_set[$awf->allocatableid]) - && isset($allocatables[$awf->allocatableid])) - $auto_sample_set[$awf->allocatableid] = $allocatables[$awf->allocatableid]; + && isset($allocatables[$awf->allocatableid])) { + $auto_sample_set[$awf->allocatableid] = $allocatables[$awf->allocatableid]; + } } } diff --git a/classes/sample_set_rule/total_sample_type.php b/classes/sample_set_rule/total_sample_type.php index 38bb27a4..504cf4aa 100644 --- a/classes/sample_set_rule/total_sample_type.php +++ b/classes/sample_set_rule/total_sample_type.php @@ -136,7 +136,9 @@ function save_form_data($assessor_number=0, &$order=0) { } static function compare_key($a, $b) { - if ($a === $b) return 0; + if ($a === $b) { + return 0; + } return ($a > $b) ? 1 : -1; } @@ -173,7 +175,9 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample if ($total_to_return > 0) { //use array chunk to split auto sample set into chunks we will only use the first chunk - if ($chunked_array = array_chunk($auto_sample_set, $total_to_return, true)) $auto_sample_set = $chunked_array[0]; + if ($chunked_array = array_chunk($auto_sample_set, $total_to_return, true)) { + $auto_sample_set = $chunked_array[0]; + } // If the number in the sample set is less than the total to return if (count($auto_sample_set) < $total_to_return) { @@ -191,10 +195,13 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample foreach ($allocatables_feedback as $af) { if (!isset($published[$af->allocatableid]) && !isset($finalised[$af->allocatableid]) - && !isset($auto_sample_set[$af->allocatableid]) && !isset($manual_sample_set[$af->allocatableid])) - $auto_sample_set[$af->allocatableid] = $allocatables[$af->allocatableid]; + && !isset($auto_sample_set[$af->allocatableid]) && !isset($manual_sample_set[$af->allocatableid])) { + $auto_sample_set[$af->allocatableid] = $allocatables[$af->allocatableid]; + } - if (count($auto_sample_set) == $total_to_return) break; + if (count($auto_sample_set) == $total_to_return) { + break; + } } } @@ -216,17 +223,22 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample $array_keys = array_rand($allocatable_sample_set, $total_to_return - count($auto_sample_set)); - if (!is_array($array_keys)) $array_keys = array($array_keys); + if (!is_array($array_keys)) { + $array_keys = array($array_keys); + } //use the allocatables array to get other ungraded allocatables foreach ($array_keys as $id) { if (!isset($published[$id]) && !isset($finalised[$id]) && !isset($auto_sample_set[$id]) && !isset($manual_sample_set[$id]) - ) + ) { $auto_sample_set[$id] = $allocatables[$id]; + } - if (count($auto_sample_set) == $total_to_return) break; + if (count($auto_sample_set) == $total_to_return) { + break; + } } } diff --git a/classes/stages/base.php b/classes/stages/base.php index c867db19..c4feae45 100644 --- a/classes/stages/base.php +++ b/classes/stages/base.php @@ -910,7 +910,9 @@ private function in_editable_period($allocatable) { $result = $this->get_coursework()->get_grade_editing_time(); // The feedback is not in the editable period if the editable setting is disabled - if (empty($this->get_coursework()->get_grade_editing_time())) return false; + if (empty($this->get_coursework()->get_grade_editing_time())) { + return false; + } $coursework_id = $this->get_coursework_id(); submission::fill_pool_coursework($coursework_id); diff --git a/mod_form.php b/mod_form.php index c832214d..3105a05a 100644 --- a/mod_form.php +++ b/mod_form.php @@ -355,7 +355,9 @@ protected function add_submission_deadline_field() { $moodle_form->addElement('html', get_string('submissionsdeadlineinfo', 'mod_coursework')); $moodle_form->addElement('html', ''); - if (!empty($CFG->coursework_submission_deadline)) $moodle_form->setDefault('deadline', $default_timestamp); + if (!empty($CFG->coursework_submission_deadline)) { + $moodle_form->setDefault('deadline', $default_timestamp); + } $moodle_form->addHelpButton('deadline', 'deadline', 'mod_coursework'); } @@ -406,7 +408,9 @@ protected function add_start_date_field() { array('optional' => true, 'disabled' => $disabled) ); - if (!empty($CFG->coursework_start_date)) $moodle_form->setDefault('startdate', $default_timestamp); + if (!empty($CFG->coursework_start_date)) { + $moodle_form->setDefault('startdate', $default_timestamp); + } $moodle_form->addHelpButton('startdate', 'startdate', 'mod_coursework'); } @@ -471,7 +475,9 @@ protected function add_initial_marking_deadline_field() { array('optional' => true, 'disabled' => $disabled) ); - if (!empty($CFG->coursework_marking_deadline)) $moodle_form->setDefault('initialmarkingdeadline', $default_timestamp); + if (!empty($CFG->coursework_marking_deadline)) { + $moodle_form->setDefault('initialmarkingdeadline', $default_timestamp); + } $moodle_form->addHelpButton('initialmarkingdeadline', 'initialmarkingdeadline', 'mod_coursework'); } @@ -524,7 +530,9 @@ protected function add_agreed_grade_marking_deadline_field() { // $moodle_form->disabledIf('agreedgrademarkingdeadline', 'numberofmarkers', 'eq', '1'); - if (!empty($CFG->coursework_agreed_marking_deadline)) $moodle_form->setDefault('agreedgrademarkingdeadline', $default_timestamp); + if (!empty($CFG->coursework_agreed_marking_deadline)) { + $moodle_form->setDefault('agreedgrademarkingdeadline', $default_timestamp); + } $moodle_form->addHelpButton('agreedgrademarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework'); } @@ -548,7 +556,9 @@ protected function add_relative_initial_marking_deadline_field() { 'relativeinitialmarkingdeadline', get_string('relativeinitialmarkingdeadline', 'mod_coursework'), $options); - if (!empty($CFG->coursework_marking_deadline)) $moodle_form->setDefault('relativeinitialmarkingdeadline', $CFG->coursework_marking_deadline); + if (!empty($CFG->coursework_marking_deadline)) { + $moodle_form->setDefault('relativeinitialmarkingdeadline', $CFG->coursework_marking_deadline); + } $moodle_form->addHelpButton('relativeinitialmarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework'); } @@ -573,7 +583,9 @@ protected function add_relative_agreed_grade_marking_deadline_field() { 'relativeagreedmarkingdeadline', get_string('relativeagreedmarkingdeadline', 'mod_coursework'), $options); - if (!empty($CFG->coursework_agreed_marking_deadline)) $moodle_form->setDefault('relativeagreedmarkingdeadline', $CFG->coursework_agreed_marking_deadline); + if (!empty($CFG->coursework_agreed_marking_deadline)) { + $moodle_form->setDefault('relativeagreedmarkingdeadline', $CFG->coursework_agreed_marking_deadline); + } $moodle_form->addHelpButton('relativeagreedmarkingdeadline', 'agreedgrademarkingdeadline', 'mod_coursework'); } diff --git a/renderers/object_renderer.php b/renderers/object_renderer.php index 04398a37..b0c613a4 100644 --- a/renderers/object_renderer.php +++ b/renderers/object_renderer.php @@ -839,7 +839,9 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin $sampling_cell .= html_writer::end_tag('div'); - if ($i == $samplingwidget->get_coursework()->get_max_markers()) $javascript = true; + if ($i == $samplingwidget->get_coursework()->get_max_markers()) { + $javascript = true; + } $graderules = @@ -1111,7 +1113,9 @@ protected function get_sampling_strategy_form_elements($coursework, $assessor_nu $html .= $sampling_rule->add_form_elements($assessor_number); - if ($load_javascript) $javascript .= $sampling_rule->add_form_elements_js($assessor_number); + if ($load_javascript) { + $javascript .= $sampling_rule->add_form_elements_js($assessor_number); + } } From abc31fddc92f341f7ce0981b75ff19b39ddfc98d Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:25:09 +0100 Subject: [PATCH 10/27] CTP-3690 object op spacing --- classes/forms/moderator_agreement_mform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/forms/moderator_agreement_mform.php b/classes/forms/moderator_agreement_mform.php index 9cc67b75..517b4cdc 100644 --- a/classes/forms/moderator_agreement_mform.php +++ b/classes/forms/moderator_agreement_mform.php @@ -60,7 +60,7 @@ public function definition() { */ $moderation = $this->_customdata['moderation']; $feedback = $moderation->get_feedback(); - $coursework = $moderation-> get_coursework(); + $coursework = $moderation->get_coursework(); $mform->addElement('hidden', 'submissionid', $moderation->get_submission()->id); $mform->setType('submissionid', PARAM_INT); From 41bc0493784da8bd0fdd7d9a4bd3cf5872ed946f Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:25:55 +0100 Subject: [PATCH 11/27] CTP-3690 ret type spacing --- classes/privacy/provider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 5680ed20..6f08e3c6 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -47,7 +47,7 @@ class provider implements * @param collection $collection A collection of meta data items to be added to. * @return collection Returns the collection of metadata. */ - public static function get_metadata(collection $collection) : collection { + public static function get_metadata(collection $collection): collection { $feedbacks = [ 'assessorid' => 'privacy:metadata:assessorid', 'timecreated' => 'privacy:metadata:timecreated', @@ -181,7 +181,7 @@ public static function get_users_in_context(userlist $userlist) { * @param int $userid The user ID. * @return contextlist an object with the contexts related to a userid. */ - public static function get_contexts_for_userid(int $userid) : contextlist { + public static function get_contexts_for_userid(int $userid): contextlist { $params = [ 'modulename' => 'coursework', 'contextlevel' => CONTEXT_MODULE, From 9b70fda7b58d8ebbfe51648b2076bf5d60b87249 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:26:33 +0100 Subject: [PATCH 12/27] CTP-3690 doc comment align --- classes/models/moderation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/models/moderation.php b/classes/models/moderation.php index db962a11..9784edb6 100644 --- a/classes/models/moderation.php +++ b/classes/models/moderation.php @@ -51,8 +51,8 @@ class moderation extends table_base { public $feedbackid; /** - * @var int - */ + * @var int + */ public $moderatorid; /** From 3b1b2b1d010e453bc6a3e5e4b864984110eaa579 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:27:36 +0100 Subject: [PATCH 13/27] CTP-3690 space after comma --- backup/moodle2/restore_coursework_stepslib.php | 4 ++-- .../grading_report/cells/personal_deadline_cell.php | 2 +- .../grading_report/cells/time_submitted_cell.php | 2 +- db/upgrade.php | 4 ++-- renderers/grading_report_renderer.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backup/moodle2/restore_coursework_stepslib.php b/backup/moodle2/restore_coursework_stepslib.php index 4413c35a..14e9bf56 100644 --- a/backup/moodle2/restore_coursework_stepslib.php +++ b/backup/moodle2/restore_coursework_stepslib.php @@ -30,7 +30,7 @@ static function cheaplog($thing, $append = true) { $append = FILE_APPEND; } - file_put_contents('/tmp/cheap.log',print_r($thing, true)."\n---------------\n", $append); + file_put_contents('/tmp/cheap.log', print_r($thing, true)."\n---------------\n", $append); } /** @@ -101,7 +101,7 @@ protected function process_coursework_submission($data) { 'timecreated', 'timesubmitted', 'firstpublished', - 'lastpublished',), $data); + 'lastpublished', ), $data); $now = time(); $this->set_defaults(array('timecreated' => $now, diff --git a/classes/render_helpers/grading_report/cells/personal_deadline_cell.php b/classes/render_helpers/grading_report/cells/personal_deadline_cell.php index 1b0d75c2..79cd4f59 100644 --- a/classes/render_helpers/grading_report/cells/personal_deadline_cell.php +++ b/classes/render_helpers/grading_report/cells/personal_deadline_cell.php @@ -71,7 +71,7 @@ public function get_table_cell($row_object) { $content .= $OUTPUT->action_icon($link, $icon, null, - array('class' => $class,'data-get' => json_encode($new_personal_deadline_params), 'data-time' => date('d-m-Y H:i', $deadline) )); + array('class' => $class, 'data-get' => json_encode($new_personal_deadline_params), 'data-time' => date('d-m-Y H:i', $deadline) )); $content .= ''; return $this->get_new_cell_with_order_data(['display' => $content, '@data-order' => $deadline]); diff --git a/classes/render_helpers/grading_report/cells/time_submitted_cell.php b/classes/render_helpers/grading_report/cells/time_submitted_cell.php index 338c7a26..f5164db4 100644 --- a/classes/render_helpers/grading_report/cells/time_submitted_cell.php +++ b/classes/render_helpers/grading_report/cells/time_submitted_cell.php @@ -74,7 +74,7 @@ public function prepare_content_cell($row_object) { $time_submitted = $submission->time_submitted(); - $content .= userdate($time_submitted,'%a, %d %b %Y, %H:%M'); + $content .= userdate($time_submitted, '%a, %d %b %Y, %H:%M'); $content .= html_writer::empty_tag('br'); if ($submission->is_late() && (!$submission->has_extension() || !$submission->submitted_within_extension())) { diff --git a/db/upgrade.php b/db/upgrade.php index b41f65c1..21f30601 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -2458,7 +2458,7 @@ function xmldb_coursework_upgrade($oldversion) { $table->add_field('submissionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null); $table->add_field('status', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); $table->add_field('comment', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('comment_format',XMLDB_TYPE_INTEGER, '2', null, null, null, null); + $table->add_field('comment_format', XMLDB_TYPE_INTEGER, '2', null, null, null, null); $table->add_field('createdby', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('lastmodifiedby', XMLDB_TYPE_INTEGER, '10', null, false, null, null); @@ -2481,7 +2481,7 @@ function xmldb_coursework_upgrade($oldversion) { // Define table coursework_plagiarism_flag to be created. $table = new xmldb_table('coursework'); - $field = $table->add_field('renamefiles',XMLDB_TYPE_INTEGER, '1', null, null, null, null); + $field = $table->add_field('renamefiles', XMLDB_TYPE_INTEGER, '1', null, null, null, null); // Conditionally launch add field. if (!$dbman->field_exists($table, $field)) { diff --git a/renderers/grading_report_renderer.php b/renderers/grading_report_renderer.php index ea532009..b37197aa 100644 --- a/renderers/grading_report_renderer.php +++ b/renderers/grading_report_renderer.php @@ -70,7 +70,7 @@ public function render_grading_report($grading_report, $is_multiple_markers) { $table_html .= $this->make_table_headers($cell_helpers, $options, $is_multiple_markers); $table_html .= ''; $table_html .= ''; - $table_html .= $this->make_rows($tablerows, $cell_helpers, $sub_row_helper, $is_multiple_markers,); + $table_html .= $this->make_rows($tablerows, $cell_helpers, $sub_row_helper, $is_multiple_markers, ); $table_html .= ''; $table_html .= $this->end_table(); From ce2ee6d8d7c2b69b6fa839777aea0b99991c99d9 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:28:09 +0100 Subject: [PATCH 14/27] CTP-3690 for loop spacing --- classes/sample_set_rule/range_sample_type.php | 4 ++-- classes/sample_set_rule/total_sample_type.php | 2 +- renderers/object_renderer.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/sample_set_rule/range_sample_type.php b/classes/sample_set_rule/range_sample_type.php index 359e41a9..890d8bef 100644 --- a/classes/sample_set_rule/range_sample_type.php +++ b/classes/sample_set_rule/range_sample_type.php @@ -88,14 +88,14 @@ public function range_elements($assessor_number, $sequence, $dbrecord=false) { $percentage_options = []; - for ($i = 0;$i < 110; $i = $i + 10) { + for ($i = 0; $i < 110; $i = $i + 10) { $percentage_options[$i] = "{$i}"; } $scale = []; if ($this->coursework->grade > 0) { - for ($i = 0;$i <= $this->coursework->grade; $i++) { + for ($i = 0; $i <= $this->coursework->grade; $i++) { $scale[] = $i; } } else { diff --git a/classes/sample_set_rule/total_sample_type.php b/classes/sample_set_rule/total_sample_type.php index 504cf4aa..36c965c1 100644 --- a/classes/sample_set_rule/total_sample_type.php +++ b/classes/sample_set_rule/total_sample_type.php @@ -66,7 +66,7 @@ public function add_form_elements($assessor_number=0) { $percentage_options = []; - for ($i = 5;$i <= 100; $i = $i + 5) { + for ($i = 5; $i <= 100; $i = $i + 5) { $percentage_options[$i] = "{$i}"; } diff --git a/renderers/object_renderer.php b/renderers/object_renderer.php index b0c613a4..4bcf74be 100644 --- a/renderers/object_renderer.php +++ b/renderers/object_renderer.php @@ -812,7 +812,7 @@ public function render_mod_coursework_sampling_set_widget(mod_coursework_samplin $percentage_options = []; - for ($i = 0;$i < 110; $i = $i + 10) { + for ($i = 0; $i < 110; $i = $i + 10) { $percentage_options[$i] = "{$i}%"; } @@ -907,7 +907,7 @@ private function sampling_strategy_column($samplingwidget, $suffix = '') { $percentage_options = []; - for ($i = 0;$i < 110; $i = $i + 10) { + for ($i = 0; $i < 110; $i = $i + 10) { $percentage_options[$i] = "{$i}%"; } From 91c19a2ce4162316031db0c2bff2446977a40c6f Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:29:24 +0100 Subject: [PATCH 15/27] CTP-3690 obj op spacing --- classes/ability.php | 8 ++++---- classes/export/grading_sheet.php | 2 +- .../grading_report/cells/moderation_agreement_cell.php | 6 +++--- .../grading_report/cells/multiple_agreed_grade_cell.php | 4 ++-- .../cells/single_assessor_feedback_cell.php | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/classes/ability.php b/classes/ability.php index 681e8a98..29c5261d 100644 --- a/classes/ability.php +++ b/classes/ability.php @@ -668,7 +668,7 @@ protected function allow_edit_moderation_if_user_created_moderation_and_can_edit 'mod_coursework\models\moderation', function (moderation $moderation) { $has_capability = has_capability('mod/coursework:moderate', $moderation->get_coursework() - ->get_context()); + ->get_context()); $is_creator = $moderation->moderatorid == $this->get_user()->id; return $has_capability && ($is_creator || is_siteadmin()); }); @@ -1066,11 +1066,11 @@ function (grading_table_row_base $grading_table_row) { ->get_context()); if ($grading_table_row->get_coursework() - ->allocation_enabled() && $grading_table_row->has_submission() + ->allocation_enabled() && $grading_table_row->has_submission() ) { $submission_has_all_initial_assessor_feedbacks = $grading_table_row->get_submission() - ->get_state() >= submission::FULLY_GRADED; + ->get_state() >= submission::FULLY_GRADED; if ($can_add_agreed_grade && $submission_has_all_initial_assessor_feedbacks ) { @@ -1172,7 +1172,7 @@ function (feedback $feedback) { ->get_context()) || has_capability('mod/coursework:addallocatedagreedgrade', $feedback->get_coursework() - ->get_context()) + ->get_context()) && $feedback->get_submission()->is_assessor_initial_grader()); }); } diff --git a/classes/export/grading_sheet.php b/classes/export/grading_sheet.php index e3166847..f41bf0e9 100644 --- a/classes/export/grading_sheet.php +++ b/classes/export/grading_sheet.php @@ -95,7 +95,7 @@ public function get_submissions($groupid = null, $selected_submission_ids = '') if (!$ability->can('show', $submission) || ($stages == 1 && !has_capability('mod/coursework:addinitialgrade', $PAGE->context)) || ($this->coursework->allocation_enabled() && !$this->coursework - ->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) + ->assessor_has_any_allocation_for_student($submission->reload()->get_allocatable()) && (has_capability('mod/coursework:addinitialgrade', $PAGE->context) && !has_capability('mod/coursework:addagreedgrade', $PAGE->context))) || ($stages > 1 && $this->coursework->sampling_enabled() && !$submission->sampled_feedback_exists() diff --git a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php index 1ab3ac31..6431a439 100644 --- a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php +++ b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php @@ -171,7 +171,7 @@ private function new_moderation_button($rowobject, $assessor) { $link = $this->get_router()->get_path('new moderations', $moderation_params); $link_id = 'new_moderation_' . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()); + ->get_allocatable_identifier_hash($rowobject->get_allocatable()); $title = get_string('moderate', 'coursework'); @@ -196,7 +196,7 @@ private function edit_moderation_button($rowobject) { $link = $this->get_router()->get_path('edit moderation', $feedback_params); $link_id = 'edit_moderation_' . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()); + ->get_allocatable_identifier_hash($rowobject->get_allocatable()); $title = get_string('editmoderation', 'coursework'); $icon = new pix_icon('edit', $title, 'coursework'); @@ -223,7 +223,7 @@ private function show_moderation_button($rowobject) { $linktitle = get_string('viewmoderation', 'mod_coursework'); $link_id = "show_moderation_" . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()); + ->get_allocatable_identifier_hash($rowobject->get_allocatable()); $link = $this->get_router()->get_path('show moderation', $moderation_params); return $OUTPUT->action_link($link, diff --git a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php index d0dc6ed4..09455a41 100644 --- a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php +++ b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php @@ -128,13 +128,13 @@ public function get_content($rowobject) { null, array('class' => 'new_final_feedback', 'id' => 'new_final_feedback_' . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()))); + ->get_allocatable_identifier_hash($rowobject->get_allocatable()))); } else if ($existing_feedback && $ability->can('show', $existing_feedback)) { $linktitle = get_string('viewfeedback', 'mod_coursework'); $link_id = "show_feedback_" . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()); + ->get_allocatable_identifier_hash($rowobject->get_allocatable()); $link = $this->get_router() ->get_path('show feedback', array('feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable()))); $iconlink = $OUTPUT->action_link($link, diff --git a/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php b/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php index 88875297..ad23b59a 100644 --- a/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php +++ b/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php @@ -172,7 +172,7 @@ private function edit_feedback_button($rowobject) { $link = $this->get_router()->get_path('edit feedback', $feedback_params); $link_id = 'edit_final_feedback_' . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()); + ->get_allocatable_identifier_hash($rowobject->get_allocatable()); $title = get_string('editfinalgrade', 'coursework'); $icon = new pix_icon('edit', $title, 'coursework'); @@ -222,7 +222,7 @@ private function new_feedback_button($rowobject, $assessor) { $link = $this->get_router()->get_path('ajax new final feedback', $feedback_params); $link_id = 'new_final_feedback_' . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()); + ->get_allocatable_identifier_hash($rowobject->get_allocatable()); $title = get_string('addfinalfeedback', 'coursework'); From dbe675f5d810142b09bc5e21b530133dccfc1ebd Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:31:12 +0100 Subject: [PATCH 16/27] CTP-3690 short array syntax --- actions/ajax/deadline_extension/edit.php | 4 +- actions/ajax/deadline_extension/new.php | 4 +- actions/ajax/deadline_extension/submit.php | 4 +- actions/allocate.php | 32 +-- actions/deadline_extensions/create.php | 4 +- actions/deadline_extensions/edit.php | 4 +- actions/deadline_extensions/new.php | 4 +- actions/deadline_extensions/show.php | 4 +- actions/deadline_extensions/update.php | 4 +- actions/feedbacks/create.php | 4 +- actions/feedbacks/edit.php | 4 +- actions/feedbacks/new.php | 4 +- actions/feedbacks/show.php | 4 +- actions/feedbacks/update.php | 4 +- actions/finalgrade.php | 16 +- actions/general_feedback.php | 10 +- actions/moderations/create.php | 4 +- actions/moderations/edit.php | 4 +- actions/moderations/new.php | 4 +- actions/moderations/show.php | 4 +- actions/moderations/update.php | 4 +- actions/personal_deadline.php | 6 +- actions/plagiarism_flagging/create.php | 4 +- actions/plagiarism_flagging/edit.php | 4 +- actions/plagiarism_flagging/new.php | 4 +- actions/plagiarism_flagging/update.php | 4 +- actions/processallocation.php | 4 +- actions/revert.php | 8 +- actions/selectallallocatables.php | 4 +- actions/set_personal_deadlines.php | 14 +- actions/submissions/create.php | 6 +- actions/submissions/edit.php | 4 +- actions/submissions/finalise.php | 4 +- actions/submissions/new.php | 4 +- actions/submissions/update.php | 4 +- actions/submitonbehalfofstudent.php | 14 +- actions/upload_allocations.php | 6 +- actions/upload_feedback.php | 8 +- actions/upload_grading_sheet.php | 6 +- backup/moodle2/backup_coursework_stepslib.php | 116 ++++----- ...restore_coursework_activity_task.class.php | 2 +- .../moodle2/restore_coursework_stepslib.php | 88 +++---- classes/ability.php | 20 +- classes/allocation/auto_allocator.php | 2 +- classes/allocation/manager.php | 18 +- classes/allocation/strategy/base.php | 16 +- classes/allocation/strategy/percentages.php | 12 +- classes/allocation/table/cell/builder.php | 20 +- classes/allocation/table/cell/processor.php | 4 +- classes/allocation/upload.php | 28 +-- classes/assessor_feedback_row.php | 4 +- classes/auto_grader/average_grade.php | 4 +- classes/auto_grader/percentage_distance.php | 4 +- classes/calendar.php | 10 +- classes/controllers/controller_base.php | 10 +- .../deadline_extensions_controller.php | 40 ++-- classes/controllers/grading_controller.php | 2 +- .../controllers/moderations_controller.php | 26 +-- .../personal_deadlines_controller.php | 22 +- .../plagiarism_flagging_controller.php | 32 +-- .../controllers/submissions_controller.php | 66 +++--- classes/cron.php | 14 +- classes/event/assessable_uploaded.php | 4 +- classes/event/course_module_viewed.php | 2 +- classes/exceptions/access_denied.php | 2 +- classes/exceptions/late_submission.php | 2 +- classes/export/csv.php | 2 +- .../export/csv/cells/agreedfeedback_cell.php | 14 +- classes/export/csv/cells/agreedgrade_cell.php | 14 +- .../csv/cells/assessorfeedback_cell.php | 20 +- .../export/csv/cells/assessorgrade_cell.php | 20 +- classes/export/csv/cells/cell_base.php | 4 +- .../csv/cells/moderationagreement_cell.php | 2 +- .../export/csv/cells/otherassessors_cell.php | 4 +- classes/export/csv/cells/singlegrade_cell.php | 14 +- classes/export/csv/cells/stages_cell.php | 2 +- .../csv/cells/submissionfileid_cell.php | 2 +- .../export/csv/cells/submissionid_cell.php | 2 +- classes/export/grading_sheet.php | 6 +- classes/export/import.php | 32 +-- classes/file_importer.php | 8 +- classes/forms/advance_plugins_form.php | 4 +- classes/forms/assessor_feedback_mform.php | 10 +- classes/forms/deadline_extension_form.php | 6 +- classes/forms/moderator_agreement_mform.php | 6 +- classes/forms/plagiarism_flagging_mform.php | 8 +- classes/forms/student_submission_form.php | 6 +- classes/forms/upload_allocations_form.php | 2 +- classes/forms/upload_feedback_form.php | 8 +- classes/forms/upload_grading_sheet_form.php | 2 +- classes/framework/decorator.php | 4 +- classes/framework/test/table_base_test.php | 34 +-- classes/grading_report.php | 4 +- classes/grading_table_row_base.php | 26 +-- classes/models/moderation.php | 4 +- classes/models/moderation_set_rule.php | 4 +- classes/models/personal_deadline.php | 8 +- classes/models/sample_set_rule.php | 4 +- .../minimum_range_grade_percent.php | 14 +- .../minimum_range_grade_raw.php | 12 +- .../range_grade_percent.php | 8 +- .../moderation_set_rule/range_grade_raw.php | 8 +- .../range_total_percent.php | 4 +- classes/personal_deadline/table/builder.php | 12 +- .../personal_deadline/table/row/builder.php | 8 +- classes/plagiarism_helpers/turnitin.php | 4 +- classes/privacy/provider.php | 16 +- .../grading_report/cells/cell_base.php | 2 +- .../cells/moderation_agreement_cell.php | 22 +- .../grading_report/cells/moderation_cell.php | 24 +- .../cells/multiple_agreed_grade_cell.php | 24 +- .../cells/personal_deadline_cell.php | 6 +- .../cells/plagiarism_flag_cell.php | 22 +- .../cells/single_assessor_feedback_cell.php | 20 +- .../grading_report/cells/submission_cell.php | 16 +- .../cells/time_submitted_cell.php | 10 +- .../renderers/personal_deadline_renderer.php | 4 +- classes/router.php | 56 ++--- classes/sample_set_rule/range_sample_type.php | 42 ++-- classes/sample_set_rule/sample_base.php | 8 +- classes/sample_set_rule/total_sample_type.php | 18 +- classes/sampling_set_widget.php | 8 +- classes/stages/base.php | 28 +-- classes/task/enrol_task.php | 4 +- classes/task/unenrol_task.php | 4 +- classes/traits/allocatable_functions.php | 16 +- classes/warnings.php | 34 +-- db/access.php | 220 +++++++++--------- db/caches.php | 8 +- db/events.php | 40 ++-- db/install.php | 2 +- db/log.php | 12 +- db/messages.php | 36 +-- db/tasks.php | 16 +- db/upgrade.php | 88 +++---- index.php | 6 +- lib.php | 134 +++++------ mod_form.php | 100 ++++---- renderers/grading_report_renderer.php | 4 +- renderers/object_renderer.php | 170 +++++++------- settings.php | 32 +-- tests/generator/lib.php | 4 +- view.php | 42 ++-- 143 files changed, 1231 insertions(+), 1231 deletions(-) diff --git a/actions/ajax/deadline_extension/edit.php b/actions/ajax/deadline_extension/edit.php index 9c66ace6..69baed75 100644 --- a/actions/ajax/deadline_extension/edit.php +++ b/actions/ajax/deadline_extension/edit.php @@ -34,11 +34,11 @@ $pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT); $submissionid = optional_param('submissionid', 0, PARAM_INT); $name = optional_param('name', 0, PARAM_ALPHANUMEXT); -$params = array( +$params = [ 'courseworkid' => $courseworkid, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, -); +]; $controller = new mod_coursework\controllers\deadline_extensions_controller($params); $params['id'] = $id; diff --git a/actions/ajax/deadline_extension/new.php b/actions/ajax/deadline_extension/new.php index 162f851b..db3b9439 100644 --- a/actions/ajax/deadline_extension/new.php +++ b/actions/ajax/deadline_extension/new.php @@ -34,11 +34,11 @@ $pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT); $submissionid = optional_param('submissionid', 0, PARAM_INT); $name = optional_param('name', 0, PARAM_ALPHANUMEXT); -$params = array( +$params = [ 'courseworkid' => $courseworkid, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, -); +]; $controller = new mod_coursework\controllers\deadline_extensions_controller($params); $params['id'] = $id; diff --git a/actions/ajax/deadline_extension/submit.php b/actions/ajax/deadline_extension/submit.php index c4461592..e8635744 100644 --- a/actions/ajax/deadline_extension/submit.php +++ b/actions/ajax/deadline_extension/submit.php @@ -34,11 +34,11 @@ $pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT); $submissionid = optional_param('submissionid', 0, PARAM_INT); $name = optional_param('name', 0, PARAM_ALPHANUMEXT); -$params = array( +$params = [ 'courseworkid' => $courseworkid, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, -); +]; $controller = new mod_coursework\controllers\deadline_extensions_controller($params); $params['id'] = $id; diff --git a/actions/allocate.php b/actions/allocate.php index 01ac806c..921739cd 100644 --- a/actions/allocate.php +++ b/actions/allocate.php @@ -34,8 +34,8 @@ $coursemoduleid = required_param('id', PARAM_INT); $coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST); -$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST); +$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST); $coursework = coursework::find($coursework); $formsavebutton = optional_param('save', 0, PARAM_BOOL); $samplingformsavebutton = optional_param('save_sampling', 0, PARAM_BOOL); @@ -83,7 +83,7 @@ require_capability('mod/coursework:allocate', $PAGE->context, null, true, "Can't allocate here - permission denied."); $url = '/mod/coursework/actions/allocate.php'; -$link = new \moodle_url($url, array('id' => $coursemoduleid)); +$link = new \moodle_url($url, ['id' => $coursemoduleid]); $PAGE->set_url($link); $title = get_string('allocatefor', 'mod_coursework', $coursework->name); $PAGE->set_title($title); @@ -94,14 +94,14 @@ $PAGE->requires->js('/mod/coursework/loadingoverlay.min.js'); // Will set off the function that adds listeners for onclick/onchange etc. -$jsmodule = array( +$jsmodule = [ 'name' => 'mod_coursework', 'fullpath' => '/mod/coursework/module.js', - 'requires' => array('base', - 'node-base'), -); + 'requires' => ['base', + 'node-base'], +]; $PAGE->requires->js_init_call('M.mod_coursework.init_allocate_page', - array('wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid), + ['wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid], false, $jsmodule); @@ -138,7 +138,7 @@ reset($deletemodsetrule); $deleteruleid = key($deletemodsetrule); // Only one button can be clicked. if (is_numeric($deleteruleid)) { - $DB->delete_records('coursework_mod_set_rules', array('id' => $deleteruleid)); + $DB->delete_records('coursework_mod_set_rules', ['id' => $deleteruleid]); } } } @@ -197,8 +197,8 @@ echo \html_writer::input_hidden_params($PAGE->url); if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring... - echo \html_writer::start_tag('form', array('id' => 'sampling_form', - 'method' => 'post')); + echo \html_writer::start_tag('form', ['id' => 'sampling_form', + 'method' => 'post']); $samplesetwidget = $allocationsmanager->get_sampling_set_widget(); echo $object_renderer->render($samplesetwidget); echo html_writer::end_tag('form'); @@ -206,22 +206,22 @@ // Start form. The page has now been broken into two forms sampling section and allocation section // Open form tag. -echo \html_writer::start_tag('form', array('id' => 'allocation_form', - 'method' => 'post')); +echo \html_writer::start_tag('form', ['id' => 'allocation_form', + 'method' => 'post']); if ($coursework->allocation_enabled()) { echo $object_renderer->render($allocationwidget); } // Spacer so that we can float the headers next to each other. -$attributes = array( +$attributes = [ 'class' => 'coursework_spacer', -); +]; echo html_writer::start_tag('div', $attributes); echo html_writer::end_tag('div'); echo html_writer::tag('h3', get_string('assessormoderatorgrades', 'mod_coursework')); -echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), array('class' => 'pininfo')); +echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), ['class' => 'pininfo']); // Start the form with save button. /* diff --git a/actions/deadline_extensions/create.php b/actions/deadline_extensions/create.php index 25eb856f..66a863b7 100644 --- a/actions/deadline_extensions/create.php +++ b/actions/deadline_extensions/create.php @@ -28,11 +28,11 @@ $allocatableid = optional_param('allocatableid', $USER->id, PARAM_INT); $allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT); -$params = array( +$params = [ 'courseworkid' => $courseworkid, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, -); +]; $url = '/mod/coursework/actions/deadline_extensions/create.php'; $link = new \moodle_url($url, $params); $PAGE->set_url($link); diff --git a/actions/deadline_extensions/edit.php b/actions/deadline_extensions/edit.php index 947d01dc..21130743 100644 --- a/actions/deadline_extensions/edit.php +++ b/actions/deadline_extensions/edit.php @@ -26,8 +26,8 @@ $id = required_param('id', PARAM_INT); -$params = array( +$params = [ 'id' => $id, -); +]; $controller = new mod_coursework\controllers\deadline_extensions_controller($params); $controller->edit_deadline_extension(); diff --git a/actions/deadline_extensions/new.php b/actions/deadline_extensions/new.php index aa55f47d..e8ff7eb6 100644 --- a/actions/deadline_extensions/new.php +++ b/actions/deadline_extensions/new.php @@ -28,10 +28,10 @@ $allocatableid = optional_param('allocatableid', $USER->id, PARAM_INT); $allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT); -$params = array( +$params = [ 'courseworkid' => $courseworkid, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, -); +]; $controller = new mod_coursework\controllers\deadline_extensions_controller($params); $controller->new_deadline_extension(); diff --git a/actions/deadline_extensions/show.php b/actions/deadline_extensions/show.php index 8a872a0a..94b428f1 100644 --- a/actions/deadline_extensions/show.php +++ b/actions/deadline_extensions/show.php @@ -26,8 +26,8 @@ $id = required_param('id', PARAM_INT); -$params = array( +$params = [ 'id' => $id, -); +]; $controller = new mod_coursework\controllers\deadline_extensions_controller($params); $controller->show_deadline_extension(); diff --git a/actions/deadline_extensions/update.php b/actions/deadline_extensions/update.php index c25265ad..13b6dc42 100644 --- a/actions/deadline_extensions/update.php +++ b/actions/deadline_extensions/update.php @@ -26,9 +26,9 @@ $id = required_param('id', PARAM_INT); -$params = array( +$params = [ 'id' => $id, -); +]; $url = '/mod/coursework/actions/deadline_extensions/create.php'; $link = new \moodle_url($url, $params); $PAGE->set_url($link); diff --git a/actions/feedbacks/create.php b/actions/feedbacks/create.php index 045f9f51..4fca2246 100644 --- a/actions/feedbacks/create.php +++ b/actions/feedbacks/create.php @@ -35,14 +35,14 @@ $finalised = !!optional_param('submitbutton', 0, PARAM_TEXT); $ajax = optional_param('ajax', 0, PARAM_INT); -$params = array( +$params = [ 'submissionid' => $submissionid, 'isfinalgrade' => $isfinalgrade, 'assessorid' => $assessorid, 'stage_identifier' => $stage_identifier, 'finalised' => $finalised, 'ajax' => $ajax, -); +]; if ($ajax) { $params['cell_type'] = required_param('cell_type', PARAM_TEXT); diff --git a/actions/feedbacks/edit.php b/actions/feedbacks/edit.php index 397d7d1b..d94343a7 100644 --- a/actions/feedbacks/edit.php +++ b/actions/feedbacks/edit.php @@ -27,9 +27,9 @@ $feedbackid = optional_param('feedbackid', 0, PARAM_INT); $ajax = optional_param('ajax', 0, PARAM_INT); -$params = array( +$params = [ 'feedbackid' => $feedbackid, 'ajax' => $ajax, -); +]; $controller = new mod_coursework\controllers\feedback_controller($params); $controller->edit_feedback(); diff --git a/actions/feedbacks/new.php b/actions/feedbacks/new.php index 701a9ea5..4082a496 100644 --- a/actions/feedbacks/new.php +++ b/actions/feedbacks/new.php @@ -31,13 +31,13 @@ $stage_identifier = optional_param('stage_identifier', 'uh-oh', PARAM_RAW); $ajax = optional_param('ajax', 0, PARAM_INT); -$params = array( +$params = [ 'submissionid' => $submissionid, 'cmid' => $cmid, 'feedbackid' => $feedbackid, 'assessorid' => $assessorid, 'stage_identifier' => $stage_identifier, 'ajax' => $ajax, -); +]; $controller = new mod_coursework\controllers\feedback_controller($params); $controller->new_feedback(); diff --git a/actions/feedbacks/show.php b/actions/feedbacks/show.php index a3ee41ef..b3949dab 100644 --- a/actions/feedbacks/show.php +++ b/actions/feedbacks/show.php @@ -27,10 +27,10 @@ $feedbackid = optional_param('feedbackid', 0, PARAM_INT); $ajax = optional_param('ajax', 0, PARAM_INT); -$params = array( +$params = [ 'feedbackid' => $feedbackid, 'ajax' => $ajax, -); +]; $controller = new mod_coursework\controllers\feedback_controller($params); $controller->show_feedback(); diff --git a/actions/feedbacks/update.php b/actions/feedbacks/update.php index 4524d49b..7d696cb5 100644 --- a/actions/feedbacks/update.php +++ b/actions/feedbacks/update.php @@ -34,13 +34,13 @@ $remove = !!optional_param('removefeedbackbutton', 0, PARAM_TEXT); $confirm = optional_param('confirm', 0, PARAM_INT); -$params = array( +$params = [ 'feedbackid' => $feedbackid, 'finalised' => $finalised, 'remove' => $remove, 'confirm' => $confirm, 'ajax' => $ajax, -); +]; if ($ajax) { $params['cell_type'] = required_param('cell_type', PARAM_TEXT); diff --git a/actions/finalgrade.php b/actions/finalgrade.php index 03dbdec0..9160da49 100644 --- a/actions/finalgrade.php +++ b/actions/finalgrade.php @@ -43,12 +43,12 @@ $gradeowner = true; $coursemodule = get_coursemodule_from_id('coursework', $cmid, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST); require_login($course, false, $coursemodule); $coursework = mod_coursework\models\coursework::find($coursemodule->instance); $submission = submission::find($submission_id); -$teacherfeedback = $DB->get_record('coursework_feedbacks', array('id' => $feedbackid)); +$teacherfeedback = $DB->get_record('coursework_feedbacks', ['id' => $feedbackid]); // This is where stuff used to construct the dynamic form is fed in. @@ -90,17 +90,17 @@ } } -$params = array('submissionid' => $submission_id, +$params = ['submissionid' => $submission_id, 'assessorid' => $assessorid, - 'isfinalgrade' => $isfinalgrade); + 'isfinalgrade' => $isfinalgrade]; $oldfinalgrade = $DB->get_record('coursework_feedbacks', $params); // If the no old final grade exists and the current user is a manager lets see if another user has created // a final grade. if (empty($oldfinalgrade) && $canfinalgrade) { - $params = array('submissionid' => $submission_id, - 'isfinalgrade' => $isfinalgrade); + $params = ['submissionid' => $submission_id, + 'isfinalgrade' => $isfinalgrade]; $oldfinalgrade = $DB->get_record('coursework_feedbacks', $params); if ($oldfinalgrade) { $gradeowner = false; @@ -132,14 +132,14 @@ echo $OUTPUT->header(); echo $OUTPUT->heading($gradingstring); -$assessor = $DB->get_record('user', array('id' => $assessorid)); +$assessor = $DB->get_record('user', ['id' => $assessorid]); echo html_writer::tag('p', get_string('assessor', 'coursework').' '.fullname($assessor)); echo html_writer::tag('p', get_string('gradingoutof', 'coursework', round($coursework->grade))); // In case we have an editor come along, we want to show that this has happened. if (!empty($teacherfeedback)) { // May not have been marked yet. if ($submission_id && !empty($teacherfeedback->lasteditedbyuser)) { - $editor = $DB->get_record('user', array('id' => $teacherfeedback->lasteditedbyuser)); + $editor = $DB->get_record('user', ['id' => $teacherfeedback->lasteditedbyuser]); } else { $editor = $assessor; } diff --git a/actions/general_feedback.php b/actions/general_feedback.php index 4246d4d7..e3b6d3ba 100644 --- a/actions/general_feedback.php +++ b/actions/general_feedback.php @@ -30,17 +30,17 @@ $ajax = optional_param('ajax', false, PARAM_BOOL); $cm = get_coursemodule_from_instance('coursework', $cmid); -$course = $DB->get_record('course', array('id' => $cm->course)); +$course = $DB->get_record('course', ['id' => $cm->course]); require_login($course, false, $cm); -$coursework = $DB->get_record('coursework', array('id' => $cm->instance)); +$coursework = $DB->get_record('coursework', ['id' => $cm->instance]); if (!has_capability('mod/coursework:addinitialgrade', $PAGE->context)) { throw new \moodle_exception('access_denied', 'coursework'); } $url = '/mod/coursework/actions/general_feedback.php'; -$link = new moodle_url($url, array('cmid' => $cmid)); +$link = new moodle_url($url, ['cmid' => $cmid]); $PAGE->set_url($link); $title = get_string('generalfeedback', 'mod_coursework'); $PAGE->set_title($title); @@ -55,13 +55,13 @@ $returneddata = $gradingform->get_data(); if ($gradingform->is_cancelled()) { - redirect(new moodle_url('/mod/coursework/view.php', array('id' => $cmid))); + redirect(new moodle_url('/mod/coursework/view.php', ['id' => $cmid])); } else if ($returneddata) { $gradingform->process_data($returneddata); // TODO should not echo before header. echo 'General feedback updated..'; if (!$ajax) { - redirect(new moodle_url('/mod/coursework/view.php', array('id' => $cmid)), + redirect(new moodle_url('/mod/coursework/view.php', ['id' => $cmid]), get_string('changessaved')); } } else { diff --git a/actions/moderations/create.php b/actions/moderations/create.php index 9b11c938..2227a523 100644 --- a/actions/moderations/create.php +++ b/actions/moderations/create.php @@ -33,11 +33,11 @@ $moderatorid = optional_param('moderatorid', $USER->id, PARAM_INT); $stage_identifier = optional_param('stage_identifier', '', PARAM_ALPHANUMEXT); -$params = array( +$params = [ 'submissionid' => $submissionid, 'feedbackid' => $feedbackid, 'moderatorid' => $moderatorid, 'stage_identifier' => $stage_identifier, -); +]; $controller = new mod_coursework\controllers\moderations_controller($params); $controller->create_moderation(); diff --git a/actions/moderations/edit.php b/actions/moderations/edit.php index 8028b076..7cd51812 100644 --- a/actions/moderations/edit.php +++ b/actions/moderations/edit.php @@ -26,8 +26,8 @@ $moderationid = optional_param('moderationid', 0, PARAM_INT); -$params = array( +$params = [ 'moderationid' => $moderationid, -); +]; $controller = new mod_coursework\controllers\moderations_controller($params); $controller->edit_moderation(); diff --git a/actions/moderations/new.php b/actions/moderations/new.php index ba7a7004..7a8cf85f 100644 --- a/actions/moderations/new.php +++ b/actions/moderations/new.php @@ -30,12 +30,12 @@ $moderatorid = optional_param('moderatorid', $USER->id, PARAM_INT); $stage_identifier = optional_param('stage_identifier', 'uh-oh', PARAM_RAW); -$params = array( +$params = [ 'submissionid' => $submissionid, 'cmid' => $cmid, 'feedbackid' => $feedbackid, 'moderatorid' => $moderatorid, 'stage_identifier' => $stage_identifier, -); +]; $controller = new mod_coursework\controllers\moderations_controller($params); $controller->new_moderation(); diff --git a/actions/moderations/show.php b/actions/moderations/show.php index 171473ba..8c6946e7 100644 --- a/actions/moderations/show.php +++ b/actions/moderations/show.php @@ -26,8 +26,8 @@ $moderationid = optional_param('moderationid', 0, PARAM_INT); -$params = array( +$params = [ 'moderationid' => $moderationid, -); +]; $controller = new mod_coursework\controllers\moderations_controller($params); $controller->show_moderation(); diff --git a/actions/moderations/update.php b/actions/moderations/update.php index 627e82ba..d8ebd219 100644 --- a/actions/moderations/update.php +++ b/actions/moderations/update.php @@ -30,8 +30,8 @@ $moderationid = required_param('moderationid', PARAM_INT); -$params = array( +$params = [ 'moderationid' => $moderationid, -); +]; $controller = new mod_coursework\controllers\moderations_controller($params); $controller->update_moderation(); diff --git a/actions/personal_deadline.php b/actions/personal_deadline.php index 63508468..a6bbb06a 100644 --- a/actions/personal_deadline.php +++ b/actions/personal_deadline.php @@ -35,19 +35,19 @@ $allocatableid = (!empty($allocatableid_arr)) ? $allocatableid_arr : $allocatableid; -$coursework_db = $DB->get_record('coursework', array('id' => $courseworkid)); +$coursework_db = $DB->get_record('coursework', ['id' => $courseworkid]); $coursework = \mod_coursework\models\coursework::find($coursework_db); require_login($coursework->get_course(), false, $coursework->get_course_module()); -$params = array( +$params = [ 'courseworkid' => $courseworkid, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, 'setpersonaldeadlinespage' => $setpersonaldeadlinespage, 'multipleuserdeadlines' => $multipleuserdeadlines, -); +]; if ($selectedtype != 'unfinalise') { $controller = new mod_coursework\controllers\personal_deadlines_controller($params); diff --git a/actions/plagiarism_flagging/create.php b/actions/plagiarism_flagging/create.php index 12eb39fe..2ca0f950 100644 --- a/actions/plagiarism_flagging/create.php +++ b/actions/plagiarism_flagging/create.php @@ -30,9 +30,9 @@ $submissionid = required_param('submissionid', PARAM_INT); -$params = array( +$params = [ 'submissionid' => $submissionid, -); +]; $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); $controller->create_plagiarism_flag(); diff --git a/actions/plagiarism_flagging/edit.php b/actions/plagiarism_flagging/edit.php index deb30313..f3270d57 100644 --- a/actions/plagiarism_flagging/edit.php +++ b/actions/plagiarism_flagging/edit.php @@ -26,9 +26,9 @@ $flagid = optional_param('flagid', 0, PARAM_INT); -$params = array( +$params = [ 'flagid' => $flagid, -); +]; $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); $controller->edit_plagiarism_flag(); diff --git a/actions/plagiarism_flagging/new.php b/actions/plagiarism_flagging/new.php index a4b01cb1..1bf0f6e8 100644 --- a/actions/plagiarism_flagging/new.php +++ b/actions/plagiarism_flagging/new.php @@ -26,9 +26,9 @@ $submissionid = required_param('submissionid', PARAM_INT); -$params = array( +$params = [ 'submissionid' => $submissionid, -); +]; $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); $controller->new_plagiarism_flag(); diff --git a/actions/plagiarism_flagging/update.php b/actions/plagiarism_flagging/update.php index 33d2825f..bee0ed85 100644 --- a/actions/plagiarism_flagging/update.php +++ b/actions/plagiarism_flagging/update.php @@ -30,9 +30,9 @@ $flagid = required_param('flagid', PARAM_INT); -$params = array( +$params = [ 'flagid' => $flagid, -); +]; $controller = new mod_coursework\controllers\plagiarism_flagging_controller($params); $controller->update_plagiarism_flag(); diff --git a/actions/processallocation.php b/actions/processallocation.php index bbed5f0d..690d4cb0 100644 --- a/actions/processallocation.php +++ b/actions/processallocation.php @@ -37,8 +37,8 @@ $coursemoduleid = required_param('coursemoduleid', PARAM_INT); $coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST); -$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST); +$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST); $coursework = coursework::find($coursework); $assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT); diff --git a/actions/revert.php b/actions/revert.php index 78aff861..38d26e97 100644 --- a/actions/revert.php +++ b/actions/revert.php @@ -33,14 +33,14 @@ $cmid = required_param('cmid', PARAM_INT); $submission_id = required_param('submissionid', PARAM_INT); -$cm = $DB->get_record('course_modules', array('id' => $cmid)); +$cm = $DB->get_record('course_modules', ['id' => $cmid]); $coursework = coursework::find($cm->instance); -$course = $DB->get_record('course', array('id' => $cm->course)); -$submission_db = $DB->get_record('coursework_submissions', array('id' => $submission_id)); +$course = $DB->get_record('course', ['id' => $cm->course]); +$submission_db = $DB->get_record('coursework_submissions', ['id' => $submission_id]); $submission = submission::find($submission_db); require_login($course, false, $cm); -$url = new moodle_url('/mod/coursework/view.php', array('id' => $cm->id)); +$url = new moodle_url('/mod/coursework/view.php', ['id' => $cm->id]); // Bounce anyone who shouldn't be here. if (!has_capability('mod/coursework:revertfinalised', $PAGE->context)) { diff --git a/actions/selectallallocatables.php b/actions/selectallallocatables.php index e241d770..75aa14f6 100644 --- a/actions/selectallallocatables.php +++ b/actions/selectallallocatables.php @@ -32,8 +32,8 @@ $coursemoduleid = required_param('coursemoduleid', PARAM_INT); $stagenumber = required_param('stage', PARAM_INT); $coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST); -$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST); +$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST); $coursework = coursework::find($coursework); $assessorallocationstrategy = optional_param('assessorallocationstrategy', false, PARAM_TEXT); diff --git a/actions/set_personal_deadlines.php b/actions/set_personal_deadlines.php index 2e946a07..6f712c91 100644 --- a/actions/set_personal_deadlines.php +++ b/actions/set_personal_deadlines.php @@ -33,8 +33,8 @@ $coursemoduleid = required_param('id', PARAM_INT); $coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST); -$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST); -$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST); +$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST); $coursework = coursework::find($coursework); // SQL sort for allocation table. @@ -46,7 +46,7 @@ require_capability('mod/coursework:editpersonaldeadline', $PAGE->context, null, true, "Can't change personal deadlines here - permission denied."); $url = '/mod/coursework/actions/set_personal_deadlines.php'; -$link = new \moodle_url($url, array('id' => $coursemoduleid)); +$link = new \moodle_url($url, ['id' => $coursemoduleid]); $PAGE->set_url($link); $title = get_string('setpersonaldeadlinesfor', 'mod_coursework', $coursework->name); $PAGE->set_title($title); @@ -55,12 +55,12 @@ $PAGE->requires->jquery(); // Will set off the function that adds listeners for onclick/onchange etc. -$jsmodule = array( +$jsmodule = [ 'name' => 'mod_coursework', 'fullpath' => '/mod/coursework/module.js', - 'requires' => array('base', - 'node-base'), -); + 'requires' => ['base', + 'node-base'], +]; $PAGE->requires->js_init_call('M.mod_coursework.init_personal_deadlines_page', [], false, diff --git a/actions/submissions/create.php b/actions/submissions/create.php index 336fbf68..360cf73a 100644 --- a/actions/submissions/create.php +++ b/actions/submissions/create.php @@ -34,17 +34,17 @@ $submissionid = optional_param('submissionid', 0, PARAM_INT); $finalised = !!optional_param('finalisebutton', 0, PARAM_TEXT); -if (!in_array($allocatabletype, array('user', 'group'))) { +if (!in_array($allocatabletype, ['user', 'group'])) { throw new \mod_coursework\exceptions\access_denied(\mod_coursework\models\coursework::find($courseworkid), 'Bad alloctable type'); } -$params = array( +$params = [ 'courseworkid' => $courseworkid, 'finalised' => $finalised, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, -); +]; if ($submissionid) { $params['submissionid'] = $submissionid; } diff --git a/actions/submissions/edit.php b/actions/submissions/edit.php index 061d591c..af5f2fe9 100644 --- a/actions/submissions/edit.php +++ b/actions/submissions/edit.php @@ -28,8 +28,8 @@ $submissionid = required_param('submissionid', PARAM_INT); -$params = array( +$params = [ 'submissionid' => $submissionid, -); +]; $controller = new mod_coursework\controllers\submissions_controller($params); $controller->edit_submission(); diff --git a/actions/submissions/finalise.php b/actions/submissions/finalise.php index 0695511b..d27505aa 100644 --- a/actions/submissions/finalise.php +++ b/actions/submissions/finalise.php @@ -28,8 +28,8 @@ $submissionid = required_param('submissionid', PARAM_INT); -$params = array( +$params = [ 'submissionid' => $submissionid, -); +]; $controller = new mod_coursework\controllers\submissions_controller($params); $controller->finalise_submission(); diff --git a/actions/submissions/new.php b/actions/submissions/new.php index 20a33ba6..125fc919 100644 --- a/actions/submissions/new.php +++ b/actions/submissions/new.php @@ -32,10 +32,10 @@ $allocatableid = optional_param('allocatableid', $USER->id, PARAM_INT); $allocatabletype = optional_param('allocatabletype', 'user', PARAM_ALPHANUMEXT); -$params = array( +$params = [ 'courseworkid' => $courseworkid, 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, -); +]; $controller = new mod_coursework\controllers\submissions_controller($params); $controller->new_submission(); diff --git a/actions/submissions/update.php b/actions/submissions/update.php index 02bc61b3..0b974f8d 100644 --- a/actions/submissions/update.php +++ b/actions/submissions/update.php @@ -29,9 +29,9 @@ $submissionid = required_param('submissionid', PARAM_INT); $finalised = !!optional_param('finalisebutton', 0, PARAM_TEXT); -$params = array( +$params = [ 'submissionid' => $submissionid, 'finalised' => $finalised, -); +]; $controller = new mod_coursework\controllers\submissions_controller($params); $controller->update_submission(); diff --git a/actions/submitonbehalfofstudent.php b/actions/submitonbehalfofstudent.php index 39d23809..b9c0a794 100644 --- a/actions/submitonbehalfofstudent.php +++ b/actions/submitonbehalfofstudent.php @@ -31,9 +31,9 @@ global $CFG, $DB, $PAGE, $OUTPUT; $coursemoduleid = required_param('cmid', PARAM_INT); -$coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid)); +$coursemodule = $DB->get_record('course_modules', ['id' => $coursemoduleid]); $coursework = coursework::find($coursemodule->instance); -$course = $DB->get_record('course', array('id' => $coursemodule->course)); +$course = $DB->get_record('course', ['id' => $coursemodule->course]); $studentid = optional_param('userid', 0, PARAM_INT); $student = \mod_coursework\models\user::find($studentid); @@ -48,7 +48,7 @@ require_capability('mod/coursework:submitonbehalfof', $PAGE->context); -$params = array('cmid' => $coursemoduleid); +$params = ['cmid' => $coursemoduleid]; $url = new moodle_url('/mod/coursework/actions/submitonbehalfofstudent.php', $params); $PAGE->set_url($url, $params); @@ -57,12 +57,12 @@ $customdata->coursework = $coursework; $chooseform = new \mod_coursework\forms\choose_student_for_submission_mform($PAGE->url->out(), $customdata); if ($chooseform->is_cancelled()) { - redirect(new moodle_url('mod/coursework/view.php', array('id' => $coursemoduleid))); + redirect(new moodle_url('mod/coursework/view.php', ['id' => $coursemoduleid])); } $student = false; if ($studentid) { - $student = $DB->get_record('user', array('id' => $studentid)); + $student = $DB->get_record('user', ['id' => $studentid]); $title = get_string('submitonbehalfofstudent', 'mod_coursework', fullname($student)); } else { $title = get_string('submitonbehalfof', 'mod_coursework'); @@ -72,10 +72,10 @@ $html = ''; -$customdata = array( +$customdata = [ 'coursework' => $coursework, 'submission' => $submission, -); +]; $submitform = new mod_coursework\forms\student_submission_form($url->out(), $customdata); // Save any data that's there and redirect if successful. diff --git a/actions/upload_allocations.php b/actions/upload_allocations.php index 20842086..572d87a8 100644 --- a/actions/upload_allocations.php +++ b/actions/upload_allocations.php @@ -33,9 +33,9 @@ $coursemoduleid = required_param('cmid', PARAM_INT); -$coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid)); +$coursemodule = $DB->get_record('course_modules', ['id' => $coursemoduleid]); $coursework = coursework::find($coursemodule->instance); -$course = $DB->get_record('course', array('id' => $coursemodule->course)); +$course = $DB->get_record('course', ['id' => $coursemodule->course]); require_login($course, false, $coursemodule); $csvtype = 'allocationsupload'; @@ -44,7 +44,7 @@ $PAGE->set_title($title); $PAGE->set_heading($title); -$grading_sheet_capabilities = array('mod/coursework:allocate'); +$grading_sheet_capabilities = ['mod/coursework:allocate']; // Bounce anyone who shouldn't be here. if (!has_any_capability($grading_sheet_capabilities, $PAGE->context)) { diff --git a/actions/upload_feedback.php b/actions/upload_feedback.php index fd59f960..bb37fc39 100644 --- a/actions/upload_feedback.php +++ b/actions/upload_feedback.php @@ -33,9 +33,9 @@ $coursemoduleid = required_param('cmid', PARAM_INT); -$coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid)); +$coursemodule = $DB->get_record('course_modules', ['id' => $coursemoduleid]); $coursework = coursework::find($coursemodule->instance); -$course = $DB->get_record('course', array('id' => $coursemodule->course)); +$course = $DB->get_record('course', ['id' => $coursemodule->course]); require_login($course, false, $coursemodule); @@ -44,7 +44,7 @@ $PAGE->set_title($title); $PAGE->set_heading($title); -$grading_sheet_capabilities = array('mod/coursework:addinitialgrade', 'mod/coursework:addagreedgrade', 'mod/coursework:administergrades'); +$grading_sheet_capabilities = ['mod/coursework:addinitialgrade', 'mod/coursework:addagreedgrade', 'mod/coursework:administergrades']; // Bounce anyone who shouldn't be here. if (!has_any_capability($grading_sheet_capabilities, $PAGE->context)) { @@ -55,7 +55,7 @@ $feedbackform = new upload_feedback_form($coursework, $coursemoduleid); if ($feedbackform->is_cancelled()) { - redirect(new moodle_url("$CFG->wwwroot/mod/coursework/view.php", array('id' => $coursemoduleid))); + redirect(new moodle_url("$CFG->wwwroot/mod/coursework/view.php", ['id' => $coursemoduleid])); } if ($data = $feedbackform->get_data()) { diff --git a/actions/upload_grading_sheet.php b/actions/upload_grading_sheet.php index 1dbae1e1..08ed1318 100644 --- a/actions/upload_grading_sheet.php +++ b/actions/upload_grading_sheet.php @@ -33,9 +33,9 @@ $coursemoduleid = required_param('cmid', PARAM_INT); -$coursemodule = $DB->get_record('course_modules', array('id' => $coursemoduleid)); +$coursemodule = $DB->get_record('course_modules', ['id' => $coursemoduleid]); $coursework = coursework::find($coursemodule->instance); -$course = $DB->get_record('course', array('id' => $coursemodule->course)); +$course = $DB->get_record('course', ['id' => $coursemodule->course]); require_login($course, false, $coursemodule); @@ -45,7 +45,7 @@ $PAGE->set_url(new moodle_url('/mod/coursework/actions/upload_grading_sheet.php')); $PAGE->set_title($title); $PAGE->set_heading($title); -$grading_sheet_capabilities = array('mod/coursework:addinitialgrade', 'mod/coursework:addagreedgrade', 'mod/coursework:administergrades'); +$grading_sheet_capabilities = ['mod/coursework:addinitialgrade', 'mod/coursework:addagreedgrade', 'mod/coursework:administergrades']; // Bounce anyone who shouldn't be here. if (!has_any_capability($grading_sheet_capabilities, $PAGE->context)) { diff --git a/backup/moodle2/backup_coursework_stepslib.php b/backup/moodle2/backup_coursework_stepslib.php index 960553cf..6eb53e1c 100644 --- a/backup/moodle2/backup_coursework_stepslib.php +++ b/backup/moodle2/backup_coursework_stepslib.php @@ -24,12 +24,12 @@ class backup_coursework_activity_structure_step extends backup_activity_structur protected function define_structure() { global $DB; - foreach (array('coursework_submissions', + foreach (['coursework_submissions', 'coursework_allocation_pairs', 'coursework_mod_set_members', 'coursework_sample_set_mbrs', 'coursework_extensions', - 'coursework_person_deadlines') as $tablename) { + 'coursework_person_deadlines'] as $tablename) { $DB->execute("update {{$tablename}} set allocatableuser=0, allocatablegroup=0"); $DB->execute("update {{$tablename}} set allocatableuser=allocatableid where allocatabletype='user'"); $DB->execute("update {{$tablename}} set allocatablegroup=allocatableid where allocatabletype='group'"); @@ -37,8 +37,8 @@ protected function define_structure() { $userinfo = $this->get_setting_value('userinfo'); - $coursework = new backup_nested_element('coursework', array('id'), - array('formid', + $coursework = new backup_nested_element('coursework', ['id'], + ['formid', 'course', 'name', 'intro', @@ -106,32 +106,32 @@ protected function define_structure() { 'processenrol', 'processunenrol', 'plagiarismflagenabled', - )); + ]); $sample_strategies = new backup_nested_element('coursework_sample_set_rules'); - $sample_strategy = new backup_nested_element('coursework_sample_set_rule', array('id'), - array('courseworkid', + $sample_strategy = new backup_nested_element('coursework_sample_set_rule', ['id'], + ['courseworkid', 'sample_set_plugin_id', 'ruleorder', 'ruletype', 'upperlimit', 'lowerlimit', - 'stage_identifier')); + 'stage_identifier']); $coursework->add_child($sample_strategies); $sample_strategies->add_child($sample_strategy); $sample_strategy->set_source_table('coursework_sample_set_rules', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); if ($userinfo) { $plagiarism_flags = new backup_nested_element('coursework_plagiarism_flags'); - $plagiarism_flag = new backup_nested_element('coursework_plagiarism_flag', array('id'), - array( + $plagiarism_flag = new backup_nested_element('coursework_plagiarism_flag', ['id'], + [ "courseworkid", "submissiond", "status", @@ -141,12 +141,12 @@ protected function define_structure() { "timecreated", "lastmodifiedby", "timemodified", - )); + ]); $moderation_agreements = new backup_nested_element('coursework_mod_agreements'); - $moderation_agreement = new backup_nested_element('coursework_mod_agreement', array('id'), - array( + $moderation_agreement = new backup_nested_element('coursework_mod_agreement', ['id'], + [ "feedbackid", "moderatorid", "agreement", @@ -155,12 +155,12 @@ protected function define_structure() { "lasteditedby", "modcomment", "modecommentformat", - )); + ]); $feedbacks = new backup_nested_element('coursework_feedbacks'); - $feedback = new backup_nested_element('coursework_feedback', array('id'), - array( + $feedback = new backup_nested_element('coursework_feedback', ['id'], + [ "submissionid", "assessorid", "timecreated", @@ -177,12 +177,12 @@ protected function define_structure() { "markernumber", "stage_identifier", "finalised", - )); + ]); $submissions = new backup_nested_element('coursework_submissions'); - $submission = new backup_nested_element('coursework_submission', array('id'), - array( + $submission = new backup_nested_element('coursework_submission', ['id'], + [ "courseworkid", "userid", "authorid", @@ -199,21 +199,21 @@ protected function define_structure() { "firstpublished", "lastpublished", "timesubmitted", - )); + ]); $reminders = new backup_nested_element('coursework_reminders'); - $reminder = new backup_nested_element('coursework_reminder', array('id'), - array( + $reminder = new backup_nested_element('coursework_reminder', ['id'], + [ "userid", "coursework_id", "remindernumber", "extension", - )); + ]); $pairs = new backup_nested_element('coursework_allocation_pairs'); - $pair = new backup_nested_element('coursework_allocation_pair', array('id'), - array( + $pair = new backup_nested_element('coursework_allocation_pair', ['id'], + [ "courseworkid", "assessorid", "manual", @@ -224,47 +224,47 @@ protected function define_structure() { "allocatabletype", 'allocatableuser', 'allocatablegroup', - )); + ]); $modsetrules = new backup_nested_element('coursework_mod_set_rules'); - $modsetrule = new backup_nested_element('coursework_mod_set_rule', array('id'), - array( + $modsetrule = new backup_nested_element('coursework_mod_set_rule', ['id'], + [ "courseworkid", "rulename", "ruleorder", "upperlimit", "lowerlimit", "minimum", - )); + ]); $allocation_configs = new backup_nested_element('coursework_allocation_configs'); - $allocation_config = new backup_nested_element('coursework_allocation_config', array('id'), - array( + $allocation_config = new backup_nested_element('coursework_allocation_config', ['id'], + [ "courseworkid", "allocationstrategy", "assessorid", "value", "purpose", - )); + ]); $modsetmembers = new backup_nested_element('coursework_mod_set_members'); - $modsetmember = new backup_nested_element('coursework_mod_set_member', array('id'), - array( + $modsetmember = new backup_nested_element('coursework_mod_set_member', ['id'], + [ "courseworkid", "allocatableid", "allocatabletype", 'allocatableuser', 'allocatablegroup', "stage_identifier", - )); + ]); $extensions = new backup_nested_element('coursework_extensions'); - $extension = new backup_nested_element('coursework_extension', array('id'), - array( + $extension = new backup_nested_element('coursework_extension', ['id'], + [ "allocatableid", "allocatabletype", 'allocatableuser', @@ -275,12 +275,12 @@ protected function define_structure() { "createdbyid", "extra_information_text", "extra_information_format", - )); + ]); $personal_deadlines = new backup_nested_element('coursework_person_deadlines'); - $personal_deadline = new backup_nested_element('coursework_person_deadline', array('id'), - array( + $personal_deadline = new backup_nested_element('coursework_person_deadline', ['id'], + [ "allocatableid", 'allocatableuser', 'allocatablegroup', @@ -291,12 +291,12 @@ protected function define_structure() { "timecreated", "timemodified", "lastmodifiedbyid", - )); + ]); $sample_members = new backup_nested_element('coursework_sample_set_mbrs'); - $sample_member = new backup_nested_element('coursework_sample_set_mbr', array('id'), - array( + $sample_member = new backup_nested_element('coursework_sample_set_mbr', ['id'], + [ "courseworkid", "allocatableid", "allocatabletype", @@ -304,7 +304,7 @@ protected function define_structure() { 'allocatablegroup', "stage_identifier", "selectiontype", - )); + ]); // A coursework instance has submissions. $coursework->add_child($submissions); @@ -351,40 +351,40 @@ protected function define_structure() { $allocation_configs->add_child($allocation_config); $submission->set_source_table('coursework_submissions', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); $feedback->set_source_table('coursework_feedbacks', - array('submissionid' => backup::VAR_PARENTID)); + ['submissionid' => backup::VAR_PARENTID]); $plagiarism_flag->set_source_table('coursework_plagiarism_flags', - array('submissionid' => backup::VAR_PARENTID)); + ['submissionid' => backup::VAR_PARENTID]); $moderation_agreement->set_source_table('coursework_mod_agreements', - array('feedbackid' => backup::VAR_PARENTID)); + ['feedbackid' => backup::VAR_PARENTID]); $reminder->set_source_table('coursework_reminder', - array('coursework_id' => backup::VAR_PARENTID)); + ['coursework_id' => backup::VAR_PARENTID]); $pair->set_source_table('coursework_allocation_pairs', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); $modsetrule->set_source_table('coursework_mod_set_rules', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); $extension->set_source_table('coursework_extensions', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); $personal_deadline->set_source_table('coursework_person_deadlines', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); $modsetmember->set_source_table('coursework_mod_set_members', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); $sample_member->set_source_table('coursework_sample_set_mbrs', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); $allocation_config->set_source_table('coursework_allocation_config', - array('courseworkid' => backup::VAR_PARENTID)); + ['courseworkid' => backup::VAR_PARENTID]); // Mark important foreign keys $feedback->annotate_ids('user', 'assessorid'); @@ -430,7 +430,7 @@ protected function define_structure() { $coursework->annotate_ids('grouping', 'grouping_id'); - $coursework->set_source_table('coursework', array('id' => backup::VAR_ACTIVITYID)); + $coursework->set_source_table('coursework', ['id' => backup::VAR_ACTIVITYID]); return $this->prepare_activity_structure($coursework); diff --git a/backup/moodle2/restore_coursework_activity_task.class.php b/backup/moodle2/restore_coursework_activity_task.class.php index 17f4c554..7f974a07 100644 --- a/backup/moodle2/restore_coursework_activity_task.class.php +++ b/backup/moodle2/restore_coursework_activity_task.class.php @@ -55,7 +55,7 @@ public static function define_decode_rules() { public static function define_decode_contents() { $contents = []; - $contents[] = new restore_decode_content('coursework', array('intro'), 'assign'); + $contents[] = new restore_decode_content('coursework', ['intro'], 'assign'); return $contents; } diff --git a/backup/moodle2/restore_coursework_stepslib.php b/backup/moodle2/restore_coursework_stepslib.php index 14e9bf56..928fc79f 100644 --- a/backup/moodle2/restore_coursework_stepslib.php +++ b/backup/moodle2/restore_coursework_stepslib.php @@ -53,7 +53,7 @@ protected function define_structure() { // and that the coursework_ prefix is not needed. // It would be nice to go back and take these out here and in backup. // But not essential - $bits = array('submission' => 'coursework_submissions', + $bits = ['submission' => 'coursework_submissions', 'feedback' => 'coursework_submissions/coursework_submission/coursework_feedbacks', 'reminder' => 'coursework_reminders', 'allocation_pair' => 'coursework_allocation_pairs', @@ -64,7 +64,7 @@ protected function define_structure() { 'extension' => 'coursework_extensions', 'person_deadline' => 'coursework_person_deadlines', 'mod_agreement' => 'coursework_submissions/coursework_submission/coursework_feedbacks/coursework_feedback/coursework_mod_agreements', - 'plagiarism_flag' => 'coursework_submissions/coursework_submission/coursework_plagiarism_flags'); + 'plagiarism_flag' => 'coursework_submissions/coursework_submission/coursework_plagiarism_flags']; foreach ($bits as $bit => $bitpath) { $p = new restore_path_element("coursework_$bit", "/activity/coursework/{$bitpath}/coursework_$bit"); @@ -97,23 +97,23 @@ protected function process_coursework_submission($data) { $this->fixallocatable($data); - $this->updatedate(array('timemodified', + $this->updatedate(['timemodified', 'timecreated', 'timesubmitted', 'firstpublished', - 'lastpublished', ), $data); + 'lastpublished', ], $data); $now = time(); - $this->set_defaults(array('timecreated' => $now, + $this->set_defaults(['timecreated' => $now, 'timemodified' => $now, 'firstpublished' => null, 'lastpublished' => null, 'timesubmitted' => null, 'finalised' => 0, - 'manualsrscode' => ''), + 'manualsrscode' => ''], $data); - if (!$DB->record_exists('coursework_submissions', array('courseworkid' => $data->courseworkid, 'allocatableid' => $data->allocatableid, 'allocatabletype' => $data->allocatabletype))) { + if (!$DB->record_exists('coursework_submissions', ['courseworkid' => $data->courseworkid, 'allocatableid' => $data->allocatableid, 'allocatabletype' => $data->allocatabletype])) { $newitemid = $DB->insert_record('coursework_submissions', $data); $this->set_mapping('coursework_submission', $oldid, $newitemid); @@ -135,15 +135,15 @@ protected function process_coursework_feedback($data) { $data->lasteditedbyuser = $this->get_mappingid('user', $data->lasteditedbyuser); $data->markernumber = $this->get_mappingid('user', $data->markernumber); - $this->updatedate(array('timemodified', + $this->updatedate(['timemodified', 'timecreated', - 'timepublished'), $data); + 'timepublished'], $data); $this->check_grade('grade', $data); $this->check_grade('cappedgrade', $data); $now = time(); - $this->set_defaults(array('assessorid' => 0, + $this->set_defaults(['assessorid' => 0, 'timecreated' => $now, 'timemodified' => $now, 'grade' => '', @@ -157,7 +157,7 @@ protected function process_coursework_feedback($data) { 'entry_id' => 0, 'markernumber' => 0, 'stage_identifier' => '', - 'finalised' => 0), $data); + 'finalised' => 0], $data); $newitemid = $DB->insert_record('coursework_feedbacks', $data); @@ -171,7 +171,7 @@ protected function process_coursework_reminder($data) { $data->coursework_id = $this->get_new_parentid('coursework'); $data->userid = $this->get_mappingid('user', $data->userid); - $this->set_defaults(array('remindernumber' => 0), $data); + $this->set_defaults(['remindernumber' => 0], $data); global $DB; $newitemid = $DB->insert_record('coursework_reminder', $data); @@ -183,15 +183,15 @@ protected function process_coursework_allocation_pair($data) { $data->courseworkid = $this->get_new_parentid('coursework'); $data->assessorid = $this->get_mappingid('user', $data->assessorid); - $this->updatedate(array('timelocked'), $data); + $this->updatedate(['timelocked'], $data); $this->fixallocatable($data); - $this->set_defaults(array('assessorid' => 0, + $this->set_defaults(['assessorid' => 0, 'manual' => 0, 'moderator' => 0, 'timelocked' => time(), - 'stage_identifier' => ''), $data); + 'stage_identifier' => ''], $data); global $DB; $newitemid = $DB->insert_record('coursework_allocation_pairs', $data); @@ -203,11 +203,11 @@ protected function process_coursework_mod_set_rule($data) { $data->courseworkid = $this->get_new_parentid('coursework'); - $this->set_defaults(array('rulename' => '', + $this->set_defaults(['rulename' => '', 'ruleorder' => 0, 'upperlimit' => 0, 'lowerlimit' => 0, - 'minimum' => 0), $data); + 'minimum' => 0], $data); global $DB; $newitemid = $DB->insert_record('coursework_mod_set_members', $data); @@ -219,12 +219,12 @@ protected function process_coursework_sample_set_rule($data) { $data->courseworkid = $this->get_new_parentid('coursework'); - $this->set_defaults(array('ruletype' => '', + $this->set_defaults(['ruletype' => '', 'ruleorder' => 0, 'upperlimit' => 0, 'lowerlimit' => 0, 'sample_set_plugin_id' => 0, - 'stage_identifier' => ''), $data); + 'stage_identifier' => ''], $data); global $DB; $newitemid = $DB->insert_record('coursework_sample_set_rules', $data); @@ -237,9 +237,9 @@ protected function process_coursework_allocation_config($data) { $data->courseworkid = $this->get_new_parentid('coursework'); $data->assessorid = $this->get_mappingid('user', $data->assessorid); - $this->set_defaults(array('allocationstrategy' => '', + $this->set_defaults(['allocationstrategy' => '', 'value' => 0, - 'purpose' => ''), + 'purpose' => ''], $data); global $DB; @@ -253,7 +253,7 @@ protected function process_coursework_mod_set_member($data) { $this->fixallocatable($data); - $this->set_defaults(array('stage_identifier' => ''), $data); + $this->set_defaults(['stage_identifier' => ''], $data); global $DB; $newitemid = $DB->insert_record('coursework_mod_set_members', $data); @@ -266,12 +266,12 @@ protected function process_coursework_sample_set_mbr($data) { $this->fixallocatable($data); - $this->set_defaults(array('allocatableid' => 0, + $this->set_defaults(['allocatableid' => 0, 'allocatabletype' => '', 'allocatableuser' => 0, 'allocatablegroup' => 0, 'stage_identifier' => '', - 'selectiontype' => ''), $data); + 'selectiontype' => ''], $data); global $DB; $newitemid = $DB->insert_record('coursework_sample_set_mbrs', $data); @@ -285,12 +285,12 @@ protected function process_coursework_extension($data) { $this->fixallocatable($data); - $this->updatedate(array('extended_deadline'), $data); + $this->updatedate(['extended_deadline'], $data); - $this->set_defaults(array('extended_deadline' => 0, + $this->set_defaults(['extended_deadline' => 0, 'pre_defined_reason' => '', 'extra_information_text' => '', - 'extra_information_format' => FORMAT_HTML) + 'extra_information_format' => FORMAT_HTML] , $data); global $DB; @@ -307,15 +307,15 @@ protected function process_coursework_person_deadline($data) { $this->fixallocatable($data); - $this->updatedate(array('personal_deadline', + $this->updatedate(['personal_deadline', 'timecreated', - 'timemodified'), $data); + 'timemodified'], $data); $now = time(); - $this->set_defaults(array('personal_deadline' => 0, + $this->set_defaults(['personal_deadline' => 0, 'timecreated' => $now, 'timemodified' => 0, - 'lastmodifiedbyid' => 0), $data); + 'lastmodifiedbyid' => 0], $data); global $DB; $newitemid = $DB->insert_record('coursework_person_deadlines', $data); @@ -330,15 +330,15 @@ protected function process_coursework_mod_agreement($data) { $this->fixallocatable($data); - $this->updatedate(array('timecreated', - 'timemodified'), $data); + $this->updatedate(['timecreated', + 'timemodified'], $data); $now = time(); - $this->set_defaults(array('timecreated' => $now, + $this->set_defaults(['timecreated' => $now, 'timemodified' => $now, 'lasteditedby' => 0, 'modcomment' => '', - 'modcommentformat' => 1), $data); + 'modcommentformat' => 1], $data); global $DB; $newitemid = $DB->insert_record('coursework_mod_agreements', $data); @@ -353,15 +353,15 @@ protected function process_coursework_plagiarism_flag($data) { $this->fixallocatable($data); - $this->updatedate(array('timecreated', - 'timemodified'), $data); + $this->updatedate(['timecreated', + 'timemodified'], $data); $now = time(); - $this->set_defaults(array('timecreated' => $now, + $this->set_defaults(['timecreated' => $now, 'timemodified' => $now, 'lastmodifieddby' => 0, 'comment' => '', - 'comment_format' => 1), $data); + 'comment_format' => 1], $data); global $DB; $newitemid = $DB->insert_record('coursework_plagiarism_flags', $data); @@ -380,15 +380,15 @@ protected function process_coursework($data) { $oldid = $data->id; $data->course = $this->get_courseid(); - $this->updatedate(array('timemodified', + $this->updatedate(['timemodified', 'timecreated', 'startdate', 'generalfeedbacktimepublished', - 'deadline'), $data); + 'deadline'], $data); $now = time(); // Taken from install.xml - $this->set_defaults(array('formid' => 0, + $this->set_defaults(['formid' => 0, 'course' => 0, 'name' => '', 'intro' => '', @@ -455,7 +455,7 @@ protected function process_coursework($data) { 'draftfeedbackenabled' => 0, 'processenrol' => 0, 'plagiarismflagenabled' => 0, - 'processunenrol' => 0), $data); + 'processunenrol' => 0], $data); $this->check_grade('grade', $data); @@ -501,7 +501,7 @@ protected function after_execute() { $itemid = $file->get_itemid(); $entry = $DB->get_record('coursework_submissions', - array('id' => $itemid)); + ['id' => $itemid]); $submission = \mod_coursework\models\submission::find($entry->id); $submission->rename_files(); // use cw function to handle file renaming as submission may have few files diff --git a/classes/ability.php b/classes/ability.php index 29c5261d..52d7992d 100644 --- a/classes/ability.php +++ b/classes/ability.php @@ -259,10 +259,10 @@ public function require_can($action, $thing) { * @return array */ protected function classname_mappings() { - return array( + return [ 'submission_groups_decorator' => 'submission', 'coursework_groups_decorator' => 'coursework', - ); + ]; } /** @@ -309,11 +309,11 @@ protected function prevent_new_submissions_if_one_already_exists() { $this->prevent('new', 'mod_coursework\models\submission', function (submission $submission) { - $exists_params = array( + $exists_params = [ 'courseworkid' => $submission->courseworkid, 'allocatableid' => $submission->allocatableid, 'allocatabletype' => $submission->allocatabletype, - ); + ]; if (submission::exists($exists_params)) { $this->set_message('Submission already exists'); return true; @@ -383,8 +383,8 @@ protected function allow_show_submission_if_user_has_previously_added_feedback_f $this->allow('show', 'mod_coursework\models\submission', function (submission $submission) { - return feedback::exists(array('submissionid' => $submission->id, - 'assessorid' => $this->get_user()->id())); + return feedback::exists(['submissionid' => $submission->id, + 'assessorid' => $this->get_user()->id()]); }); } @@ -1102,8 +1102,8 @@ protected function allow_show_grading_table_row_if_user_has_added_feedback_for_t 'mod_coursework\grading_table_row_base', function (grading_table_row_base $grading_table_row) { if ($grading_table_row->has_submission()) { - if (feedback::exists(array('submissionid' => $grading_table_row->get_submission()->id, - 'assessorid' => $this->get_user()->id())) + if (feedback::exists(['submissionid' => $grading_table_row->get_submission()->id, + 'assessorid' => $this->get_user()->id()]) ) { return true; } @@ -1253,11 +1253,11 @@ private function prevent_new_deadline_extension_if_already_exists() { $this->prevent('new', 'mod_coursework\models\deadline_extension', function (deadline_extension $deadline_extension) { - $conditions = array( + $conditions = [ 'allocatableid' => $deadline_extension->allocatableid, 'allocatabletype' => $deadline_extension->allocatabletype, 'courseworkid' => $deadline_extension->courseworkid, - ); + ]; return deadline_extension::exists($conditions); }); } diff --git a/classes/allocation/auto_allocator.php b/classes/allocation/auto_allocator.php index 97b65961..72b62169 100644 --- a/classes/allocation/auto_allocator.php +++ b/classes/allocation/auto_allocator.php @@ -120,7 +120,7 @@ private function delete_all_ungraded_auto_allocations() { AND s.courseworkid = p.courseworkid AND f.stage_identifier = p.stage_identifier ) - ', array('courseworkid' => $this->get_coursework()->id)); + ', ['courseworkid' => $this->get_coursework()->id]); foreach ($ungraded_allocations as &$allocation) { /** diff --git a/classes/allocation/manager.php b/classes/allocation/manager.php index 96adfde9..cb31d5f0 100644 --- a/classes/allocation/manager.php +++ b/classes/allocation/manager.php @@ -123,7 +123,7 @@ public static function get_allocation_classnames($type = coursework::ASSESSOR) { // move 'none' to be the first option if (array_key_exists('none', $options)) { - $new_value = array('none' => $options['none']); + $new_value = ['none' => $options['none']]; unset($options['none']); $options = $new_value + $options; } @@ -191,8 +191,8 @@ public function auto_generate_moderation_set() { * @return array */ public function get_sampling_options() { - return array('0' => get_string('manual', 'mod_coursework'), - '1' => get_string('automatic', 'mod_coursework')); + return ['0' => get_string('manual', 'mod_coursework'), + '1' => get_string('automatic', 'mod_coursework')]; } @@ -206,7 +206,7 @@ public function get_sampling_set_rules() { global $DB; // Get rules for include sets. - $params = array('courseworkid' => $this->coursework->id); + $params = ['courseworkid' => $this->coursework->id]; $rules = $DB->get_records('coursework_mod_set_rules', $params, 'ruleorder'); foreach ($rules as $key => &$rule) { @@ -263,7 +263,7 @@ public function save_sample_set_rule($assessor_number) { public function save_sample() { global $DB; - $DB->delete_records('coursework_sample_set_rules', array('courseworkid' => $this->coursework->id)); + $DB->delete_records('coursework_sample_set_rules', ['courseworkid' => $this->coursework->id]); for ($i = 2; $i <= $this->coursework->get_max_markers(); $i++) { $sample_strategy = required_param("assessor_{$i}_samplingstrategy", PARAM_INT); @@ -317,7 +317,7 @@ public function auto_generate_sample_set() { AND stage_identifier = :stage ORDER BY ruleorder)a"; - if ($sampleplugins = $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage))) { + if ($sampleplugins = $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id, 'stage' => $stage])) { //$allocatables = $this->get_coursework()->get_allocatables_with_feedback(); $allocatables = $this->get_coursework()->get_allocatables(); @@ -383,7 +383,7 @@ public function get_include_in_sample_set($stage_number) { // Get all users in manually selected for stage in coursework return $DB->get_records_sql($sql, - array('courseworkid' => $this->coursework->id, 'stage_identifier' => $stage)); + ['courseworkid' => $this->coursework->id, 'stage_identifier' => $stage]); } @@ -404,7 +404,7 @@ public function get_automatic_with_feedback($stage) { AND f.stage_identifier = m.stage_identifier "; - return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage)); + return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id, 'stage' => $stage]); } public function remove_unmarked_automatic_allocatables($stage) { @@ -440,7 +440,7 @@ public function get_allocatables_with_final_agreed() { WHERE s.courseworkid = {$this->coursework->id} AND f.stage_identifier = 'final_agreed_1'"; - return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id)); + return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id]); } diff --git a/classes/allocation/strategy/base.php b/classes/allocation/strategy/base.php index bd162c24..3bc982c8 100644 --- a/classes/allocation/strategy/base.php +++ b/classes/allocation/strategy/base.php @@ -54,10 +54,10 @@ abstract class base { /** * @var array the columns in the DB */ - protected $fields = array( + protected $fields = [ 'id', 'courseworkid', - ); + ]; /** * Holds the config settings to avoid repeated DB calls. @@ -143,12 +143,12 @@ final protected function get_existing_config_data($type = 'assessor', $reset = f global $DB; if (!isset($this->settings[$type]) || $reset) { - $params = array( + $params = [ 'courseworkid' => $this->coursework->id, 'allocationstrategy' => $this->get_name(), 'purpose' => $type, - ); + ]; $this->settings[$type] = $DB->get_records('coursework_allocation_config', $params); } @@ -169,12 +169,12 @@ protected function get_type() { * @return bool */ protected function teacher_already_has_an_allocation_for_this_allocatable($student, $teacher) { - $params = array( + $params = [ 'courseworkid' => $this->coursework->id, 'allocatableid' => $student->id(), 'allocatabletype' => $student->type(), 'assessorid' => $teacher->id, - ); + ]; return allocation::exists($params); } @@ -183,10 +183,10 @@ protected function teacher_already_has_an_allocation_for_this_allocatable($stude * @return int */ protected function number_of_existing_allocations_teacher_has($teacher) { - $params = array( + $params = [ 'courseworkid' => $this->coursework->id, 'assessorid' => $teacher->id, - ); + ]; return allocation::count($params); } diff --git a/classes/allocation/strategy/percentages.php b/classes/allocation/strategy/percentages.php index 90b7f098..b9db109b 100644 --- a/classes/allocation/strategy/percentages.php +++ b/classes/allocation/strategy/percentages.php @@ -102,10 +102,10 @@ public function add_form_elements($strategypurpose = 'assessor') { } } - $attributes = array( + $attributes = [ 'name' => 'assessorstrategy'.$this->get_name().'['.$teacher->id.']', 'size' => 3, - ); + ]; if ($currentsetting) { $attributes['value'] = $currentsetting->value; } @@ -155,12 +155,12 @@ public function save_allocation_strategy_options() { if (!is_numeric($value)) { // Empty or duff - make sure we delete any existing record. - $params = array( + $params = [ 'courseworkid' => $this->coursework->id, 'allocationstrategy' => $this->get_name(), 'assessorid' => $teacherid, 'purpose' => 'assessor', - ); + ]; $DB->delete_records('coursework_allocation_config', $params); continue; } @@ -202,13 +202,13 @@ private function percentage_for_teacher($teacher) { global $DB; - $params = array( + $params = [ 'courseworkid' => $this->coursework->id, 'allocationstrategy' => $this->get_name(), 'purpose' => $this->get_type(), 'assessorid' => $teacher->id, - ); + ]; $setting = $DB->get_field('coursework_allocation_config', 'value', $params); return $setting ? $setting : 0; // Default to 0 percent. diff --git a/classes/allocation/table/cell/builder.php b/classes/allocation/table/cell/builder.php index 6ffeb3a3..ff446a63 100644 --- a/classes/allocation/table/cell/builder.php +++ b/classes/allocation/table/cell/builder.php @@ -300,9 +300,9 @@ private function sampling_set_checkbox() { $checkbox_title = 'Included in sample'; - $attributes = array('class' => 'sampling_set_checkbox', + $attributes = ['class' => 'sampling_set_checkbox', 'id' => $this->get_allocatable()->type().'_' . $this->get_allocatable()->id() . '_'.$this->get_stage()->identifier() .'_samplecheckbox', - 'title' => $checkbox_title); + 'title' => $checkbox_title]; // if agreed grade given or grade published to students disable remaining sampling checkbox $submission = $this->get_submission(); @@ -329,9 +329,9 @@ private function sampling_hidden_checkbox() { 1, 1, '', - array('class' => 'sampling_set_checkbox', + ['class' => 'sampling_set_checkbox', 'id' => $this->get_allocatable()->type().'_' . $this->get_allocatable()->id() . '_'.$this->get_stage()->identifier() .'_samplecheckbox', - 'title' => $checkbox_title, 'hidden' => true)); + 'title' => $checkbox_title, 'hidden' => true]); } /** @@ -344,10 +344,10 @@ private function has_automatic_sampling() { global $DB; - $params = array('courseworkid' => $this->coursework->id(), + $params = ['courseworkid' => $this->coursework->id(), 'allocatableid' => $this->get_allocatable()->id(), 'stage_identifier' => $this->get_stage()->identifier(), - 'selectiontype' => 'automatic'); + 'selectiontype' => 'automatic']; return $DB->record_exists('coursework_sample_set_mbrs', $params); } @@ -374,8 +374,8 @@ private function pinned_checkbox() { 1, $checkbox_checked, '', - array('class' => "pinned pin_$stage", - 'title' => $checkbox_title)); + ['class' => "pinned pin_$stage", + 'title' => $checkbox_title]); } private function checkbox_checked_in_session($checkboxname, $checkboxstate) { @@ -414,7 +414,7 @@ private function stage_does_not_use_allocation() { * @throws \coding_exception */ private function get_included_in_sample_label() { - return \html_writer::label(get_string('includedinsample', 'mod_coursework'), null, true, array('class' => 'included_in_sample')); + return \html_writer::label(get_string('includedinsample', 'mod_coursework'), null, true, ['class' => 'included_in_sample']); } /** @@ -422,7 +422,7 @@ private function get_included_in_sample_label() { * @throws \coding_exception */ private function get_automatically_in_sample_label() { - return \html_writer::label(get_string('automaticallyinsample', 'mod_coursework'), null, true, array('class' => 'included_in_sample')); + return \html_writer::label(get_string('automaticallyinsample', 'mod_coursework'), null, true, ['class' => 'included_in_sample']); } /** diff --git a/classes/allocation/table/cell/processor.php b/classes/allocation/table/cell/processor.php index f009d81a..48d45d52 100644 --- a/classes/allocation/table/cell/processor.php +++ b/classes/allocation/table/cell/processor.php @@ -173,10 +173,10 @@ private function has_automatic_sampling() { global $DB; - $params = array('courseworkid' => $this->coursework->id(), + $params = ['courseworkid' => $this->coursework->id(), 'allocatableid' => $this->get_allocatable()->id(), 'stage_identifier' => $this->get_stage()->identifier(), - 'selectiontype' => 'automatic'); + 'selectiontype' => 'automatic']; return $DB->record_exists('coursework_sample_set_mbrs', $params); } diff --git a/classes/allocation/upload.php b/classes/allocation/upload.php index 625c993a..e7422523 100644 --- a/classes/allocation/upload.php +++ b/classes/allocation/upload.php @@ -81,7 +81,7 @@ public function validate_csv($content, $encoding, $delimeter) { $assessors = array_keys($assessors); // keep only assessors' ids $allocatablesinfile = []; - $csv_cells = array('allocatable'); + $csv_cells = ['allocatable']; $stages = $this->coursework->get_max_markers(); for ($i = 1; $i <= $stages; $i++) { $csv_cells[] = 'assessor_'.$i; @@ -106,12 +106,12 @@ public function validate_csv($content, $encoding, $delimeter) { if ($allocatabletype == 'user') { // get user id - $suballocatable = $DB->get_record('user', array($assessor_identifier => $value)); + $suballocatable = $DB->get_record('user', [$assessor_identifier => $value]); $allocatable = ($suballocatable) ? \mod_coursework\models\user::find($suballocatable->id) : ''; } else { // get group id - $suballocatable = $DB->get_record('groups', array('courseid' => $this->coursework->course, - 'name' => $value)); + $suballocatable = $DB->get_record('groups', ['courseid' => $this->coursework->course, + 'name' => $value]); $allocatable = ($suballocatable) ? \mod_coursework\models\group::find($suballocatable->id) : ''; } @@ -134,7 +134,7 @@ public function validate_csv($content, $encoding, $delimeter) { continue; } - $assessor = $DB->get_record('user', array($assessor_identifier => $value)); + $assessor = $DB->get_record('user', [$assessor_identifier => $value]); if (!$assessor ||!in_array($assessor->id, $assessors)) { $errors[$s] = get_string('assessornotincoursework', 'coursework', $keynum ); continue; @@ -196,7 +196,7 @@ public function process_csv($content, $encoding, $delimiter, $processingresults) $csvreader->init(); $s = 0; - $csv_cells = array('allocatable'); + $csv_cells = ['allocatable']; $stages = $this->coursework->get_max_markers(); for ($i = 1; $i <= $stages; $i++) { $csv_cells[] = 'assessor_'.$i; @@ -225,23 +225,23 @@ public function process_csv($content, $encoding, $delimiter, $processingresults) if ($cells[$keynum] == 'allocatable') { if ($allocatabletype == 'user') { // get user id - $suballocatable = $DB->get_record('user', array($assessor_identifier => $value)); + $suballocatable = $DB->get_record('user', [$assessor_identifier => $value]); $allocatable = ($suballocatable) ? \mod_coursework\models\user::find($suballocatable->id) : ''; } else { // get group id - $suballocatable = $DB->get_record('groups', array('courseid' => $this->coursework->course, - 'name' => $value)); + $suballocatable = $DB->get_record('groups', ['courseid' => $this->coursework->course, + 'name' => $value]); $allocatable = ($suballocatable) ? \mod_coursework\models\group::find($suballocatable->id) : ''; } } if (substr($cells[$keynum], 0, 8) == 'assessor' && !(empty($value))) { - $assessor = $DB->get_record('user', array($assessor_identifier => $value)); + $assessor = $DB->get_record('user', [$assessor_identifier => $value]); - $params = array('courseworkid' => $this->coursework->id, + $params = ['courseworkid' => $this->coursework->id, 'allocatableid' => $allocatable->id, 'allocatabletype' => $allocatabletype, - 'stage_identifier' => $cells[$keynum]); + 'stage_identifier' => $cells[$keynum]]; $allocation = $DB->get_record('coursework_allocation_pairs', $params); @@ -251,9 +251,9 @@ public function process_csv($content, $encoding, $delimiter, $processingresults) } else { // update allocation if submission was not marked yet - $subdbrecord = $DB->get_record('coursework_submissions', array('courseworkid' => $this->coursework->id, + $subdbrecord = $DB->get_record('coursework_submissions', ['courseworkid' => $this->coursework->id, 'allocatabletype' => $allocatabletype, - 'allocatableid' => $allocatable->id)); + 'allocatableid' => $allocatable->id]); $submission = \mod_coursework\models\submission::find($subdbrecord); if (!$submission || !$submission->get_assessor_feedback_by_stage($cells[$keynum])) { diff --git a/classes/assessor_feedback_row.php b/classes/assessor_feedback_row.php index be98e9b5..f45a965e 100644 --- a/classes/assessor_feedback_row.php +++ b/classes/assessor_feedback_row.php @@ -194,11 +194,11 @@ public function get_submission() { if (isset($this->submission)) { return $this->submission; } - $params = array( + $params = [ 'courseworkid' => $this->get_coursework()->id, 'allocatableid' => $this->get_allocatable()->id(), 'allocatabletype' => $this->get_allocatable()->type(), - ); + ]; $this->submission = submission::find($params); return $this->submission; } diff --git a/classes/auto_grader/average_grade.php b/classes/auto_grader/average_grade.php index 46114cd3..1b309537 100644 --- a/classes/auto_grader/average_grade.php +++ b/classes/auto_grader/average_grade.php @@ -132,12 +132,12 @@ private function get_allocatable() { * */ private function create_final_feedback() { - feedback::create(array( + feedback::create([ 'stage_identifier' => 'final_agreed_1', 'submissionid' => $this->get_allocatable()->get_submission($this->get_coursework())->id(), 'grade' => $this->automatic_grade(), - )); + ]); } /** diff --git a/classes/auto_grader/percentage_distance.php b/classes/auto_grader/percentage_distance.php index 4f59a389..ab4645d5 100644 --- a/classes/auto_grader/percentage_distance.php +++ b/classes/auto_grader/percentage_distance.php @@ -130,12 +130,12 @@ private function get_allocatable() { * */ private function create_final_feedback() { - feedback::create(array( + feedback::create([ 'stage_identifier' => 'final_agreed_1', 'submissionid' => $this->get_allocatable()->get_submission($this->get_coursework())->id(), 'grade' => $this->automatic_grade(), - )); + ]); } /** diff --git a/classes/calendar.php b/classes/calendar.php index 1ebcefb1..d2489124 100644 --- a/classes/calendar.php +++ b/classes/calendar.php @@ -56,15 +56,15 @@ public static function coursework_event(object $coursework, string $eventtype, ? // to support module events with file areas. $intro = strip_pluginfile_content($intro); if ($cm->showdescription) { - $event->description = array( + $event->description = [ 'text' => $intro, 'format' => $coursework->introformat, - ); + ]; } else { - $event->description = array( + $event->description = [ 'text' => '', 'format' => $coursework->introformat, - ); + ]; } $event->courseid = $coursework->course; @@ -92,7 +92,7 @@ public static function coursework_event(object $coursework, string $eventtype, ? public static function remove_event($coursework, $eventtype = '') { global $DB; - $params = array('modulename' => 'coursework', 'instance' => $coursework->id); + $params = ['modulename' => 'coursework', 'instance' => $coursework->id]; if ($eventtype) { $params['eventtype'] = $eventtype; diff --git a/classes/controllers/controller_base.php b/classes/controllers/controller_base.php index a5c4f745..5aa00a96 100644 --- a/classes/controllers/controller_base.php +++ b/classes/controllers/controller_base.php @@ -111,7 +111,7 @@ protected function prepare_environment() { } if (!empty($this->params['courseworkid'])) { - $coursework = $DB->get_record('coursework', array('id' => $this->params['courseworkid']), '*', MUST_EXIST); + $coursework = $DB->get_record('coursework', ['id' => $this->params['courseworkid']], '*', MUST_EXIST); $this->coursework = coursework::find($coursework); $this->coursemodule = get_coursemodule_from_instance('coursework', $this->coursework->id); @@ -131,7 +131,7 @@ protected function prepare_environment() { if (empty($this->course)) { if (!empty($this->params['courseid'])) { - $this->course = $DB->get_record('course', array('id' => $this->params['courseid']), '*', MUST_EXIST); + $this->course = $DB->get_record('course', ['id' => $this->params['courseid']], '*', MUST_EXIST); } if (!empty($this->coursework)) { @@ -172,8 +172,8 @@ public function __call($method_name, $arguments) { if (method_exists($this, $method_name)) { $this->prepare_environment(); - call_user_func(array($this, - $method_name)); + call_user_func([$this, + $method_name]); } else { throw new coding_exception('No page defined in the controller called "'.$method_name.'"'); } @@ -195,7 +195,7 @@ protected function get_context() { */ protected function get_path($path_name, $items) { - return call_user_func_array(array($this->get_router(), 'get_path'), func_get_args()); + return call_user_func_array([$this->get_router(), 'get_path'], func_get_args()); } diff --git a/classes/controllers/deadline_extensions_controller.php b/classes/controllers/deadline_extensions_controller.php index bf0d86d5..19ddd679 100644 --- a/classes/controllers/deadline_extensions_controller.php +++ b/classes/controllers/deadline_extensions_controller.php @@ -63,7 +63,7 @@ protected function new_deadline_extension() { $PAGE->set_url('/mod/coursework/actions/deadline_extensions/new.php', $params); $create_url = $this->get_router()->get_path('create deadline extension'); - $this->form = new deadline_extension_form($create_url, array('coursework' => $this->coursework)); + $this->form = new deadline_extension_form($create_url, ['coursework' => $this->coursework]); $this->form->set_data($this->deadline_extension); $this->render_page('new'); @@ -74,8 +74,8 @@ protected function create_deadline_extension() { global $USER; $create_url = $this->get_router()->get_path('create deadline extension'); - $this->form = new deadline_extension_form($create_url, array('coursework' => $this->coursework)); - $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework)); + $this->form = new deadline_extension_form($create_url, ['coursework' => $this->coursework]); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $this->coursework]); if ($this->cancel_button_was_pressed()) { redirect($coursework_page_url); } @@ -103,9 +103,9 @@ protected function create_deadline_extension() { protected function edit_deadline_extension() { global $USER, $PAGE; - $params = array( + $params = [ 'id' => $this->params['id'], - ); + ]; $this->deadline_extension = deadline_extension::find($params); $ability = new ability(user::find($USER), $this->coursework); @@ -114,11 +114,11 @@ protected function edit_deadline_extension() { $PAGE->set_url('/mod/coursework/actions/deadline_extensions/edit.php', $params); $update_url = $this->get_router()->get_path('update deadline extension'); - $this->form = new deadline_extension_form($update_url, array('coursework' => $this->coursework)); - $this->deadline_extension->extra_information = array( + $this->form = new deadline_extension_form($update_url, ['coursework' => $this->coursework]); + $this->deadline_extension->extra_information = [ 'text' => $this->deadline_extension->extra_information_text, 'format' => $this->deadline_extension->extra_information_format, - ); + ]; $this->form->set_data($this->deadline_extension); $this->render_page('edit'); @@ -128,8 +128,8 @@ protected function update_deadline_extension() { global $USER; $update_url = $this->get_router()->get_path('update deadline extension'); - $this->form = new deadline_extension_form($update_url, array('coursework' => $this->coursework)); - $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework)); + $this->form = new deadline_extension_form($update_url, ['coursework' => $this->coursework]); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $this->coursework]); if ($this->cancel_button_was_pressed()) { redirect($coursework_page_url); } @@ -158,11 +158,11 @@ protected function update_deadline_extension() { */ protected function set_default_current_deadline() { global $DB; - $params = array( + $params = [ 'allocatableid' => $this->params['allocatableid'], 'allocatabletype' => $this->params['allocatabletype'], 'courseworkid' => $this->params['courseworkid'], - ); + ]; $this->deadline_extension = deadline_extension::build($params); // Default to current deadline // check for personal deadline first o @@ -243,11 +243,11 @@ public function validation($data) { public function submission_exists($data) { global $DB; - return $DB->record_exists('coursework_submissions', array( + return $DB->record_exists('coursework_submissions', [ 'courseworkid' => $data['courseworkid'], 'allocatableid' => $data['allocatableid'], 'allocatabletype' => $data['allocatabletype'], - )); + ]); } public function personal_deadline() { @@ -256,7 +256,7 @@ public function personal_deadline() { $extensionid = optional_param('id', 0, PARAM_INT); if ($extensionid != 0) { - $ext = $DB->get_record('coursework_extensions', array('id' => $extensionid)); + $ext = $DB->get_record('coursework_extensions', ['id' => $extensionid]); $allocatableid = $ext->allocatableid; $allocatabletype = $ext->allocatabletype; $courseworkid = $ext->courseworkid; @@ -267,11 +267,11 @@ public function personal_deadline() { $courseworkid = required_param('courseworkid', PARAM_INT); } - $params = array( + $params = [ 'allocatableid' => $allocatableid ?? 0, 'allocatabletype' => $allocatabletype ?? 0, 'courseworkid' => $courseworkid ?? 0, - ); + ]; return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); } @@ -343,11 +343,11 @@ public function ajax_new_mitigation($data_params) { ); require_login($this->coursework->course, false, $cm); - $params = array( + $params = [ 'allocatableid' => $this->params['allocatableid'], 'allocatabletype' => $this->params['allocatabletype'], 'courseworkid' => $this->params['courseworkid'], - ); + ]; $ability = new ability(user::find($USER), $this->coursework); $deadline_extension = deadline_extension::build($params); @@ -397,7 +397,7 @@ public function table_cell_response($data_params) { $row_object = new \mod_coursework\grading_table_row_single($coursework, $participant); } - $time_submitted_cell = new \mod_coursework\render_helpers\grading_report\cells\time_submitted_cell(array('coursework' => $this->coursework)); + $time_submitted_cell = new \mod_coursework\render_helpers\grading_report\cells\time_submitted_cell(['coursework' => $this->coursework]); $content = $time_submitted_cell->prepare_content_cell($row_object); diff --git a/classes/controllers/grading_controller.php b/classes/controllers/grading_controller.php index 6548460e..b3a39bf5 100644 --- a/classes/controllers/grading_controller.php +++ b/classes/controllers/grading_controller.php @@ -33,7 +33,7 @@ class grading_controller extends controller_base { public function get_remain_rows_grading_table($options) { global $DB, $PAGE; - $coursework_record = $DB->get_record('coursework', array('id' => $options['courseworkid']), '*', MUST_EXIST); + $coursework_record = $DB->get_record('coursework', ['id' => $options['courseworkid']], '*', MUST_EXIST); //$coursework = mod_coursework\models\coursework::find($coursework_record); $coursework = coursework::find($coursework_record, false); diff --git a/classes/controllers/moderations_controller.php b/classes/controllers/moderations_controller.php index d80c822c..18f771ce 100644 --- a/classes/controllers/moderations_controller.php +++ b/classes/controllers/moderations_controller.php @@ -101,12 +101,12 @@ protected function edit_moderation() { $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('edit', $moderation); - $urlparams = array('moderationid' => $this->params['moderationid']); + $urlparams = ['moderationid' => $this->params['moderationid']]; $PAGE->set_url('/mod/coursework/actions/moderations/edit.php', $urlparams); - $moderator = $DB->get_record('user', array('id' => $moderation->moderatorid)); + $moderator = $DB->get_record('user', ['id' => $moderation->moderatorid]); if (!empty($moderation->lasteditedby)) { - $editor = $DB->get_record('user', array('id' => $moderation->lasteditedby)); + $editor = $DB->get_record('user', ['id' => $moderation->lasteditedby]); } else { $editor = $moderator; } @@ -132,20 +132,20 @@ protected function create_moderation() { $moderatoragreement->feedbackid = $this->params['feedbackid']; $submission = submission::find($this->params['submissionid']); - $path_params = array( + $path_params = [ 'submission' => $submission, 'moderator' => \core_user::get_user($this->params['moderatorid']), 'stage' => 'moderator', - ); + ]; $url = $this->get_router()->get_path('new moderation', $path_params, true); $PAGE->set_url($url); $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('new', $moderatoragreement); - $form = new moderator_agreement_mform(null, array('moderation' => $moderatoragreement)); + $form = new moderator_agreement_mform(null, ['moderation' => $moderatoragreement]); - $coursework_page_url = $this->get_path('coursework', array('coursework' => $moderatoragreement->get_coursework())); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $moderatoragreement->get_coursework()]); if ($form->is_cancelled()) { redirect($coursework_page_url); } @@ -178,9 +178,9 @@ protected function update_moderation() { $this->check_stage_permissions($moderatoragreement->stage_identifier); - $form = new moderator_agreement_mform(null, array('moderation' => $moderatoragreement)); + $form = new moderator_agreement_mform(null, ['moderation' => $moderatoragreement]); - $coursework_page_url = $this->get_path('coursework', array('coursework' => $moderatoragreement->get_coursework())); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $moderatoragreement->get_coursework()]); if ($form->is_cancelled()) { redirect($coursework_page_url); } @@ -200,7 +200,7 @@ protected function update_moderation() { protected function show_moderation() { global $PAGE, $USER; - $urlparams = array('moderationid' => $this->params['moderationid']); + $urlparams = ['moderationid' => $this->params['moderationid']]; $PAGE->set_url('/mod/coursework/actions/moderations/show.php', $urlparams); $moderation = new moderation($this->params['moderationid']); @@ -220,7 +220,7 @@ protected function prepare_environment() { if (!empty($this->params['feedbackid'])) { $feedback = $DB->get_record('coursework_feedbacks', - array('id' => $this->params['feedbackid']), + ['id' => $this->params['feedbackid']], '*', MUST_EXIST); $this->feedback = new feedback($feedback); @@ -229,7 +229,7 @@ protected function prepare_environment() { if (!empty($this->params['submissionid'])) { $submission = $DB->get_record('coursework_submissions', - array('id' => $this->params['submissionid']), + ['id' => $this->params['submissionid']], '*', MUST_EXIST); $this->submission = submission::find($submission); @@ -238,7 +238,7 @@ protected function prepare_environment() { if (!empty($this->params['moderationid'])) { $moderation = $DB->get_record('coursework_mod_agreements', - array('id' => $this->params['moderationid']), + ['id' => $this->params['moderationid']], '*', MUST_EXIST); $this->moderation = moderation::find($moderation); diff --git a/classes/controllers/personal_deadlines_controller.php b/classes/controllers/personal_deadlines_controller.php index be1a73ec..63842e27 100644 --- a/classes/controllers/personal_deadlines_controller.php +++ b/classes/controllers/personal_deadlines_controller.php @@ -42,8 +42,8 @@ class personal_deadlines_controller extends controller_base { protected function new_personal_deadline() { global $USER, $PAGE; - $coursework_page_url = (empty($this->params['setpersonaldeadlinespage'])) ? $this->get_path('coursework', array('coursework' => $this->coursework)) : - $this->get_path('set personal deadlines', array('coursework' => $this->coursework)); + $coursework_page_url = (empty($this->params['setpersonaldeadlinespage'])) ? $this->get_path('coursework', ['coursework' => $this->coursework]) : + $this->get_path('set personal deadlines', ['coursework' => $this->coursework]); $params = $this->set_default_current_deadline(); $ability = new ability(user::find($USER), $this->coursework); @@ -56,7 +56,7 @@ protected function new_personal_deadline() { $PAGE->set_url('/mod/coursework/actions/personal_deadline/new.php', $params); $create_url = $this->get_router()->get_path('edit personal deadline'); - $this->form = new personal_deadline_form($create_url, array('coursework' => $this->coursework)); + $this->form = new personal_deadline_form($create_url, ['coursework' => $this->coursework]); $this->personal_deadline->setpersonaldeadlinespage = $this->params['setpersonaldeadlinespage']; $this->personal_deadline->multipleuserdeadlines = $this->params['multipleuserdeadlines']; @@ -89,11 +89,11 @@ protected function new_personal_deadline() { $data->allocatableid = $allocatableid; $data->id = ''; //$data->id = ''; - $findparams = array( + $findparams = [ 'allocatableid' => $allocatableid, 'allocatabletype' => $data->allocatabletype, 'courseworkid' => $data->courseworkid, - ); + ]; $this->personal_deadline = personal_deadline::find_or_build($findparams); if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist @@ -125,11 +125,11 @@ protected function new_personal_deadline() { * @return array */ protected function set_default_current_deadline() { - $params = array( + $params = [ 'allocatableid' => $this->params['allocatableid'], 'allocatabletype' => $this->params['allocatabletype'], 'courseworkid' => $this->params['courseworkid'], - ); + ]; // If the allocatableid is an array then the current page will probably be setting multiple the personal deadlines // We use the first element in the array to setup the personal deadline object @@ -155,11 +155,11 @@ protected function set_default_current_deadline() { */ protected function get_personal_deadline() { global $DB; - $params = array( + $params = [ 'allocatableid' => $this->params['allocatableid'], 'allocatabletype' => $this->params['allocatabletype'], 'courseworkid' => $this->params['courseworkid'], - ); + ]; return $DB->get_record('coursework_person_deadlines', $params); } @@ -215,11 +215,11 @@ public function insert_update($time) { $data->allocatableid = $allocatableid; $data->id = ''; //$data->id = ''; - $findparams = array( + $findparams = [ 'allocatableid' => $allocatableid, 'allocatabletype' => $data->allocatabletype, 'courseworkid' => $data->courseworkid, - ); + ]; $this->personal_deadline = personal_deadline::find_or_build($findparams); if (empty($this->personal_deadline->personal_deadline)) { // personal deadline doesnt exist diff --git a/classes/controllers/plagiarism_flagging_controller.php b/classes/controllers/plagiarism_flagging_controller.php index c08c6abd..6253f195 100644 --- a/classes/controllers/plagiarism_flagging_controller.php +++ b/classes/controllers/plagiarism_flagging_controller.php @@ -93,12 +93,12 @@ protected function edit_plagiarism_flag() { $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('edit', $plagiarism_flag); - $urlparams = array('flagid' => $this->params['flagid']); + $urlparams = ['flagid' => $this->params['flagid']]; $PAGE->set_url('/mod/coursework/actions/plagiarism_flagging/edit.php', $urlparams); - $creator = $DB->get_record('user', array('id' => $plagiarism_flag->createdby)); + $creator = $DB->get_record('user', ['id' => $plagiarism_flag->createdby]); if (!empty($plagiarism_flag->lastmodifiedby)) { - $editor = $DB->get_record('user', array('id' => $plagiarism_flag->lastmodifiedby)); + $editor = $DB->get_record('user', ['id' => $plagiarism_flag->lastmodifiedby]); } else { $editor = $creator; } @@ -120,16 +120,16 @@ protected function create_plagiarism_flag() { $plagiarismflag->createdby = $USER->id; $submission = submission::find($this->params['submissionid']); - $path_params = array('submission' => $submission); + $path_params = ['submission' => $submission]; $url = $this->get_router()->get_path('new plagiarism flag', $path_params, true); $PAGE->set_url($url); $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('new', $plagiarismflag); - $form = new plagiarism_flagging_mform(null, array('plagiarism_flag' => $plagiarismflag)); + $form = new plagiarism_flagging_mform(null, ['plagiarism_flag' => $plagiarismflag]); - $coursework_page_url = $this->get_path('coursework', array('coursework' => $plagiarismflag->get_coursework())); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $plagiarismflag->get_coursework()]); if ($form->is_cancelled()) { redirect($coursework_page_url); } @@ -161,9 +161,9 @@ protected function update_plagiarism_flag() { $ability = new ability(user::find($USER), $this->coursework); $ability->require_can('edit', $plagiarismflag); - $form = new plagiarism_flagging_mform(null, array('plagiarism_flag' => $plagiarismflag)); + $form = new plagiarism_flagging_mform(null, ['plagiarism_flag' => $plagiarismflag]); - $coursework_page_url = $this->get_path('coursework', array('coursework' => $plagiarismflag->get_coursework())); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $plagiarismflag->get_coursework()]); if ($form->is_cancelled()) { redirect($coursework_page_url); } @@ -171,19 +171,19 @@ protected function update_plagiarism_flag() { $plagiarismflag = $form->process_data($plagiarismflag); // add to log here - $oldstatus = $DB->get_field(plagiarism_flag::get_table_name(), 'status', array('id' => $flagid)); // Retrieve old status before saving new - $params = array( + $oldstatus = $DB->get_field(plagiarism_flag::get_table_name(), 'status', ['id' => $flagid]); // Retrieve old status before saving new + $params = [ 'context' => \context_module::instance($this->coursework->get_course_module()->id), 'courseid' => $this->coursework->get_course()->id, 'objectid' => $this->coursework->id, - 'other' => array( + 'other' => [ 'courseworkid' => $this->coursework->id, 'submissionid' => $plagiarismflag->submissionid, 'flagid' => $flagid, 'oldstatus' => $oldstatus, 'newstatus' => $plagiarismflag->status, - ), - ); + ], + ]; $event = \mod_coursework\event\coursework_plagiarism_flag_updated::create($params); $event->trigger(); @@ -201,7 +201,7 @@ protected function prepare_environment() { if (!empty($this->params['flagid'])) { $plagiarism_flag = $DB->get_record('coursework_plagiarism_flags', - array('id' => $this->params['flagid']), + ['id' => $this->params['flagid']], '*', MUST_EXIST); $this->flag = new plagiarism_flag($plagiarism_flag); @@ -210,7 +210,7 @@ protected function prepare_environment() { if (!empty($this->params['submissionid'])) { $submission = $DB->get_record('coursework_submissions', - array('id' => $this->params['submissionid']), + ['id' => $this->params['submissionid']], '*', MUST_EXIST); $this->submission = submission::find($submission); @@ -219,7 +219,7 @@ protected function prepare_environment() { if (!empty($this->params['moderationid'])) { $moderation = $DB->get_record('coursework_mod_agreements', - array('id' => $this->params['moderationid']), + ['id' => $this->params['moderationid']], '*', MUST_EXIST); $this->moderation = moderation::find($moderation); diff --git a/classes/controllers/submissions_controller.php b/classes/controllers/submissions_controller.php index 9d9dac90..11a300bf 100644 --- a/classes/controllers/submissions_controller.php +++ b/classes/controllers/submissions_controller.php @@ -57,11 +57,11 @@ protected function new_submission() { $user = user::find($USER); $validation = false; - $submission = submission::build(array( + $submission = submission::build([ 'allocatableid' => $this->params['allocatableid'], 'allocatabletype' => $this->params['allocatabletype'], 'courseworkid' => $this->coursework->id, - 'createdby' => $user->id())); + 'createdby' => $user->id()]); $ability = new ability($user, $this->coursework); if (!$ability->can('new', $submission)) { @@ -70,15 +70,15 @@ protected function new_submission() { $this->check_coursework_is_open($this->coursework); - $urlparams = array('courseworkid' => $this->params['courseworkid']); + $urlparams = ['courseworkid' => $this->params['courseworkid']]; $PAGE->set_url('/mod/coursework/actions/submissions/new.php', $urlparams); - $path = $this->get_router()->get_path('create submission', array('coursework' => $this->coursework)); + $path = $this->get_router()->get_path('create submission', ['coursework' => $this->coursework]); $submit_form = new student_submission_form($path, - array( + [ 'coursework' => $this->coursework, 'submission' => $submission, - )); + ]); if ($submit_form->is_submitted()) { $validation = $submit_form->validate_defined_fields(); } @@ -95,7 +95,7 @@ protected function new_submission() { protected function create_submission() { global $USER, $CFG, $DB; - $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework)); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $this->coursework]); if ($this->cancel_button_was_pressed()) { redirect($coursework_page_url); } @@ -148,13 +148,13 @@ protected function create_submission() { $context = \context_module::instance($this->coursemodule->id); // Trigger assessable_submitted event to show files are complete. - $params = array( + $params = [ 'context' => $context, 'objectid' => $submission->id, - 'other' => array( + 'other' => [ 'courseworkid' => $this->coursework->id, - ), - ); + ], + ]; $event = assessable_submitted::create($params); $event->trigger(); @@ -174,7 +174,7 @@ protected function create_submission() { if (!empty($userids)) { foreach ($userids as $u) { - $notifyuser = $DB->get_record('user', array('id' => trim($u))); + $notifyuser = $DB->get_record('user', ['id' => trim($u)]); if (!empty($notifyuser)) { $mailer->send_submission_notification($notifyuser); @@ -208,15 +208,15 @@ protected function edit_submission() { throw new access_denied($this->coursework); } - $urlparams = array('submissionid' => $this->params['submissionid']); + $urlparams = ['submissionid' => $this->params['submissionid']]; $PAGE->set_url('/mod/coursework/actions/submissions/edit.php', $urlparams); - $path = $this->get_router()->get_path('update submission', array('submission' => $submission)); + $path = $this->get_router()->get_path('update submission', ['submission' => $submission]); $submit_form = new student_submission_form($path, - array( + [ 'coursework' => $this->coursework, 'submission' => $submission, - )); + ]); if ($submit_form->is_submitted()) { $validation = $submit_form->validate_defined_fields(); } @@ -236,7 +236,7 @@ protected function update_submission() { global $USER, $CFG; - $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework)); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $this->coursework]); if ($this->cancel_button_was_pressed()) { redirect($coursework_page_url); } @@ -271,13 +271,13 @@ protected function update_submission() { $context = \context_module::instance($this->coursemodule->id); // Trigger assessable_submitted event to show files are complete. - $params = array( + $params = [ 'context' => $context, 'objectid' => $submission->id, - 'other' => array( + 'other' => [ 'courseworkid' => $this->coursework->id, - ), - ); + ], + ]; $event = assessable_submitted::create($params); $event->trigger(); @@ -301,7 +301,7 @@ protected function finalise_submission() { global $USER; - $coursework_page_url = $this->get_path('coursework', array('coursework' => $this->coursework)); + $coursework_page_url = $this->get_path('coursework', ['coursework' => $this->coursework]); if ($this->cancel_button_was_pressed()) { redirect($coursework_page_url); } @@ -329,18 +329,18 @@ protected function unfinalise_submission() { global $USER, $DB; - $allocatableids = (!is_array($this->params['allocatableid'])) ? array($this->params['allocatableid']) : $this->params['allocatableid']; + $allocatableids = (!is_array($this->params['allocatableid'])) ? [$this->params['allocatableid']] : $this->params['allocatableid']; $personaldeadline_page_url = new \moodle_url('/mod/coursework/actions/personal_deadline.php', - array('id' => $this->coursework->get_coursemodule_id(), 'multipleuserdeadlines' => 1, 'setpersonaldeadlinespage' => 1, - 'courseworkid' => $this->params['courseworkid'], 'allocatabletype' => $this->params['allocatabletype'])); + ['id' => $this->coursework->get_coursemodule_id(), 'multipleuserdeadlines' => 1, 'setpersonaldeadlinespage' => 1, + 'courseworkid' => $this->params['courseworkid'], 'allocatabletype' => $this->params['allocatabletype']]); $changedeadlines = false; foreach ($allocatableids as $aid) { $submission_db = $DB->get_record('coursework_submissions', - array('courseworkid' => $this->params['courseworkid'], 'allocatableid' => $aid, 'allocatabletype' => $this->params['allocatabletype'])); + ['courseworkid' => $this->params['courseworkid'], 'allocatableid' => $aid, 'allocatabletype' => $this->params['allocatabletype']]); if (!empty($submission_db)) { $submission = \mod_coursework\models\submission::find($submission_db); @@ -358,7 +358,7 @@ protected function unfinalise_submission() { redirect($personaldeadline_page_url, get_string('unfinalisedchangesubmissiondate', 'mod_coursework')); } else { $setpersonaldeadline_page_url = new \moodle_url('/mod/coursework/actions/set_personal_deadlines.php', - array('id' => $this->coursework->get_coursemodule_id())); + ['id' => $this->coursework->get_coursemodule_id()]); redirect($setpersonaldeadline_page_url); } @@ -420,9 +420,9 @@ protected function submissions_exists($submission) { global $DB; $sub_exists = $DB->record_exists('coursework_submissions', - array('courseworkid' => $submission->courseworkid, + ['courseworkid' => $submission->courseworkid, 'allocatableid' => $submission->allocatableid, - 'allocatabletype' => $submission->allocatabletype)); + 'allocatabletype' => $submission->allocatabletype]); return $sub_exists; } @@ -436,9 +436,9 @@ protected function has_valid_extension($submission) { $valid_extension = false; $extension = $DB->get_record('coursework_extensions', - array('courseworkid' => $submission->courseworkid, + ['courseworkid' => $submission->courseworkid, 'allocatableid' => $submission->allocatableid, - 'allocatabletype' => $submission->allocatabletype)); + 'allocatabletype' => $submission->allocatabletype]); if ($extension) { if ($extension->extended_deadline > time()) { @@ -458,9 +458,9 @@ protected function has_valid_personal_deadline($submission) { $valid_personal_deadline = false; $personal_deadline = $DB->get_record('coursework_person_deadlines', - array('courseworkid' => $submission->courseworkid, + ['courseworkid' => $submission->courseworkid, 'allocatableid' => $submission->allocatableid, - 'allocatabletype' => $submission->allocatabletype)); + 'allocatabletype' => $submission->allocatabletype]); if ($personal_deadline) { if ($personal_deadline->personal_deadline > time()) { $valid_personal_deadline = true; diff --git a/classes/cron.php b/classes/cron.php index b04ee7df..049ade3f 100644 --- a/classes/cron.php +++ b/classes/cron.php @@ -69,10 +69,10 @@ private static function send_reminders_to_students() { global $CFG, $DB; - $counts = array( + $counts = [ 'emails' => 0, 'users' => 0, - ); + ]; $userswhoneedreminding = []; @@ -226,11 +226,11 @@ private static function send_first_reminders_to_admins() { foreach ($users as $user) { - if ($DB->record_exists('coursework_reminder', array( + if ($DB->record_exists('coursework_reminder', [ 'coursework_id' => $coursework_instance->id, 'userid' => $user->id, 'remindernumber' => 1, - ))) { + ])) { continue; } @@ -248,9 +248,9 @@ private static function send_first_reminders_to_admins() { $emailssent++; // Need to record this so they don;t get another one. - $number_of_existing_reminders = $DB->count_records('coursework_reminder', array('coursework_id' => $coursework_instance->id, + $number_of_existing_reminders = $DB->count_records('coursework_reminder', ['coursework_id' => $coursework_instance->id, 'userid' => $user->id, - )); + ]); $reminder = new stdClass(); $reminder->userid = $user->id; $reminder->coursework_id = $coursework_instance->id; @@ -395,7 +395,7 @@ private static function autorelease_feedbacks_where_the_release_date_has_passed( AND c.individualfeedback IS NOT NULL AND cs.firstpublished IS NULL"; - $coursework_submissions = $DB->get_records_sql($sql, array('now' => time())); + $coursework_submissions = $DB->get_records_sql($sql, ['now' => time()]); foreach ($coursework_submissions as $coursework_submission) { diff --git a/classes/event/assessable_uploaded.php b/classes/event/assessable_uploaded.php index fe25b149..98551bbb 100644 --- a/classes/event/assessable_uploaded.php +++ b/classes/event/assessable_uploaded.php @@ -58,7 +58,7 @@ public static function get_name() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/coursework/view.php', array('id' => $this->contextinstanceid)); + return new \moodle_url('/mod/coursework/view.php', ['id' => $this->contextinstanceid]); } /** @@ -82,6 +82,6 @@ protected function init() { } public static function get_objectid_mapping() { - return array('db' => 'coursework_submissions', 'restore' => 'submission'); + return ['db' => 'coursework_submissions', 'restore' => 'submission']; } } diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php index 185374ee..cb348115 100644 --- a/classes/event/course_module_viewed.php +++ b/classes/event/course_module_viewed.php @@ -39,7 +39,7 @@ protected function init() { * @return \moodle_url */ public function get_url() { - return new \moodle_url("/mod/$this->objecttable/view.php", array('id' => $this->contextinstanceid)); + return new \moodle_url("/mod/$this->objecttable/view.php", ['id' => $this->contextinstanceid]); } // You might need to override get_url() and get_legacy_log_data() if view mode needs to be stored as well. } diff --git a/classes/exceptions/access_denied.php b/classes/exceptions/access_denied.php index 2c8c0620..c79afc02 100644 --- a/classes/exceptions/access_denied.php +++ b/classes/exceptions/access_denied.php @@ -42,7 +42,7 @@ class access_denied extends \moodle_exception { */ public function __construct($coursework, $message = null) { - $link = router::instance()->get_path('coursework', array('coursework' => $coursework)); + $link = router::instance()->get_path('coursework', ['coursework' => $coursework]); parent::__construct('access_denied', 'mod_coursework', $link, null, $message); } diff --git a/classes/exceptions/late_submission.php b/classes/exceptions/late_submission.php index 07291198..3b191d0a 100644 --- a/classes/exceptions/late_submission.php +++ b/classes/exceptions/late_submission.php @@ -42,7 +42,7 @@ class late_submission extends \moodle_exception { */ public function __construct($coursework, $message = null) { - $link = router::instance()->get_path('coursework', array('coursework' => $coursework)); + $link = router::instance()->get_path('coursework', ['coursework' => $coursework]); parent::__construct('latesubmissionsnotallowed', 'mod_coursework', $link, null, $message); } diff --git a/classes/export/csv.php b/classes/export/csv.php index 704f9498..e431f76b 100644 --- a/classes/export/csv.php +++ b/classes/export/csv.php @@ -88,7 +88,7 @@ public function export() { $submissions = $this->get_submissions(); // sort submissions by lastname - usort($submissions, array($this, "sort_by_lastname")); + usort($submissions, [$this, "sort_by_lastname"]); // loop through each submission in the coursework foreach ($submissions as $submission) { diff --git a/classes/export/csv/cells/agreedfeedback_cell.php b/classes/export/csv/cells/agreedfeedback_cell.php index 9e2f3ea1..ed452c3a 100644 --- a/classes/export/csv/cells/agreedfeedback_cell.php +++ b/classes/export/csv/cells/agreedfeedback_cell.php @@ -56,13 +56,13 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo global $DB, $PAGE, $USER; $stage_identifier = 'final_agreed_1'; - $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', - 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade'); + $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', + 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade']; if (has_any_capability($agreedgradecap, $PAGE->context) || has_capability('mod/coursework:administergrades', $PAGE->context)) { - $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); + $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]); $submission = \mod_coursework\models\submission::find($subdbrecord); // Is the submission in question ready to grade? @@ -81,10 +81,10 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, - ); + ]; $feedback = feedback::find($feedback_params); @@ -92,11 +92,11 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo //does a feedback exist for this stage if (empty($feedback)) { - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submissionid, 'assessorid' => $USER->id, 'stage_identifier' => $stage_identifier, - ); + ]; $new_feedback = feedback::build($feedback_params); // This is a new feedback check it against the new ability checks diff --git a/classes/export/csv/cells/agreedgrade_cell.php b/classes/export/csv/cells/agreedgrade_cell.php index 93e9a2a8..c8fb3971 100644 --- a/classes/export/csv/cells/agreedgrade_cell.php +++ b/classes/export/csv/cells/agreedgrade_cell.php @@ -77,8 +77,8 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo global $DB, $PAGE, $USER; $stage_identifier = 'final_agreed_1'; - $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', - 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade'); + $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', + 'mod/coursework:addallocatedagreedgrade', 'mod/coursework:editallocatedagreedgrade']; if (empty($value)) { return true; @@ -152,7 +152,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo return $errormsg; } - $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); + $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]); $submission = \mod_coursework\models\submission::find($subdbrecord); // Is the submission in question ready to grade? @@ -170,10 +170,10 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, - ); + ]; $feedback = feedback::find($feedback_params); @@ -182,11 +182,11 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo //does a feedback exist for this stage if (empty($feedback)) { - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submissionid, 'assessorid' => $USER->id, 'stage_identifier' => $stage_identifier, - ); + ]; $new_feedback = feedback::build($feedback_params); // This is a new feedback check it against the new ability checks diff --git a/classes/export/csv/cells/assessorfeedback_cell.php b/classes/export/csv/cells/assessorfeedback_cell.php index 2a424812..aac4b4ba 100644 --- a/classes/export/csv/cells/assessorfeedback_cell.php +++ b/classes/export/csv/cells/assessorfeedback_cell.php @@ -46,10 +46,10 @@ public function get_cell($submission, $student, $stage_identifier) { // check if user can see initial grades before all of them are completed $ability = new ability(user::find($USER), $this->coursework); - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, - ); + ]; $feedback = feedback::find($feedback_params); if ($submission->get_agreed_grade() || $ability->can('show', $feedback) || is_siteadmin($USER->id)) { @@ -86,10 +86,10 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo "Invalid context level " . $modulecontext->contextlevel ); } - $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade'); - $initialgradecap = array('mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade'); + $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade']; + $initialgradecap = ['mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade']; - $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); + $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]); $submission = \mod_coursework\models\submission::find($subdbrecord); if (has_any_capability($agreedgradecap, $modulecontext) && has_any_capability($initialgradecap, $modulecontext) || has_capability('mod/coursework:administergrades', $modulecontext)) { @@ -110,10 +110,10 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, - ); + ]; $feedback = feedback::find($feedback_params); $ability = new ability(user::find($USER), $this->coursework); @@ -144,12 +144,12 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo if ($this->coursework->allocation_enabled()) { // Check that the user is allocated to the author of the submission - $allocation_params = array( + $allocation_params = [ 'courseworkid' => $this->coursework->id, 'allocatableid' => $submission->allocatableid, 'allocatabletype' => $submission->allocatabletype, 'stage_identifier' => $stage_identifier, - ); + ]; if (!has_capability('mod/coursework:administergrades', $modulecontext) && !$DB->get_record('coursework_allocation_pairs', $allocation_params)) { @@ -162,7 +162,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo && $this->coursework->get_max_markers() > 1 && !$this->coursework->allocation_enabled()) { // check how many feedbacks for this submission - $feedbacks = $DB->count_records('coursework_feedbacks', array('submissionid' => $submissionid)); + $feedbacks = $DB->count_records('coursework_feedbacks', ['submissionid' => $submissionid]); if ($this->coursework->sampling_enabled()) { // check how many sample assessors + add 1 that is always in sample diff --git a/classes/export/csv/cells/assessorgrade_cell.php b/classes/export/csv/cells/assessorgrade_cell.php index ae30eb1b..a1ee3d5a 100644 --- a/classes/export/csv/cells/assessorgrade_cell.php +++ b/classes/export/csv/cells/assessorgrade_cell.php @@ -48,10 +48,10 @@ public function get_cell($submission, $student, $stage_identifier) { // check if user can see initial grades before all of them are completed $ability = new ability(user::find($USER), $this->coursework); - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, - ); + ]; $feedback = feedback::find($feedback_params); if (($submission->get_agreed_grade() || ($feedback && $ability->can('show', $feedback))) || !$submission->any_editable_feedback_exists() || is_siteadmin($USER->id)) { @@ -110,9 +110,9 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo return true; } - $agreedgradecap = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade'); - $initialgradecap = array('mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade'); - $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); + $agreedgradecap = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade']; + $initialgradecap = ['mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade']; + $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]); $submission = \mod_coursework\models\submission::find($subdbrecord); if (has_any_capability($agreedgradecap, $PAGE->context) && has_any_capability($initialgradecap, $PAGE->context) @@ -194,10 +194,10 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, - ); + ]; $feedback = feedback::find($feedback_params); $ability = new ability(user::find($USER), $this->coursework); @@ -228,12 +228,12 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo if ($this->coursework->allocation_enabled()) { // Check that the user is allocated to the author of the submission - $allocation_params = array( + $allocation_params = [ 'courseworkid' => $this->coursework->id, 'allocatableid' => $submission->allocatableid, 'allocatabletype' => $submission->allocatabletype, 'stage_identifier' => $stage_identifier, - ); + ]; if (!has_capability('mod/coursework:administergrades', $PAGE->context) && !$DB->get_record('coursework_allocation_pairs', $allocation_params) @@ -248,7 +248,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo ) { // check how many feedbacks for this submission - $feedbacks = $DB->count_records('coursework_feedbacks', array('submissionid' => $submissionid)); + $feedbacks = $DB->count_records('coursework_feedbacks', ['submissionid' => $submissionid]); if ($this->coursework->sampling_enabled()) { // check how many sample assessors + add 1 that is always in sample diff --git a/classes/export/csv/cells/cell_base.php b/classes/export/csv/cells/cell_base.php index ff72d309..9a61b19a 100644 --- a/classes/export/csv/cells/cell_base.php +++ b/classes/export/csv/cells/cell_base.php @@ -182,7 +182,7 @@ public function get_actual_grade($grade) { public function get_assessor_name($assessorid) { global $DB; - $assessor = $DB->get_record('user', array('id' => $assessorid), 'firstname, lastname'); + $assessor = $DB->get_record('user', ['id' => $assessorid], 'firstname, lastname'); return $assessor->lastname .' '. $assessor->firstname; } @@ -195,7 +195,7 @@ public function get_assessor_name($assessorid) { public function get_assessor_username($assessorid) { global $DB; - $assessor = $DB->get_record('user', array('id' => $assessorid), 'username'); + $assessor = $DB->get_record('user', ['id' => $assessorid], 'username'); return $assessor->username; } diff --git a/classes/export/csv/cells/moderationagreement_cell.php b/classes/export/csv/cells/moderationagreement_cell.php index 421606f9..0852b6c0 100644 --- a/classes/export/csv/cells/moderationagreement_cell.php +++ b/classes/export/csv/cells/moderationagreement_cell.php @@ -54,7 +54,7 @@ public function get_cell($submission, $student, $stage_identifier) { } $feedback = $submission->get_assessor_feedback_by_stage('assessor_1'); if ($feedback) { - $moderation = moderation::find(array('feedbackid' => $feedback->id)); + $moderation = moderation::find(['feedbackid' => $feedback->id]); } if ($moderation) { diff --git a/classes/export/csv/cells/otherassessors_cell.php b/classes/export/csv/cells/otherassessors_cell.php index 3e946a3f..dbbc894b 100644 --- a/classes/export/csv/cells/otherassessors_cell.php +++ b/classes/export/csv/cells/otherassessors_cell.php @@ -45,11 +45,11 @@ public function get_cell($submission, $student, $stage_identifier) { // $stage_identifier = // retrieve all feedbacks without currents user feedback - $params = array( + $params = [ 'submissionid' => $submission->id, 'assessorid' => $USER->id, 'stageidentifier' => $stage_identifier, - ); + ]; $sql = "SELECT * FROM {coursework_feedbacks} WHERE submissionid = :submissionid diff --git a/classes/export/csv/cells/singlegrade_cell.php b/classes/export/csv/cells/singlegrade_cell.php index f6837623..5ac3c02a 100644 --- a/classes/export/csv/cells/singlegrade_cell.php +++ b/classes/export/csv/cells/singlegrade_cell.php @@ -137,7 +137,7 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo return $errormsg; } - $dbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); + $dbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]); $submission = \mod_coursework\models\submission::find($dbrecord); @@ -162,10 +162,10 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo } // Has this submission been graded if yes then check if the current user graded it (only if allocation is not enabled). - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, - ); + ]; $feedback = feedback::find($feedback_params); if (!$this->coursework->allocation_enabled() && !empty($feedback)) { @@ -178,10 +178,10 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo $ability = new ability(user::find($USER), $this->coursework); - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submission->id, 'stage_identifier' => $stage_identifier, - ); + ]; $feedback = feedback::find($feedback_params); //if (!$ability->can('edit', $feedback)) return get_string('nopermissiontoeditgrade', 'coursework'); @@ -189,11 +189,11 @@ public function validate_cell($value, $submissionid, $stage_identifier='', $uplo //does a feedback exist for this stage if (empty($feedback)) { - $feedback_params = array( + $feedback_params = [ 'submissionid' => $submissionid, 'assessorid' => $USER->id, 'stage_identifier' => $stage_identifier, - ); + ]; $new_feedback = feedback::build($feedback_params); // This is a new feedback check it against the new ability checks diff --git a/classes/export/csv/cells/stages_cell.php b/classes/export/csv/cells/stages_cell.php index aa595648..3b89f517 100644 --- a/classes/export/csv/cells/stages_cell.php +++ b/classes/export/csv/cells/stages_cell.php @@ -40,7 +40,7 @@ public function get_cell($submission, $student, $stage_identifier) { $timecreated = 0; $timemodified = 0; - $feedback = $DB->get_record('coursework_feedbacks', array('submissionid' => $submission->id, 'assessorid' => 0)); + $feedback = $DB->get_record('coursework_feedbacks', ['submissionid' => $submission->id, 'assessorid' => 0]); if ($feedback) { $timecreated = $feedback->timecreated; $timemodified = $feedback->timemodified; diff --git a/classes/export/csv/cells/submissionfileid_cell.php b/classes/export/csv/cells/submissionfileid_cell.php index 36b014b2..39d5615d 100644 --- a/classes/export/csv/cells/submissionfileid_cell.php +++ b/classes/export/csv/cells/submissionfileid_cell.php @@ -53,7 +53,7 @@ public function validate_cell($value, $submissionid, $stage_dentifier='', $uploa return 'No submission hash value entered'; } - $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); + $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]); $submission = \mod_coursework\models\submission::find($subdbrecord); diff --git a/classes/export/csv/cells/submissionid_cell.php b/classes/export/csv/cells/submissionid_cell.php index 228cae80..75537f60 100644 --- a/classes/export/csv/cells/submissionid_cell.php +++ b/classes/export/csv/cells/submissionid_cell.php @@ -48,7 +48,7 @@ public function get_header($stage) { public function validate_cell($value, $submissionid, $stage_dentifier = '', $uploadedgradecells = []) { global $DB; - return $DB->record_exists('coursework_submissions', array('id' => $submissionid, 'courseworkid' => $this->coursework->id())) + return $DB->record_exists('coursework_submissions', ['id' => $submissionid, 'courseworkid' => $this->coursework->id()]) ? true : get_string('submissionnotfoundincoursework', 'coursework'); } diff --git a/classes/export/grading_sheet.php b/classes/export/grading_sheet.php index f41bf0e9..f6fc91e2 100644 --- a/classes/export/grading_sheet.php +++ b/classes/export/grading_sheet.php @@ -31,9 +31,9 @@ class grading_sheet extends csv { public function get_submissions($groupid = null, $selected_submission_ids = '') { global $PAGE, $USER; - $params = array( + $params = [ 'courseworkid' => $this->coursework->id, - ); + ]; $submissions = submission::find_all($params); @@ -151,7 +151,7 @@ public static function cells_array($coursework) { global $PAGE; // headers and data for csv - $csv_cells = array('submissionid', 'submissionfileid'); + $csv_cells = ['submissionid', 'submissionfileid']; if ($coursework->is_configured_to_have_group_submissions()) { $csv_cells[] = 'group'; diff --git a/classes/export/import.php b/classes/export/import.php index f2836c42..5ab84d9c 100644 --- a/classes/export/import.php +++ b/classes/export/import.php @@ -166,7 +166,7 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) { // get criteria of rubrics and match it to grade cells if ($this->coursework->is_using_rubric()) { - $types = array("singlegrade", "assessorgrade"); + $types = ["singlegrade", "assessorgrade"]; if ($this->coursework->finalstagegrading == 0 ) { $types[] = "agreedgrade"; } @@ -212,7 +212,7 @@ function rubric_count_correct($csvheader, $linefromimportedcsv) { unset($linefromimportedcsv[$position + $offset]); // if ($type == 'agreedgrade' && $this->coursework->finalstagegrading == 0) { array_splice($csvheader, $position + $offset, 0, array_keys($headers)); - array_splice($linefromimportedcsv, $position + $offset, 0, array('')); + array_splice($linefromimportedcsv, $position + $offset, 0, ['']); // } $offset = $offset + count($headers) - 1; $expectedsize = (int)count($csvheader); @@ -233,7 +233,7 @@ function get_rubric_headers($csvheader) { // get criteria of rubrics and match it to grade cells if ($this->coursework->is_using_rubric()) { - $types = array("singlegrade", "assessorgrade"); + $types = ["singlegrade", "assessorgrade"]; foreach ($types as $type) { @@ -335,7 +335,7 @@ public function process_csv($content, $encoding, $delimiter, $csv_cells, $proces $i++; } - $subdbrecord = $DB->get_record('coursework_submissions', array('id' => $submissionid)); + $subdbrecord = $DB->get_record('coursework_submissions', ['id' => $submissionid]); $submission = \mod_coursework\models\submission::find($subdbrecord); // Is this submission graded? if yes did this user grade it? @@ -585,7 +585,7 @@ public function add_grade($submissionid, $grade, $feedback, $stage_identifier, $ $markernumber = 1; } else { // get all feedbacks and add 1 - $feedbacks = $DB->count_records('coursework_feedbacks', array('submissionid' => $submissionid)); + $feedbacks = $DB->count_records('coursework_feedbacks', ['submissionid' => $submissionid]); $markernumber = $feedbacks + 1; } @@ -637,8 +637,8 @@ public function add_grade($submissionid, $grade, $feedback, $stage_identifier, $ public function get_coursework_feedback_id($submissionid, $stage_identifier) { global $DB; - $record = $DB->get_record('coursework_feedbacks', array('submissionid' => $submissionid, - 'stage_identifier' => $stage_identifier), + $record = $DB->get_record('coursework_feedbacks', ['submissionid' => $submissionid, + 'stage_identifier' => $stage_identifier], 'id'); return $record->id; @@ -670,7 +670,7 @@ public function edit_grade($cwfeedbackid, $grade, $feedback, $uses_rubric=false) $update = false; // update record only if the value of grade or feedback is changed - $current_feedback = $DB->get_record('coursework_feedbacks', array('id' => $cwfeedbackid)); + $current_feedback = $DB->get_record('coursework_feedbacks', ['id' => $cwfeedbackid]); if ($current_feedback->grade != $grade || strip_tags($current_feedback->feedbackcomment) != $feedback) { @@ -706,7 +706,7 @@ public function edit_grade($cwfeedbackid, $grade, $feedback, $uses_rubric=false) public function get_stage_identifier($submissionid, $cell_identifier) { global $DB, $USER; - $submission = $DB->get_record('coursework_submissions', array('id' => $submissionid)); + $submission = $DB->get_record('coursework_submissions', ['id' => $submissionid]); $submission = \mod_coursework\models\submission::find($submission); @@ -718,11 +718,11 @@ public function get_stage_identifier($submissionid, $cell_identifier) { && $this->coursework->allocation_enabled()) { $dbrecord = $DB->get_record('coursework_allocation_pairs', - array('courseworkid' => $this->coursework->id, + ['courseworkid' => $this->coursework->id, 'allocatableid' => $submission->allocatableid, 'allocatabletype' => $submission->allocatabletype, 'assessorid' => $USER->id, - )); + ]); $stage_identifier = $dbrecord->stage_identifier; } @@ -752,16 +752,16 @@ public function get_stage_identifier($submissionid, $cell_identifier) { } } else if ($this->coursework->sampling_enabled()) { // samplings enabled $in_sample = ($subs = $submission->get_submissions_in_sample()) ? count($subs) : 0; - $feedback = $DB->record_exists('coursework_feedbacks', array('submissionid' => $submissionid, - 'stage_identifier' => 'assessor_1')); + $feedback = $DB->record_exists('coursework_feedbacks', ['submissionid' => $submissionid, + 'stage_identifier' => 'assessor_1']); // no sample or no feedback for sample yet if (!$in_sample || ($in_sample && !$feedback)) { $stage_identifier = 'assessor_1'; } else { // find out which sample wasn't graded yet $samples = $submission->get_submissions_in_sample(); foreach ($samples as $sample) { - $feedback = $DB->record_exists('coursework_feedbacks', array('submissionid' => $submissionid, - 'stage_identifier' => $sample->stage_identifier)); + $feedback = $DB->record_exists('coursework_feedbacks', ['submissionid' => $submissionid, + 'stage_identifier' => $sample->stage_identifier]); // if feedback doesn't exist, we'll use this stage identifier for a new feedback if (!$feedback) { $stage_identifier = $sample->stage_identifier; @@ -793,7 +793,7 @@ public function get_stage_identifier($submissionid, $cell_identifier) { public function auto_agreement($cwfeedbackid) { global $DB; - $feedback = $DB->get_record('coursework_feedbacks', array('id' => $cwfeedbackid)); + $feedback = $DB->get_record('coursework_feedbacks', ['id' => $cwfeedbackid]); $feedback = \mod_coursework\models\feedback::find($feedback); $auto_feedback_classname = '\mod_coursework\auto_grader\\' . $this->coursework->automaticagreementstrategy; diff --git a/classes/file_importer.php b/classes/file_importer.php index b73413ee..0a9ef229 100644 --- a/classes/file_importer.php +++ b/classes/file_importer.php @@ -118,7 +118,7 @@ public function import_zip_files($coursework, $feedbackstage, $overwritecurrent) if ($allocatableid = $this->is_valid_feedback_file_filename($coursework, $file, $participants) ) { - $subdbrecord = $DB->get_record('coursework_submissions', array('courseworkid' => $coursework->id(), 'allocatableid' => $allocatableid, 'allocatabletype' => $coursework->get_allocatable_type())); + $subdbrecord = $DB->get_record('coursework_submissions', ['courseworkid' => $coursework->id(), 'allocatableid' => $allocatableid, 'allocatabletype' => $coursework->get_allocatable_type()]); $submission = \mod_coursework\models\submission::find($subdbrecord); @@ -127,7 +127,7 @@ public function import_zip_files($coursework, $feedbackstage, $overwritecurrent) // If only add/edit initial capability then workout stage identifier if ($feedbackstage == 'initialassessor') { - $feedback = $DB->get_record('coursework_feedbacks', array('submissionid' => $submission->id, 'assessorid' => $USER->id )); + $feedback = $DB->get_record('coursework_feedbacks', ['submissionid' => $submission->id, 'assessorid' => $USER->id ]); if ($feedback) { $feedbackstage = $feedback->stage_identifier; @@ -230,8 +230,8 @@ public function feedback_exists($coursework, $submission, $stageidentifier) { AND stage_identifier = :stage "; - $params = array('submissionid' => $submission->id, - 'stage' => $stageidentifier); + $params = ['submissionid' => $submission->id, + 'stage' => $stageidentifier]; if (!has_capability('mod/coursework:administergrades', $coursework->get_context())) { $sql .= "AND (assessorid = :assessorid || lasteditedbyuser = :lasteditedbyuser)"; diff --git a/classes/forms/advance_plugins_form.php b/classes/forms/advance_plugins_form.php index 75c8a343..f95b9acf 100644 --- a/classes/forms/advance_plugins_form.php +++ b/classes/forms/advance_plugins_form.php @@ -50,11 +50,11 @@ public function definition() { $mform->addElement('editor', 'text_element', get_string('comment', 'mod_coursework'), []); $mform->setType('editor', PARAM_RAW); - $file_manager_options = array( + $file_manager_options = [ 'subdirs' => false, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL, - ); + ]; $this->_form->addElement('filemanager', 'file_element', '', diff --git a/classes/forms/assessor_feedback_mform.php b/classes/forms/assessor_feedback_mform.php index d27d5f43..1ee7b250 100644 --- a/classes/forms/assessor_feedback_mform.php +++ b/classes/forms/assessor_feedback_mform.php @@ -91,13 +91,13 @@ public function definition() { if (($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 0 ) || ($coursework->is_using_advanced_grading() && $coursework->finalstagegrading == 1 && $feedback->stage_identifier != 'final_agreed_1')) { $this->_grading_controller = $coursework->get_advanced_grading_active_controller(); $this->_grading_instance = $this->_grading_controller->get_or_create_instance(0, $feedback->assessorid, $feedback->id); - $mform->addElement('grading', 'advancedgrading', get_string('grade', 'mod_coursework'), array('gradinginstance' => $this->_grading_instance)); + $mform->addElement('grading', 'advancedgrading', get_string('grade', 'mod_coursework'), ['gradinginstance' => $this->_grading_instance]); } else { $mform->addElement('select', 'grade', get_string('grade', 'mod_coursework'), $grademenu, - array('id' => 'feedback_grade')); + ['id' => 'feedback_grade']); } // Useful to keep the overall comments even if we have a rubric or something. There may be a place @@ -105,11 +105,11 @@ public function definition() { $mform->addElement('editor', 'feedbackcomment', get_string('comment', 'mod_coursework')); $mform->setType('editor', PARAM_RAW); - $file_manager_options = array( + $file_manager_options = [ 'subdirs' => false, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL, - ); + ]; $uploadfilestring = get_string('uploadafile'); $this->_form->addElement('filemanager', @@ -151,7 +151,7 @@ public function add_submit_buttons($draftenabled, $feedbackid) { $button_array[] = $this->_form->createElement('submit', 'removefeedbackbutton', get_string('removefeedback', 'coursework')); } $button_array[] = $this->_form->createElement('cancel'); - $this->_form->addGroup($button_array, 'buttonar', '', array(' '), false); + $this->_form->addGroup($button_array, 'buttonar', '', [' '], false); $this->_form->closeHeaderBefore('buttonar'); } diff --git a/classes/forms/deadline_extension_form.php b/classes/forms/deadline_extension_form.php index 5ea0553d..163b82e4 100644 --- a/classes/forms/deadline_extension_form.php +++ b/classes/forms/deadline_extension_form.php @@ -106,7 +106,7 @@ public function personal_deadline() { $extensionid = optional_param('id', 0, PARAM_INT); if ($extensionid != 0) { - $ext = $DB->get_record('coursework_extensions', array('id' => $extensionid)); + $ext = $DB->get_record('coursework_extensions', ['id' => $extensionid]); $allocatableid = $ext->allocatableid; $allocatabletype = $ext->allocatabletype; $courseworkid = $ext->courseworkid; @@ -118,11 +118,11 @@ public function personal_deadline() { $courseworkid = required_param('courseworkid', PARAM_INT); } - $params = array( + $params = [ 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype , 'courseworkid' => $courseworkid, - ); + ]; return $personal_deadline = $DB->get_record('coursework_person_deadlines', $params); } diff --git a/classes/forms/moderator_agreement_mform.php b/classes/forms/moderator_agreement_mform.php index 517b4cdc..899cc172 100644 --- a/classes/forms/moderator_agreement_mform.php +++ b/classes/forms/moderator_agreement_mform.php @@ -81,13 +81,13 @@ public function definition() { $mform->setType('courseworkid', PARAM_INT); // moderator agreement - $options = array('agreed' => get_string('agreed', 'coursework'), 'disagreed' => get_string('disagreed', 'coursework')); + $options = ['agreed' => get_string('agreed', 'coursework'), 'disagreed' => get_string('disagreed', 'coursework')]; $mform->addElement('select', 'agreement', get_string('moderationagreement', 'coursework'), $options, - array('id' => 'moderation_agreement')); + ['id' => 'moderation_agreement']); - $mform->addElement('editor', 'modcomment', get_string('comment', 'mod_coursework'), array('id' => 'moderation_comment')); + $mform->addElement('editor', 'modcomment', get_string('comment', 'mod_coursework'), ['id' => 'moderation_comment']); $mform->setType('editor', PARAM_RAW); $this->add_action_buttons(); diff --git a/classes/forms/plagiarism_flagging_mform.php b/classes/forms/plagiarism_flagging_mform.php index b66e8940..99cf4c5b 100644 --- a/classes/forms/plagiarism_flagging_mform.php +++ b/classes/forms/plagiarism_flagging_mform.php @@ -59,19 +59,19 @@ public function definition() { $mform->setType('submissionid', PARAM_INT); // plagiarism status - $options = array(plagiarism_flag::INVESTIGATION => get_string('plagiarism_'.plagiarism_flag::INVESTIGATION, 'coursework'), + $options = [plagiarism_flag::INVESTIGATION => get_string('plagiarism_'.plagiarism_flag::INVESTIGATION, 'coursework'), plagiarism_flag::RELEASED => get_string('plagiarism_'.plagiarism_flag::RELEASED, 'coursework'), plagiarism_flag::CLEARED => get_string('plagiarism_'.plagiarism_flag::CLEARED, 'coursework'), - plagiarism_flag::NOTCLEARED => get_string('plagiarism_'.plagiarism_flag::NOTCLEARED, 'coursework')); + plagiarism_flag::NOTCLEARED => get_string('plagiarism_'.plagiarism_flag::NOTCLEARED, 'coursework')]; $mform->addElement('select', 'status', get_string('status', 'coursework'), $options, - array('id' => 'plagiarism_status')); + ['id' => 'plagiarism_status']); $mform->addHelpButton('status', 'status', 'mod_coursework'); - $mform->addElement('editor', 'plagiarismcomment', get_string('comment', 'mod_coursework'), array('id' => 'plagiarism_comment')); + $mform->addElement('editor', 'plagiarismcomment', get_string('comment', 'mod_coursework'), ['id' => 'plagiarism_comment']); $mform->setType('editor', PARAM_RAW); $mform->hideIf('plagiarismcomment', 'status', 'eq', "1"); diff --git a/classes/forms/student_submission_form.php b/classes/forms/student_submission_form.php index ea366b41..c95d483a 100644 --- a/classes/forms/student_submission_form.php +++ b/classes/forms/student_submission_form.php @@ -103,7 +103,7 @@ public function handle() { $link = $CFG->wwwroot.'/mod/coursework/view.php?id='.$cmid; if ($this->is_cancelled()) { - redirect(new moodle_url('/mod/coursework/view.php', array('id' => $cmid))); + redirect(new moodle_url('/mod/coursework/view.php', ['id' => $cmid])); } $data = $this->get_data(); @@ -179,7 +179,7 @@ public function handle() { if (!empty($userids)) { foreach ($userids as $u) { - $notifyuser = $DB->get_record('user', array('id' => trim($u))); + $notifyuser = $DB->get_record('user', ['id' => trim($u)]); $mailer = new mailer($coursework); if (!empty($notifyuser)) { @@ -314,7 +314,7 @@ protected function add_submit_buttons_to_form() { $this->_form->createElement('submit', 'finalisebutton', get_string('submitandfinalise', 'coursework')); } $button_array[] = $this->_form->createElement('cancel'); - $this->_form->addGroup($button_array, 'buttonar', '', array(' '), false); + $this->_form->addGroup($button_array, 'buttonar', '', [' '], false); $this->_form->closeHeaderBefore('buttonar'); } diff --git a/classes/forms/upload_allocations_form.php b/classes/forms/upload_allocations_form.php index 8b97e771..9824b6cd 100644 --- a/classes/forms/upload_allocations_form.php +++ b/classes/forms/upload_allocations_form.php @@ -35,7 +35,7 @@ function __construct($cmid) { function definition() { $mform =& $this->_form; - $mform->addElement('filepicker', 'allocationsdata', get_string('allocationsfile', 'coursework'), null, array( 'accepted_types' => '*.csv')); + $mform->addElement('filepicker', 'allocationsdata', get_string('allocationsfile', 'coursework'), null, [ 'accepted_types' => '*.csv']); $mform->addRule('allocationsdata', null, 'required'); // $mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework')); diff --git a/classes/forms/upload_feedback_form.php b/classes/forms/upload_feedback_form.php index eb8b410c..362e7a0e 100644 --- a/classes/forms/upload_feedback_form.php +++ b/classes/forms/upload_feedback_form.php @@ -37,11 +37,11 @@ function __construct($coursework, $cmid) { function definition() { $mform =& $this->_form; - $mform->addElement('filepicker', 'feedbackzip', get_string('feedbackzipfile', 'coursework'), null, array( 'accepted_types' => '*.zip')); + $mform->addElement('filepicker', 'feedbackzip', get_string('feedbackzipfile', 'coursework'), null, [ 'accepted_types' => '*.zip']); $mform->addRule('feedbackzip', null, 'required'); $mform->addHelpButton('feedbackzip', 'feedbackzipfile', 'coursework'); - $mform->addElement('advcheckbox', 'overwrite', '', get_string('overwritefeedback', 'coursework'), null, array(0, 1)); + $mform->addElement('advcheckbox', 'overwrite', '', get_string('overwritefeedback', 'coursework'), null, [0, 1]); $mform->addElement('hidden', 'cmid', $this->cmid); $mform->setType('cmid', PARAM_RAW); @@ -49,7 +49,7 @@ function definition() { if ($this->coursework->get_max_markers() > 1) { - $capability = array('mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade'); + $capability = ['mod/coursework:addinitialgrade', 'mod/coursework:editinitialgrade']; if (has_any_capability($capability, $this->coursework->get_context()) && !has_capability('mod/coursework:administergrades', $this->coursework->get_context())) { $options['initialassessor'] = get_string('initialassessor', 'coursework'); @@ -63,7 +63,7 @@ function definition() { } } - $capability = array('mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', 'mod/coursework:administergrades'); + $capability = ['mod/coursework:addagreedgrade', 'mod/coursework:editagreedgrade', 'mod/coursework:administergrades']; if (has_any_capability($capability, $this->coursework->get_context())) { $options['final_agreed_1'] = get_string('finalagreed', 'coursework'); } diff --git a/classes/forms/upload_grading_sheet_form.php b/classes/forms/upload_grading_sheet_form.php index fd396742..e409a72b 100644 --- a/classes/forms/upload_grading_sheet_form.php +++ b/classes/forms/upload_grading_sheet_form.php @@ -35,7 +35,7 @@ function __construct($cmid) { function definition() { $mform =& $this->_form; - $mform->addElement('filepicker', 'gradingdata', get_string('gradingsheetfile', 'coursework'), null, array( 'accepted_types' => '*.csv')); + $mform->addElement('filepicker', 'gradingdata', get_string('gradingsheetfile', 'coursework'), null, [ 'accepted_types' => '*.csv']); $mform->addRule('gradingdata', null, 'required'); $mform->addElement('checkbox', 'overwrite', '', get_string('overwritegrades', 'coursework')); diff --git a/classes/framework/decorator.php b/classes/framework/decorator.php index 7ebe0f7d..c4baa925 100644 --- a/classes/framework/decorator.php +++ b/classes/framework/decorator.php @@ -50,8 +50,8 @@ public function __construct($wrapped_object) { * @return mixed */ public function __call($method, $args) { - return call_user_func_array(array($this->wrapped_object, - $method), + return call_user_func_array([$this->wrapped_object, + $method], $args); } diff --git a/classes/framework/test/table_base_test.php b/classes/framework/test/table_base_test.php index 14f9dd5f..e7851dba 100644 --- a/classes/framework/test/table_base_test.php +++ b/classes/framework/test/table_base_test.php @@ -51,9 +51,9 @@ public function test_get_table_name() { public function test_find_when_true_with_id() { $generator = testing_util::get_data_generator(); - $params = array( + $params = [ 'username' => 'freddo', - ); + ]; $user = $generator->create_user($params); $this->assertEquals($user->id, framework_user_table::find($user->id)->id); @@ -62,9 +62,9 @@ public function test_find_when_true_with_id() { public function test_find_when_true_with_other_param() { $generator = testing_util::get_data_generator(); - $params = array( + $params = [ 'username' => 'freddo', - ); + ]; $user = $generator->create_user($params); $this->assertEquals($user->id, framework_user_table::find($params)->id); @@ -73,18 +73,18 @@ public function test_find_when_true_with_other_param() { public function test_find_when_true_with_entire_db_object() { $generator = testing_util::get_data_generator(); - $params = array( + $params = [ 'username' => 'freddo', - ); + ]; $user = $generator->create_user($params); $this->assertEquals($user->id, framework_user_table::find($user)->id); } public function test_find_when_false() { - $params = array( + $params = [ 'username' => 'freddo', - ); + ]; $this->assertFalse(framework_user_table::find($params)); } @@ -95,27 +95,27 @@ public function test_find_when_false_and_zero_supplied() { public function test_exists_when_true() { $generator = testing_util::get_data_generator(); - $params = array( + $params = [ 'username' => 'freddo', - ); + ]; $generator->create_user($params); $this->assertTrue(framework_user_table::exists($params)); } public function test_exists_when_false() { - $params = array( + $params = [ 'username' => 'freddo', - ); + ]; $this->assertFalse(framework_user_table::exists($params)); } public function test_find_when_given_a_db_record() { $generator = testing_util::get_data_generator(); - $params = array( + $params = [ 'username' => 'freddo', - ); + ]; $user = $generator->create_user($params); $this->assertEquals($user->id, framework_user_table::find($user)->id); } @@ -133,10 +133,10 @@ public function test_find_all_returns_records() { public function test_find_all_returns_specific_records() { $generator = testing_util::get_data_generator(); - $generator->create_user(array('firstname' => 'Dave')); - $generator->create_user(array('firstname' => 'Dave')); + $generator->create_user(['firstname' => 'Dave']); + $generator->create_user(['firstname' => 'Dave']); // Admin user and guest user are there too - $this->assertEquals(2, count(framework_user_table::find_all(array('firstname' => 'Dave')))); + $this->assertEquals(2, count(framework_user_table::find_all(['firstname' => 'Dave']))); } } diff --git a/classes/grading_report.php b/classes/grading_report.php index b98c7351..0a6960ff 100644 --- a/classes/grading_report.php +++ b/classes/grading_report.php @@ -397,8 +397,8 @@ public function get_table_rows_for_page($rowcount = false) { $method_name = 'sort_by_' . $options['sortby']; if (method_exists($this, $method_name)) { usort($rows, - array($this, - $method_name)); + [$this, + $method_name]); } // Some will have submissions and therefore data fields. Others will have those fields null. diff --git a/classes/grading_table_row_base.php b/classes/grading_table_row_base.php index 6c9a71c1..7a08b2f4 100644 --- a/classes/grading_table_row_base.php +++ b/classes/grading_table_row_base.php @@ -107,12 +107,12 @@ public function get_user_name($link = false) { $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->get_coursework()->get_context()); if (!$this->get_coursework()->blindmarking || $viewanonymous || $this->is_published()) { - $user = $DB->get_record('user', array('id' => $this->get_allocatable_id())); + $user = $DB->get_record('user', ['id' => $this->get_allocatable_id()]); $fullname = fullname($user); $allowed = has_capability('moodle/user:viewdetails', $this->get_coursework()->get_context()); if ($link && $allowed) { - $url = new moodle_url('/user/view.php', array('id' => $this->get_allocatable_id(), - 'course' => $this->get_coursework()->get_course_id())); + $url = new moodle_url('/user/view.php', ['id' => $this->get_allocatable_id(), + 'course' => $this->get_coursework()->get_course_id()]); return html_writer::link($url, $fullname); } else { return $fullname; @@ -133,7 +133,7 @@ public function get_idnumber() { $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->get_coursework()->get_context()); if (!$this->get_coursework()->blindmarking || $viewanonymous || $this->is_published()) { - $user = $DB->get_record('user', array('id' => $this->get_allocatable_id())); + $user = $DB->get_record('user', ['id' => $this->get_allocatable_id()]); return $user->idnumber; } else { return get_string('hidden', 'mod_coursework'); @@ -151,7 +151,7 @@ public function get_email() { $viewanonymous = has_capability('mod/coursework:viewanonymous', $this->get_coursework()->get_context()); if (!$this->get_coursework()->blindmarking || $viewanonymous || $this->is_published()) { - $user = $DB->get_record('user', array('id' => $this->get_allocatable_id())); + $user = $DB->get_record('user', ['id' => $this->get_allocatable_id()]); return $user->email; } else { return ''; @@ -198,9 +198,9 @@ public function get_personal_deadlines() { } $personal_deadline = $DB->get_record('coursework_person_deadlines', - array('courseworkid' => $this->get_coursework()->id, + ['courseworkid' => $this->get_coursework()->id, 'allocatableid' => $allocatable->id(), - 'allocatabletype' => $allocatable->type())); + 'allocatabletype' => $allocatable->type()]); if ($personal_deadline) { $personal_deadline = $personal_deadline->personal_deadline; } else { @@ -256,9 +256,9 @@ public function get_submission() { public function get_plagiarism_flag() { $submission = $this->get_submission(); - $params = array( + $params = [ 'submissionid' => $submission->id, - ); + ]; return plagiarism_flag::find($params); } @@ -405,9 +405,9 @@ public function get_single_feedback() { public function has_extension() { global $DB; - return $DB->record_exists('coursework_extensions', array('courseworkid' => $this->get_coursework()->id, + return $DB->record_exists('coursework_extensions', ['courseworkid' => $this->get_coursework()->id, 'allocatableid' => $this->get_allocatable()->id(), - 'allocatabletype' => $this->get_allocatable()->type())); + 'allocatabletype' => $this->get_allocatable()->type()]); } @@ -419,9 +419,9 @@ public function has_extension() { */ public function get_extension() { global $DB; - return $DB->get_record('coursework_extensions', array('courseworkid' => $this->get_coursework()->id, + return $DB->get_record('coursework_extensions', ['courseworkid' => $this->get_coursework()->id, 'allocatableid' => $this->get_allocatable()->id(), - 'allocatabletype' => $this->get_allocatable()->type())); + 'allocatabletype' => $this->get_allocatable()->type()]); } public function get_user_firstname() { diff --git a/classes/models/moderation.php b/classes/models/moderation.php index 9784edb6..86614f88 100644 --- a/classes/models/moderation.php +++ b/classes/models/moderation.php @@ -96,7 +96,7 @@ public function get_feedback() { global $DB; //Moderation done only for single courseworks so submission id to retrieve feedback is enough - $params = array('id' => $this->feedbackid); + $params = ['id' => $this->feedbackid]; $feedback = $DB->get_record('coursework_feedbacks', $params); return $feedback; @@ -173,7 +173,7 @@ public function get_stage() { public static function get_moderator_agreement($feedback) { global $DB; - $params = array('feedbackid' => $feedback->id); + $params = ['feedbackid' => $feedback->id]; // Should only ever be one that has the particular combination of these three options. $moderation = $DB->get_record('coursework_mod_agreements', $params); diff --git a/classes/models/moderation_set_rule.php b/classes/models/moderation_set_rule.php index 15ab01d2..5242553d 100644 --- a/classes/models/moderation_set_rule.php +++ b/classes/models/moderation_set_rule.php @@ -89,7 +89,7 @@ abstract class moderation_set_rule extends table_base implements renderable { /** * @var array List of class properties that correspond with DB fields. */ - protected $fields = array( + protected $fields = [ 'id', 'courseworkid', 'rulename', @@ -97,7 +97,7 @@ abstract class moderation_set_rule extends table_base implements renderable { 'upperlimit', 'lowerlimit', 'minimum', - ); + ]; /** * @param bool|int|stdClass $dbrecord diff --git a/classes/models/personal_deadline.php b/classes/models/personal_deadline.php index 00025a09..f9afd807 100644 --- a/classes/models/personal_deadline.php +++ b/classes/models/personal_deadline.php @@ -70,9 +70,9 @@ public function get_allocatable() { public function extension_exists() { $coursework = $this->get_coursework(); - $params = array('courseworkid' => $coursework->id, + $params = ['courseworkid' => $coursework->id, 'allocatableid' => $this->allocatableid, - 'allocatabletype' => $this->allocatabletype); + 'allocatabletype' => $this->allocatabletype]; return deadline_extension::find($params); } @@ -89,10 +89,10 @@ public static function get_personal_deadline_for_student($student, $coursework) $allocatable = $student; } if ($allocatable) { - return static::find(array('courseworkid' => $coursework->id, + return static::find(['courseworkid' => $coursework->id, 'allocatableid' => $allocatable->id(), 'allocatabletype' => $allocatable->type(), - )); + ]); } } diff --git a/classes/models/sample_set_rule.php b/classes/models/sample_set_rule.php index a3411d1c..88f5227d 100644 --- a/classes/models/sample_set_rule.php +++ b/classes/models/sample_set_rule.php @@ -89,7 +89,7 @@ abstract class sample_set_rule extends table_base implements renderable { /** * @var array List of class properties that correspond with DB fields. */ - protected $fields = array( + protected $fields = [ 'id', 'courseworkid', 'rulename', @@ -97,7 +97,7 @@ abstract class sample_set_rule extends table_base implements renderable { 'upperlimit', 'lowerlimit', 'minimum', - ); + ]; /** * @param bool|int|stdClass $dbrecord diff --git a/classes/moderation_set_rule/minimum_range_grade_percent.php b/classes/moderation_set_rule/minimum_range_grade_percent.php index 6551a877..e0b503f1 100644 --- a/classes/moderation_set_rule/minimum_range_grade_percent.php +++ b/classes/moderation_set_rule/minimum_range_grade_percent.php @@ -56,7 +56,7 @@ public function adjust_set(array &$moderation_set, array &$potential_allocatable // Convert percentages to raw grades for comparison. global $DB; - $params = array('id' => $this->courseworkid); + $params = ['id' => $this->courseworkid]; $maxgrade = $DB->get_field('coursework', 'grade', $params); // Convert percentages to raw grades for comparison. $upperlimit = ($this->upperlimit / 100) * $maxgrade; @@ -126,28 +126,28 @@ public function get_form_elements() { // Upper limit. $html .= html_writer::start_tag('p'); $html .= get_string('upperlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_'.self::get_name().'_upperlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); // Lower limit. $html .= html_writer::start_tag('p'); $html .= get_string('lowerlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => self::get_name().'_lowerlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); // Lower limit. $html .= html_writer::start_tag('p'); $html .= get_string('modsetminimum', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => self::get_name().'_minimum', 'size' => 4, - ); + ]; $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); return $html; diff --git a/classes/moderation_set_rule/minimum_range_grade_raw.php b/classes/moderation_set_rule/minimum_range_grade_raw.php index 42598297..cc4083e0 100644 --- a/classes/moderation_set_rule/minimum_range_grade_raw.php +++ b/classes/moderation_set_rule/minimum_range_grade_raw.php @@ -120,28 +120,28 @@ public function get_form_elements() { // Upper limit. $html .= html_writer::start_tag('p'); $html .= get_string('upperlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_minimum_range_grade_raw_upperlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); // Lower limit. $html .= html_writer::start_tag('p'); $html .= get_string('lowerlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_minimum_range_grade_raw_lowerlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); // Lower limit. $html .= html_writer::start_tag('p'); $html .= get_string('modsetminimum', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_minimum_range_grade_raw_minimum', 'size' => 4, - ); + ]; $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); diff --git a/classes/moderation_set_rule/range_grade_percent.php b/classes/moderation_set_rule/range_grade_percent.php index 73e14808..5a5b7544 100644 --- a/classes/moderation_set_rule/range_grade_percent.php +++ b/classes/moderation_set_rule/range_grade_percent.php @@ -117,19 +117,19 @@ public function get_form_elements() { // Upper limit. $html .= html_writer::start_tag('p'); $html .= get_string('upperlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_range_grade_percent_upperlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes).'%'; $html .= html_writer::end_tag('p'); // Lower limit. $html .= html_writer::start_tag('p'); $html .= get_string('lowerlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_range_grade_percent_lowerlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes).'%'; $html .= html_writer::end_tag('p'); diff --git a/classes/moderation_set_rule/range_grade_raw.php b/classes/moderation_set_rule/range_grade_raw.php index f6913c03..eae805ad 100644 --- a/classes/moderation_set_rule/range_grade_raw.php +++ b/classes/moderation_set_rule/range_grade_raw.php @@ -108,19 +108,19 @@ public function get_form_elements() { // Upper limit. $html .= html_writer::start_tag('p'); $html .= get_string('upperlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_range_grade_raw_upperlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); // Lower limit. $html .= html_writer::start_tag('p'); $html .= get_string('lowerlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_range_grade_raw_lowerlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes); $html .= html_writer::end_tag('p'); return $html; diff --git a/classes/moderation_set_rule/range_total_percent.php b/classes/moderation_set_rule/range_total_percent.php index eb0563d7..fa44c7cc 100644 --- a/classes/moderation_set_rule/range_total_percent.php +++ b/classes/moderation_set_rule/range_total_percent.php @@ -125,10 +125,10 @@ public function get_form_elements() { // Upper limit. $html .= html_writer::start_tag('p'); $html .= get_string('upperlimit', 'mod_coursework').' '; - $attributes = array( + $attributes = [ 'name' => 'rule_range_total_percent_upperlimit', 'size' => 3, - ); + ]; $html .= html_writer::empty_tag('input', $attributes).'%'; $html .= html_writer::end_tag('p'); return $html; diff --git a/classes/personal_deadline/table/builder.php b/classes/personal_deadline/table/builder.php index 6610bee2..2da72880 100644 --- a/classes/personal_deadline/table/builder.php +++ b/classes/personal_deadline/table/builder.php @@ -81,8 +81,8 @@ public function get_rows() { $method_name = 'sort_by_' . $this->options['sortby']; if (method_exists($sorting, $method_name)) { usort($rows, - array($sorting, - $method_name)); + [$sorting, + $method_name]); } return $rows; @@ -111,9 +111,9 @@ public function get_options() { * @return allocatable_cell */ public function get_allocatable_cell() { - $items = array( + $items = [ 'coursework' => $this->coursework, - ); + ]; if ($this->coursework->is_configured_to_have_group_submissions()) { return new group_cell($items); @@ -125,9 +125,9 @@ public function get_allocatable_cell() { * @return personal_deadline_cell */ public function get_personal_deadline_cell() { - $items = array( + $items = [ 'coursework' => $this->coursework, - ); + ]; return new personal_deadline_cell($items); } diff --git a/classes/personal_deadline/table/row/builder.php b/classes/personal_deadline/table/row/builder.php index f6e8bb89..be671094 100644 --- a/classes/personal_deadline/table/row/builder.php +++ b/classes/personal_deadline/table/row/builder.php @@ -185,9 +185,9 @@ public function get_personal_deadlines() { } $personal_deadline = $DB->get_record('coursework_person_deadlines', - array('courseworkid' => $this->get_coursework()->id, + ['courseworkid' => $this->get_coursework()->id, 'allocatableid' => $this->allocatable->id(), - 'allocatabletype' => $this->allocatable->type())); + 'allocatabletype' => $this->allocatable->type()]); if ($personal_deadline) { $personal_deadline = $personal_deadline->personal_deadline; } else { @@ -201,9 +201,9 @@ public function get_submission_status() { global $DB; $submission_db = $DB->get_record('coursework_submissions', - array('courseworkid' => $this->get_coursework()->id, + ['courseworkid' => $this->get_coursework()->id, 'allocatableid' => $this->allocatable->id(), - 'allocatabletype' => $this->allocatable->type())); + 'allocatabletype' => $this->allocatable->type()]); $submission = \mod_coursework\models\submission::find($submission_db); diff --git a/classes/plagiarism_helpers/turnitin.php b/classes/plagiarism_helpers/turnitin.php index 2ba1c168..58af3da1 100644 --- a/classes/plagiarism_helpers/turnitin.php +++ b/classes/plagiarism_helpers/turnitin.php @@ -47,11 +47,11 @@ public function enabled() { if ($CFG->enableplagiarism) { $plagiarismsettings = (array)get_config('plagiarism_turnitin'); if (!empty($plagiarismsettings['enabled'])) { - $params = array( + $params = [ 'cm' => $this->get_coursework()->get_course_module()->id, 'name' => 'use_turnitin', 'value' => 1, - ); + ]; if ($DB->record_exists('plagiarism_turnitin_config', $params)) { return true; } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 6f08e3c6..c70e9b14 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -376,11 +376,11 @@ public static function delete_data_for_users(approved_userlist $userlist) { } protected static function get_coursework_instance(\context $context) { global $DB; - $courseId = array('id' => $context->get_course_context()->instanceid); + $courseId = ['id' => $context->get_course_context()->instanceid]; $course = $DB->get_record('course', $courseId, '*', MUST_EXIST); $modinfo = get_fast_modinfo($course); $coursemodule = $modinfo->get_cm($context->instanceid); - $courseworkId = array('id' => $coursemodule->instance); + $courseworkId = ['id' => $coursemodule->instance]; $coursework = new \mod_coursework\models\coursework($courseworkId); return $coursework; } @@ -425,7 +425,7 @@ protected static function export_submission_files($context, $submissionId, $curr */ protected static function get_user_submissions($userid, $courseworkid) { global $DB; - $params = array('courseworkid' => $courseworkid, 'authorid' => $userid); + $params = ['courseworkid' => $courseworkid, 'authorid' => $userid]; $submissions = $DB->get_records('coursework_submissions', $params); return $submissions; } @@ -459,7 +459,7 @@ protected static function get_submissions_status($submissionid) { } protected static function get_submission_feedbacks($submissionid) { global $DB; - $params = array('submissionid' => $submissionid); + $params = ['submissionid' => $submissionid]; $feedbacks = $DB->get_records('coursework_feedbacks', $params); return $feedbacks; } @@ -515,7 +515,7 @@ protected static function export_coursework_extension($courseworkId, $userId, $c } protected static function get_coursework_extension($courseworkId, $userId) { global $DB; - $params = array('courseworkid' => $courseworkId, 'allocatableid' => $userId); + $params = ['courseworkid' => $courseworkId, 'allocatableid' => $userId]; $extension = $DB->get_record('coursework_extensions', $params); return $extension; } @@ -536,7 +536,7 @@ protected static function export_person_deadlines($courseworkId, $userId, $conte } protected static function get_person_deadline($courseworkId, $userId) { global $DB; - $params = array('courseworkid' => $courseworkId, 'allocatableid' => $userId); + $params = ['courseworkid' => $courseworkId, 'allocatableid' => $userId]; $personDeadline = $DB->get_record('coursework_person_deadlines', $params); return $personDeadline; } @@ -561,7 +561,7 @@ protected static function export_plagiarism_flags($courseworkId, $context, $path protected static function get_plagiarism_flags($courseworkId) { global $DB; - $param = array('courseworkid' => $courseworkId); + $param = ['courseworkid' => $courseworkId]; $plagiarism = $DB->get_record('coursework_plagiarism_flags', $param); @@ -614,7 +614,7 @@ protected static function export_mod_agreements($feedbackId, $context, $path) { } protected static function get_mod_agreement($feedbackId) { global $DB; - $param = array('feedbackid' => $feedbackId); + $param = ['feedbackid' => $feedbackId]; $agreement = $DB->get_record('coursework_mod_agreements', $param); return $agreement; } diff --git a/classes/render_helpers/grading_report/cells/cell_base.php b/classes/render_helpers/grading_report/cells/cell_base.php index d3fdb5a6..7e6af525 100644 --- a/classes/render_helpers/grading_report/cells/cell_base.php +++ b/classes/render_helpers/grading_report/cells/cell_base.php @@ -57,7 +57,7 @@ protected function helper_sortable_heading($display_name, $field, $sort_how, $so global $PAGE; - $params = array('id' => optional_param('id', 0, PARAM_INT)); + $params = ['id' => optional_param('id', 0, PARAM_INT)]; $tablename = (!empty($tablename)) ? $tablename.'_' : ''; diff --git a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php index 6431a439..c3a994c1 100644 --- a/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php +++ b/classes/render_helpers/grading_report/cells/moderation_agreement_cell.php @@ -74,12 +74,12 @@ public function get_table_cell($rowobject) { $rowobject->get_submission()->final_grade_agreed() && ($this->stage->user_is_moderator($USER))) { - $moderation_params = array( + $moderation_params = [ 'submissionid' => $rowobject->get_submission()->id, 'moderatorid' => $USER->id, 'stage_identifier' => $this->stage->identifier(), 'feedbackid' => $rowobject->get_single_feedback()->id, - ); + ]; // allow moderations if feedback exists $new_moderation = moderation::build($moderation_params); if ($ability->can('new', $new_moderation) && ($rowobject->get_single_feedback()->finalised || is_siteadmin($USER->id))) { @@ -162,12 +162,12 @@ private function new_moderation_button($rowobject, $assessor) { // moderation only done for single marking courseworks $feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1'); - $moderation_params = array( + $moderation_params = [ 'submission' => $rowobject->get_submission(), 'assessor' => $assessor, 'stage' => $this->stage, 'feedbackid' => $feedback->id, - ); + ]; $link = $this->get_router()->get_path('new moderations', $moderation_params); $link_id = 'new_moderation_' . $rowobject->get_coursework() @@ -178,7 +178,7 @@ private function new_moderation_button($rowobject, $assessor) { return $OUTPUT->action_link($link, $title, null, - array('class' => 'new_moderation', 'id' => $link_id)); + ['class' => 'new_moderation', 'id' => $link_id]); } /** @@ -190,9 +190,9 @@ private function edit_moderation_button($rowobject) { global $OUTPUT; $feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1'); - $feedback_params = array( + $feedback_params = [ 'moderation' => $this->stage->get_moderation_for_feedback($feedback), - ); + ]; $link = $this->get_router()->get_path('edit moderation', $feedback_params); $link_id = 'edit_moderation_' . $rowobject->get_coursework() @@ -204,7 +204,7 @@ private function edit_moderation_button($rowobject) { return $OUTPUT->action_icon($link, $icon, null, - array('id' => $link_id)); + ['id' => $link_id]); } @@ -217,9 +217,9 @@ private function show_moderation_button($rowobject) { global $OUTPUT; $feedback = $rowobject->get_submission()->get_assessor_feedback_by_stage('assessor_1'); - $moderation_params = array( + $moderation_params = [ 'moderation' => $this->stage->get_moderation_for_feedback($feedback), - ); + ]; $linktitle = get_string('viewmoderation', 'mod_coursework'); $link_id = "show_moderation_" . $rowobject->get_coursework() @@ -229,6 +229,6 @@ private function show_moderation_button($rowobject) { return $OUTPUT->action_link($link, $linktitle, null, - array('class' => 'show_moderation', 'id' => $link_id)); + ['class' => 'show_moderation', 'id' => $link_id]); } } diff --git a/classes/render_helpers/grading_report/cells/moderation_cell.php b/classes/render_helpers/grading_report/cells/moderation_cell.php index 91addf16..c7962bbf 100644 --- a/classes/render_helpers/grading_report/cells/moderation_cell.php +++ b/classes/render_helpers/grading_report/cells/moderation_cell.php @@ -64,11 +64,11 @@ public function get_table_cell($row_object) { $ability = new ability(user::find($USER), $row_object->get_coursework()); $existing_feedback = $this->stage->get_feedback_for_allocatable($row_object->get_allocatable()); - $new_feedback = feedback::build(array( + $new_feedback = feedback::build([ 'submissionid' => $row_object->get_submission_id(), 'stage_identifier' => $this->stage->identifier(), 'assessorid' => $USER->id, - )); + ]); // New or edit for moderators if ($existing_feedback && $ability->can('edit', $existing_feedback)) { // Edit $content .= $this->add_edit_feedback_link_to_cell($row_object, $existing_feedback); @@ -126,16 +126,16 @@ protected function add_edit_feedback_link_to_cell($row_object, $feedback) { global $OUTPUT; $title = get_string('moderatethis', 'coursework'); - $icon = new pix_icon('moderate', $title, 'coursework', array('width' => '20px')); + $icon = new pix_icon('moderate', $title, 'coursework', ['width' => '20px']); - $feedback_params = array( + $feedback_params = [ 'feedback' => $feedback, - ); + ]; $link = $this->get_router()->get_path('edit feedback', $feedback_params); - $html_attributes = array( + $html_attributes = [ 'id' => 'edit_moderator_feedback_' . $row_object->get_filename_hash(), 'class' => 'edit_feedback', - ); + ]; $iconlink = $OUTPUT->action_icon($link, $icon, null, $html_attributes); return ' ' . $iconlink; @@ -150,18 +150,18 @@ protected function add_new_feedback_link_to_cell($row_object) { global $OUTPUT; $title = get_string('moderatethis', 'coursework'); - $icon = new pix_icon('moderate', $title, 'coursework', array('width' => '20px')); + $icon = new pix_icon('moderate', $title, 'coursework', ['width' => '20px']); - $feedback_params = array( + $feedback_params = [ 'submission' => $row_object->get_submission(), 'stage' => $this->stage, - ); + ]; $link = $this->get_router()->get_path('new moderator feedback', $feedback_params); - $html_attributes = array( + $html_attributes = [ 'id' => 'new_moderator_feedback_' . $row_object->get_coursework()->get_allocatable_identifier_hash($row_object->get_allocatable()), 'class' => 'new_feedback', - ); + ]; $iconlink = $OUTPUT->action_icon($link, $icon, null, $html_attributes); return ' ' . $iconlink; } diff --git a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php index 09455a41..de94579c 100644 --- a/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php +++ b/classes/render_helpers/grading_report/cells/multiple_agreed_grade_cell.php @@ -91,44 +91,44 @@ public function get_content($rowobject) { if ($existing_feedback && $ability->can('edit', $existing_feedback)) { - $feedback_route_params = array( + $feedback_route_params = [ 'feedback' => $finalfeedback, - ); + ]; $link = $this->get_router()->get_path('ajax edit feedback', $feedback_route_params); $iconlink = $OUTPUT->action_icon($link, $icon, null, - array( + [ 'class' => 'edit_final_feedback', 'id' => 'edit_final_feedback_' . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()))); + ->get_allocatable_identifier_hash($rowobject->get_allocatable())]); } else if ($rowobject->has_submission()) { // New - $feedback_params = array( + $feedback_params = [ 'submissionid' => $rowobject->get_submission()->id, 'assessorid' => $USER->id, 'stage_identifier' => $this->stage->identifier(), - ); + ]; $new_feedback = feedback::build($feedback_params); // If the user is a site admin then they can add final feedback if ($ability->can('new', $new_feedback) || is_siteadmin()) { $title = get_string('addfinalfeedback', 'coursework'); - $feedback_route_params = array( + $feedback_route_params = [ 'submission' => $rowobject->get_submission(), 'assessor' => $USER, 'stage' => $this->stage, - ); + ]; $link = $this->get_router()->get_path('ajax new final feedback', $feedback_route_params); $iconlink = $OUTPUT->action_link($link, $title, null, - array('class' => 'new_final_feedback', + ['class' => 'new_final_feedback', 'id' => 'new_final_feedback_' . $rowobject->get_coursework() - ->get_allocatable_identifier_hash($rowobject->get_allocatable()))); + ->get_allocatable_identifier_hash($rowobject->get_allocatable())]); } else if ($existing_feedback && $ability->can('show', $existing_feedback)) { @@ -136,11 +136,11 @@ public function get_content($rowobject) { $link_id = "show_feedback_" . $rowobject->get_coursework() ->get_allocatable_identifier_hash($rowobject->get_allocatable()); $link = $this->get_router() - ->get_path('show feedback', array('feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable()))); + ->get_path('show feedback', ['feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable())]); $iconlink = $OUTPUT->action_link($link, $linktitle, null, - array('class' => 'show_feedback', 'id' => $link_id)); + ['class' => 'show_feedback', 'id' => $link_id]); } } diff --git a/classes/render_helpers/grading_report/cells/personal_deadline_cell.php b/classes/render_helpers/grading_report/cells/personal_deadline_cell.php index 79cd4f59..6ef94aa5 100644 --- a/classes/render_helpers/grading_report/cells/personal_deadline_cell.php +++ b/classes/render_helpers/grading_report/cells/personal_deadline_cell.php @@ -45,11 +45,11 @@ public function get_table_cell($row_object) { $deadline = $coursework->get_deadline(); $content = '
'; - $new_personal_deadline_params = array( + $new_personal_deadline_params = [ 'allocatableid' => $row_object->get_allocatable()->id(), 'allocatabletype' => $row_object->get_allocatable()->type(), 'courseworkid' => $row_object->get_coursework()->id, - ); + ]; $personal_deadline = personal_deadline::find_or_build($new_personal_deadline_params); if ($personal_deadline->personal_deadline) { @@ -71,7 +71,7 @@ public function get_table_cell($row_object) { $content .= $OUTPUT->action_icon($link, $icon, null, - array('class' => $class, 'data-get' => json_encode($new_personal_deadline_params), 'data-time' => date('d-m-Y H:i', $deadline) )); + ['class' => $class, 'data-get' => json_encode($new_personal_deadline_params), 'data-time' => date('d-m-Y H:i', $deadline) ]); $content .= '
'; return $this->get_new_cell_with_order_data(['display' => $content, '@data-order' => $deadline]); diff --git a/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php b/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php index 019e6ddd..c5f7657d 100644 --- a/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php +++ b/classes/render_helpers/grading_report/cells/plagiarism_flag_cell.php @@ -50,14 +50,14 @@ public function get_table_cell($rowobject) { $ability = new ability(user::find($USER), $rowobject->get_coursework()); if ($rowobject->has_submission() && $rowobject->get_submission()->finalised) { - $plagiarism_flag_params = array( + $plagiarism_flag_params = [ 'submissionid' => $rowobject->get_submission()->id, - ); + ]; $plagiarism_flag = plagiarism_flag::find($plagiarism_flag_params); if (!$plagiarism_flag) { // if plagiarism flag for this submission doesn't exist, we can create one - $plagiarism_flag_params = array('courseworkid' => $rowobject->get_coursework()->id, - 'submissionid' => $rowobject->get_submission()->id); + $plagiarism_flag_params = ['courseworkid' => $rowobject->get_coursework()->id, + 'submissionid' => $rowobject->get_submission()->id]; $new_plagiarism_flag = plagiarism_flag::build($plagiarism_flag_params); if ($ability->can('new', $new_plagiarism_flag)) { @@ -110,15 +110,15 @@ private function new_flag_plagiarism_button($row_object) { $title = get_string('flagplagiarism', 'coursework'); - $feedback_params = array( + $feedback_params = [ 'submission' => $row_object->get_submission(), - ); + ]; $link = $this->get_router()->get_path('new plagiarism flag', $feedback_params); - $html_attributes = array( + $html_attributes = [ 'id' => 'new_plagiarism_flag_' . $row_object->get_coursework()->get_allocatable_identifier_hash($row_object->get_allocatable()), 'class' => 'new_plagiarism_flag', - ); + ]; return $OUTPUT->action_link($link, $title, null, $html_attributes); } @@ -133,14 +133,14 @@ private function edit_flag_plagiarism_button($row_object) { $title = get_string('editflagplagiarism', 'coursework'); - $feedback_params = array( + $feedback_params = [ 'flag' => $row_object->get_plagiarism_flag(), - ); + ]; $link = $this->get_router()->get_path('edit plagiarism flag', $feedback_params); $link_id = 'edit_plagiarism_flag_' . $row_object->get_coursework()->get_allocatable_identifier_hash($row_object->get_allocatable()); $icon = new pix_icon('edit', $title, 'coursework'); - return $OUTPUT->action_icon($link, $icon, null, array('id' => $link_id)); + return $OUTPUT->action_icon($link, $icon, null, ['id' => $link_id]); } } diff --git a/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php b/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php index ad23b59a..6c96accf 100644 --- a/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php +++ b/classes/render_helpers/grading_report/cells/single_assessor_feedback_cell.php @@ -87,11 +87,11 @@ public function get_content($rowobject) { ($this->stage->user_is_assessor($USER) || has_capability('mod/coursework:administergrades', $this->coursework->get_context()))) { - $feedback_params = array( + $feedback_params = [ 'submissionid' => $rowobject->get_submission()->id, 'assessorid' => $USER->id, 'stage_identifier' => $this->stage->identifier(), - ); + ]; $new_feedback = feedback::build($feedback_params); if ($ability->can('new', $new_feedback)) { $content .= $this->new_feedback_button($rowobject, user::find($USER)); @@ -166,9 +166,9 @@ public function header_group() { private function edit_feedback_button($rowobject) { global $OUTPUT; - $feedback_params = array( + $feedback_params = [ 'feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable()), - ); + ]; $link = $this->get_router()->get_path('edit feedback', $feedback_params); $link_id = 'edit_final_feedback_' . $rowobject->get_coursework() @@ -180,7 +180,7 @@ private function edit_feedback_button($rowobject) { return $OUTPUT->action_icon($link, $icon, null, - array('id' => $link_id, 'class' => 'edit_final_feedback')); + ['id' => $link_id, 'class' => 'edit_final_feedback']); } @@ -196,11 +196,11 @@ private function show_feedback_button($rowobject) { $link_id = "show_feedback_" . $rowobject->get_coursework() ->get_allocatable_identifier_hash($rowobject->get_allocatable()); $link = $this->get_router() - ->get_path('show feedback', array('feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable()))); + ->get_path('show feedback', ['feedback' => $this->stage->get_feedback_for_allocatable($rowobject->get_allocatable())]); $iconlink = $OUTPUT->action_link($link, $linktitle, null, - array('class' => 'show_feedback', 'id' => $link_id)); + ['class' => 'show_feedback', 'id' => $link_id]); return $iconlink; } @@ -214,11 +214,11 @@ private function show_feedback_button($rowobject) { private function new_feedback_button($rowobject, $assessor) { global $OUTPUT; - $feedback_params = array( + $feedback_params = [ 'submission' => $rowobject->get_submission(), 'assessor' => $assessor, 'stage' => $this->stage, - ); + ]; $link = $this->get_router()->get_path('ajax new final feedback', $feedback_params); $link_id = 'new_final_feedback_' . $rowobject->get_coursework() @@ -229,7 +229,7 @@ private function new_feedback_button($rowobject, $assessor) { return $OUTPUT->action_link($link, $title, null, - array('class' => 'new_final_feedback', 'id' => $link_id)); + ['class' => 'new_final_feedback', 'id' => $link_id]); } } diff --git a/classes/render_helpers/grading_report/cells/submission_cell.php b/classes/render_helpers/grading_report/cells/submission_cell.php index ff4eff2b..d105fafa 100644 --- a/classes/render_helpers/grading_report/cells/submission_cell.php +++ b/classes/render_helpers/grading_report/cells/submission_cell.php @@ -58,8 +58,8 @@ public function get_table_cell($rowobject) { if ($ability->can('revert', $rowobject->get_submission())) { $url = new moodle_url('/mod/coursework/actions/revert.php', - array('cmid' => $rowobject->get_course_module_id(), - 'submissionid' => $rowobject->get_submission_id())); + ['cmid' => $rowobject->get_course_module_id(), + 'submissionid' => $rowobject->get_submission_id()]); $content .= html_writer::empty_tag('br'); $revertstring = get_string('revert', 'coursework'); $content .= html_writer::link($url, $revertstring); @@ -70,14 +70,14 @@ public function get_table_cell($rowobject) { $ability = new ability(user::find($USER), $rowobject->get_coursework()); - $submission_on_behalf_of_allocatable = submission::build(array( + $submission_on_behalf_of_allocatable = submission::build([ 'allocatableid' => $rowobject->get_allocatable() ->id(), 'allocatabletype' => $rowobject->get_allocatable() ->type(), 'courseworkid' => $rowobject->get_coursework()->id, 'createdby' => $USER->id, - )); + ]); if (($rowobject->get_submission()&& !$rowobject->get_submission()->finalised) || !$rowobject->get_submission()) { @@ -88,7 +88,7 @@ public function get_table_cell($rowobject) { // New submission on behalf of button $url = $this->get_router() - ->get_path('new submission', array('submission' => $submission_on_behalf_of_allocatable), true); + ->get_path('new submission', ['submission' => $submission_on_behalf_of_allocatable], true); $label = 'Submit on behalf'; @@ -96,7 +96,7 @@ public function get_table_cell($rowobject) { $content .= $OUTPUT->action_link($url, $label, null, - array('class' => 'new_submission')); + ['class' => 'new_submission']); } else if ($rowobject->has_submission() && $ability->can('edit', $rowobject->get_submission()) && !$rowobject->has_feedback() ) { @@ -104,7 +104,7 @@ public function get_table_cell($rowobject) { // Edit submission on behalf of button $url = $this->get_router() - ->get_path('edit submission', array('submission' => $rowobject->get_submission()), true); + ->get_path('edit submission', ['submission' => $rowobject->get_submission()], true); $label = 'Edit submission on behalf of this ' . ($rowobject->get_coursework() @@ -115,7 +115,7 @@ public function get_table_cell($rowobject) { $content .= ' '.$OUTPUT->action_icon($url, $icon, null, - array('class' => 'edit_submission')); + ['class' => 'edit_submission']); } } diff --git a/classes/render_helpers/grading_report/cells/time_submitted_cell.php b/classes/render_helpers/grading_report/cells/time_submitted_cell.php index f5164db4..f2af78ef 100644 --- a/classes/render_helpers/grading_report/cells/time_submitted_cell.php +++ b/classes/render_helpers/grading_report/cells/time_submitted_cell.php @@ -120,11 +120,11 @@ public function prepare_content_cell($row_object) { $allocatableid = $row_object->get_allocatable()->id(); $allocatabletype = $row_object->get_allocatable()->type(); $coursework = $row_object->get_coursework(); - $new_extension_params = array( + $new_extension_params = [ 'allocatableid' => $allocatableid, 'allocatabletype' => $allocatabletype, 'courseworkid' => $coursework->id, - ); + ]; $extension = deadline_extension::find_or_build($new_extension_params); $ability = new ability(user::find($USER), $row_object->get_coursework()); @@ -154,16 +154,16 @@ public function prepare_content_cell($row_object) { $content .= $OUTPUT->action_link($link, $title, null, - array('class' => 'new_deadline_extension', 'data-name' => $row_object->get_allocatable()->name(), 'data-params' => json_encode($new_extension_params), 'data-time' => json_encode($content_time) )); + ['class' => 'new_deadline_extension', 'data-name' => $row_object->get_allocatable()->name(), 'data-params' => json_encode($new_extension_params), 'data-time' => json_encode($content_time) ]); } else if ($ability->can('edit', $extension) && $coursework->extensions_enabled()) { - $link = $this->get_router()->get_path('edit deadline extension', array('id' => $extension->id)); + $link = $this->get_router()->get_path('edit deadline extension', ['id' => $extension->id]); $icon = new pix_icon('edit', 'Edit extension', 'coursework'); $content .= $OUTPUT->action_icon($link, $icon, null, - array('class' => 'edit_deadline_extension', 'data-name' => $row_object->get_allocatable()->name(), 'data-params' => json_encode($new_extension_params), 'data-time' => json_encode($content_time))); + ['class' => 'edit_deadline_extension', 'data-name' => $row_object->get_allocatable()->name(), 'data-params' => json_encode($new_extension_params), 'data-time' => json_encode($content_time)]); } $content .= ''; diff --git a/classes/renderers/personal_deadline_renderer.php b/classes/renderers/personal_deadline_renderer.php index c0f81d59..c8d6c308 100644 --- a/classes/renderers/personal_deadline_renderer.php +++ b/classes/renderers/personal_deadline_renderer.php @@ -48,8 +48,8 @@ public function new_page($vars) { //deadline if (empty($vars['params']['multipleuserdeadlines'])) { $allocatable = $vars['personal_deadline']->get_allocatable(); - $createdby = $DB->get_record('user', array('id' => $vars['personal_deadline']->createdbyid)); - $lasteditedby = $DB->get_record('user', array('id' => $vars['personal_deadline']->lastmodifiedbyid)); + $createdby = $DB->get_record('user', ['id' => $vars['personal_deadline']->createdbyid]); + $lasteditedby = $DB->get_record('user', ['id' => $vars['personal_deadline']->lastmodifiedbyid]); $html = '

Edit personal deadline for ' . $allocatable->name() . '

'; diff --git a/classes/router.php b/classes/router.php index 6ff4682e..07a75233 100644 --- a/classes/router.php +++ b/classes/router.php @@ -94,7 +94,7 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap break; case 'course': - $url = new moodle_url('/course/view.php', array('id' => $items['course']->id)); + $url = new moodle_url('/course/view.php', ['id' => $items['course']->id]); break; case 'edit coursework': @@ -102,47 +102,47 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap break; case 'coursework settings': - $url = new moodle_url('/course/modedit.php', array('update' => $coursemodule_id)); + $url = new moodle_url('/course/modedit.php', ['update' => $coursemodule_id]); break; case 'coursework': - $url = new moodle_url('/mod/coursework/view.php', array('id' => $coursemodule_id)); + $url = new moodle_url('/mod/coursework/view.php', ['id' => $coursemodule_id]); break; case 'allocations': $url = new moodle_url('/mod/coursework/actions/allocate.php', - array('id' => $coursemodule_id)); + ['id' => $coursemodule_id]); break; case 'assessor grading': case 'ajax new feedback': $url = new moodle_url('/mod/coursework/actions/feedbacks/new.php', - array('submissionid' => $items['submission']->id, + ['submissionid' => $items['submission']->id, 'stage_identifier' => $items['stage']->identifier(), 'assessorid' => $items['assessor']->id, - 'ajax' => 1)); + 'ajax' => 1]); break; case 'new feedback': $url = new moodle_url('/mod/coursework/actions/feedbacks/new.php', - array('submissionid' => $items['submission']->id, + ['submissionid' => $items['submission']->id, 'stage_identifier' => $items['stage']->identifier(), - 'assessorid' => $items['assessor']->id)); + 'assessorid' => $items['assessor']->id]); break; case 'ajax new final feedback': - $params = array('submissionid' => $items['submission']->id, + $params = ['submissionid' => $items['submission']->id, 'stage_identifier' => $items['stage']->identifier(), 'isfinalgrade' => 1, - 'ajax' => 1); + 'ajax' => 1]; $url = new moodle_url('/mod/coursework/actions/feedbacks/new.php', $params); break; case 'new final feedback': - $params = array('submissionid' => $items['submission']->id, + $params = ['submissionid' => $items['submission']->id, 'stage_identifier' => $items['stage']->identifier(), - 'isfinalgrade' => 1); + 'isfinalgrade' => 1]; $url = new moodle_url('/mod/coursework/actions/feedbacks/new.php', $params); break; @@ -155,31 +155,31 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap case 'new submission': $url = new moodle_url('/mod/coursework/actions/submissions/new.php', - array( + [ 'allocatableid' => $items['submission']->allocatableid, 'allocatabletype' => $items['submission']->allocatabletype, 'courseworkid' => $items['submission']->courseworkid, - )); + ]); break; case 'ajax edit feedback': $url = new moodle_url('/mod/coursework/actions/feedbacks/edit.php', - array('feedbackid' => $items['feedback']->id, 'ajax' => 1)); + ['feedbackid' => $items['feedback']->id, 'ajax' => 1]); break; case 'edit feedback': $url = new moodle_url('/mod/coursework/actions/feedbacks/edit.php', - array('feedbackid' => $items['feedback']->id)); + ['feedbackid' => $items['feedback']->id]); break; case 'ajax update feedback': $url = new moodle_url('/mod/coursework/actions/feedbacks/update.php', - array('feedbackid' => $items['feedback']->id, 'ajax' => 1)); + ['feedbackid' => $items['feedback']->id, 'ajax' => 1]); break; case 'update feedback': $url = new moodle_url('/mod/coursework/actions/feedbacks/update.php', - array('feedbackid' => $items['feedback']->id)); + ['feedbackid' => $items['feedback']->id]); break; case 'new deadline extension': @@ -199,13 +199,13 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap case 'set personal deadlines': $url = new moodle_url('/mod/coursework/actions/set_personal_deadlines.php', - array('id' => $coursemodule_id)); + ['id' => $coursemodule_id]); break; case 'new moderations': - $params = array('submissionid' => $items['submission']->id, + $params = ['submissionid' => $items['submission']->id, 'stage_identifier' => $items['stage']->identifier(), - 'feedbackid' => $items['feedbackid']); + 'feedbackid' => $items['feedbackid']]; $url = new moodle_url('/mod/coursework/actions/moderations/new.php', $params); break; @@ -215,8 +215,8 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap case 'edit moderation': $url = new moodle_url('/mod/coursework/actions/moderations/edit.php', - array('moderationid' => $items['moderation']->id, - 'feedbackid' => $items['moderation']->feedbackid)); + ['moderationid' => $items['moderation']->id, + 'feedbackid' => $items['moderation']->feedbackid]); break; case 'update moderation': @@ -225,14 +225,14 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap case 'show moderation': $url = new moodle_url('/mod/coursework/actions/moderations/show.php', - array('moderationid' => $items['moderation']->id, - 'feedbackid' => $items['moderation']->feedbackid)); + ['moderationid' => $items['moderation']->id, + 'feedbackid' => $items['moderation']->feedbackid]); break; case 'new plagiarism flag': $url = new moodle_url('/mod/coursework/actions/plagiarism_flagging/new.php', - array('submissionid' => $items['submission']->id )); + ['submissionid' => $items['submission']->id ]); break; @@ -243,13 +243,13 @@ public function get_path($path_name, $items = [], $as_url_object = false, $escap case 'edit plagiarism flag': $url = new moodle_url('/mod/coursework/actions/plagiarism_flagging/edit.php', - array('flagid' => $items['flag']->id )); + ['flagid' => $items['flag']->id ]); break; case 'update plagiarism flag': $url = new moodle_url('/mod/coursework/actions/plagiarism_flagging/update.php', - array('flagid' => $items['flag']->id)); + ['flagid' => $items['flag']->id]); break; } diff --git a/classes/sample_set_rule/range_sample_type.php b/classes/sample_set_rule/range_sample_type.php index 890d8bef..8861142b 100644 --- a/classes/sample_set_rule/range_sample_type.php +++ b/classes/sample_set_rule/range_sample_type.php @@ -77,9 +77,9 @@ public function add_form_elements($assessor_number=0) { $html .= $this->range_elements($assessor_number, 0, false); } - $html .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), array('id' => "assessor_{$assessor_number}_addgradderule", 'class' => 'addgradderule sample_set_rule')); + $html .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), ['id' => "assessor_{$assessor_number}_addgradderule", 'class' => 'addgradderule sample_set_rule']); $html .= " "; - $html .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), array('id' => "assessor_{$assessor_number}_removegradderule", 'class' => 'removegradderule sample_set_rule')); + $html .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), ['id' => "assessor_{$assessor_number}_removegradderule", 'class' => 'removegradderule sample_set_rule']); return $html; } @@ -99,41 +99,41 @@ public function range_elements($assessor_number, $sequence, $dbrecord=false) { $scale[] = $i; } } else { - $grade_scale = \grade_scale::fetch(array('id' => abs($this->coursework->grade))); + $grade_scale = \grade_scale::fetch(['id' => abs($this->coursework->grade)]); $scale = explode(",", $grade_scale->scale); } if ($dbrecord) { - $selected_type = array($dbrecord->ruletype => get_string($dbrecord->ruletype, 'mod_coursework')); - $selected_to = ($dbrecord->ruletype == 'scale') ? array($dbrecord->upperlimit => $scale[$dbrecord->upperlimit]) : array($dbrecord->upperlimit => $dbrecord->upperlimit); + $selected_type = [$dbrecord->ruletype => get_string($dbrecord->ruletype, 'mod_coursework')]; + $selected_to = ($dbrecord->ruletype == 'scale') ? [$dbrecord->upperlimit => $scale[$dbrecord->upperlimit]] : [$dbrecord->upperlimit => $dbrecord->upperlimit]; - $selected_from = ($dbrecord->ruletype == 'scale') ? array($dbrecord->lowerlimit => $scale[$dbrecord->lowerlimit]) : array($dbrecord->lowerlimit => $dbrecord->lowerlimit); + $selected_from = ($dbrecord->ruletype == 'scale') ? [$dbrecord->lowerlimit => $scale[$dbrecord->lowerlimit]] : [$dbrecord->lowerlimit => $dbrecord->lowerlimit]; $rules_checked = ($dbrecord) ? true : false; } else { - $selected_type = array('percentage' => get_string('percentage', 'mod_coursework')); - $selected_to = array('100' => '100'); - $selected_from = array('0' => '0');; + $selected_type = ['percentage' => get_string('percentage', 'mod_coursework')]; + $selected_to = ['100' => '100']; + $selected_from = ['0' => '0'];; $rules_checked = false; } - $html = html_writer::start_tag('div', array('class' => "assessor_{$assessor_number}_grade_rules", 'id' => "assessor_{$assessor_number}_grade_rules_{$sequence}")); + $html = html_writer::start_tag('div', ['class' => "assessor_{$assessor_number}_grade_rules", 'id' => "assessor_{$assessor_number}_grade_rules_{$sequence}"]); $html .= html_writer::checkbox("assessor_{$assessor_number}_samplerules[]", 1, $rules_checked, '', - array('id' => "assessor_{$assessor_number}_samplerules_{$sequence}", 'class' => "assessor_{$assessor_number} range_grade_checkbox sample_set_rule")); + ['id' => "assessor_{$assessor_number}_samplerules_{$sequence}", 'class' => "assessor_{$assessor_number} range_grade_checkbox sample_set_rule"]); $grade_scale_text = ($this->coursework->grade < 0) ? get_string('scale', 'mod_coursework') : get_string('grade', 'mod_coursework'); $grade_scale_val = ($this->coursework->grade < 0) ? 'scale' : 'grade'; - $options = array('percentage' => get_string('percentage', 'mod_coursework'), - $grade_scale_val => $grade_scale_text); + $options = ['percentage' => get_string('percentage', 'mod_coursework'), + $grade_scale_val => $grade_scale_text]; $html .= html_writer::select($options, "assessor_{$assessor_number}_sampletype[]", "", $selected_type, - array('id' => "assessor_{$assessor_number}_sampletype_{$sequence}", 'class' => "grade_type sample_set_rule")); + ['id' => "assessor_{$assessor_number}_sampletype_{$sequence}", 'class' => "grade_type sample_set_rule"]); $html .= html_writer::label(get_string('from', 'mod_coursework'), 'assessortwo_samplefrom[0]'); @@ -143,7 +143,7 @@ public function range_elements($assessor_number, $sequence, $dbrecord=false) { "assessor_{$assessor_number}_samplefrom[]", "", $selected_from, - array('id' => "assessor_{$assessor_number}_samplefrom_{$sequence}", 'class' => " sample_set_rule range_drop_down range_samp_from")); + ['id' => "assessor_{$assessor_number}_samplefrom_{$sequence}", 'class' => " sample_set_rule range_drop_down range_samp_from"]); $html .= html_writer::label(get_string('to', 'mod_coursework'), "assessor_{$assessor_number}_sampleto[0]"); @@ -151,7 +151,7 @@ public function range_elements($assessor_number, $sequence, $dbrecord=false) { "assessor_{$assessor_number}_sampleto[]", "", $selected_to, - array('id' => "assessor_{$assessor_number}_sampleto_{$sequence}", 'class' => " sample_set_rule range_drop_down")); + ['id' => "assessor_{$assessor_number}_sampleto_{$sequence}", 'class' => " sample_set_rule range_drop_down"]); $html .= html_writer::end_tag('div', ''); @@ -335,7 +335,7 @@ public function save_form_data($assessor_number=0, &$order=0) { $sample_from = optional_param_array("assessor_{$assessor_number}_samplefrom", false, PARAM_RAW); $sample_to = optional_param_array("assessor_{$assessor_number}_sampleto", false, PARAM_RAW); - $sample_plugin = $DB->get_record('coursework_sample_set_plugin', array('rulename' => 'range_sample_type')); + $sample_plugin = $DB->get_record('coursework_sample_set_plugin', ['rulename' => 'range_sample_type']); if ($sample_rules) { foreach ($sample_rules as $i => $val) { @@ -372,7 +372,7 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample AND stage_identifier = :stage ORDER BY ruleorder"; - $ruleinstance = $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage)); + $ruleinstance = $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id, 'stage' => $stage]); foreach ($ruleinstance as $ri) { @@ -415,7 +415,7 @@ private function rationalise($ruletype, $limit1, $limit2) { $limits[0] = $this->coursework->grade * $limits[0] / 100; $limits[1] = $this->coursework->grade * $limits[1] / 100; } else { - $scale = $DB->get_record("scale", array('id' => abs($this->coursework->grade))); + $scale = $DB->get_record("scale", ['id' => abs($this->coursework->grade)]); if ($scale) { @@ -454,8 +454,8 @@ private function get_allocatables_in_range($stage, $limit1, $limit2) { // Note as things stand limit1 and limit2 can not be params as the type of the grade field (varchar) //means the values are cast as strings - return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id, - 'stage' => $stage)); + return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id, + 'stage' => $stage]); } diff --git a/classes/sample_set_rule/sample_base.php b/classes/sample_set_rule/sample_base.php index 308f6775..03d38d0d 100644 --- a/classes/sample_set_rule/sample_base.php +++ b/classes/sample_set_rule/sample_base.php @@ -80,7 +80,7 @@ abstract class sample_base { /** * @var array List of class properties that correspond with DB fields. */ - protected $fields = array( + protected $fields = [ 'id', 'courseworkid', 'rulename', @@ -88,7 +88,7 @@ abstract class sample_base { 'upperlimit', 'lowerlimit', 'minimum', - ); + ]; function __construct($coursework) { $this->coursework = $coursework; @@ -164,7 +164,7 @@ protected function finalised_submissions() { WHERE s.courseworkid = :courseworkid AND f.stage_identifier = 'final_agreed_1'"; - return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id)); + return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id]); } /** @@ -179,7 +179,7 @@ protected function released_submissions() { WHERE courseworkid = :courseworkid AND firstpublished IS NOT NULL"; - return $DB->get_records_sql($sql, array('courseworkid' => $this->coursework->id)); + return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id]); } } diff --git a/classes/sample_set_rule/total_sample_type.php b/classes/sample_set_rule/total_sample_type.php index 36c965c1..81cc9019 100644 --- a/classes/sample_set_rule/total_sample_type.php +++ b/classes/sample_set_rule/total_sample_type.php @@ -61,7 +61,7 @@ public function add_form_elements($assessor_number=0) { AND sr.stage_identifier = 'assessor_{$assessor_number}' AND sp.rulename = 'total_sample_type'"; - $selected = ($record = $DB->get_record_sql($sql)) ? array($record->upperlimit => $record->upperlimit) : false; + $selected = ($record = $DB->get_record_sql($sql)) ? [$record->upperlimit => $record->upperlimit] : false; $checked = ($selected) ? true : false; $percentage_options = []; @@ -73,13 +73,13 @@ public function add_form_elements($assessor_number=0) { $html = html_writer::start_div('sampletotal'); $html .= html_writer::checkbox("assessor_{$assessor_number}_sampletotal_checkbox", 1, $checked, get_string('topupto', 'mod_coursework'), - array('id' => "assessor_{$assessor_number}_sampletotal_checkbox", 'class' => "assessor_{$assessor_number} total_checkbox sample_set_rule")); + ['id' => "assessor_{$assessor_number}_sampletotal_checkbox", 'class' => "assessor_{$assessor_number} total_checkbox sample_set_rule"]); $html .= html_writer::select($percentage_options, "assessor_{$assessor_number}_sampletotal", "", $selected, - array('id' => "assessor_{$assessor_number}_sampletotal", 'class' => " sample_set_rule")); + ['id' => "assessor_{$assessor_number}_sampletotal", 'class' => " sample_set_rule"]); $html .= html_writer::label(get_string('ofallstudents', 'mod_coursework'), 'assessortwo_sampletotal[]'); $html .= html_writer::end_div(); @@ -157,7 +157,7 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample AND stage_identifier = :stage ORDER BY ruleorder"; - $rule = $DB->get_record_sql($sql, array('courseworkid' => $this->coursework->id, 'stage' => $stage)); + $rule = $DB->get_record_sql($sql, ['courseworkid' => $this->coursework->id, 'stage' => $stage]); if ($rule) { @@ -210,21 +210,21 @@ public function adjust_sample_set($stage_number, &$allocatables, &$manual_sample if (count($auto_sample_set) < $total_to_return) { // Remove allocatables with published submissions - $allocatable_sample_set = array_diff_ukey($allocatables, $published, array("mod_coursework\\sample_set_rule\\total_sample_type", "compare_key")); + $allocatable_sample_set = array_diff_ukey($allocatables, $published, ["mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"]); // Remove allocatables with finalised submissions - $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $finalised, array("mod_coursework\\sample_set_rule\\total_sample_type", "compare_key")); + $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $finalised, ["mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"]); // Remove allocatables who have been manually selected - $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $manual_sample_set, array("mod_coursework\\sample_set_rule\\total_sample_type", "compare_key")); + $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $manual_sample_set, ["mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"]); // Remove allocatables already in the sample set - $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $auto_sample_set, array("mod_coursework\\sample_set_rule\\total_sample_type", "compare_key")); + $allocatable_sample_set = array_diff_ukey($allocatable_sample_set, $auto_sample_set, ["mod_coursework\\sample_set_rule\\total_sample_type", "compare_key"]); $array_keys = array_rand($allocatable_sample_set, $total_to_return - count($auto_sample_set)); if (!is_array($array_keys)) { - $array_keys = array($array_keys); + $array_keys = [$array_keys]; } //use the allocatables array to get other ungraded allocatables diff --git a/classes/sampling_set_widget.php b/classes/sampling_set_widget.php index 7ef9ca6e..bae38f7e 100644 --- a/classes/sampling_set_widget.php +++ b/classes/sampling_set_widget.php @@ -124,10 +124,10 @@ public function get_potential_rule_class_names() { $fullclassname = '\mod_coursework\sample_set_rule\\'. $rulename; if (!$fullclassname::allow_multiple()) { - $params = array( + $params = [ 'courseworkid' => $this->coursework->id, 'rulename' => $rulename, - ); + ]; $alreadygotone = $DB->record_exists('coursework_mod_set_rules', $params); if ($alreadygotone) { continue; @@ -171,11 +171,11 @@ public function get_add_rule_form_elements() { $classes = $this->get_potential_rule_class_names(); foreach ($classes as $shortname => $class) { - $attributes = array( + $attributes = [ 'class' => 'rule-config', 'id' => 'rule-config-'.$shortname, 'style' => 'display:none', // Always hide, so they only get revealed by clicking the radio buttons. - ); + ]; $html .= html_writer::start_tag('div', $attributes); /* @var models\moderation_set_rule $instance */ $instance = new $class(); diff --git a/classes/stages/base.php b/classes/stages/base.php index c4feae45..4f2362a1 100644 --- a/classes/stages/base.php +++ b/classes/stages/base.php @@ -250,7 +250,7 @@ private function get_next_teacher($allocatable) { private function get_percentage_allocated_teachers() { global $DB; - return $DB->get_records('coursework_allocation_config', array('courseworkid' => $this->get_coursework_id()), '', 'assessorid as id'); + return $DB->get_records('coursework_allocation_config', ['courseworkid' => $this->get_coursework_id()], '', 'assessorid as id'); } /** @@ -350,7 +350,7 @@ public function has_moderation($submission) { $sql = "SELECT * FROM {coursework_mod_agreements} WHERE feedbackid = ?"; - return $DB->record_exists_sql($sql, array($feedback->id)); + return $DB->record_exists_sql($sql, [$feedback->id]); } else { return false; } @@ -363,7 +363,7 @@ public function has_moderation($submission) { public function get_moderation($submission) { $feedback = $this->get_single_feedback($submission); if ($feedback) { - $moderation_params = array('feedbackid' => $feedback->id); + $moderation_params = ['feedbackid' => $feedback->id]; return moderation::find($moderation_params); } else { return false; @@ -548,12 +548,12 @@ public function add_allocatable_to_sampling($allocatable) { public function remove_allocatable_from_sampling($allocatable) { global $DB; - $params = array( + $params = [ 'courseworkid' => $this->coursework->id, 'allocatableid' => $allocatable->id(), 'allocatabletype' => $allocatable->type(), 'stage_identifier' => $this->stage_identifier, - ); + ]; $DB->delete_records('coursework_sample_set_mbrs', $params); } @@ -718,9 +718,9 @@ public function get_feedback_for_submission($submission) { * @return moderation|bool */ public function get_moderation_for_feedback($feedback) { - $moderation_params = array( + $moderation_params = [ 'feedbackid' => $feedback->id, - ); + ]; return moderation::find($moderation_params); } @@ -728,7 +728,7 @@ public function get_moderation_for_feedback($feedback) { * return bool */ public function assessment_set_is_not_empty() { - return assessment_set_membership::exists(array('courseworkid' => $this->coursework->id)); + return assessment_set_membership::exists(['courseworkid' => $this->coursework->id]); } /** @@ -772,10 +772,10 @@ public function potential_marker_dropdown($allocatable) { return '
' . get_string('nomarkers', 'mod_coursework'); } - $html_attributes = array( + $html_attributes = [ 'id' => $this->assessor_dropdown_id($allocatable), 'class' => 'assessor_id_dropdown', - ); + ]; if ($this->identifier() != 'assessor_1' && !$this->currently_allocated_assessor($allocatable) && $this->coursework->sampling_enabled() && !$this->allocatable_is_in_sample($allocatable) @@ -790,7 +790,7 @@ public function potential_marker_dropdown($allocatable) { $identifier = 'change' . $grader; } - $option_for_nothing_chosen_yet = array('' => get_string($identifier, 'mod_coursework')); + $option_for_nothing_chosen_yet = ['' => get_string($identifier, 'mod_coursework')]; $dropdown_name = $this->assessor_dropdown_name($allocatable); @@ -812,11 +812,11 @@ public function potential_marker_dropdown($allocatable) { */ public function potential_moderator_dropdown($allocatable) { - $option_for_nothing_chosen_yet = array('' => 'Choose Moderator'); - $html_attributes = array( + $option_for_nothing_chosen_yet = ['' => 'Choose Moderator']; + $html_attributes = [ 'id' => $this->moderator_dropdown_id($allocatable), 'class' => 'moderator_id_dropdown', - ); + ]; $dropdown_name = $this->assessor_dropdown_name($allocatable); diff --git a/classes/task/enrol_task.php b/classes/task/enrol_task.php index 0de5827b..8f4372ec 100644 --- a/classes/task/enrol_task.php +++ b/classes/task/enrol_task.php @@ -43,7 +43,7 @@ public function execute() { global $DB; - $courseworkids = $DB->get_records('coursework', array('processenrol' => 1)); + $courseworkids = $DB->get_records('coursework', ['processenrol' => 1]); if (!empty($courseworkids)) { foreach ($courseworkids as $courseworkid) { @@ -57,7 +57,7 @@ public function execute() { $allocator = new \mod_coursework\allocation\auto_allocator($coursework); $allocator->process_allocations(); - $DB->set_field('coursework', 'processenrol', 0, array('id' => $coursework->id())); + $DB->set_field('coursework', 'processenrol', 0, ['id' => $coursework->id()]); } } diff --git a/classes/task/unenrol_task.php b/classes/task/unenrol_task.php index acdc1d96..f5b7584a 100644 --- a/classes/task/unenrol_task.php +++ b/classes/task/unenrol_task.php @@ -43,7 +43,7 @@ public function execute() { global $DB; - $courseworkids = $DB->get_records('coursework', array('processunenrol' => 1)); + $courseworkids = $DB->get_records('coursework', ['processunenrol' => 1]); if (!empty($courseworkids)) { foreach ($courseworkids as $courseworkid) { @@ -55,7 +55,7 @@ public function execute() { $allocator = new \mod_coursework\allocation\auto_allocator($coursework); $allocator->process_allocations(); - $DB->set_field('coursework', 'processunenrol', 0, array('id' => $coursework->id())); + $DB->set_field('coursework', 'processunenrol', 0, ['id' => $coursework->id()]); } } diff --git a/classes/traits/allocatable_functions.php b/classes/traits/allocatable_functions.php index ccbf9a43..94d939cf 100644 --- a/classes/traits/allocatable_functions.php +++ b/classes/traits/allocatable_functions.php @@ -55,12 +55,12 @@ public function delete_all_submission_allocations($coursework) { AND allocatabletype = :type "; - $params = array( + $params = [ 'courseworkid' => $coursework->id, 'courseworkid2' => $coursework->id, 'id' => $this->id(), 'type' => $this->type(), - ); + ]; $DB->execute($sql, $params); } @@ -79,7 +79,7 @@ public function has_agreed_feedback($coursework) { AND s.allocatableid = :id AND s.courseworkid = :courseworkid "; - $result = $DB->count_records_sql($sql, array('id' => $this->id(), 'courseworkid' => $coursework->id())); + $result = $DB->count_records_sql($sql, ['id' => $this->id(), 'courseworkid' => $coursework->id()]); return !empty($result); } @@ -98,7 +98,7 @@ public function get_agreed_feedback($coursework) { AND s.allocatableid = :id AND s.courseworkid = :courseworkid"; - return $DB->get_record_sql($sql, array('id' => $this->id(), 'courseworkid' => $coursework->id())); + return $DB->get_record_sql($sql, ['id' => $this->id(), 'courseworkid' => $coursework->id()]); } /** @@ -120,8 +120,8 @@ public function has_all_initial_feedbacks($coursework) { AND s.courseworkid = :courseworkid "; $feedbacks = $DB->count_records_sql($sql, - array('id' => $this->id(), - 'courseworkid' => $coursework->id())); + ['id' => $this->id(), + 'courseworkid' => $coursework->id()]); // when sampling is enabled, calculate how many stages are in sample if ($coursework->sampling_enabled()) { @@ -133,9 +133,9 @@ public function has_all_initial_feedbacks($coursework) { AND allocatabletype = :allocatabletype"; $markers = $DB->count_records_sql($sql, - array('courseworkid' => $coursework->id(), + ['courseworkid' => $coursework->id(), 'allocatableid' => $this->id(), - 'allocatabletype' => $this->type())); + 'allocatabletype' => $this->type()]); $expected_markers = $markers + 1; // there is always a marker for stage 1 } diff --git a/classes/warnings.php b/classes/warnings.php index 5f86c68b..ae412286 100644 --- a/classes/warnings.php +++ b/classes/warnings.php @@ -99,8 +99,8 @@ public function students_in_mutiple_grouos() { GROUP BY gm.userid, groupings.groupingid, u.firstname, u.lastname)a WHERE noofgroups > 1"; - $params = array('courseid' => $this->coursework->get_course()->id, - 'groupingid' => $this->coursework->grouping_id); + $params = ['courseid' => $this->coursework->get_course()->id, + 'groupingid' => $this->coursework->grouping_id]; } else { $sql = "SELECT * FROM ( SELECT gm.userid, @@ -116,7 +116,7 @@ public function students_in_mutiple_grouos() { GROUP BY gm.userid, u.firstname, u.lastname) a WHERE noofgroups > 1"; - $params = array('courseid' => $this->coursework->get_course()->id); + $params = ['courseid' => $this->coursework->get_course()->id]; } // get all students that are in more than a one group @@ -142,10 +142,10 @@ public function students_in_mutiple_grouos() { AND gm.userid = :userid AND groupings.groupingid =:grouping_id"; - $params = array( + $params = [ 'grouping_id' => $this->coursework->grouping_id, 'courseid' => $this->coursework->get_course()->id, - 'userid' => $student->userid); + 'userid' => $student->userid]; } else { $sql = "SELECT groups.id,groups.name @@ -155,9 +155,9 @@ public function students_in_mutiple_grouos() { WHERE groups.courseid = :courseid AND gm.userid = :userid"; - $params = array( + $params = [ 'courseid' => $this->coursework->get_course()->id, - 'userid' => $student->userid); + 'userid' => $student->userid]; } $studentmessage .= '