Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-68853

Create web service to trigger report_viewed event for H5P activities

XMLWordPrintable

    • MOODLE_38_STABLE
    • MOODLE_311_STABLE
    • MDL-68853-master
    • Hide
      1. Enable webservices in site advanced features
      2. create external webservice and enable it
      3. add mod_h5pactivity_log_report_viewed function to it
      4. create webservice user
      5. create a token at http://YOURMOODLE/admin/settings.php?section=webservicetokens and remember it as WSTOKEN
      6. create a course
      7. add h5pactivity to a course (you can use attached package)
      8. Go to your 5pactivity page - smth like http://YOURMOODLE/mod/h5pactivity/view.php?id=INSTANCEID and remember INSTANCEID
      9. Run this query to get H5PACTIVITYID:

        select instance from mdl_course_modules where id = INSTANCEID;
        

      10. enroll user
      11. Call a webservice:

        curl 'http://YOURMOODLE/webservice/rest/server.php?wsfunction=mod_h5pactivity_log_report_viewed&moodlewsrestformat=json&wstoken=WSTOKEN&h5pactivityid=H5PACTIVITYID&userid=USERID' | python -m "json.tool"
        

      12. Ensure you can see a log entry in course log page with name 'Report viewed' http://YOURMOODLE/report/log/index.php?id=COURSEID
      13. Ensure there is new log entry in mdl_logstore_standard_log

        SELECT * FROM mdl_logstore_standard_log where courseid = COURSEID and eventname = '\mod_h5pactivity\event\report_viewed';
        

        id                | 3161
        eventname         | \mod_h5pactivity\event\report_viewed
        component         | mod_h5pactivity
        action            | viewed
        target            | report
        objecttable       | h5pactivity
        objectid          | 4
        crud              | r
        edulevel          | 2
        contextid         | 308
        contextlevel      | 70
        contextinstanceid | 120
        userid            | 2
        courseid          | 12
        relateduserid     | 
        anonymous         | 0
        other             | {"instanceid":"4","userid":2,"attemptid":null}
        timecreated       | 1610371183
        origin            | ws
        ip                | 0:0:0:0:0:0:0:1
        realuserid        | 
        }

      Show
      Enable webservices in site advanced features create external webservice and enable it add mod_h5pactivity_log_report_viewed function to it create webservice user create a token at http://YOURMOODLE/admin/settings.php?section=webservicetokens and remember it as WSTOKEN create a course add h5pactivity to a course (you can use attached package) Go to your 5pactivity page - smth like http://YOURMOODLE/mod/h5pactivity/view.php?id=INSTANCEID and remember INSTANCEID Run this query to get H5PACTIVITYID: select instance from mdl_course_modules where id = INSTANCEID; enroll user Call a webservice: curl 'http://YOURMOODLE/webservice/rest/server.php?wsfunction=mod_h5pactivity_log_report_viewed&moodlewsrestformat=json&wstoken=WSTOKEN&h5pactivityid=H5PACTIVITYID&userid=USERID' | python -m "json.tool" Ensure you can see a log entry in course log page with name 'Report viewed' http://YOURMOODLE/report/log/index.php?id=COURSEID Ensure there is new log entry in mdl_logstore_standard_log SELECT * FROM mdl_logstore_standard_log where courseid = COURSEID and eventname = '\mod_h5pactivity\event\report_viewed' ; id | 3161 eventname | \mod_h5pactivity\event\report_viewed component | mod_h5pactivity action | viewed target | report objecttable | h5pactivity objectid | 4 crud | r edulevel | 2 contextid | 308 contextlevel | 70 contextinstanceid | 120 userid | 2 courseid | 12 relateduserid | anonymous | 0 other | { "instanceid" : "4" , "userid" : 2 , "attemptid" : null } timecreated | 1610371183 origin | ws ip | 0 : 0 : 0 : 0 : 0 : 0 : 0 : 1 realuserid | }
    • Moppies Kanban

      When a user views his attempts or a single attempt in web, a report_viewed event is triggered. We need a WebSevice to be able to trigger that event when the reports are viewed in the mobile app too.

            ilyatregubov Ilya Tregubov
            dpalou Dani Palou
            Carlos Escobedo Carlos Escobedo
            Andrew Lyons Andrew Lyons
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 31 minutes
                1d 31m

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