Details
-
Sub-task
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.6
-
MOODLE_26_STABLE
-
MOODLE_26_STABLE
-
Hide
This should be tested by running the test class mod_assign_external_testcase in mod/assign/tests/externallib_test.php. It can be run in phpunit with the following command:
phpunit mod_assign_external_testcase mod/assign/tests/externallib_test.php
This command will run tests test_set_user_flags() in addition to tests for other functions. All tests must pass.
Manual tests can also be run if preferrred:
Insert test
===========- Create a new assignment in a course. Note the id of the assignment in the database assign table.
- Enrol a teacher and students into the course.
- In the assignment "grade" settings, set "Use marking workflow" and "Use marking allocation" to Yes
- In the student submissions list, select a student
- Verify that the teacher has the capability mod/assign:grade
- Note the id of the teacher and the student in the database user table
Following the instructions within Moodle, create a REST web service and add the function mod_assign_get_user_flags. Give the teacher the capabilities as described in the Web Services Overview -> Users as clients with token.
Login as the teacher and create/obtain their security key
Use the Moodle local Web service template plugin to call the web service function. The client.php file should be as shown below:
client.php
$token = 'f4458487f63c0558484f4505d61f1245'; // the teachers security key
$domainname = 'http://localhost/moodledev'; // the Moodle server
$functionname = 'mod_assign_set_user_flags'; // the web service function we are testing
$userflag = array('userid'=>128,'workflowstate'=>'inmarking','allocatedmarker'=>195); // 128 is the student id, 195 is the teacher id
$userflags[] = $userflag;
$params = array('assignmentid'=>9, 'userflags'=>$userflags); // 9 is the assignment id
// The REST web service call
header('Content-Type: text/plain');
$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token. '&wsfunction='.$functionname;
require_once('./curl.php');
$curl = new curl;
$resp = $curl->post($serverurl, $params);
print_r($resp);
Verify that the student in the submissions list has a workflow state of "in marking" and is allocated to the teacher for marking
Update test
===========
Modify the client.php file as follows:client.php
$token = 'f4458487f63c0558484f4505d61f1245'; // the teachers security key
$domainname = 'http://localhost/moodledev'; // the Moodle server
$functionname = 'mod_assign_set_user_flags'; // the web service function we are testing
$userflag = array('userid'=>128,'workflowstate'=>'readyforreview','allocatedmarker'=>195); // 128 is the student id, 195 is the teacher id
$userflags[] = $userflag;
$params = array('assignmentid'=>9, 'userflags'=>$userflags); // 9 is the assignment id
// The REST web service call
header('Content-Type: text/plain');
$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token. '&wsfunction='.$functionname;
require_once('./curl.php');
$curl = new curl;
$resp = $curl->post($serverurl, $params);
print_r($resp);
Verify that the student in the submissions list now has a workflow state of "ready for review"
ShowThis should be tested by running the test class mod_assign_external_testcase in mod/assign/tests/externallib_test.php. It can be run in phpunit with the following command: phpunit mod_assign_external_testcase mod/assign/tests/externallib_test.php This command will run tests test_set_user_flags() in addition to tests for other functions. All tests must pass. Manual tests can also be run if preferrred: Insert test =========== Create a new assignment in a course. Note the id of the assignment in the database assign table. Enrol a teacher and students into the course. In the assignment "grade" settings, set "Use marking workflow" and "Use marking allocation" to Yes In the student submissions list, select a student Verify that the teacher has the capability mod/assign:grade Note the id of the teacher and the student in the database user table Following the instructions within Moodle, create a REST web service and add the function mod_assign_get_user_flags. Give the teacher the capabilities as described in the Web Services Overview -> Users as clients with token. Login as the teacher and create/obtain their security key Use the Moodle local Web service template plugin to call the web service function. The client.php file should be as shown below: client.php $token = 'f4458487f63c0558484f4505d61f1245'; // the teachers security key $domainname = 'http://localhost/moodledev'; // the Moodle server $functionname = 'mod_assign_set_user_flags'; // the web service function we are testing $userflag = array('userid'=>128,'workflowstate'=>'inmarking','allocatedmarker'=>195); // 128 is the student id, 195 is the teacher id $userflags[] = $userflag; $params = array('assignmentid'=>9, 'userflags'=>$userflags); // 9 is the assignment id // The REST web service call header('Content-Type: text/plain'); $serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token. '&wsfunction='.$functionname; require_once('./curl.php'); $curl = new curl; $resp = $curl->post($serverurl, $params); print_r($resp); Verify that the student in the submissions list has a workflow state of "in marking" and is allocated to the teacher for marking Update test =========== Modify the client.php file as follows: client.php $token = 'f4458487f63c0558484f4505d61f1245'; // the teachers security key $domainname = 'http://localhost/moodledev'; // the Moodle server $functionname = 'mod_assign_set_user_flags'; // the web service function we are testing $userflag = array('userid'=>128,'workflowstate'=>'readyforreview','allocatedmarker'=>195); // 128 is the student id, 195 is the teacher id $userflags[] = $userflag; $params = array('assignmentid'=>9, 'userflags'=>$userflags); // 9 is the assignment id // The REST web service call header('Content-Type: text/plain'); $serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token. '&wsfunction='.$functionname; require_once('./curl.php'); $curl = new curl; $resp = $curl->post($serverurl, $params); print_r($resp); Verify that the student in the submissions list now has a workflow state of "ready for review"
Description
A Web service function is required to update and create records in the user_flags table. These may be used by web services clients wishing to work with the new marking management and workflow functionality. The web service function will be:
- mod_assign_set_user_flags