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

mod_assign_get_submissions not returning group submissions

XMLWordPrintable

    • MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_38_STABLE, MOODLE_39_STABLE
    • MDL-68605_master
    • Hide

      Setup

      1. As an admin, create a course.
      2. Enrol one teacher and one student.
      3. Create a group.
      4. Add the student to the group.
      5. Create an assignment with "Students submit in groups" -> Yes.
      6. Enable web services
        1. As admin go to Site administration -> Advanced features
        2. Select "Enable web services"
        3. Click "Save changes".
      7. Enable REST protocol
        1. As admin go to Site administration -> Plugins -> Web services -> Manage protocols
        2. Enable "REST protocol"
        3. Click "Save changes".
      8. Enable web services for mobile devices
        1. As admin go to Site administration -> Mobile app -> Mobile settings
        2. Select "Enable web services for mobile devices"
        3. Click "Save changes".
      9. Create a webservice token:
        1. As admin go to Site administration -> Plugins -> Web services -> Manage tokens -> Add.
        2. In "Username / User id" enter the teacher's username or userid.
        3. In "Service" select "Moodle mobile web service".
        4. Click "Save changes".
        5. Look for the token you just created and copy it.
      10. As Student, go to the Assignment and submit any file.

      Test

      1. With the teacher's token call the web service function "mod_assign_get_assignments" to get the ID of the assignment you created earlier.
        • In the terminal, do a CURL REST call simulating a WS client with the user. ("YOURMOODLEINSTANCE" =  The path to your moodle instance; "TEACHERWSTOKEN" = The webservice token of the teacher )
          curl 'http://YOURMOODLEINSTANCE/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_assign_get_assignments&wstoken=TEACHERWSTOKEN' | python -m "json.tool"
          (Alternatively, you can also do this by using Postman and sending the following GET request: http://YOURMOODLEINSTANCE/webservice/rest/server.php?wstoken=TEACHERWSTOKEN&moodlewsrestformat=json&wsfunction=mod_assign_get_assignments)
          • In the response object, in the "assignments" property there should be only 1 object that represents the course assignment. The "id" from this object will be used in step 2.
      2. With the teacher's token call the web service function "mod_assign_get_submissions" and pass the ID of your assignment via the "assignmentids" parameter.
        • In the terminal, do a CURL REST call simulating a WS client with the user. ("YOURMOODLEINSTANCE" =  The path to your moodle instance; "TEACHERWSTOKEN" = The webservice token of the teacher; ASSIGNMENTID = The id of the assignment )
          curl 'http://YOURMOODLEINSTANCE/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_assign_get_submissions&wstoken=TEACHERWSTOKEN&assignmentids[]=ASSIGNMENTID' | python -m "json.tool"
          (Alternatively, you can also do this by using Postman and sending the following GET request: 'http://YOURMOODLEINSTANCE/webservice/rest/server.php?wstoken=TEACHERWSTOKEN&moodlewsrestformat=json&wsfunction=mod_assign_get_submissions&assignmentids[]=ASSIGNMENTID)
          • You should get a response which contains a submission object where:
            •  the properties "userid" == 0 and "groupid" != 0.
            • the uploaded submission file can be found in the "files" property
      3. Install the official Moodle Mobile app and with the teacher user navigate to the assignment activity to confirm that you see the student submission listed including the files submitted
      Show
      Setup As an admin, create a course. Enrol one teacher and one student. Create a group. Add the student to the group. Create an assignment with "Students submit in groups" -> Yes. Enable web services As admin go to Site administration -> Advanced features Select "Enable web services" Click "Save changes". Enable REST protocol As admin go to Site administration -> Plugins -> Web services -> Manage protocols Enable "REST protocol" Click "Save changes". Enable web services for mobile devices As admin go to Site administration -> Mobile app -> Mobile settings Select "Enable web services for mobile devices" Click "Save changes". Create a webservice token: As admin go to Site administration -> Plugins -> Web services -> Manage tokens -> Add. In "Username / User id" enter the teacher's username or userid. In "Service" select "Moodle mobile web service". Click "Save changes". Look for the token you just created and copy it. As Student, go to the Assignment and submit any file. Test With the teacher's token call the web service function "mod_assign_get_assignments" to get the ID of the assignment you created earlier. In the terminal, do a CURL REST call simulating a WS client with the user. ("YOURMOODLEINSTANCE" =  The path to your moodle instance; "TEACHERWSTOKEN" = The webservice token of the teacher ) curl 'http://YOURMOODLEINSTANCE/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_assign_get_assignments&wstoken=TEACHERWSTOKEN' | python -m "json.tool" (Alternatively, you can also do this by using Postman and sending the following GET request: http://YOURMOODLEINSTANCE/webservice/rest/server.php?wstoken=TEACHERWSTOKEN&moodlewsrestformat=json&wsfunction= mod_assign_get_assignments) In the response object, in the "assignments" property there should be only 1 object that represents the course assignment. The "id" from this object will be used in step 2. With the teacher's token call the web service function "mod_assign_get_submissions" and pass the ID of your assignment via the "assignmentids" parameter. In the terminal, do a CURL REST call simulating a WS client with the user. ("YOURMOODLEINSTANCE" =  The path to your moodle instance; "TEACHERWSTOKEN" = The webservice token of the teacher; ASSIGNMENTID = The id of the assignment ) curl 'http://YOURMOODLEINSTANCE/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_assign_get_submissions&wstoken=TEACHERWSTOKEN&assignmentids[]=ASSIGNMENTID' | python -m "json.tool" (Alternatively, you can also do this by using Postman and sending the following GET request: 'http://YOURMOODLEINSTANCE/webservice/rest/server.php?wstoken=TEACHERWSTOKEN&moodlewsrestformat=json&wsfunction=mod_assign_get_submissions&assignmentids[]=ASSIGNMENTID) You should get a response which contains a submission object where:   the properties "userid" == 0 and "groupid" != 0. the uploaded submission file can be found in the "files" property Install the official Moodle Mobile app and with the teacher user navigate to the assignment activity to confirm that you see the student submission listed including the files submitted

      The webservice function mod_assign_get_submissions doesn't return files that were submitted as a group.

      Group submissions are stored with userid == 0 and groupid != 0 which is why the following line causes them to be skipped: https://github.com/moodle/moodle/blob/cd391f9922a7fdfbf0e57709c216725aa66d5293/mod/assign/externallib.php#L797

        1. Screenshot_1.png
          146 kB
          Janelle Barcega
        2. Screenshot_2.png
          33 kB
          Janelle Barcega

            tschroeder Tim Schroeder
            tschroeder Tim Schroeder
            Mihail Geshoski Mihail Geshoski
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Janelle Barcega Janelle Barcega
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 23 minutes
                4h 23m

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