From 92a6f83096ec0f1a32a306fda21ab2d324a3a433 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Mon, 26 Feb 2018 11:53:34 +0100
Subject: [PATCH] 'update'

---
 models/course.js                            | 16 +++++++++-------
 models/evaluation.js                        |  8 --------
 public/javascripts/components/statements.js | 12 +++++++-----
 views/course.pug                            |  2 +-
 4 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/models/course.js b/models/course.js
index cbe2c44..748ab6c 100644
--- a/models/course.js
+++ b/models/course.js
@@ -1,5 +1,4 @@
 const UserModel = require("../models/user");
-const EvaluationModel = require("../models/evaluation");
 const db = require("../utils/database");
 
 const CourseModel =
@@ -160,12 +159,15 @@ const CourseModel =
 			if (!!err || !course || !course.uid.equals(uid))
 				return cb({errmsg:"Not your course"},{});
 			// 2) remove all associated evaluations
-			EvaluationModel.removeGroup(cid, (err2,ret) => {
-				if (!!err)
-					return cb(err,{});
-				// 3) remove course (with its students)
-				CourseModel.remove(cid, cb);
-			});
+			db.evaluations.remove(
+				{ cid: cid },
+				(err2,ret) => {
+					if (!!err)
+						return cb(err,{});
+					// 3) remove course (with its students)
+					CourseModel.remove(cid, cb);
+				}
+			);
 		});
 	},
 }
diff --git a/models/evaluation.js b/models/evaluation.js
index be5dbc2..8cf7e64 100644
--- a/models/evaluation.js
+++ b/models/evaluation.js
@@ -260,14 +260,6 @@ const EvaluationModel =
 		);
 	},
 
-	removeGroup: function(cid, cb)
-	{
-		db.evaluations.remove(
-			{ cid: cid },
-			cb
-		);
-	},
-
 	/////////////////////
 	// ADVANCED FUNCTIONS
 
diff --git a/public/javascripts/components/statements.js b/public/javascripts/components/statements.js
index 65bab5f..0b8ef65 100644
--- a/public/javascripts/components/statements.js
+++ b/public/javascripts/components/statements.js
@@ -6,13 +6,15 @@ NOTE: questions can contain parameterized exercises (how ?
 --> write javascript script (OK, users trusted ? ==> safe mode possible if public website)
 Imaginary example: (using math.js)
 	<params> (avant l'exo)
-	x: math.random()
-	y: math.random()
-	M: math.matrix([[7, x], [y, -3]]);
-	res: math.det(M)
+	const x = math.random()
+	const y = math.random()
 	</params>
+	<result>
+	let M = math.matrix([[7, x], [y, -3]]);
+	return math.det(M);
+	</result>
 	<div>Calculer le déterminant de 
-	$$\begin{matrix}7 & x\\y & -3\end{matrix}$$</div>
+	$$\begin{matrix}7 & £x£\\£y£ & -3\end{matrix}$$</div>
 	* ...
 
 + fixed + question time (syntax ?)
diff --git a/views/course.pug b/views/course.pug
index 4e44ec7..2a3f549 100644
--- a/views/course.pug
+++ b/views/course.pug
@@ -66,7 +66,7 @@ block content
 									button.waves-effect.waves-light.btn(@click="redirect(evaluation.name)") View
 								div
 									.introduction(v-html="evaluation.introduction")
-									statements(:questions="evaluation.questions" :display="'solution'")
+									statements(:questions="evaluation.questions" :answers="evaluation.answers" :display="'solution'")
 							.card(v-show="mode=='edit'")
 								form(@submit.prevent)
 									p
-- 
2.44.0