]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6387 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Oct 2023 17:22:34 +0000 (19:22 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Oct 2023 17:22:34 +0000 (19:22 +0200)
js/quiz.attemptslog.js
js/quiz.score.js
js/quiz.screen.outro.js
package.json [new file with mode: 0644]
style/100-global.sass

index 42dbb3d18b2deb8f382ae46923ae459e45e1af14..5dbd1e47d6d2bc14ff1be054069d0160cd516d0c 100644 (file)
@@ -1,8 +1,41 @@
+import axios from 'axios';
+
 function QuizAttemptsLog(quiz) {
     this.quiz = quiz;
-
 }
 
-QuizAttemptsLog.prototype = {}
+QuizAttemptsLog.prototype = {
+    log: function () {
+        if (!this.quiz.data.logattempts) {
+            return;
+        }
+
+        let score = this.quiz.score.getNormalizedScore(true);
+        if (isNaN(score)) {
+            score = 0;
+        }
+        let logdata = {
+            score: score, passed: this.quiz.score.isPassed(), questions: this.getQuestionsToLog(),
+        };
+
+        let dom = this.quiz.data.env === 'dev' ? 'dev.toolbox.fluidbook.com' : 'toolbox.fluidbook.com';
+
+        axios({
+            url: 'https://' + dom + '/quiz/' + this.quiz.data.id + '/log',
+            method: 'post',
+            data: logdata,
+            withCredentials: false,
+        }).then(function (response) {
+            console.log(response);
+        }).catch(function (error) {
+            console.log(error);
+        });
+
+    },
+
+    getQuestionsToLog: function () {
+        return this.quiz.score.logQuestions;
+    },
+}
 
 export default QuizAttemptsLog;
index 9c124058cd0b095863d203265a488391c14a6cdf..3f82ec835c9ac20843e0ead49c1ec2e4eddf9965 100644 (file)
@@ -189,7 +189,9 @@ QuizScore.prototype = {
         return {
             q: this.lastAnsweredQuestion, a: this.answers
         };
-    }, execAction: function (action) {
+    },
+
+    execAction: function (action) {
         if (action === undefined || action === null || action === '' || !action) {
             return;
         }
index f1d7342652725e1e6dd5bb3f51d00818f88c33b8..8462d7b9a94b74b66da876b8b27a6b66c5805b91 100644 (file)
@@ -116,6 +116,7 @@ QuizScreenOutro.prototype = {
         $("[id^=maxScore-]").text(maxScore);
 
         this.quiz.score.runEndAction();
+        this.quiz.attemptsLog.log();
 
         this.animate(score, percent)
         this.displayReviewList()
diff --git a/package.json b/package.json
new file mode 100644 (file)
index 0000000..f639a63
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "name": "fluidbook-toolbox-quiz",
+  "version": "1.0.0",
+  "dependencies": {
+    "axios": "^1.5.1"
+  }
+}
index dbe750601e554fc9e7e1ca71ad424a80c4054cf2..31ca619b8d85bccb3539c5aa6e57a811e3dd0b33 100644 (file)
@@ -1,8 +1,11 @@
 @use 'sass:color'
 @import 005-utilities
 
+*
+    user-select: none
+
 body
-    background-color: $neutral-color
+    background-color: $background-color
     font-family: $font
     color: $texts-color