Merge forename + name into [identifying] 'name' (more general)
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 10 Feb 2018 11:36:39 +0000 (12:36 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 10 Feb 2018 11:36:39 +0000 (12:36 +0100)
15 files changed:
entities/course.js
entities/user.js
models/user.js
public/javascripts/course.js
public/javascripts/login.js
public/javascripts/monitor.js
public/javascripts/utils/validation.js
routes/users.js
setup/students.sample.csv
views/assessment.pug
views/course.pug
views/grading.pug
views/index.pug
views/login.pug
views/monitor.pug

index 66fcaee..9b3fb46 100644 (file)
@@ -11,7 +11,6 @@ const CourseEntity =
         *   password: monitoring password hash
         *   students: array of
         *     number: student number
-        *     forename: varchar
         *     name: varchar
         *     group: integer
         */
index 1026eaf..72b3a43 100644 (file)
@@ -7,7 +7,6 @@ const UserEntity =
         *   _id: BSON id
         *   ** Strings, identification informations:
         *   email
-        *   forename
         *   name
         *   initials : computed, Benjamin Auder --> ba ...etc
         *   loginToken: {
index f495bdc..c6fa776 100644 (file)
@@ -5,12 +5,9 @@ const UserModel =
 {
        create: function(newUser, callback)
        {
-               // Determine initials from forename+name
-               let forenameParts = newUser.forename.split(/[ -]+/);
+               // Determine initials from name parts
                let nameParts = newUser.name.split(/[ -]+/);
-               let initials =
-                       forenameParts.map( n => { return n.charAt(0).toLowerCase(); }).join("") +
-                       nameParts.map( n => { return n.charAt(0).toLowerCase(); }).join("");
+               let initials = nameParts.map( n => { return n.charAt(0).toLowerCase(); }).join("");
                // First retrieve all users with similar prefix initials
                UserEntity.getInitialsByPrefix(initials, (err,userArray) => {
                        if (!!userArray && userArray.length == 1)
index 85172dc..e0f2e37 100644 (file)
@@ -57,12 +57,7 @@ window.onload = function() {
                                return this.course.students
                                        .filter( s => { return group==0 || s.group == group; })
                                        .map( s => { return Object.assign({}, s); }) //not altering initial array
-                                       .sort( (a,b) => {
-                                               let res = a.name.localeCompare(b.name);
-                                               if (res == 0)
-                                                       res += a.forename.localeCompare(b.forename);
-                                               return res;
-                                       });
+                                       .sort( (a,b) => { return a.name.localeCompare(b.name); })
                        },
                        // STUDENTS:
                        uploadTrigger: function() {
@@ -311,7 +306,7 @@ window.onload = function() {
                                                        s["final"] = finalGrade; //TODO: forbid "final" as assessment name
                                                });
                                        }
-                                       data.push(s); //number,forename,name,group,assessName1...assessNameN,final
+                                       data.push(s); //number,name,group,assessName1...assessNameN,final
                                });
                                let csv = Papa.unparse(data, {
                                        quotes: true,
index 1bb5b72..4f70e19 100644 (file)
@@ -25,7 +25,6 @@ window.onload = function() {
                data: {
                        messages: messages,
                        user: {
-                               forename: "",
                                name: "",
                                email: "",
                        },
@@ -52,7 +51,7 @@ window.onload = function() {
                                }
                                let error = Validator.checkObject({email: this.user.email}, "User");
                                if (!error && this.stage == "register")
-                                       error = Validator.checkObject({forename: this.user.forename, name: this.user.name}, "User");
+                                       error = Validator.checkObject({name: this.user.name}, "User");
                                let $dialog = $("#dialog");
                                show($dialog);
                                setTimeout(() => {hide($dialog);}, 3000);
@@ -65,14 +64,12 @@ window.onload = function() {
                                                data:
                                                {
                                                        email: encodeURIComponent(this.user.email),
-                                                       forename: encodeURIComponent(this.user.forename), //may be unused
                                                        name: encodeURIComponent(this.user.name), //may be unused
                                                },
                                                dataType: "json",
                                                success: res => {
                                                        if (!res.errmsg)
                                                        {
-                                                               this.user["forename"] = "";
                                                                this.user["name"] = "";
                                                                this.user["email"] = "";
                                                                showMsg($dialog, "info", infos[this.stage]);
index 23972a9..8963731 100644 (file)
@@ -29,12 +29,7 @@ new Vue({
                        return this.students
                                .filter( s => { return group==0 || s.group == group; })
                                .map( s => { return Object.assign({}, s); }) //not altering initial array
-                               .sort( (a,b) => {
-                                       let res = a.name.localeCompare(b.name);
-                                       if (res == 0)
-                                               res += a.forename.localeCompare(b.forename);
-                                       return res;
-                               });
+                               .sort( (a,b) => { return a.name.localeCompare(b.name); });
                },
                groupList: function() {
                        let maxGrp = 1;
index aa39ebe..530713a 100644 (file)
@@ -51,7 +51,6 @@ Validator.Assessment = {
 Validator.User = {
        "_id": "bson",
        "email": "email",
-       "forename": "name",
        "name": "name",
        "initials": "unchecked", //not a user input
        "loginToken": "unchecked",
@@ -61,7 +60,6 @@ Validator.User = {
 
 Validator.Student = {
        "number": "code",
-       "forename": "name",
        "name": "name",
        "group": "positiveInteger",
 };
index c42b447..2de89b0 100644 (file)
@@ -31,12 +31,10 @@ function sendLoginToken(subject, to, res)
 
 router.get('/register', access.ajax, access.unlogged, (req,res) => {
        let email = decodeURIComponent(req.query.email);
-       let forename = decodeURIComponent(req.query.forename);
        let name = decodeURIComponent(req.query.name);
        const newUser = {
                email: email,
                name: name,
-               forename: forename,
        };
        let error = validator(newUser, "User");
        if (error.length > 0)
index 91d1105..eb1fbef 100644 (file)
@@ -1,28 +1,28 @@
-forename,name
-William,Plaisance
-Rosamonde,Dupuy
-Fabienne,Aubin
-Grégoire,Léveillé
-Fantina,Quinn
-Amitee,Morneau
-William,Lespérance
-Dreux,Vadeboncoeur
-Brigliador,Cadieux
-Grosvenor,Provencher
-Landers,Devost
-Joy,Laprise
-Dielle,Séguin
-Sidney,DeGrasse
-Jules,Gaillou
-Archaimbau,Bizier
-Dexter,Aucoin
-Searlas,Rivière
-Germain,Charpie
-Honore,Charlesbois
-Georges,LaCaille
-Anne,Ruest
-Searlas,Rochefort
-Ferrau,Adler
-Aimée,Asselin
-Delit,Cyr
-Noël,Babin
+name
+PLAISANCE William
+DUPUY Rosamonde
+AUBIN Fabienne
+LÉVEILLÉ Grégoire
+QUINN Fantina
+MORNEAU Amitee
+LESPÉRANCE William
+VADEBONCOEUR Dreux
+CADIEUX Brigliador
+PROVENCHER Grosvenor
+DEVOST Landers
+LAPRISE Joy
+SÉGUIN Dielle
+DEGRASSE Sidney
+GAILLOU Jules
+BIZIER Archaimbau
+AUCOIN Dexter
+RIVIÈRE Searlas
+CHARPIE Germain
+CHARLESBOIS Honore
+LACAILLE Georges
+RUEST Anne
+ROCHEFORT Searlas
+ADLER Ferrau
+ASSELIN Aimée
+CYR Delit
+BABIN Noël
index e45e282..d1f696f 100644 (file)
@@ -29,9 +29,6 @@ block content
                                #stage1(v-show="stage==1")
                                        .card
                                                if assessment.mode != "open"
-                                                       .input-field.inline.on-left
-                                                               label(for="forename") Forename
-                                                               input#forename(type="text" v-model="student.forename" disabled)
                                                        .input-field.inline
                                                                label(for="name") Name
                                                                input#name(type="text" v-model="student.name" disabled)
index aa412e2..7aa6619 100644 (file)
@@ -89,7 +89,8 @@ block content
                                                tbody
                                                        tr.grade(v-for="student in studentList(group)")
                                                                td {{ student.number }}
-                                                               td(v-for="(assessment,i) in assessmentArray" @click="togglePresence(student.number,i)") {{ grade(i,student.number) }}
+                                                               td(v-for="(assessment,i) in assessmentArray" @click="togglePresence(student.number,i)")
+                                                                       {{ grade(i,student.number) }}
                                .modal-footer
                                        .center-align
                                                a.modal-action.modal-close.waves-effect.waves-light.btn-flat(href="#!") Close
@@ -105,13 +106,11 @@ block content
                                                        thead
                                                                tr
                                                                        th Number
-                                                                       th Forename
                                                                        th Name
                                                                        th Group
                                                        tbody
                                                                tr.student(v-for="student in studentList(0)")
                                                                        td {{ student.number }}
-                                                                       td {{ student.forename }}
                                                                        td {{ student.name }}
                                                                        td {{ student.group }}
                                h4.title(@click="toggleDisplay('assessments')") Assessments
@@ -119,7 +118,8 @@ block content
                                        if teacher
                                                .center-align
                                                        a.on-left.waves-effect.waves-light.btn.modal-trigger(href="#newAssessment") New assessment
-                                                       input#password(type="password" v-model="monitorPwd" @keyup.enter="setPassword" placeholder="Password" title="Monitoring password")
+                                                       input#password(type="password" v-model="monitorPwd" @keyup.enter="setPassword"
+                                                                       placeholder="Password" title="Monitoring password")
                                        table
                                                thead
                                                        tr
@@ -128,7 +128,8 @@ block content
                                                                th #Questions
                                                                th Time
                                                tbody
-                                                       tr.assessment(v-for="(assessment,i) in assessmentArray" @click.left="actionAssessment(i)" @contextmenu.prevent="deleteAssessment(assessment)")
+                                                       tr.assessment(v-for="(assessment,i) in assessmentArray" v-if="assessment.active"
+                                                                       @click.left="actionAssessment(i)" @contextmenu.prevent="deleteAssessment(assessment)")
                                                                td {{ assessment.name }}
                                                                td {{ assessment.mode }}
                                                                td {{ assessment.questions.reduce( (a,b) => { return b.active ? a+1 : a; }, 0) }}
@@ -149,13 +150,11 @@ block content
                                                        thead
                                                                tr
                                                                        th Number
-                                                                       th Forename
                                                                        th Name
                                                                        th Final
                                                        tbody
                                                                tr.grade(v-for="student in studentList(group)")
                                                                        td {{ student.number }}
-                                                                       td {{ student.forename }}
                                                                        td {{ student.name }}
                                                                        td grade...
                                                                        //td {{ grades[student.number].final }}
index 58dc5e0..f7eda27 100644 (file)
@@ -16,12 +16,10 @@ block content
                                        table(:id="groupId(group)" v-for="group in [0].concat(groupList())")
                                                thead
                                                        tr
-                                                               th Forename
                                                                th Name
                                                                th(v-for="(q,i) in assessment.questions") Q.{{ (i+1) }}
                                                tbody
                                                        tr.assessment(v-for="s in studentList(group)")
-                                                               td {{ s.forename }}
                                                                td {{ s.name }}
                                                                td(v-for="(q,i) in assessment.questions" :style="{background-color: getColor(number,i)}" @click="seeDetails(number,i)") &nbsp;
                                h4.title(@click="toggleDisplay('assessment')") Assessment
index 70ac099..9856758 100644 (file)
@@ -11,9 +11,7 @@ block content
                                        thead
                                                tr
                                                        th Name
-                                                       th Forename
                                        tbody
                                                each user in userArray
                                                        tr.teacher(onClick="document.location.href='/" + user.initials+ "'")
                                                                td= user.name
-                                                               td= user.forename
index 215f83f..31adc75 100644 (file)
@@ -12,9 +12,6 @@ block content
                                                .input-field
                                                        input#email.validate(type="email", ref="userEmail", v-model="user.email", required)
                                                        label(for="email") Email
-                                               .input-field(v-show="stage=='register'")
-                                                       input#forename.validate(type="text", v-model="user.forename", :required="stage=='register'")
-                                                       label(for="forename") Forename
                                                .input-field(v-show="stage=='register'")
                                                        input#name.validate(type="text", v-model="user.name", :required="stage=='register'")
                                                        label(for="name") Name
index 339ca47..891dda2 100644 (file)
@@ -27,12 +27,10 @@ block content
                                                table(:id="groupId(group)" v-for="group in [0].concat(groupList())")
                                                        thead
                                                                tr
-                                                                       th Forename
                                                                        th Name
                                                                        th(v-for="(q,i) in assessment.questions") Q.{{ (i+1) }}
                                                        tbody
                                                                tr.assessment(v-for="s in studentList(group)")
-                                                                       td {{ s.forename }}
                                                                        td {{ s.name }}
                                                                        td(v-for="(q,i) in assessment.questions" :style="{backgroundColor: getColor(s.number,i)}" @click="seeDetails(s.number,i)") &nbsp;
                                        h4.title(@click="toggleDisplay('assessment')") Assessment