Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31409 Incorporate Lightwork into the Moodle core
  3. MDL-31861

Create web service core_grading_save_definitions

XMLWordPrintable

    • MySQL
    • MOODLE_28_STABLE
    • Hide

      Both the unit tests and the following manual test should be run

      Manual test to add a new Marking Guide definition for an assignment
      ===================================================================

      1. Create a course and enrol a teacher into the course
      2. Create a new assignment in the course
      3. In the database, make a note of the following values
      • The course id (course table) - required to obtain the following values
      • The course module id of the assignment (course_modules table)
      • The context id of the assignment (context table)

      Following the instructions within Moodle, create a REST web service and add the function core_grading_save_definitions. 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_save_definitions'; // the web service function we are testing
       
      $gradingarea = array(
                  'cmid' => 3, // the course module id
                  'contextid' => 232, // the context id
                  'component' => 'mod_assign',
                  'areaname'  => 'submissions',
                  'activemethod' => 'guide'
              );
      $definition = array(
                  'method' => 'guide',
                  'name' => 'Understand zoonose control',
                  'description' => 'Demonstrate an understanding of the control of zoonoses',
                  'status' => 20,
                  'copiedfromid' => 1,
                  'timecreated' => 1,
                  'usercreated' => 199,
                  'timemodified' => 1,
                  'usermodified' => 199,
                  'timecopied' => 0
              );
      $guidecomment = array(
                   'sortorder' => 1,
                   'description' => 'Students need to show that they understand the control of zoonoses',
                   'descriptionformat' => 0
      );
      $guidecriteria1 = array (
                   'sortorder' => 1,
                   'shortname' => 'Rabies Control',
                   'description' => 'Understand rabies control',
                   'descriptionformat' => 0,
                   'descriptionmarkers' => 'Student must demonstrate that they understand rabies control',
                   'descriptionmarkersformat' => 0,
                   'maxscore' => 50
              );
      $guidecriteria2 = array (
                   'sortorder' => 2,
                   'shortname' => 'Anthrax Control',
                   'description' => 'Understand anthrax control',
                   'descriptionformat' => 0,
                   'descriptionmarkers' => 'Student must demonstrate that they understand anthrax control',
                   'descriptionmarkersformat' => 0,
                   'maxscore' => 50
              );
             
      $definition['guide'] = array('guide_criteria' => array($guidecriteria1, $guidecriteria2),
                                   'guide_comments' => array($guidecomment));
      $gradingarea['definitions'] = array($definition);
      $params = array('areas' => array ($gradingarea));
       
      ///// REST 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);
      

      The new Marking guide should now be visible in the UI

      Show
      Both the unit tests and the following manual test should be run Manual test to add a new Marking Guide definition for an assignment =================================================================== Create a course and enrol a teacher into the course Create a new assignment in the course In the database, make a note of the following values The course id (course table) - required to obtain the following values The course module id of the assignment (course_modules table) The context id of the assignment (context table) Following the instructions within Moodle, create a REST web service and add the function core_grading_save_definitions. 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_save_definitions'; // the web service function we are testing   $gradingarea = array( 'cmid' => 3, // the course module id 'contextid' => 232, // the context id 'component' => 'mod_assign', 'areaname' => 'submissions', 'activemethod' => 'guide' ); $definition = array( 'method' => 'guide', 'name' => 'Understand zoonose control', 'description' => 'Demonstrate an understanding of the control of zoonoses', 'status' => 20, 'copiedfromid' => 1, 'timecreated' => 1, 'usercreated' => 199, 'timemodified' => 1, 'usermodified' => 199, 'timecopied' => 0 ); $guidecomment = array( 'sortorder' => 1, 'description' => 'Students need to show that they understand the control of zoonoses', 'descriptionformat' => 0 ); $guidecriteria1 = array ( 'sortorder' => 1, 'shortname' => 'Rabies Control', 'description' => 'Understand rabies control', 'descriptionformat' => 0, 'descriptionmarkers' => 'Student must demonstrate that they understand rabies control', 'descriptionmarkersformat' => 0, 'maxscore' => 50 ); $guidecriteria2 = array ( 'sortorder' => 2, 'shortname' => 'Anthrax Control', 'description' => 'Understand anthrax control', 'descriptionformat' => 0, 'descriptionmarkers' => 'Student must demonstrate that they understand anthrax control', 'descriptionmarkersformat' => 0, 'maxscore' => 50 ); $definition['guide'] = array('guide_criteria' => array($guidecriteria1, $guidecriteria2), 'guide_comments' => array($guidecomment)); $gradingarea['definitions'] = array($definition); $params = array('areas' => array ($gradingarea));   ///// REST 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); The new Marking guide should now be visible in the UI

      Create web service core_grading_save_definitions

      Parameters: array of areas containing grading definitions with criteria to be inserted or updated
      Returns: Null. An exception is thrown if the user does not have the required capability or the grading method is unknown

            pcharsle Paul Charsley
            pcharsle Paul Charsley
            Marina Glancy Marina Glancy
            Damyon Wiese Damyon Wiese
            Jetha Chan Jetha Chan
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.