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

mod_assign_get_submissions returns no more than one group submission

XMLWordPrintable

    • MOODLE_39_STABLE
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • MDL-70110-master
    • Hide

      Setup

      1. As an admin, create a course.
      2. Enrol one teacher and two students A and B.
      3. Create two groups A and B.
      4. Add student A to group A and student B to group B.
      5. Create an assignment with "Students submit in groups" -> Yes and "Attempts reopened" -> Manually
      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 A, go to the Assignment and submit any file.
      11. As Student B, go to the Assignment and submit any file.
      12. As Teacher got to assignment and click on 'View all submissions'
      13. In the submission list, 'Edit' -> 'Allow another attempt' in Student A's submission row.
      14. As Student A, go to the Assignment -> 'Add a new attempt' and submit a new file.

       

      * From Moodle 3.11 onwards, "Web services" can be found under "Site administration > Server > Web services".

      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.
            •  there are two submissions from different groups
            • 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 submissions listed including the files submitted

       

      Show
      Setup As an admin, create a course. Enrol one teacher and two students A and B. Create two groups A and B. Add student A to group A and student B to group B. Create an assignment with "Students submit in groups" -> Yes and "Attempts reopened" -> Manually 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 A, go to the Assignment and submit any file. As Student B, go to the Assignment and submit any file. As Teacher got to assignment and click on 'View all submissions' In the submission list, 'Edit' -> 'Allow another attempt' in Student A's submission row. As Student A, go to the Assignment -> 'Add a new attempt' and submit a new file.   * From Moodle 3.11 onwards, "Web services" can be found under "Site administration > Server > Web services". 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.   there are two submissions from different groups 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 submissions listed including the files submitted  

      In MDL-68605 I tried to fix mod_assign_get_submissions not returning group submissions. While I did fix it, that fix only works as long as you have 0 or 1 group submissions. As soon as there are more than that the webservice function will only return one of the group submissions seemingly at random.

      That's because in https://github.com/moodle/moodle/blob/58ba94a7290940391d1581e591a64fc7e6bb410a/mod/assign/externallib.php#L757-L765 we get the latest attempt for each user. Since group submissions all have a userid of 0, all but one of them are discarded here.

            septatrix septatrix
            tschroeder Tim Schroeder
            Amaia Anabitarte Amaia Anabitarte
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Gladys Basiana Gladys Basiana
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour, 28 minutes
                1d 1h 28m

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