2017-06-15 19:28:54 +00:00
|
|
|
|
|
|
|
window.onload = function(){
|
2017-06-15 23:08:23 +00:00
|
|
|
addScenario = function(scenario){
|
2017-06-15 19:28:54 +00:00
|
|
|
|
2017-06-15 23:16:00 +00:00
|
|
|
let $liElement = $("<li id=\"scenarios-"+scenario.name+"\"></li>")
|
2017-06-15 23:08:23 +00:00
|
|
|
|
|
|
|
if(scenario.adult == true){
|
|
|
|
$adultText = $("<p class=\"adult\">(question for those over the age of 18... or those mature enough)</p>");
|
|
|
|
$liElement.append($adultText);
|
|
|
|
}
|
|
|
|
$description = $("<p>" + scenario.description +"</p>");
|
2017-06-15 19:28:54 +00:00
|
|
|
|
2017-06-15 23:08:23 +00:00
|
|
|
$options = $("<ul></ul>");
|
|
|
|
for(option of scenario.options){
|
2017-06-15 23:16:00 +00:00
|
|
|
$options.append($("<li><input type=\"radio\" name=\"radio-"+scenario.name+"\">" + option + "</radio></li>"));
|
2017-06-15 23:08:23 +00:00
|
|
|
}
|
|
|
|
$question = $("<p>" + scenario.question + "</p>");
|
2017-06-15 19:28:54 +00:00
|
|
|
|
2017-06-15 23:16:00 +00:00
|
|
|
$textArea = $("<textArea placeholder=\"Enter response here\"></textArea>")
|
2017-06-15 23:08:23 +00:00
|
|
|
|
2017-06-15 22:23:51 +00:00
|
|
|
$liElement.append($description);
|
|
|
|
$liElement.append($options);
|
2017-06-15 23:16:00 +00:00
|
|
|
$liElement.append($textArea);
|
2017-06-15 22:23:51 +00:00
|
|
|
|
|
|
|
$("#scenarios").append($liElement);
|
|
|
|
}
|
2017-06-15 19:28:54 +00:00
|
|
|
|
2017-06-15 23:08:23 +00:00
|
|
|
$.getJSON("./resources/questions/scenarios.json", "", function(data){
|
|
|
|
for(const scenario of data.scenarios){
|
|
|
|
addScenario(scenario);
|
|
|
|
}
|
2017-06-15 22:35:01 +00:00
|
|
|
});
|
2017-06-15 23:08:23 +00:00
|
|
|
}
|