From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sat, 10 Feb 2018 11:36:39 +0000 (+0100)
Subject: Merge forename + name into [identifying] 'name' (more general)
X-Git-Url: https://git.auder.net/doc/html/vendor/current/img/cross.svg?a=commitdiff_plain;h=b3540dbb5c169db3c7cf49a04e253ab3a6940916;p=qomet.git

Merge forename + name into [identifying] 'name' (more general)
---

diff --git a/entities/course.js b/entities/course.js
index 66fcaee..9b3fb46 100644
--- a/entities/course.js
+++ b/entities/course.js
@@ -11,7 +11,6 @@ const CourseEntity =
 	 *   password: monitoring password hash
 	 *   students: array of
 	 *     number: student number
-	 *     forename: varchar
 	 *     name: varchar
 	 *     group: integer
 	 */
diff --git a/entities/user.js b/entities/user.js
index 1026eaf..72b3a43 100644
--- a/entities/user.js
+++ b/entities/user.js
@@ -7,7 +7,6 @@ const UserEntity =
 	 *   _id: BSON id
 	 *   ** Strings, identification informations:
 	 *   email
-	 *   forename
 	 *   name
 	 *   initials : computed, Benjamin Auder --> ba ...etc
 	 *   loginToken: {
diff --git a/models/user.js b/models/user.js
index f495bdc..c6fa776 100644
--- a/models/user.js
+++ b/models/user.js
@@ -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)
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index 85172dc..e0f2e37 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -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,
diff --git a/public/javascripts/login.js b/public/javascripts/login.js
index 1bb5b72..4f70e19 100644
--- a/public/javascripts/login.js
+++ b/public/javascripts/login.js
@@ -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]);
diff --git a/public/javascripts/monitor.js b/public/javascripts/monitor.js
index 23972a9..8963731 100644
--- a/public/javascripts/monitor.js
+++ b/public/javascripts/monitor.js
@@ -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;
diff --git a/public/javascripts/utils/validation.js b/public/javascripts/utils/validation.js
index aa39ebe..530713a 100644
--- a/public/javascripts/utils/validation.js
+++ b/public/javascripts/utils/validation.js
@@ -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",
 };
diff --git a/routes/users.js b/routes/users.js
index c42b447..2de89b0 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -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)
diff --git a/setup/students.sample.csv b/setup/students.sample.csv
index 91d1105..eb1fbef 100644
--- a/setup/students.sample.csv
+++ b/setup/students.sample.csv
@@ -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
diff --git a/views/assessment.pug b/views/assessment.pug
index e45e282..d1f696f 100644
--- a/views/assessment.pug
+++ b/views/assessment.pug
@@ -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)
diff --git a/views/course.pug b/views/course.pug
index aa412e2..7aa6619 100644
--- a/views/course.pug
+++ b/views/course.pug
@@ -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 }}
diff --git a/views/grading.pug b/views/grading.pug
index 58dc5e0..f7eda27 100644
--- a/views/grading.pug
+++ b/views/grading.pug
@@ -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
diff --git a/views/index.pug b/views/index.pug
index 70ac099..9856758 100644
--- a/views/index.pug
+++ b/views/index.pug
@@ -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
diff --git a/views/login.pug b/views/login.pug
index 215f83f..31adc75 100644
--- a/views/login.pug
+++ b/views/login.pug
@@ -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
diff --git a/views/monitor.pug b/views/monitor.pug
index 339ca47..891dda2 100644
--- a/views/monitor.pug
+++ b/views/monitor.pug
@@ -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