XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.0
    • Fix Version/s: None
    • Component/s: Choice, Web Services
    • Labels:
    • Testing Instructions:
      Hide

      Note: Version number is bumped because a new web service is added into the Mobile app service.

      1. create a course with a choice/activity
      2. set timeopen as a past date and timeclose as a future date
      3. set the activity option Publish Results as "Show results to students after they answer"
      4. set the activity option Privacy of results as "Publish full results, showing names and their choices"
      5. create 3 possible options for this choice
      6. create two students (student1 and student2)
      7. enroll student1 to this course
      8. as student1 choose a response between the possible options
      1. Create a Token for the Student1:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      2. Next, you can do a couple of CURL REST call simulating a WS client as Student
      1. As student1 call get_choice_results()
      2. using a curl call as in the following example:

      curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, /; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'wsfunction=mod_choice_get_choice_results&choiceinstanceid=4&wstoken=19d196c6b5e94efb8c84dd534c1f9018' --compressed

      1. the result of the webservice call should show all the possible options, plus the option (ID = 0) which reports a list of users who did not answered yet
      2. verify that student1 is listed into the option's userresponses property for the correct option
      3. verify that student2 is listed into the option's userresponses property of the option zero (as he did not choose any response)
      1. The webservice should return this kind of result:

        {"options":[{"id":1,"text":"PIZZA MARGHERITA","maxanswer":3,"userresponses":[{"userid":5,"fullname":"student2 student2","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/25\/user\/icon\/f1","answerid":4,"timemodified":1431966375}],"numberofuser":1,"percentageamount":20},{"id":2,"text":"PIZZA 4 FORMAGGI","maxanswer":2,"userresponses":[{"userid":4,"fullname":"student1 student1","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/24\/user\/icon\/f1","answerid":8,"timemodified":1432023005},{"userid":6,"fullname":"teacher1 teacher1","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/26\/user\/icon\/f1","answerid":11,"timemodified":1433341128}],"numberofuser":2,"percentageamount":40},{"id":3,"text":"PIZZA DIAVOLA","maxanswer":2,"userresponses":[{"userid":8,"fullname":"student3 student3","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/59\/user\/icon\/f1","answerid":12,"timemodified":1433516029}],"numberofuser":1,"percentageamount":20},{"id":0,"text":"Not answered yet","maxanswer":0,"userresponses":[{"userid":7,"fullname":"teacher2 teacher2","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/30\/user\/icon\/f1"}],"numberofuser":1,"percentageamount":20}],"warnings":[]}
        

      1. set the activity option Publish Results as "Show results to students only after the choice is closed"
      2. in this case the webservice will return an exception error, as we cannot see results until the activity close
      3. set the activity option Privacy of results as "Publish anonymous results, do not show student names" will make the webservice hiding the userresponses
        ( you will still be able to see useful properties like numberofuser and percentageamount )
      Show
      Note: Version number is bumped because a new web service is added into the Mobile app service. create a course with a choice/activity set timeopen as a past date and timeclose as a future date set the activity option Publish Results as "Show results to students after they answer" set the activity option Privacy of results as "Publish full results, showing names and their choices" create 3 possible options for this choice create two students (student1 and student2) enroll student1 to this course as student1 choose a response between the possible options Create a Token for the Student1: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a couple of CURL REST call simulating a WS client as Student As student1 call get_choice_results() using a curl call as in the following example: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file:// ' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, / ; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'wsfunction=mod_choice_get_choice_results&choiceinstanceid=4&wstoken=19d196c6b5e94efb8c84dd534c1f9018' --compressed the result of the webservice call should show all the possible options, plus the option (ID = 0) which reports a list of users who did not answered yet verify that student1 is listed into the option's userresponses property for the correct option verify that student2 is listed into the option's userresponses property of the option zero (as he did not choose any response) The webservice should return this kind of result: {"options":[{"id":1,"text":"PIZZA MARGHERITA","maxanswer":3,"userresponses":[{"userid":5,"fullname":"student2 student2","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/25\/user\/icon\/f1","answerid":4,"timemodified":1431966375}],"numberofuser":1,"percentageamount":20},{"id":2,"text":"PIZZA 4 FORMAGGI","maxanswer":2,"userresponses":[{"userid":4,"fullname":"student1 student1","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/24\/user\/icon\/f1","answerid":8,"timemodified":1432023005},{"userid":6,"fullname":"teacher1 teacher1","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/26\/user\/icon\/f1","answerid":11,"timemodified":1433341128}],"numberofuser":2,"percentageamount":40},{"id":3,"text":"PIZZA DIAVOLA","maxanswer":2,"userresponses":[{"userid":8,"fullname":"student3 student3","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/59\/user\/icon\/f1","answerid":12,"timemodified":1433516029}],"numberofuser":1,"percentageamount":20},{"id":0,"text":"Not answered yet","maxanswer":0,"userresponses":[{"userid":7,"fullname":"teacher2 teacher2","profileimageurl":"http:\/\/localhost\/m\/stable_master\/webservice\/pluginfile.php\/30\/user\/icon\/f1"}],"numberofuser":1,"percentageamount":20}],"warnings":[]} set the activity option Publish Results as "Show results to students only after the choice is closed" in this case the webservice will return an exception error, as we cannot see results until the activity close set the activity option Privacy of results as "Publish anonymous results, do not show student names" will make the webservice hiding the userresponses ( you will still be able to see useful properties like numberofuser and percentageamount )
    • Affected Branches:
      MOODLE_30_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-50137-master

      Description

      Retrieve choice's results.
      Use core API prepare_choice_show_result

        Attachments

          Activity

            People

            • Assignee:
              ccito Costantino Cito
              Reporter:
              jleyva Juan Leyva
              Participants:
              Component watchers:
              Dan Marsden, Jake Dallimore, Jun Pataleta, Ryan Wyllie, Juan Leyva, Jake Dallimore, Jun Pataleta, Ryan Wyllie
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: