.
This commit is contained in:
+1
-1
@@ -409,7 +409,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
for question in exam.exam_questions.all():
|
||||
# Generate json if needed
|
||||
if question.json_creation_time is None:
|
||||
question.get_json(question.pk)
|
||||
question.get_question_json()
|
||||
h[question.pk] = question.question_json_id
|
||||
obj["multi_question_json"] = h
|
||||
active_exams["exams"].append( obj )
|
||||
|
||||
+13
-12
@@ -176,15 +176,16 @@ class Long(models.Model):
|
||||
answers = self.cid_user_answers.all()
|
||||
return [ans for ans in answers if not ans.is_marked()]
|
||||
|
||||
def get_json(self, question_id, based=True):
|
||||
def get_question_json(self, based=True):
|
||||
# self == q?
|
||||
q = get_object_or_404(Long, pk=question_id)
|
||||
#q = get_object_or_404(Long, pk=question_id)
|
||||
question_id = self.pk
|
||||
|
||||
|
||||
if not based:
|
||||
image_titles = []
|
||||
images = []
|
||||
question_series = q.series.all()
|
||||
question_series = self.series.all()
|
||||
# Loop through longimage associations
|
||||
for i, series in enumerate(question_series):
|
||||
#image_array = []
|
||||
@@ -199,7 +200,7 @@ class Long(models.Model):
|
||||
image_titles.append(series.get_examination())
|
||||
|
||||
question_json = {
|
||||
"title": q.history,
|
||||
"title": self.history,
|
||||
"images": images,
|
||||
"image_titles": image_titles,
|
||||
#"feedback_image": [],
|
||||
@@ -215,9 +216,9 @@ class Long(models.Model):
|
||||
url= "{0}longs/questions/{1}.json".format(settings.MEDIA_URL, question_id)
|
||||
|
||||
timestamp = timezone.now()
|
||||
q.question_json_id += 1
|
||||
self.question_json_id += 1
|
||||
|
||||
print("QID", q.question_json_id)
|
||||
print("QID", self.question_json_id)
|
||||
|
||||
with open(path, "w+") as f:
|
||||
|
||||
@@ -227,7 +228,7 @@ class Long(models.Model):
|
||||
"type": "long",
|
||||
"generated": "{}",
|
||||
"question_json_id": "{}",
|
||||
""".format(q.history, timestamp.isoformat(), q.question_json_id)
|
||||
""".format(self.history, timestamp.isoformat(), self.question_json_id)
|
||||
)
|
||||
|
||||
|
||||
@@ -235,7 +236,7 @@ class Long(models.Model):
|
||||
#images = []
|
||||
image_titles = []
|
||||
|
||||
question_series = q.series.all()
|
||||
question_series = self.series.all()
|
||||
# Loop through longimage associations
|
||||
for i, series in enumerate(question_series):
|
||||
#image_array = []
|
||||
@@ -255,10 +256,10 @@ class Long(models.Model):
|
||||
|
||||
f.write('"image_titles" : {} }}'.format(json.dumps(image_titles)))
|
||||
|
||||
print("QID2", q.question_json_id)
|
||||
print("QID2", self.question_json_id)
|
||||
|
||||
q.json_creation_time = timestamp
|
||||
q.save()
|
||||
self.json_creation_time = timestamp
|
||||
self.save()
|
||||
|
||||
#exam_question = {
|
||||
# "title": q.history,
|
||||
@@ -592,7 +593,7 @@ class Exam(ExamBase):
|
||||
|
||||
# If it is a new question we need to for a question json refresh
|
||||
if q.json_creation_time is None:
|
||||
q.get_json(q.pk)
|
||||
q.get_question_json()
|
||||
exam_questions[q.id] = q.question_json_id
|
||||
|
||||
else:
|
||||
|
||||
+3
-3
@@ -957,7 +957,7 @@ def question_json_unbased(request, pk):
|
||||
"""
|
||||
question = get_object_or_404(Long, pk=pk)
|
||||
|
||||
question_json = question.get_json(pk, based=False)
|
||||
question_json = question.get_question_json(based=False)
|
||||
return JsonResponse(question_json)
|
||||
|
||||
def question_json(request, pk):
|
||||
@@ -973,7 +973,7 @@ def question_json(request, pk):
|
||||
if os.path.isfile(path) and not question.recreate_json:
|
||||
return redirect(url)
|
||||
|
||||
question_json = question.get_json(pk)
|
||||
question_json = question.get_question_json()
|
||||
|
||||
question.recreate_json = False
|
||||
question.save()
|
||||
@@ -988,6 +988,6 @@ def question_json_recreate(request, pk):
|
||||
question.recreate_json = True
|
||||
question.save()
|
||||
|
||||
question.get_json(pk)
|
||||
question.get_question_json()
|
||||
|
||||
return redirect("longs:question_detail", pk=pk)
|
||||
Reference in New Issue
Block a user