Skip to content

Commit

Permalink
Final changes (except #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
karansampath committed Jan 18, 2022
1 parent f99957e commit 002311b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion routes/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const router = express.Router()
var csrf = require("csurf")
const csrfProtection = csrf({ cookie: true })

const required = false;
const required = true;

router.get("/", verify_admin_token, (req, res) => {
res.render("admin", {
Expand Down
37 changes: 28 additions & 9 deletions views/survey.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ html
form(action = "/survey", method = "POST")
ul
each item, index in survey
-req = true
if item.required
-req = item.required
- req = required
if item.required == 'false'
- req = false
else if item.required == 'true'
- req = true
if !item.prompt || !item.response
-continue
if index == 0
Expand All @@ -21,8 +23,7 @@ html
a(href='/')
|
= item.group_prompt ? item.group_prompt : generic_group_prompt
if required
p * answer required for submission.
p * answer required for submission.
else if survey[index-1].group_prompt != item.group_prompt
h2= item.group_prompt ? item.group_prompt : generic_group_prompt
div(class='inputBlock')
Expand All @@ -43,9 +44,17 @@ html
if answer.includes("#")
- main = answer.substring(1)
- id = (main+item.name).replace(/ /g,'')
h1 Check
input(type='checkbox' role='checkbox' name= item.name id= id value= main)
input(type='text' name=item.name placeholder='Type your answer' required= req)
input(type='checkbox' role='checkbox' name= item.name id= id value= main)
//- script.
//- document.addEventListener("DOMContentLoaded", function(event) {
//- var n = document.getElementById(id);
//- console.log(n);
//- });
//- if n.checked {
//- check = true;
//- }
//- if check
//- input(type='text' name=item.name placeholder='Type your answer' required= req)
label(for=id)= main
else
- id = (answer+item.name).replace(/ /g,'')
Expand All @@ -58,8 +67,18 @@ html
if answer.includes("#")
- main = answer.substring(1)
- id = (main+item.name).replace(/ /g,'')
- check = false
input(type='radio' role='radio' name= item.name id= id value= main required= req)
input(type='text' name=item.name placeholder='Type your answer' required= req)
//- script.
//- document.addEventListener("DOMContentLoaded", function(event) {
//- var n = document.getElementById(id);
//- console.log(n);
//- });
//- if n.checked {
//- check = true;
//- }
//- if check
//- input(type='text' name=item.name placeholder='Type your answer' required= req)
label(for=id)= main
else
- id = (answer+item.name).replace(/ /g,'')
Expand Down

0 comments on commit 002311b

Please sign in to comment.