XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • None
    • 3.0
    • Choice, Web Services
    • MOODLE_30_STABLE
    • MDL-50138-master
    • 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 and timeclose as a future dates
      3. mark the Show Preview checkbox
      4. create 3 possible options for this choice
      5. create a student (student1)
      6. enroll student1 to this course
      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_options()
      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_options&choiceinstanceid=4&wstoken=19d196c6b5e94efb8c84dd534c1f9018' --compressed

      1. The webservice should return this kind of result:

      {"options":[{"id":1,"text":"PIZZA MARGHERITA","maxanswers":3,"displaylayout":false,"countanswers":1,"checked":false,"disabled":false},{"id":2,"text":"PIZZA 4 FORMAGGI","maxanswers":2,"displaylayout":false,"countanswers":2,"checked":false,"disabled":true},{"id":3,"text":"PIZZA DIAVOLA","maxanswers":2,"displaylayout":false,"countanswers":1,"checked":true,"disabled":false}],"warnings":[]}
      

      1. The webservice will return all the options (but the disabled property will be true)
      2. disabled = true, means we can see options but we cannot submit a response
      3. Open the choice activity by setting the timeclose as a future date
      4. Now as student1 choose a response between the available options
      5. call the webservice
      6. now the "checked" property will be true for that option you just choosed
      7. When the activity option setting: "Allow choice to be updated" is set as NO but you already submitted your response, you will also see all options as disabled=true
      8. If you close the activity by setting timeclose as a past day and call the webservice, you will receive a warning message advising you this activity has expired
      1. set the activity option setting "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 closes
      3. set the activity option setting "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 and timeclose as a future dates mark the Show Preview checkbox create 3 possible options for this choice create a student (student1) enroll student1 to this course 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_options() 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_options&choiceinstanceid=4&wstoken=19d196c6b5e94efb8c84dd534c1f9018' --compressed The webservice should return this kind of result: {"options":[{"id":1,"text":"PIZZA MARGHERITA","maxanswers":3,"displaylayout":false,"countanswers":1,"checked":false,"disabled":false},{"id":2,"text":"PIZZA 4 FORMAGGI","maxanswers":2,"displaylayout":false,"countanswers":2,"checked":false,"disabled":true},{"id":3,"text":"PIZZA DIAVOLA","maxanswers":2,"displaylayout":false,"countanswers":1,"checked":true,"disabled":false}],"warnings":[]} The webservice will return all the options (but the disabled property will be true) disabled = true, means we can see options but we cannot submit a response Open the choice activity by setting the timeclose as a future date Now as student1 choose a response between the available options call the webservice now the "checked" property will be true for that option you just choosed When the activity option setting: "Allow choice to be updated" is set as NO but you already submitted your response, you will also see all options as disabled=true If you close the activity by setting timeclose as a past day and call the webservice, you will receive a warning message advising you this activity has expired set the activity option setting "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 closes set the activity option setting "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 )

      Retrieve a list of choice options
      get_choice_options (choiseinstanceid) (use core API choice_prepare_options mod/choice/lib.php)

            ccito Costantino Cito
            jleyva Juan Leyva
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

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