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_get_user_flags() and test_get_user_mappings() in addition to tests for other functions. All tests must pass.

      A manual test can also be run for each function if preferrred:

      mod_assign_get_user_flags
      =========================

      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 and set their workflow state to "In marking" and the allocated marker to the name of the teacher
      5. 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_get_user_flags'; // the web service function we are testing
      $assignmentids[] = 1; // the assignment id
      $params = array('assignmentids'=>$assignmentids); // the parameters
      // 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 the results by searching for the assignmentid. Nested inside this element you should find an element representing a record in the user_flags database table with a userid for the selected student. This element must have workflowstate - "inmarking" and allocatedmarker that is the id of the teacher.

      mod_assign_get_user_mappings
      =========================

      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 "Blind marking" to Yes
      4. Note the user id of the students in the database user table
      5. Select "View/grade all submissions". You should see the students listed as "ParticipantId". Id represents the id of the mapping record in the assign_user_mapping table

      Following the instructions within Moodle, create a REST web service and add the function mod_assign_get_user_mappings. 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_get_user_mappings'; // the web service function we are testing
      $assignmentids[] = 1; // the assignment id
      $params = array('assignmentids'=>$assignmentids); // the parameters
      // 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 the results by searching for the assignmentid. There should be an associated list of "mappings". There should be a mapping for each student.

      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_get_user_flags() and test_get_user_mappings() in addition to tests for other functions. All tests must pass. A manual test can also be run for each function if preferrred: mod_assign_get_user_flags ========================= 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 and set their workflow state to "In marking" and the allocated marker to the name of the teacher 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_get_user_flags'; // the web service function we are testing $assignmentids[] = 1; // the assignment id $params = array('assignmentids'=>$assignmentids); // the parameters // 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 the results by searching for the assignmentid. Nested inside this element you should find an element representing a record in the user_flags database table with a userid for the selected student. This element must have workflowstate - "inmarking" and allocatedmarker that is the id of the teacher. mod_assign_get_user_mappings ========================= 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 "Blind marking" to Yes Note the user id of the students in the database user table Select "View/grade all submissions". You should see the students listed as "ParticipantId". Id represents the id of the mapping record in the assign_user_mapping table Following the instructions within Moodle, create a REST web service and add the function mod_assign_get_user_mappings. 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_get_user_mappings'; // the web service function we are testing $assignmentids[] = 1; // the assignment id $params = array('assignmentids'=>$assignmentids); // the parameters // 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 the results by searching for the assignmentid. There should be an associated list of "mappings". There should be a mapping for each student.
    • Affected Branches:
      MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull Master Branch:

      Description

      Two web service functions, mod_assign_get_user_mapping and mod_assign_get_user_flags, return information about marking allocation, marking workflow and blind marking contained in the tables user_flags and user_mapping.

      Each web service function accepts a single parameter - an array of assignmentids specifying which assignment information to return.

        Gliffy Diagrams

          Activity

          Hide
          Damyon Wiese added a comment -

          Hi Paul,

          Quick comment - it does not make sense to bunch all this in a single function (I know you want this for performance, but it is not a nice API).

          Show
          Damyon Wiese added a comment - Hi Paul, Quick comment - it does not make sense to bunch all this in a single function (I know you want this for performance, but it is not a nice API).
          Hide
          Paul Charsley added a comment -

          Hi Damyon,

          OK, I'll split this into 2 functions, mod_assign_get_user_flags and mod_assign_get_user_mapping if that is acceptable.

          Show
          Paul Charsley added a comment - Hi Damyon, OK, I'll split this into 2 functions, mod_assign_get_user_flags and mod_assign_get_user_mapping if that is acceptable.
          Hide
          Damyon Wiese added a comment -

          Yes please (you can still do it in this one issue).

          Show
          Damyon Wiese added a comment - Yes please (you can still do it in this one issue).
          Hide
          Paul Charsley added a comment -

          Ready for peer review

          Show
          Paul Charsley added a comment - Ready for peer review
          Hide
          Paul Charsley added a comment -

          Rebased with the weekly release. Ready for peer review.

          Show
          Paul Charsley added a comment - Rebased with the weekly release. Ready for peer review.
          Hide
          Damyon Wiese added a comment -

          Hi Paul,

          Thank-you for working on this.

          General comment:

          I dis-like these externallib functions that go direct to the database and do not use the built assignment functions to get the required information. But the assignment functions are not meant to handle multiple assignments with a single query (and I don't really want it to).

          The one thing that actually needs fixing - is that the permission required to load the identities of the users should be 'mod/assign:revealidentities' not 'mod/assign:grade'.

          Feel free to send this for integration once that capability is changed.

          Cheers - Damyon

          Show
          Damyon Wiese added a comment - Hi Paul, Thank-you for working on this. General comment: I dis-like these externallib functions that go direct to the database and do not use the built assignment functions to get the required information. But the assignment functions are not meant to handle multiple assignments with a single query (and I don't really want it to). The one thing that actually needs fixing - is that the permission required to load the identities of the users should be 'mod/assign:revealidentities' not 'mod/assign:grade'. Feel free to send this for integration once that capability is changed. Cheers - Damyon
          Hide
          Paul Charsley added a comment -

          Hi Damyon,

          I've fixed the incorrect capability but I don't think I have the access rights to send it straight to integration? Can I be given these access rights? I've assigned it into peer review. Please can you send it to integration?

          Thanks, Paul

          Show
          Paul Charsley added a comment - Hi Damyon, I've fixed the incorrect capability but I don't think I have the access rights to send it straight to integration? Can I be given these access rights? I've assigned it into peer review. Please can you send it to integration? Thanks, Paul
          Hide
          Damyon Wiese added a comment -

          Hi Paul,

          I've sent this to integration for you and pulled it into this weeks set of issues.

          Show
          Damyon Wiese added a comment - Hi Paul, I've sent this to integration for you and pulled it into this weeks set of issues.
          Hide
          Dan Poltawski added a comment -

          Hi Paul,

          We need some testing instructions for this change?

          Show
          Dan Poltawski added a comment - Hi Paul, We need some testing instructions for this change?
          Hide
          Paul Charsley added a comment -

          Hi Dan, I've added instructions to run the unit tests. Is that OK?
          Paul

          Show
          Paul Charsley added a comment - Hi Dan, I've added instructions to run the unit tests. Is that OK? Paul
          Hide
          Dan Poltawski added a comment -

          Hi Paul,

          Could add some manual testing instructions for the function too, as the unit tests only test the actual external function and now the whole mechanics of it.

          I've integrated this to master now.

          cheers,
          dan

          Show
          Dan Poltawski added a comment - Hi Paul, Could add some manual testing instructions for the function too, as the unit tests only test the actual external function and now the whole mechanics of it. I've integrated this to master now. cheers, dan
          Hide
          Paul Charsley added a comment -

          Hi Dan, manual instructions have been added.
          Paul

          Show
          Paul Charsley added a comment - Hi Dan, manual instructions have been added. Paul
          Hide
          Ankit Agarwal added a comment -

          phpunit are executed automatically during integration, so skipping.
          Rest things work as described.
          passing.
          Thanks

          Show
          Ankit Agarwal added a comment - phpunit are executed automatically during integration, so skipping. Rest things work as described. passing. Thanks
          Hide
          Sam Hemelryk added a comment -

          Against all probability we've achieved normality. You changes didn't break the tests I pretended to run and are now immortalised upstream. Good for you!

          "It was a programming technique that had been reverse-engineered from the sort of psychotic mental blocks that otherwise perfectly normal people had been observed invariably to develop when elected to high political office."
          Adams, D (1992) Mostly Harmless. London: William Heinemann.

          Show
          Sam Hemelryk added a comment - Against all probability we've achieved normality. You changes didn't break the tests I pretended to run and are now immortalised upstream. Good for you! "It was a programming technique that had been reverse-engineered from the sort of psychotic mental blocks that otherwise perfectly normal people had been observed invariably to develop when elected to high political office." Adams, D (1992) Mostly Harmless. London: William Heinemann.

            People

            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: