{"size": 1341, "ext": "js", "max_stars_repo_path": "controllers/answer.js", "max_stars_repo_name": "pratik2542/first-release-comp229-group-05", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "controllers/answer.js", "max_issues_repo_name": "pratik2542/first-release-comp229-group-05", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "controllers/answer.js", "max_forks_repo_name": "pratik2542/first-release-comp229-group-05", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.8873239437, "max_line_length": 60, "alphanum_fraction": 0.5100671141}



  let express = require('express');
  let router = express.Router();
  let mongoose = require('mongoose');
  
  //let jwt = require('jsonwebtoken');
  
  //create a reference to the model
  let Questions = require('../models/questions');
  let Survey = require('../models/survey');

  module.exports.displayAnswer= (req, res, next) => {
    Questions.find((err, questionList) => {
        if (err)
        {
            return console.error(err);
        }
        else
        {
            
            res.render('survey/answer', {
                title: 'Survey Answers',
                  QuestionsList: questionList});      
        }
    });
  }


module.exports.displayAnswerPage = (req, res, next) => {
     
      res.render('survey/answer', {title: 'Survey Answers'
      });
  }
  

module.exports.processAnswerPage = (req, res, next) => {
    
     let id = req.params.id

    let updatedAnswers =Questions({
        "_id": id,
        "question": req.body.question,
        "questionsAnswer": req.body.questionsAnswer
     
    });

    Questions.updateOne({_id: id}, updatedAnswers, (err) =>{
        if(err)
        {
            console.log(err);
            res.end(err);
        }
        else
        {
            //refresh the answers page
            res.redirect('/survey-answer');

        }
    });
  
}





 

