From f9c20767b3db8d6bbbedd019d025e8ce01fd9d6c Mon Sep 17 00:00:00 2001
From: Ruben Young On <r.d.youngon@student.tudelft.nl>
Date: Sat, 25 May 2019 13:23:32 +0200
Subject: [PATCH] Feedback options now automatically have the label of their
 associated checkbox if they have one

---
 zesje/api/mult_choice.py |  4 ++--
 zesje/pregrader.py       | 19 +------------------
 2 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/zesje/api/mult_choice.py b/zesje/api/mult_choice.py
index 8a1b2c9f..29eaa61d 100644
--- a/zesje/api/mult_choice.py
+++ b/zesje/api/mult_choice.py
@@ -64,8 +64,8 @@ class MultipleChoice(Resource):
         mc_type = 'mcq_widget'
 
         if not id:
-            # Insert new empty feedback option that links to the same problem
-            new_feedback_option = FeedbackOption(problem_id=problem_id, text='')
+            # Insert new empty feedback option that links to the same problem, with the label as name
+            new_feedback_option = FeedbackOption(problem_id=problem_id, text=label)
             db.session.add(new_feedback_option)
             db.session.commit()
 
diff --git a/zesje/pregrader.py b/zesje/pregrader.py
index 22500020..2175ee9e 100644
--- a/zesje/pregrader.py
+++ b/zesje/pregrader.py
@@ -1,19 +1,7 @@
-# 3 - resolution / dpi to convert points to inches to pixels
-# 4 - get corner marker keypoints per page
-# 5 - optional? determine blank pdf corner markers vs submission corner markers
-# 6 - transform submission image
-# 7 - determine checkbox locations
-# 8 - get box location and check if it is filled
-# 8.5 - check if feedback option exists
-# 9 - connect to feedback option
-
-# coupled feedback cannot be deleted
-
-
 import cv2
 import numpy as np
 
-from zesje.database import db, Solution, ProblemWidget
+from zesje.database import db, Solution
 from zesje.images import guess_dpi, get_box, fix_corner_markers
 
 
@@ -44,11 +32,6 @@ def add_feedback_to_solution(exam, page, page_img, corner_keypoints):
 
             if box_is_filled(box, page_img, top_left_point):
                 feedback = mc_option.feedback
-
-                if mc_option.label:
-                    feedback.text = mc_option.label
-                    db.session.commit()
-
                 sol.feedback.append(feedback)
                 db.session.commit()
 
-- 
GitLab