'update'
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 19 Feb 2018 11:11:23 +0000 (12:11 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 19 Feb 2018 11:11:23 +0000 (12:11 +0100)
public/javascripts/components/statements.js
public/javascripts/course.js
public/javascripts/grade.js
routes/users.js
views/course.pug

index 86138c0..6e12eb6 100644 (file)
@@ -32,7 +32,7 @@ Vue.component("statements", {
                        displayStyle: "compact", //or "all": all on same page
                        parameters: 0, //TODO: DO NOT re-draw parameters for already answered questions
                };
-       }
+       },
        // Full questions tree is rendered, but some parts hidden depending on display settings
        render(h) {
                // Prepare questions groups, ordered
@@ -158,7 +158,7 @@ Vue.component("statements", {
                                        {
                                                "class": {
                                                        "question": true,
-                                                       "depth" + depth: true,
+                                                       ["depth" + depth]: true,
                                                },
                                        },
                                        questionContent
@@ -171,7 +171,7 @@ Vue.component("statements", {
                                                "questionGroup": true,
                                                "hide": this.display == "one" && this.iidx != i,
                                        },
-                               }
+                               },
                                qgDom
                        );
                });
index 6320538..781424a 100644 (file)
@@ -44,23 +44,8 @@ new Vue({
                questionsText: "", //questions in an evaluation, in text format
        },
        mounted: function() {
-               
-               
-               
-               $('.modal').each( (i,elem) => {
-                       if (elem.id != "evaluationEdit")
-                               $(elem).modal();
-               });
-               $('ul.tabs').tabs(); //--> migrate to grade.js
-               
-               
-               
-               $('#evaluationEdit').modal({
-                       complete: () => {
-                               this.parseEvaluation();
-                               Vue.nextTick(statementsLibsRefresh);
-                       },
-               });
+               $('.modal').modal();
+               Materialize.updateTextFields(); //textareas, time field...
        },
        methods: {
                // GENERAL:
@@ -145,10 +130,6 @@ new Vue({
                                }
                        );
                },
-               materialOpenModal: function(id) {
-                       $("#" + id).modal("open");
-                       Materialize.updateTextFields(); //textareas, time field...
-               },
                updateEvaluation: function() {
                        $.ajax("/evaluations", {
                                method: "PUT",
index d0f04cf..74e4c04 100644 (file)
@@ -14,6 +14,7 @@ new Vue({
        },
        mounted: function() {
                // TODO
+               $('ul.tabs').tabs(); //--> migrate to grade.js
        },
        methods: {
                // GRADES:
index 993c15e..f56b4af 100644 (file)
@@ -19,7 +19,7 @@ function setAndSendLoginToken(subject, to, res)
                                subject: subject,
                                body: "Hello " + to.initials + "!\n" +
                                        "Access your account here: " +
-                                       params.siteURL + "/authenticate?token=" + token + "\\n" +
+                                       params.siteURL + "/authenticate/" + token + "\\n" +
                                        "Token will expire in " + params.token.expire/(1000*60) + " minutes."
                        }, err => {
                                res.json(err || {});
@@ -30,8 +30,8 @@ function setAndSendLoginToken(subject, to, res)
 
 router.post('/register', access.ajax, access.unlogged, (req,res) => {
        const newUser = {
-               email: req.body.email,
-               name: req.body.name,
+               email: decodeURIComponent(req.body.email),
+               name: decodeURIComponent(req.body.name),
        };
        let error = validator(newUser, "User");
        if (error.length > 0)
@@ -52,7 +52,7 @@ router.post('/register', access.ajax, access.unlogged, (req,res) => {
 
 // Login:
 router.put('/sendtoken', access.ajax, access.unlogged, (req,res) => {
-       const email = req.body.email;
+       const email = decodeURIComponent(req.body.email);
        let error = validator({email:email}, "User");
        if (error.length > 0)
                return res.json({errmsg:error});
@@ -65,7 +65,7 @@ router.put('/sendtoken', access.ajax, access.unlogged, (req,res) => {
 });
 
 // Authentication process, optionally with email changing:
-router.put('/authenticate/:token([a-z0-9]+)', access.unlogged, (req,res) => {
+router.get('/authenticate/:token([a-z0-9]+)', access.unlogged, (req,res) => {
        const loginToken = req.params.token;
        UserModel.getByLoginToken(loginToken, (err,user) => {
                access.checkRequest(res, err, user, "Invalid token", () => {
@@ -96,7 +96,7 @@ router.put('/authenticate/:token([a-z0-9]+)', access.unlogged, (req,res) => {
        });
 });
 
-router.put('/logout', access.logged, (req,res) => {
+router.get('/logout', access.logged, (req,res) => {
        UserModel.removeToken(req.user._id, req.cookies.token, (err,ret) => {
                access.checkRequest(res, err, ret, "Logout failed", () => {
                        res.clearCookie("initials");
index 9d84018..cfe56a4 100644 (file)
@@ -7,9 +7,9 @@ block append stylesheets
 block content
        .container#course
                if teacher
-                       #newevaluation.modal
+                       #newEvaluation.modal
                                .modal-content
-                                       form(@submit.prevent="addevaluation")
+                                       form(@submit.prevent="addEvaluation")
                                                .input-field
                                                        input#evaluationName(type="text" v-model="newEvaluation.name" required)
                                                        label(for="evaluationName") Name
@@ -38,11 +38,11 @@ block content
                                                                        td {{ student.group }}
                .row
                        .col.s12.m10.offset-m1
-                               h4.title(@click="toggleDisplay('evaluations')") evaluations
+                               h4.title(@click="toggleDisplay('evaluations')") Evaluations
                                .card(v-show="display=='evaluations'")
                                        if teacher
                                                .center-align
-                                                       a.on-left.waves-effect.waves-light.btn.modal-trigger(href="#newevaluation") New evaluation
+                                                       a.on-left.waves-effect.waves-light.btn.modal-trigger(href="#newEvaluation") New evaluation
                                                        input#password(type="password" v-model="monitorPwd" @keyup.enter="setPassword"
                                                                        placeholder="Password" title="Monitoring password")
                                        table
@@ -53,7 +53,7 @@ block content
                                                                th #Questions
                                                tbody
                                                        tr.evaluation(v-for="(evaluation,i) in evaluationArray" :class="{idle:!evaluation.active}"
-                                                                       @click.left="actionevaluation(i)" @contextmenu.prevent="deleteevaluation(evaluation)")
+                                                                       @click.left="actionEvaluation(i)" @contextmenu.prevent="deleteEvaluation(evaluation)")
                                                                td {{ evaluation.name }}
                                                                td {{ evaluation.mode }}
                                                                td {{ evaluation.questions.length }}