我有下面的考试路线。
Router.post('/exam', auth.checkLogin, function(req , res){
examModel.findOne({'exam_code' : req.body.exam_code} , function(err,doc1){
if(err)
res.send("Some error occurred");
else if(doc1)
{
responseModel.findOne({'exam_code': req.body.exam_code}, function(err,doc){
if(err)
res.send("Some error occurred");
else if(doc)
res.redirect('/exam');
else
{
res.render('take_exam', { title: 'Take Exam', exam_code: req.body.exam_code, Username: req.body.Username});
}
})
}
else
{
res.redirect('/exam');
}
})
});
Below is the route for submitting test:
Router.post('/submit', auth.checkLogin, function(req , res){
var object = req.body;
var response = [];
for(var key in object) {
response.push(object[key]);
}
response.pop();
response.pop();
var temp_response = new responseModel({
Username : req.body.Username,
exam_code: req.body.exam_code,
response : req.body.response
});
temp_response.save(function(err , docs){
if(err)
res.send("Some error occurred");
else
res.render('exam_submit', {title: 'Response Submitted Successfully', response: req.body.response, Username: req.body.Username, exam_code: req.body.exam_code});
});
});
app.use('/take_exam',Router);
}
当我点击开始测试按钮并进入测试页面时,我会看到测试页面"但问题没有出现。只有标题和选项A.B.C.& D出现。
我已包含所需的观点。
请看看它并建议我下一步做什么?