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

Feedback web services incorrectly treat courseid

XMLWordPrintable

    • MOODLE_33_STABLE, MOODLE_36_STABLE
    • MOODLE_36_STABLE
    • MDL-60578-master
    • Hide

      Setup

      1. Log in as an admin.
      2. Go to "Site administration / Users / Permissions / Define roles"
      3. Edit the "Authenticated user role in frontpage".
      4. Ensure that the capabilities "mod/feedback:complete" and "mod/feedback:view" are set to "Allow". Save the changes if necessary.
      5. Create two courses 1 and 2. Take note of the courses' IDs. Let's call these IDs as COURSE1_ID and COURSE2_ID
      6. Enrol a user as student in both courses.
      7. Go to the site home.
      8. Turn editing on and create a Feedback activity. Take note of the feedback's ID (this can be found in the mdl_feedback table in the database), let's call this FEEDBACK_ID.
      9. On the Feedback activity's page, click "Edit questions"
      10. Add 2 questions in two separate pages. You can use "Numeric answer" and/or "Short text answer" questions for simplicity. After creating these questions, take note of the element name of the question fields (using the browser's inspector and checking the "name" attribute of the question fields). Let's call these names as Q1_NAME and Q2_NAME.
      11. Click on the "Mapped courses" tab select COURSE1. Save the changes.
      12. Go to COURSE1's course page.
      13. Turn editing on and add the "Feedback" block.
      14. Go to "Site administration / Mobile app / Mobile settings"
      15. Tick "Enable web services for mobile devices". Save the changes.
      16. Go to "Site administration / Plugins / Web services / Manage tokens"
      17. Create a token for the student. Let's call this STUDENT_TOKEN.

      Submitting responses to mapped course

      Submitting response for the first page
      1. Open your terminal and execute the following CURL REST command. Make sure to substitute YOUR_MOODLE_URL, COURSE1_ID, FEEDBACK_ID, STUDENT_TOKEN, and Q1_NAME accordingly. Substitute the values VAL_1 according to the type of the question for page 1. (e.g. If it's a Numeric answer question, use a numeric value within the allowed values. If it's a Short text answer question, enter a simple word.)

        curl 'http://YOUR_MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'feedbackid=FEEDBACK_ID&courseid=COURSE1_ID&wsfunction=mod_feedback_process_page&wstoken=STUDENT_TOKEN&moodlewssettingfilter=true&page=0&responses[0][name]=Q1_NAME&responses[0][value]=VAL_1' | python -m "json.tool"

      2. Confirm that you get a nice JSON response showing the "jumpto" field set to 1 (next page) and the "completed" field set to false.
      3. On an incognito browser window, log in as the student.
      4. Go to COURSE1 and click on the feedback link in the Feedback block.
      5. Click "Answer the questions"
      6. Confirm that you see value you entered in the curl request for the question in the first page of the feedback actity.
      Submitting response for the second page
      1. Back on the terminal, do the following CURL request. Substitute the values just like in the previous section. This time though, notice that we set "page" parameter to 1 (which indicates the second page of the feedback) and we add the parameter "goprevious" with a value of 1 and are submitting response with a value of VAL_2 for the second question (Q2_NAME) which is in the second page.

        curl 'http://YOUR_MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'feedbackid=FEEDBACK_ID&courseid=COURSE1_ID&wsfunction=mod_feedback_process_page&wstoken=STUDENT_TOKEN&moodlewssettingfilter=true&page=1&responses[0][name]=Q2_NAME&responses[0][value]=VAL_2&goprevious=1' | python -m "json.tool"

      2. Confirm that you get a nice JSON response showing the "jumpto" field set to 0 (next page) and the "completed" field set to false.
      3. Back on the student's browser window, go to the next page.
      4. Confirm that the student's answer is entered on the second question's field.
      Completing the submission.
      1. Execute again the first CURL request.
      2. Execute again the second CURL request, but this time, remove the "goprevious" parameter.

        curl 'http://YOUR_MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'feedbackid=FEEDBACK_ID&courseid=COURSE1_ID&wsfunction=mod_feedback_process_page&wstoken=STUDENT_TOKEN&moodlewssettingfilter=true&page=1&responses[0][name]=Q2_NAME&responses[0][value]=VAL_2' | python -m "json.tool"

      3. Confirm that you get a nice JSON response showing that the "completed" field is now set to true.
      4. Log in as a teacher in COURSE1 and go to the feedback activity.
      5. Click on the "Show responses" tab.
      6. Confirm that you see the responses made by the user.

      Accessing a feedback via an unmapped course

      1. Try access the site feedback via COURSE2 using the following CURL request. Make sure to substitute the values for the parameters accordingly.

        curl 'http://YOUR_MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'feedbackid=FEEDBACK_ID&courseid=COURSE2_ID&wsfunction=mod_feedback_get_feedback_access_information&wstoken=STUDENT_TOKEN&moodlewssettingfilter=true' | python -m "json.tool"

      2. Confirm that you get an exception that tells you that the course is not mapped
      Testing on the mobile app
      1. Back on the teacher's browser window, go to COURSE1.
      2. Create feedback activity for that course with some questions.
      3. Using the Moodle Mobile app, access the course as a student and complete the feedback activity in the course.
      4. Confirm that you can successfully complete the feedback activity.
      Show
      Setup Log in as an admin. Go to " Site administration / Users / Permissions / Define roles " Edit the "Authenticated user role in frontpage". Ensure that the capabilities " mod/feedback:complete " and " mod/feedback:view " are set to " Allow ". Save the changes if necessary. Create two courses 1 and 2. Take note of the courses' IDs. Let's call these IDs as COURSE1_ID and COURSE2_ID Enrol a user as student in both courses. Go to the site home. Turn editing on and create a Feedback activity. Take note of the feedback's ID (this can be found in the mdl_feedback table in the database), let's call this FEEDBACK_ID . On the Feedback activity's page, click " Edit questions " Add 2 questions in two separate pages. You can use " Numeric answer " and/or " Short text answer " questions for simplicity. After creating these questions, take note of the element name of the question fields (using the browser's inspector and checking the " name " attribute of the question fields). Let's call these names as Q1_NAME and Q2_NAME . Click on the " Mapped courses " tab select COURSE1. Save the changes. Go to COURSE1's course page. Turn editing on and add the " Feedback " block. Go to " Site administration / Mobile app / Mobile settings " Tick " Enable web services for mobile devices ". Save the changes. Go to " Site administration / Plugins / Web services / Manage tokens " Create a token for the student. Let's call this STUDENT_TOKEN . Submitting responses to mapped course Submitting response for the first page Open your terminal and execute the following CURL REST command. Make sure to substitute YOUR_MOODLE_URL , COURSE1_ID , FEEDBACK_ID , STUDENT_TOKEN , and Q1_NAME accordingly. Substitute the values VAL_1 according to the type of the question for page 1. (e.g. If it's a Numeric answer question, use a numeric value within the allowed values. If it's a Short text answer question, enter a simple word.) curl 'http:// YOUR_MOODLE_URL /webservice/rest/server.php?moodlewsrestformat=json' --data 'feedbackid= FEEDBACK_ID &courseid= COURSE1_ID &wsfunction=mod_feedback_process_page&wstoken= STUDENT_TOKEN &moodlewssettingfilter=true&page=0&responses [0] [name] = Q1_NAME &responses [0] [value] = VAL_1 ' | python -m "json.tool" Confirm that you get a nice JSON response showing the " jumpto " field set to 1 (next page) and the " completed " field set to false. On an incognito browser window, log in as the student. Go to COURSE1 and click on the feedback link in the Feedback block. Click " Answer the questions " Confirm that you see value you entered in the curl request for the question in the first page of the feedback actity. Submitting response for the second page Back on the terminal, do the following CURL request. Substitute the values just like in the previous section. This time though, notice that we set " page " parameter to 1 (which indicates the second page of the feedback) and we add the parameter " goprevious " with a value of 1 and are submitting response with a value of VAL_2 for the second question ( Q2_NAME ) which is in the second page. curl 'http:// YOUR_MOODLE_URL /webservice/rest/server.php?moodlewsrestformat=json' --data 'feedbackid= FEEDBACK_ID &courseid= COURSE1_ID &wsfunction=mod_feedback_process_page&wstoken= STUDENT_TOKEN &moodlewssettingfilter=true&page=1&responses [0] [name] = Q2_NAME &responses [0] [value] = VAL_2 &goprevious=1' | python -m "json.tool" Confirm that you get a nice JSON response showing the " jumpto " field set to 0 (next page) and the " completed " field set to false. Back on the student's browser window, go to the next page. Confirm that the student's answer is entered on the second question's field. Completing the submission. Execute again the first CURL request. Execute again the second CURL request, but this time, remove the " goprevious " parameter. curl 'http:// YOUR_MOODLE_URL /webservice/rest/server.php?moodlewsrestformat=json' --data 'feedbackid= FEEDBACK_ID &courseid= COURSE1_ID &wsfunction=mod_feedback_process_page&wstoken= STUDENT_TOKEN &moodlewssettingfilter=true&page=1&responses [0] [name] = Q2_NAME &responses [0] [value] = VAL_2 ' | python -m "json.tool" Confirm that you get a nice JSON response showing that the " completed " field is now set to true. Log in as a teacher in COURSE1 and go to the feedback activity. Click on the " Show responses " tab. Confirm that you see the responses made by the user. Accessing a feedback via an unmapped course Try access the site feedback via COURSE2 using the following CURL request. Make sure to substitute the values for the parameters accordingly. curl 'http:// YOUR_MOODLE_URL /webservice/rest/server.php?moodlewsrestformat=json' --data 'feedbackid= FEEDBACK_ID &courseid= COURSE2_ID &wsfunction=mod_feedback_get_feedback_access_information&wstoken= STUDENT_TOKEN &moodlewssettingfilter=true' | python -m "json.tool" Confirm that you get an exception that tells you that the course is not mapped Testing on the mobile app Back on the teacher's browser window, go to COURSE1. Create feedback activity for that course with some questions. Using the Moodle Mobile app, access the course as a student and complete the feedback activity in the course. Confirm that you can successfully complete the feedback activity.

      For feedback the courseid is the course where user completes feedback. It is only applicable for site feedbacks (feedbacks on the frontpage). Such feedbacks can be completed by students multiple times for different courses.

      Web services such as mod_feedback_external::process_page do not have argument for courseid and pass the feedback course to the validation functions.

        1. 1.PNG
          1.PNG
          460 kB
        2. 2.PNG
          2.PNG
          75 kB

            jleyva Juan Leyva
            marina Marina Glancy
            Jake Dallimore Jake Dallimore
            Jun Pataleta Jun Pataleta
            Janelle Barcega Janelle Barcega
            Votes:
            0 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 - 30 minutes
                30m

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