Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.6
    • Fix Version/s: 2.6
    • Component/s: Assignment, Web Services
    • Labels:
    • Testing Instructions:
      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
      ===========

      1. Create a new assignment in a course. Note the id of the assignment in the database assign table.
      2. Enrol a teacher and students into the course.
      3. In the assignment "grade" settings, set "Use marking workflow" and "Use marking allocation" to Yes
      4. In the student submissions list, select a student
      5. Verify that the teacher has the capability mod/assign:grade
      6. 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"

      Show
      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"
    • Affected Branches:
      MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull Master Branch:

      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

        Gliffy Diagrams

          Activity

          Hide
          Damyon Wiese added a comment -

          This looks good Paul, thanks for the patch.

          I don't see the need for a separate create and update here. It would be annoying to try and create a user_flags record and get an error telling me to call update with the exact same parameters. I recommend only having one set_user_flags function that creates it if required.

          Show
          Damyon Wiese added a comment - This looks good Paul, thanks for the patch. I don't see the need for a separate create and update here. It would be annoying to try and create a user_flags record and get an error telling me to call update with the exact same parameters. I recommend only having one set_user_flags function that creates it if required.
          Hide
          Paul Charsley added a comment -

          Hi Damyon,

          I separated them into create and update because most of the other web service functions appear to have been designed this way (although I couldn't see anything in the documentation specifically talking about a standard pattern for create/update). However, I agree with your point and will combine them into one function as you suggest.

          Thanks, Paul

          Show
          Paul Charsley added a comment - Hi Damyon, I separated them into create and update because most of the other web service functions appear to have been designed this way (although I couldn't see anything in the documentation specifically talking about a standard pattern for create/update). However, I agree with your point and will combine them into one function as you suggest. Thanks, Paul
          Hide
          Paul Charsley added a comment -

          Modified to perform create and update in a single web service function. Rebased with latest weekly release. Assigned for peer review.

          Show
          Paul Charsley added a comment - Modified to perform create and update in a single web service function. Rebased with latest weekly release. Assigned for peer review.
          Hide
          Damyon Wiese added a comment -

          Looks good - just running unit tests now - if it passes I'll push for integration.

          Thanks Paul.

          Show
          Damyon Wiese added a comment - Looks good - just running unit tests now - if it passes I'll push for integration. Thanks Paul.
          Hide
          Damyon Wiese added a comment -

          All passed - thanks Paul - pushing for integration.

          Show
          Damyon Wiese added a comment - All passed - thanks Paul - pushing for integration.
          Hide
          Paul Charsley added a comment -

          Added test instructions. Rebased with latest weekly release.

          Show
          Paul Charsley added a comment - Added test instructions. Rebased with latest weekly release.
          Hide
          Sam Hemelryk added a comment -

          Thanks Paul this has been integrated now

          Show
          Sam Hemelryk added a comment - Thanks Paul this has been integrated now
          Hide
          Mark Nelson added a comment -

          I ran the PHPUnit test and it all passes. I did not perform the manual tests as it did state - "Manual tests can also be run if preferred". However, if I am required to run these as well I will do so.

          Thanks Paul for your contribution.

          Show
          Mark Nelson added a comment - I ran the PHPUnit test and it all passes. I did not perform the manual tests as it did state - "Manual tests can also be run if preferred". However, if I am required to run these as well I will do so. Thanks Paul for your contribution.
          Hide
          Dan Poltawski added a comment -

          You did it!

          Thanks for your contribution, this change has been merged upstream and is now available on your local git mirror and on download sites shortly.

          Show
          Dan Poltawski added a comment - You did it! Thanks for your contribution, this change has been merged upstream and is now available on your local git mirror and on download sites shortly.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: