Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help3403


This forum is provided to promote discussion amongst students enrolled in Agile Web Development (CITS3403).
 
Options:
RSS cloud
Jump to:

Flask REST API and Live Feedback

1 of 419 articles shown, currently no other people reading this forum.
photo
From: Matthew C.
Date: Wed 20th May, 10:43am
Actions: 
        Login-to-reply
Hi Tim, Tom and Haolin,

As per my last post https://secure.csse.uwa.edu.au/run/help3403?p=np&a=239&all=y3

I have been looking into added live feedback (and other live things) into our project. 
For context, once a user completes a quiz they see a "View Attempt Page" for that 
quiz, which contains all the quiz questions, the user's submitted answers, the marks 
and the feedback. The admin can provide feedback from flask admin (will likely 
implement a marking page for this) on each attempt of each question. The admin changes 
an entry in our database when they do this. 

To allow for live feedback to be added to this page, I have implemented a REST API for 
flask with limited functionality, that can extract the database entries for question 
attempts (which is where feedback is added) using an ajax call with xmlhttprequest. 
Such that this extracted json from the api has the new feedback from the admin and if 
this feedback does not correspond with the feedback on the page the user is looking 
at, it is changed without having to refresh the page.  

I have made this work without the use of token's in the api. However, when I try to 
add token functionality to the API, the request will work but I can not use the 
"setInterval" function to repeatedly call the function that retrieves the new json.

This is my pastebin: https://pastebin.com/TRK44dqa

My question is how do I allow this script to repeated call the API with the acquired 
token such that the old feedback can be replaced.

I am also interested in what sort of error handling I need to do for ajax, and how to 
do it as well as whether or not I need to delete this token for the user when the page 
isn't being used, though I also don't know how to do this.

Sincerely,
Matthew Carter

Related articles

Flask REST API and Live Feedback (all 3) RSS
├─ THIS   Wed 20th May, 10:43am, Matthew C.
├─ reply 1   Wed 20th May, 3:33pm, Matthew C.  O.P.
└─ reply 2   Thu 21st May, 11:24am, Timothy F.
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020