+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;
return {
q: this.lastAnsweredQuestion, a: this.answers
};
- }, execAction: function (action) {
+ },
+
+ execAction: function (action) {
if (action === undefined || action === null || action === '' || !action) {
return;
}
$("[id^=maxScore-]").text(maxScore);
this.quiz.score.runEndAction();
+ this.quiz.attemptsLog.log();
this.animate(score, percent)
this.displayReviewList()