mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-69486 webservices: Added user and grade idnumber to grade items
This commit is contained in:
parent
a0fc902eb1
commit
1cdee63821
@ -165,6 +165,7 @@ class gradereport_user_external extends external_api {
|
|||||||
'courseid' => $course->id,
|
'courseid' => $course->id,
|
||||||
'userid' => $user->id,
|
'userid' => $user->id,
|
||||||
'userfullname' => fullname($user),
|
'userfullname' => fullname($user),
|
||||||
|
'useridnumber' => $user->idnumber,
|
||||||
'maxdepth' => $report->maxdepth,
|
'maxdepth' => $report->maxdepth,
|
||||||
);
|
);
|
||||||
if ($tabledata) {
|
if ($tabledata) {
|
||||||
@ -191,6 +192,7 @@ class gradereport_user_external extends external_api {
|
|||||||
'courseid' => $course->id,
|
'courseid' => $course->id,
|
||||||
'userid' => $currentuser->id,
|
'userid' => $currentuser->id,
|
||||||
'userfullname' => fullname($currentuser),
|
'userfullname' => fullname($currentuser),
|
||||||
|
'useridnumber' => $currentuser->idnumber,
|
||||||
'maxdepth' => $report->maxdepth,
|
'maxdepth' => $report->maxdepth,
|
||||||
);
|
);
|
||||||
if ($tabledata) {
|
if ($tabledata) {
|
||||||
@ -478,6 +480,7 @@ class gradereport_user_external extends external_api {
|
|||||||
'courseid' => new external_value(PARAM_INT, 'course id'),
|
'courseid' => new external_value(PARAM_INT, 'course id'),
|
||||||
'userid' => new external_value(PARAM_INT, 'user id'),
|
'userid' => new external_value(PARAM_INT, 'user id'),
|
||||||
'userfullname' => new external_value(PARAM_TEXT, 'user fullname'),
|
'userfullname' => new external_value(PARAM_TEXT, 'user fullname'),
|
||||||
|
'useridnumber' => new external_value(PARAM_TEXT, 'user idnumber'),
|
||||||
'maxdepth' => new external_value(PARAM_INT, 'table max depth (needed for printing it)'),
|
'maxdepth' => new external_value(PARAM_INT, 'table max depth (needed for printing it)'),
|
||||||
'gradeitems' => new external_multiple_structure(
|
'gradeitems' => new external_multiple_structure(
|
||||||
new external_single_structure(
|
new external_single_structure(
|
||||||
@ -488,6 +491,7 @@ class gradereport_user_external extends external_api {
|
|||||||
'itemmodule' => new external_value(PARAM_PLUGIN, 'Grade item module'),
|
'itemmodule' => new external_value(PARAM_PLUGIN, 'Grade item module'),
|
||||||
'iteminstance' => new external_value(PARAM_INT, 'Grade item instance'),
|
'iteminstance' => new external_value(PARAM_INT, 'Grade item instance'),
|
||||||
'itemnumber' => new external_value(PARAM_INT, 'Grade item item number'),
|
'itemnumber' => new external_value(PARAM_INT, 'Grade item item number'),
|
||||||
|
'idnumber' => new external_value(PARAM_TEXT, 'Grade item idnumber'),
|
||||||
'categoryid' => new external_value(PARAM_INT, 'Grade item category id'),
|
'categoryid' => new external_value(PARAM_INT, 'Grade item category id'),
|
||||||
'outcomeid' => new external_value(PARAM_INT, 'Outcome id'),
|
'outcomeid' => new external_value(PARAM_INT, 'Outcome id'),
|
||||||
'scaleid' => new external_value(PARAM_INT, 'Scale id'),
|
'scaleid' => new external_value(PARAM_INT, 'Scale id'),
|
||||||
|
@ -517,6 +517,7 @@ class grade_report_user extends grade_report {
|
|||||||
$gradeitemdata['itemmodule'] = $grade_object->itemmodule;
|
$gradeitemdata['itemmodule'] = $grade_object->itemmodule;
|
||||||
$gradeitemdata['iteminstance'] = $grade_object->iteminstance;
|
$gradeitemdata['iteminstance'] = $grade_object->iteminstance;
|
||||||
$gradeitemdata['itemnumber'] = $grade_object->itemnumber;
|
$gradeitemdata['itemnumber'] = $grade_object->itemnumber;
|
||||||
|
$gradeitemdata['idnumber'] = $grade_object->idnumber;
|
||||||
$gradeitemdata['categoryid'] = $grade_object->categoryid;
|
$gradeitemdata['categoryid'] = $grade_object->categoryid;
|
||||||
$gradeitemdata['outcomeid'] = $grade_object->outcomeid;
|
$gradeitemdata['outcomeid'] = $grade_object->outcomeid;
|
||||||
$gradeitemdata['scaleid'] = $grade_object->outcomeid;
|
$gradeitemdata['scaleid'] = $grade_object->outcomeid;
|
||||||
|
@ -52,7 +52,7 @@ class gradereport_user_externallib_testcase extends externallib_advanced_testcas
|
|||||||
$course = $this->getDataGenerator()->create_course(array('groupmode' => SEPARATEGROUPS, 'groupmodeforce' => 1));
|
$course = $this->getDataGenerator()->create_course(array('groupmode' => SEPARATEGROUPS, 'groupmodeforce' => 1));
|
||||||
|
|
||||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||||
$student1 = $this->getDataGenerator()->create_user();
|
$student1 = $this->getDataGenerator()->create_user(array('idnumber' => 'testidnumber'));
|
||||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||||
|
|
||||||
$student2 = $this->getDataGenerator()->create_user();
|
$student2 = $this->getDataGenerator()->create_user();
|
||||||
@ -76,8 +76,8 @@ class gradereport_user_externallib_testcase extends externallib_advanced_testcas
|
|||||||
$modcontext = get_coursemodule_from_instance('assign', $assignment->id, $course->id);
|
$modcontext = get_coursemodule_from_instance('assign', $assignment->id, $course->id);
|
||||||
$assignment->cmidnumber = $modcontext->id;
|
$assignment->cmidnumber = $modcontext->id;
|
||||||
|
|
||||||
$student1grade = array('userid' => $student1->id, 'rawgrade' => $s1grade);
|
$student1grade = array('userid' => $student1->id, 'rawgrade' => $s1grade, 'idnumber' => 'testidnumber1');
|
||||||
$student2grade = array('userid' => $student2->id, 'rawgrade' => $s2grade);
|
$student2grade = array('userid' => $student2->id, 'rawgrade' => $s2grade, 'idnumber' => 'testidnumber2');
|
||||||
$studentgrades = array($student1->id => $student1grade, $student2->id => $student2grade);
|
$studentgrades = array($student1->id => $student1grade, $student2->id => $student2grade);
|
||||||
assign_grade_item_update($assignment, $studentgrades);
|
assign_grade_item_update($assignment, $studentgrades);
|
||||||
|
|
||||||
@ -347,6 +347,7 @@ class gradereport_user_externallib_testcase extends externallib_advanced_testcas
|
|||||||
|
|
||||||
$this->assertEquals($course->id, $studentgrades['usergrades'][0]['courseid']);
|
$this->assertEquals($course->id, $studentgrades['usergrades'][0]['courseid']);
|
||||||
$this->assertEquals($student1->id, $studentgrades['usergrades'][0]['userid']);
|
$this->assertEquals($student1->id, $studentgrades['usergrades'][0]['userid']);
|
||||||
|
$this->assertEquals($student1->idnumber, $studentgrades['usergrades'][0]['useridnumber']);
|
||||||
$this->assertEquals($assignment->name, $studentgrades['usergrades'][0]['gradeitems'][0]['itemname']);
|
$this->assertEquals($assignment->name, $studentgrades['usergrades'][0]['gradeitems'][0]['itemname']);
|
||||||
$this->assertEquals('mod', $studentgrades['usergrades'][0]['gradeitems'][0]['itemtype']);
|
$this->assertEquals('mod', $studentgrades['usergrades'][0]['gradeitems'][0]['itemtype']);
|
||||||
$this->assertEquals('assign', $studentgrades['usergrades'][0]['gradeitems'][0]['itemmodule']);
|
$this->assertEquals('assign', $studentgrades['usergrades'][0]['gradeitems'][0]['itemmodule']);
|
||||||
@ -373,6 +374,10 @@ class gradereport_user_externallib_testcase extends externallib_advanced_testcas
|
|||||||
$this->assertEquals(2, $studentgrades['usergrades'][0]['gradeitems'][0]['numusers']);
|
$this->assertEquals(2, $studentgrades['usergrades'][0]['gradeitems'][0]['numusers']);
|
||||||
$this->assertEquals(70, $studentgrades['usergrades'][0]['gradeitems'][0]['averageformatted']);
|
$this->assertEquals(70, $studentgrades['usergrades'][0]['gradeitems'][0]['averageformatted']);
|
||||||
|
|
||||||
|
// Check that the idnumber for assignment grades is equal to the cmid.
|
||||||
|
$this->assertEquals((string) $studentgrades['usergrades'][0]['gradeitems'][0]['cmid'],
|
||||||
|
$studentgrades['usergrades'][0]['gradeitems'][0]['idnumber']);
|
||||||
|
|
||||||
// Hide one grade for the user.
|
// Hide one grade for the user.
|
||||||
$gradegrade = new grade_grade(array('userid' => $student1->id,
|
$gradegrade = new grade_grade(array('userid' => $student1->id,
|
||||||
'itemid' => $studentgrades['usergrades'][0]['gradeitems'][0]['id']), true);
|
'itemid' => $studentgrades['usergrades'][0]['gradeitems'][0]['id']), true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user