Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
6d46332a
Commit
6d46332a
authored
Jun 30, 2022
by
Andrew Nicols
Browse files
Merge branch 'MDL-74613-master' of
https://github.com/NoelDeMartin/moodle
parents
956bb8eb
bbaf8332
Changes
3
Hide whitespace changes
Inline
Side-by-side
grade/report/grader/tests/behat/switch_views.feature
View file @
6d46332a
...
...
@@ -12,7 +12,7 @@ Feature: We can change what we are viewing on the grader report
|
username
|
firstname
|
lastname
|
email
|
|
teacher1
|
Teacher
|
1
|
teacher1@example.com
|
|
student1
|
Student
|
1
|
student1@example.com
|
|
student2
|
Student
|
1
|
student2@example.com
|
|
student2
|
Student
|
2
|
student2@example.com
|
And the following "course enrolments" exist
:
|
user
|
course
|
role
|
|
teacher1
|
C1
|
editingteacher
|
...
...
@@ -26,18 +26,15 @@ Feature: We can change what we are viewing on the grader report
|
assign
|
user
|
onlinetext
|
|
Test
assignment
name
1
|
student1
|
This
is
a
submission
for
assignment
1
|
|
Test
assignment
name
2
|
student1
|
This
is
a
submission
for
assignment
2
|
And
I am on the
"Test assignment name 1"
"assign activity"
page logged in as student1
Then
I should see
"Submitted for grading"
And
I am on the
"Test assignment name 2"
"assign activity"
page
Then
I should see
"Submitted for grading"
And
I log out
And the following "grade items" exist
:
|
itemname
|
grademin
|
grademax
|
course
|
|
Manual
grade
|
20
|
40
|
C1
|
And the following "grade grades" exist
:
|
gradeitem
|
user
|
grade
|
|
Test
assignment
name
1
|
student1
|
80
|
|
Test
assignment
name
2
|
student1
|
90
|
|
Manual
grade
|
student1
|
30
|
And
I log in as
"teacher1"
And
I am on
"Course 1"
course homepage
And
I navigate to
"View > Grader report"
in the course gradebook
And
I turn editing mode on
And
I give the grade
"80.00"
to the user
"Student 1"
for the grade item
"Test assignment name 1"
And
I give the grade
"90.00"
to the user
"Student 1"
for the grade item
"Test assignment name 2"
And
I press
"Save changes"
@javascript
Scenario
:
View and minimise the grader report containing hidden activities
...
...
@@ -48,13 +45,15 @@ Feature: We can change what we are viewing on the grader report
And
I navigate to
"View > Grader report"
in the course gradebook
And
I should see
"Test assignment name 1"
And
I should see
"Test assignment name 2"
And
I should see
"Manual grade"
And
I should see
"Course total"
And the following should exist in the "user-grades" table
:
|
-1-
|
-4-
|
-5-
|
-6-
|
|
Student
1
|
80
|
90
|
170
|
|
-1-
|
-4-
|
-5-
|
-6-
|
-7-
|
|
Student
1
|
80
|
90
|
30
|
170
|
And
I click on
"Change to aggregates only"
"link"
And
I should not see
"Test assignment name 1"
And
I should not see
"Test assignment name 2"
And
I should not see
"Manual grade"
And
I should see
"Course total"
And the following should exist in the "user-grades" table
:
|
-1-
|
-4-
|
...
...
@@ -62,10 +61,11 @@ Feature: We can change what we are viewing on the grader report
And
I click on
"Change to grades only"
"link"
And
I should see
"Test assignment name 1"
And
I should see
"Test assignment name 2"
And
I should see
"Manual grade"
And
I should not see
"Course total"
And the following should exist in the "user-grades" table
:
|
-1-
|
-4-
|
-5-
|
|
Student
1
|
80
|
90
|
|
-1-
|
-4-
|
-5-
|
-6-
|
|
Student
1
|
80
|
90
|
30
|
@javascript
@skip_chrome_zerosize
Scenario
:
View and minimise the grader report containing hidden activities without the 'moodle/grade
:
viewhidden'
capability
...
...
@@ -83,21 +83,24 @@ Feature: We can change what we are viewing on the grader report
And
I navigate to
"View > Grader report"
in the course gradebook
And
I should see
"Test assignment name 1"
And
I should see
"Test assignment name 2"
And
I should see
"Manual grade"
And
I should see
"Course total"
And the following should exist in the "user-grades" table
:
|
-1-
|
-4-
|
-5-
|
-6-
|
|
Student
1
|
80
|
-
|
80
|
|
-1-
|
-4-
|
-5-
|
-6-
|
-7-
|
|
Student
1
|
80
|
-
|
30
|
105.71
|
And
I click on
"Change to aggregates only"
"link"
And
I should not see
"Test assignment name 1"
And
I should not see
"Test assignment name 2"
And
I should not see
"Manual grade"
And
I should see
"Course total"
And the following should exist in the "user-grades" table
:
|
-1-
|
-4-
|
|
Student
1
|
80
|
|
Student
1
|
105.71
|
And
I click on
"Change to grades only"
"link"
And
I should see
"Test assignment name 1"
And
I should see
"Test assignment name 2"
And
I should see
"Manual grade"
And
I should not see
"Course total"
And the following should exist in the "user-grades" table
:
|
-1-
|
-4-
|
-5-
|
|
Student
1
|
80
|
-
|
|
-1-
|
-4-
|
-5-
|
-6-
|
|
Student
1
|
80
|
-
|
30
|
lib/behat/classes/behat_core_generator.php
View file @
6d46332a
...
...
@@ -162,6 +162,12 @@ class behat_core_generator extends behat_generator_base {
'required'
=>
[
'fullname'
,
'course'
],
'switchids'
=>
[
'course'
=>
'courseid'
,
'gradecategory'
=>
'parent'
],
],
'grade grades'
=>
[
'singular'
=>
'grade grade'
,
'datagenerator'
=>
'grade_grade'
,
'required'
=>
[
'gradeitem'
],
'switchids'
=>
[
'user'
=>
'userid'
,
'gradeitem'
=>
'itemid'
],
],
'grade items'
=>
[
'singular'
=>
'grade item'
,
'datagenerator'
=>
'grade_item'
,
...
...
@@ -298,6 +304,22 @@ class behat_core_generator extends behat_generator_base {
return
$entities
;
}
/**
* Get the grade item id using a name.
*
* @param string $name
* @return int The grade item id
*/
protected
function
get_gradeitem_id
(
string
$name
):
int
{
global
$DB
;
if
(
!
$id
=
$DB
->
get_field
(
'grade_items'
,
'id'
,
[
'itemname'
=>
$name
]))
{
throw
new
Exception
(
'The specified grade item with name "'
.
$name
.
'" could not be found.'
);
}
return
$id
;
}
/**
* Remove any empty custom fields, to avoid errors when creating the course.
*
...
...
lib/testing/generator/data_generator.php
View file @
6d46332a
...
...
@@ -1010,6 +1010,57 @@ EOD;
return
$gradecategory
->
get_record_data
();
}
/**
* Create a grade_grade.
*
* @param array $record
* @return grade_grade the grade record
*/
public
function
create_grade_grade
(
?array
$record
=
null
):
grade_grade
{
global
$DB
,
$USER
;
$item
=
$DB
->
get_record
(
'grade_items'
,
[
'id'
=>
$record
[
'itemid'
]]);
$userid
=
$record
[
'userid'
]
??
$USER
->
id
;
unset
(
$record
[
'itemid'
]);
unset
(
$record
[
'userid'
]);
if
(
$item
->
itemtype
===
'mod'
)
{
$cm
=
get_coursemodule_from_instance
(
$item
->
itemmodule
,
$item
->
iteminstance
);
$module
=
new
$item
->
itemmodule
(
context_module
::
instance
(
$cm
->
id
),
$cm
,
false
);
$record
[
'attemptnumber'
]
=
$record
[
'attemptnumber'
]
??
0
;
$module
->
save_grade
(
$userid
,
(
object
)
$record
);
$grade
=
grade_grade
::
fetch
([
'userid'
=>
$userid
,
'itemid'
=>
$item
->
id
]);
}
else
{
$grade
=
grade_grade
::
fetch
([
'userid'
=>
$userid
,
'itemid'
=>
$item
->
id
]);
$record
[
'rawgrade'
]
=
$record
[
'rawgrade'
]
??
$record
[
'grade'
]
??
null
;
$record
[
'finalgrade'
]
=
$record
[
'finalgrade'
]
??
$record
[
'grade'
]
??
null
;
unset
(
$record
[
'grade'
]);
if
(
$grade
)
{
$fields
=
$grade
->
required_fields
+
array_keys
(
$grade
->
optional_fields
);
foreach
(
$fields
as
$field
)
{
$grade
->
{
$field
}
=
$record
[
$field
]
??
$grade
->
{
$field
};
}
$grade
->
update
();
}
else
{
$record
[
'userid'
]
=
$userid
;
$record
[
'itemid'
]
=
$item
->
id
;
$grade
=
new
grade_grade
(
$record
,
false
);
$grade
->
insert
();
}
}
return
$grade
;
}
/**
* Create a grade_item.
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment