Details

    • Testing Instructions:
      Hide

      Run the unit tests at grade/tests/externallib_test.php.

      A manual test can also be run if preferrred:

      1. Create a new assignment in a course.
      2. Enrol a teacher and students into the course
      3. Login as the teacher
        1. Define a marking guide with two criteria in Assignment administration -> Advanced grading and make it ready for use
        2. Select view/grade all submissions
        3. Select a student and grade them by giving them scores for the two criteria defined in the marking guide
      4. Find the marking guide record in the GRADING_DEFINITIONS database table and note the id

      Following the instructions within Moodle, create a REST web service and add the function core_grading_get_gradingform_instances.
      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 = 'core_grading_get_gradingform_instances'; // the web service function we are testing
      $params = array('definitionid'=>3); // the parameters (assuming a definition id of 3)
      // 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 checking that both criteria are returned with the correct scores.

      Show
      Run the unit tests at grade/tests/externallib_test.php. A manual test can also be run if preferrred: Create a new assignment in a course. Enrol a teacher and students into the course Login as the teacher Define a marking guide with two criteria in Assignment administration -> Advanced grading and make it ready for use Select view/grade all submissions Select a student and grade them by giving them scores for the two criteria defined in the marking guide Find the marking guide record in the GRADING_DEFINITIONS database table and note the id Following the instructions within Moodle, create a REST web service and add the function core_grading_get_gradingform_instances. 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 = 'core_grading_get_gradingform_instances'; // the web service function we are testing $params = array('definitionid'=>3); // the parameters (assuming a definition id of 3) // 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 checking that both criteria are returned with the correct scores.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull Master Branch:
    • Rank:
      38536

      Description

      Returns grading form instances data from the grading_instances and gradingform_XXX_fillings tables.

      Parameters:
      definition id
      array of itemids (optional)
      modified_since (optional)
      Returns:
      array of grading form instance data

        Issue Links

          Activity

          Hide
          Jérôme Mouneyrac added a comment -

          Could that be encapsulated in core_grade_get_grades in an optional element ? Would it be an advantage (in which use case would you call these function, do you need to call core_grade_get_gradingform_instances before)?

          If not I guess these three get/create/update_grading_instances can go into the roadmap.

          Show
          Jérôme Mouneyrac added a comment - Could that be encapsulated in core_grade_get_grades in an optional element ? Would it be an advantage (in which use case would you call these function, do you need to call core_grade_get_gradingform_instances before)? If not I guess these three get/create/update_grading_instances can go into the roadmap.
          Hide
          Paul Charsley added a comment -

          Hi Jerome, I don't believe it would be appropriate to encapsulate this into core_grade_get_grades. Grading instances are separate to grades and so I think it makes sense to have separate web services.

          Show
          Paul Charsley added a comment - Hi Jerome, I don't believe it would be appropriate to encapsulate this into core_grade_get_grades. Grading instances are separate to grades and so I think it makes sense to have separate web services.
          Hide
          Paul Charsley added a comment -

          Hi Marina,

          Assigning to you for peer review.

          Thanks, Paul

          Show
          Paul Charsley added a comment - Hi Marina, Assigning to you for peer review. Thanks, Paul
          Hide
          Marina Glancy added a comment -

          Hi Paul, thanks for working on it.
          Sorry it took me so long to start looking at it. I was looking at more prioritised tasks thinking that this issue won't be integrated until the end of on-sync period anyway.

          I like your solution. There are a couple small things I've noticed:
          1. Make sure all functions have phpdocs with function description (and it is separated with a newline from parameters list)

          2. it is an interesting fact that all advanced grading methods already have function get_<method>_filling, assumably copied from rubric. But it is not a part of API, so you should check that function exists before calling it. We don't want php fatal errors:
          https://github.com/Lightwork-Marking/moodle/compare/master...MDL-31890#L0R357
          Maybe developer debugging message should be displayed, although I don't know how will debugging message work with web services.
          (I saw that you mentioned it in phpdocs but it may not be enough)

          Great work!

          Show
          Marina Glancy added a comment - Hi Paul, thanks for working on it. Sorry it took me so long to start looking at it. I was looking at more prioritised tasks thinking that this issue won't be integrated until the end of on-sync period anyway. I like your solution. There are a couple small things I've noticed: 1. Make sure all functions have phpdocs with function description (and it is separated with a newline from parameters list) 2. it is an interesting fact that all advanced grading methods already have function get_<method>_filling, assumably copied from rubric. But it is not a part of API, so you should check that function exists before calling it. We don't want php fatal errors: https://github.com/Lightwork-Marking/moodle/compare/master...MDL-31890#L0R357 Maybe developer debugging message should be displayed, although I don't know how will debugging message work with web services. (I saw that you mentioned it in phpdocs but it may not be enough) Great work!
          Hide
          Paul Charsley added a comment -

          Hi Marina,
          Thanks for reviewing this. I've updated the phpdocs and also modified the code to check that the get_<method>_filling function exists prior to calling it. I've also created warning messages for when this problem occurs.
          Thanks, Paul

          Show
          Paul Charsley added a comment - Hi Marina, Thanks for reviewing this. I've updated the phpdocs and also modified the code to check that the get_<method>_filling function exists prior to calling it. I've also created warning messages for when this problem occurs. Thanks, Paul
          Hide
          Paul Charsley added a comment -

          Rebased with the latest weekly release.

          Show
          Paul Charsley added a comment - Rebased with the latest weekly release.
          Hide
          Paul Charsley added a comment -

          Hi Marina, I've rebased with the latest weekly release. Ready for peer review.
          Thanks, Paul

          Show
          Paul Charsley added a comment - Hi Marina, I've rebased with the latest weekly release. Ready for peer review. Thanks, Paul
          Hide
          Paul Charsley added a comment -

          Rebased with the latest weekly release and ready for peer review.

          Show
          Paul Charsley added a comment - Rebased with the latest weekly release and ready for peer review.
          Hide
          Paul Charsley added a comment -

          Rebased with the latest weekly release and ready for peer review

          Show
          Paul Charsley added a comment - Rebased with the latest weekly release and ready for peer review
          Hide
          Paul Charsley added a comment -

          Returning to development to rename to core_grading_get_gradingform_instances

          Show
          Paul Charsley added a comment - Returning to development to rename to core_grading_get_gradingform_instances
          Hide
          Paul Charsley added a comment -

          Updated to rename web service functions to core_grading_xx. Successfully ran unit tests and rebased with the latest weekly release. Ready for peer review.

          Show
          Paul Charsley added a comment - Updated to rename web service functions to core_grading_xx. Successfully ran unit tests and rebased with the latest weekly release. Ready for peer review.
          Hide
          Paul Charsley added a comment -

          Rebased with the latest weekly release. Ready for peer review.

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

          Rebased with the latest weekly release. Ready for peer review. Note that I haven't added a deprecated web service function for the renamed core_grade_get_definitions because I believe that is being done in MDL-30085.

          Show
          Paul Charsley added a comment - Rebased with the latest weekly release. Ready for peer review. Note that I haven't added a deprecated web service function for the renamed core_grade_get_definitions because I believe that is being done in MDL-30085 .
          Hide
          Paul Charsley added a comment -

          Rebased with the latest weekly release. Successfully ran phpunit tests. I have also added the deprecated web service function for the renamed core_grade_get_definitions.

          Ready for peer review.

          Show
          Paul Charsley added a comment - Rebased with the latest weekly release. Successfully ran phpunit tests. I have also added the deprecated web service function for the renamed core_grade_get_definitions. Ready for peer review.
          Hide
          Paul Charsley added a comment -

          Rebased with the latest weekly release. Ready for peer review.

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

          Rebased with the latest weekly release. Ready for peer review.

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

          Rebased with the latest weekly release. Ready for peer review.

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

          Rebased with the latest weekly release. Ready for peer review.

          Show
          Paul Charsley added a comment - Rebased with the latest weekly release. Ready for peer review.
          Hide
          Marina Glancy added a comment -

          Hi Paul, sorry it took so long.
          The code looks good, I'm submitting it for integration

          For the future, please try to avoid space when declaring a function between it's name and open bracket.

          Show
          Marina Glancy added a comment - Hi Paul, sorry it took so long. The code looks good, I'm submitting it for integration For the future, please try to avoid space when declaring a function between it's name and open bracket.
          Hide
          Marina Glancy added a comment -

          TO INTEGRATORS: I added commit correcting one of phpdocs. Also removed the whitespaces after function name:

          git pull git://github.com/marinaglancy/moodle wip-MDL-31890-master
          

          https://github.com/marinaglancy/moodle/compare/master...wip-MDL-31890-master

          Show
          Marina Glancy added a comment - TO INTEGRATORS: I added commit correcting one of phpdocs. Also removed the whitespaces after function name: git pull git: //github.com/marinaglancy/moodle wip-MDL-31890-master https://github.com/marinaglancy/moodle/compare/master...wip-MDL-31890-master
          Hide
          Dan Poltawski added a comment -

          Thanks Paul/Marina, i've integrated this to master (along with a trailing whitespace fix and version bump).

          Show
          Dan Poltawski added a comment - Thanks Paul/Marina, i've integrated this to master (along with a trailing whitespace fix and version bump).
          Hide
          Dan Poltawski added a comment -

          Ah, please can you add testing instructions!

          Show
          Dan Poltawski added a comment - Ah, please can you add testing instructions!
          Hide
          Paul Charsley added a comment -

          Thanks Marina, Dan. Testing instructions added. I will make a note to remember not to add a space between the function name and the open bracket.

          Show
          Paul Charsley added a comment - Thanks Marina, Dan. Testing instructions added. I will make a note to remember not to add a space between the function name and the open bracket.
          Hide
          David Monllaó added a comment -

          Unit test passing in CI server, manual test also passing:

          <RESPONSE>
          <SINGLE>
          <KEY name="instances"><MULTIPLE>
          <SINGLE>
          <KEY name="id"><VALUE>2</VALUE>
          </KEY>
          <KEY name="raterid"><VALUE>1004</VALUE>
          </KEY>
          <KEY name="itemid"><VALUE>1</VALUE>
          </KEY>
          <KEY name="rawgrade"><VALUE null="null"/>
          </KEY>
          <KEY name="status"><VALUE>1</VALUE>
          </KEY>
          <KEY name="feedback"><VALUE></VALUE>
          </KEY>
          <KEY name="feedbackformat"><VALUE>1</VALUE>
          </KEY>
          <KEY name="timemodified"><VALUE>1378262087</VALUE>
          </KEY>
          <KEY name="guide"><SINGLE>
          <KEY name="criteria"><MULTIPLE>
          <SINGLE>
          <KEY name="id"><VALUE>1</VALUE>
          </KEY>
          <KEY name="criterionid"><VALUE>1</VALUE>
          </KEY>
          <KEY name="levelid"><VALUE null="null"/>
          </KEY>
          <KEY name="remark"><VALUE>grade1</VALUE>
          </KEY>
          <KEY name="remarkformat"><VALUE>1</VALUE>
          </KEY>
          <KEY name="score"><VALUE>6</VALUE>
          </KEY>
          </SINGLE>
          <SINGLE>
          <KEY name="id"><VALUE>2</VALUE>
          </KEY>
          <KEY name="criterionid"><VALUE>2</VALUE>
          </KEY>
          <KEY name="levelid"><VALUE null="null"/>
          </KEY>
          <KEY name="remark"><VALUE>grade2</VALUE>
          </KEY>
          <KEY name="remarkformat"><VALUE>1</VALUE>
          </KEY>
          <KEY name="score"><VALUE>5</VALUE>
          </KEY>
          </SINGLE>
          </MULTIPLE>
          </KEY>
          </SINGLE>
          </KEY>
          <KEY name="rubric"><SINGLE>
          <KEY name="criteria"><MULTIPLE>
          </MULTIPLE>
          </KEY>
          </SINGLE>
          </KEY>
          </SINGLE>
          </MULTIPLE>
          </KEY>
          <KEY name="warnings"><MULTIPLE>
          </MULTIPLE>
          </KEY>
          </SINGLE>
          </RESPONSE>
          
          Show
          David Monllaó added a comment - Unit test passing in CI server, manual test also passing: <RESPONSE> <SINGLE> <KEY name= "instances" ><MULTIPLE> <SINGLE> <KEY name= "id" ><VALUE>2</VALUE> </KEY> <KEY name= "raterid" ><VALUE>1004</VALUE> </KEY> <KEY name= "itemid" ><VALUE>1</VALUE> </KEY> <KEY name= "rawgrade" ><VALUE null = " null " /> </KEY> <KEY name= "status" ><VALUE>1</VALUE> </KEY> <KEY name= "feedback" ><VALUE></VALUE> </KEY> <KEY name= "feedbackformat" ><VALUE>1</VALUE> </KEY> <KEY name= "timemodified" ><VALUE>1378262087</VALUE> </KEY> <KEY name= "guide" ><SINGLE> <KEY name= "criteria" ><MULTIPLE> <SINGLE> <KEY name= "id" ><VALUE>1</VALUE> </KEY> <KEY name= "criterionid" ><VALUE>1</VALUE> </KEY> <KEY name= "levelid" ><VALUE null = " null " /> </KEY> <KEY name= "remark" ><VALUE>grade1</VALUE> </KEY> <KEY name= "remarkformat" ><VALUE>1</VALUE> </KEY> <KEY name= "score" ><VALUE>6</VALUE> </KEY> </SINGLE> <SINGLE> <KEY name= "id" ><VALUE>2</VALUE> </KEY> <KEY name= "criterionid" ><VALUE>2</VALUE> </KEY> <KEY name= "levelid" ><VALUE null = " null " /> </KEY> <KEY name= "remark" ><VALUE>grade2</VALUE> </KEY> <KEY name= "remarkformat" ><VALUE>1</VALUE> </KEY> <KEY name= "score" ><VALUE>5</VALUE> </KEY> </SINGLE> </MULTIPLE> </KEY> </SINGLE> </KEY> <KEY name= "rubric" ><SINGLE> <KEY name= "criteria" ><MULTIPLE> </MULTIPLE> </KEY> </SINGLE> </KEY> </SINGLE> </MULTIPLE> </KEY> <KEY name= "warnings" ><MULTIPLE> </MULTIPLE> </KEY> </SINGLE> </RESPONSE>
          Hide
          Dan Poltawski added a comment -

          Congratulations! This change has been integrated upstream and is now available from our git and download mirrors. To celebrate, here is a joke:

          A SQL query goes into a bar, walks up to two tables and asks, "Can I join you?"

          Show
          Dan Poltawski added a comment - Congratulations! This change has been integrated upstream and is now available from our git and download mirrors. To celebrate, here is a joke: A SQL query goes into a bar, walks up to two tables and asks, "Can I join you?"
          Hide
          Michael de Raadt added a comment -

          Removing the dev_docs_required label as this is now documented in the embedded Web services documentation.

          Show
          Michael de Raadt added a comment - Removing the dev_docs_required label as this is now documented in the embedded Web services documentation.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: