Different question types
Now 3 different question types are supported for admin to create.
Multi choice
Same to the previous question type.
Filling in blank
The user need to fill in the blank to answer the question.
Uploading a file
Upload a file to Parse by the javascript API of Parse.
How to upload a file to Parse hosting
Parse hosting is using a modified version of Express.js framework. Some of the functionalities are disabled, e.g. file uploading in a form.
For the normal Express.js, an <input type="file"> will put the file into req.body. But as Parsed modified the Express.js framework, the file is not uploaded to req.body, and the developer can not access the file from Express.
Parse javascript API is the only solution.
How to use Parse javascript API
Follow the guide at https://parse.com/docs/js_guide.
For uploading a file:
- call Parse.initialize("APP_ID", "Javascript key");
- create a file object, and pass into the file object got from input tag
var parseFile = new Parse.File(file[0].name, file[0]); - call save()
parseFile.save().then(...) - when save() succeeds, reference the file object from to another object
var fileInstance = new Parse.Object("AppFiles");
fileInstance.set("file", parseFile); - submit the form when fileInstance is saved to cloud
A file object doesn't have an objectID. So linking with another object is the only way of reuse the file object.
When the server get the object linked with the file object:\
- Fetch the object
- Fetch the file object reference by it
- get the file url by
file.url()
No comments:
Post a Comment