Commit aee71502 authored by antoine masson's avatar antoine masson
Browse files

v1.05

-Fix survey_id in answer export
-When token is set to new answer and submited date are reseted
parent eb980bf0
...@@ -385,7 +385,7 @@ exports.delete_a_langtrans = async (req, res) => { ...@@ -385,7 +385,7 @@ exports.delete_a_langtrans = async (req, res) => {
} }
}; };
exports.update_a_langtrans = async (req, res) => { //TODO : update here exports.update_a_langtrans = async (req, res) => {
LanguageTrans.replaceOne( LanguageTrans.replaceOne(
{ _id: req.params.id }, { _id: req.params.id },
{ {
......
...@@ -91,6 +91,10 @@ exports.update_a_token = async (req, res) => { ...@@ -91,6 +91,10 @@ exports.update_a_token = async (req, res) => {
for (key in req.body) { for (key in req.body) {
token[key] = req.body[key]; token[key] = req.body[key];
} }
if(token.status==='new'){
token.answers=null
token.submitedAt=null
}
token.admin=false; token.admin=false;
await token.save(); await token.save();
res.json({ id: req.params.id,message:"Token modified",status: "OK"}); res.json({ id: req.params.id,message:"Token modified",status: "OK"});
...@@ -115,10 +119,10 @@ exports.delete_a_token = (req, res) => { ...@@ -115,10 +119,10 @@ exports.delete_a_token = (req, res) => {
exports.down_survey_tokens = async (req,res)=>{ exports.down_survey_tokens = async (req,res)=>{
try{ try{
console.log(req.params.survey_id)
const survey=await Survey.findById(req.params.survey_id) const survey=await Survey.findById(req.params.survey_id)
Token.find({survey_id:req.params.survey_id,test:false},). Token.find({survey_id:req.params.survey_id,test:false},).
exec(async function (err, tokens) { exec(async function (err, tokens) {
tokens.forEach(o=>o.survey_id=survey.general.short_name)
res.set("Content-Type", "application/octet-stream"); res.set("Content-Type", "application/octet-stream");
res.set("Content-Disposition", "attachment;filename="+survey.general.short_name+"-token.json"); res.set("Content-Disposition", "attachment;filename="+survey.general.short_name+"-token.json");
await res.send(tokens); await res.send(tokens);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment