From 9a9ffb9b1b4e98479e8c694a231be5f98ecc0436 Mon Sep 17 00:00:00 2001 From: Timo <timotei96@gmail.com> Date: Wed, 22 May 2019 15:32:30 +0200 Subject: [PATCH] Fixed a issue when fetching cb locations from the database --- client/views/Exam.jsx | 14 ++++++++++---- client/views/ExamEditor.jsx | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client/views/Exam.jsx b/client/views/Exam.jsx index a603661a..f70b4a40 100644 --- a/client/views/Exam.jsx +++ b/client/views/Exam.jsx @@ -42,7 +42,11 @@ class Exams extends React.Component { page: problem.page, name: problem.name, graded: problem.graded, - mc_options: problem.mc_options, + mc_options: problem.mc_options.map((option) => { + option.widget.x -= 7 + option.widget.y -= 21 + return option + }), isMCQ: problem.mc_options && problem.mc_options.length !== 0 // is the problem a mc question - used to display PanelMCQ } } @@ -319,7 +323,7 @@ class Exams extends React.Component { return { 'widget': { 'x': { - $set: data.x + i * 23 + $set: data.x + i * 24 }, 'y': { // each mc option needs to be positioned next to the previous option and should not overlap it @@ -359,8 +363,8 @@ class Exams extends React.Component { 'feedback_id': null, 'widget': { 'name': 'mc_option_' + labels[index], - 'x': xPos + 6, - 'y': yPos + 11, + 'x': xPos + 7, + 'y': yPos + 21, 'type': 'mcq_widget' } } @@ -373,6 +377,8 @@ class Exams extends React.Component { formData.append('label', data.label) api.put('mult-choice/', formData).then(result => { data.id = result.mult_choice_id + data.widget.x -= 7 + data.widget.y -= 21 this.createNewMCOWidget(problemWidget, data) this.generateAnswerBoxes(problemWidget, labels, index + 1, xPos + 24, yPos) }).catch(err => { diff --git a/client/views/ExamEditor.jsx b/client/views/ExamEditor.jsx index 11c69600..086dfa91 100644 --- a/client/views/ExamEditor.jsx +++ b/client/views/ExamEditor.jsx @@ -232,7 +232,7 @@ class ExamEditor extends React.Component { widget.problem.mc_options.forEach( (option, i) => { let newData = { - x: Math.round(data.x) + i * 23 + 7, + x: Math.round(data.x) + i * 24 + 7, y: Math.round(data.y) + 21 } this.updateWidgetPositionDB(option, newData) -- GitLab