Added doc to quiz js

This commit is contained in:
Max Geldner 2018-12-11 11:13:38 +01:00 committed by Nanne Baars
parent 3d7974aa45
commit 8b61811278
3 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,12 @@
/**
This is the basic javascript that can be used for a quiz assignment. It is made for single choice quizzes (tho a multiple choice extension should be easy to make).
Basic steps for implementing a quiz:
1. HTML: include this js script file for the assignment, build a basic form, where you include a #q_container div element, create a submit button with "Quiz_solutions" as name attribute
2. JSON: Create a JSON-file with the name questions_lesson_name.json, include a span element #quiz_id with lesson_name as the data-quiz_id attribute. Build a JSON file like the one in sql-injection -> resources -> js
3. Java: Create a normal assignment that has a String[] where the correct solutions are contained in the form of "Solution [i]", replace [i] with the position of the solution beginning at 1.
The request parameters will contain the answer in full text with "Solution [i]" in front of the text. Use them to check the answers validity.
**/
$(function () {
var json = "";
var client = new XMLHttpRequest();

View File

@ -16,10 +16,10 @@ import java.sql.SQLException;
import java.sql.Statement;
/**
* @TODO: Get JSON from file not from hardcoded string
* add a question: 1. Append new question to JSON string
* 2. add right solution to solutions array
* 3. add Request param with name of question to method head
* For a more detailed description how to implement the quiz go to the quiz.js file in webgoat-container -> js
*/
@AssignmentPath("/SqlInjection/quiz")
public class SqlInjectionQuiz extends AssignmentEndpoint {

View File

@ -173,7 +173,7 @@
method="POST" name="form"
action="SqlInjection/quiz"
enctype="application/json;charset=UTF-8" role="form">
<div id="q_container"></div>
<div id="q_container"></div>
<br />
<input name="Quiz_solutions" value="Submit answers" type="SUBMIT"/>
</form>