This commit is contained in:
Ross
2021-08-01 09:48:01 +01:00
parent 64737ee341
commit 9b057e3e47
13 changed files with 201 additions and 87 deletions
@@ -0,0 +1,18 @@
# Generated by Django 3.2.4 on 2021-08-01 08:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('anatomy', '0042_exam_json_creation_id'),
]
operations = [
migrations.RenameField(
model_name='exam',
old_name='json_creation_id',
new_name='exam_json_id',
),
]
@@ -43,6 +43,10 @@
{% endfor %} {% endfor %}
</div> </div>
<p><button id='button-edit-order'>Edit exam order</button></p> <p><button id='button-edit-order'>Edit exam order</button></p>
<div>
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
JSON creation id: {{exam.exam_json_id}}
</div>
<a href="{% url 'anatomy:exam_json' pk=exam.pk %}">JSON</a> <a href="{% url 'anatomy:exam_json' pk=exam.pk %}">JSON</a>
<a href="{% url 'anatomy:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a> <a href="{% url 'anatomy:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a>
<button id='button-open-access'>Make questions open access</button> <button id='button-open-access'>Make questions open access</button>
+1 -1
View File
@@ -73,7 +73,7 @@ class ExamBase(models.Model):
) )
json_creation_time = models.DateTimeField(blank=True, default=None, null=True) json_creation_time = models.DateTimeField(blank=True, default=None, null=True)
json_creation_id = models.IntegerField(default=1, help_text="auto incrementing field when json recreated") exam_json_id = models.IntegerField(default=1, help_text="auto incrementing field when json recreated")
#time_limit = models.IntegerField( #time_limit = models.IntegerField(
# help_text="Exam time limit (in seconds). Default is 2100 secondse (35 minutes)", # help_text="Exam time limit (in seconds). Default is 2100 secondse (35 minutes)",
+4 -4
View File
@@ -401,7 +401,7 @@ class ExamViews(View, LoginRequiredMixin):
"type": self.question_type, "type": self.question_type,
"eid": "{}/{}".format(self.question_type, exam.pk), "eid": "{}/{}".format(self.question_type, exam.pk),
"json_creation_time": creation_time, "json_creation_time": creation_time,
"json_creation_id": exam.creation_id "exam_json_id": exam.exam_json_id
} }
if self.question_type == "long": if self.question_type == "long":
@@ -410,7 +410,7 @@ class ExamViews(View, LoginRequiredMixin):
# Generate json if needed # Generate json if needed
if question.json_creation_time is None: if question.json_creation_time is None:
question.get_json(question.pk) question.get_json(question.pk)
h[question.pk] = question.json_creation_id h[question.pk] = question.question_json_id
obj["multi_question_json"] = h obj["multi_question_json"] = h
active_exams["exams"].append( obj ) active_exams["exams"].append( obj )
@@ -477,12 +477,12 @@ class ExamViews(View, LoginRequiredMixin):
time = datetime.now() time = datetime.now()
exam.json_creation_id += 1 exam.exam_json_id += 1
with open(path, "w+") as f: with open(path, "w+") as f:
exam_json = exam.get_exam_json() exam_json = exam.get_exam_json()
exam_json["generated"] = time.isoformat() exam_json["generated"] = time.isoformat()
exam_json["creation_id"] = exam.json_creation_id exam_json["exam_json_id"] = exam.exam_json_id
f.write(json.dumps(exam_json)) f.write(json.dumps(exam_json))
exam.recreate_json = False exam.recreate_json = False
@@ -0,0 +1,23 @@
# Generated by Django 3.2.4 on 2021-08-01 08:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('longs', '0039_auto_20210801_0918'),
]
operations = [
migrations.RenameField(
model_name='exam',
old_name='json_creation_id',
new_name='exam_json_id',
),
migrations.RenameField(
model_name='long',
old_name='json_creation_id',
new_name='question_json_id',
),
]
+4 -4
View File
@@ -126,7 +126,7 @@ class Long(models.Model):
json_creation_time = models.DateTimeField(blank=True, default=None, null=True) json_creation_time = models.DateTimeField(blank=True, default=None, null=True)
json_creation_id = models.IntegerField(default=1, help_text="Auto incrementing json creation number") question_json_id = models.IntegerField(default=1, help_text="Auto incrementing json creation number")
#question_file = models.FileField(upload_to=question_file_directory_path, blank=True, null=True) #question_file = models.FileField(upload_to=question_file_directory_path, blank=True, null=True)
@@ -214,7 +214,7 @@ class Long(models.Model):
url= "{0}longs/questions/{1}.json".format(settings.MEDIA_URL, question_id) url= "{0}longs/questions/{1}.json".format(settings.MEDIA_URL, question_id)
timestamp = datetime.datetime.now() timestamp = datetime.datetime.now()
q.json_creation_id += 1 q.question_json_id += 1
with open(path, "w+") as f: with open(path, "w+") as f:
@@ -224,7 +224,7 @@ class Long(models.Model):
"type": "long", "type": "long",
"generated": "{}", "generated": "{}",
"creation_id": "{}", "creation_id": "{}",
""".format(q.history, timestamp.isoformat(), q.json_creation_id) """.format(q.history, timestamp.isoformat(), q.question_json_id)
) )
@@ -589,7 +589,7 @@ class Exam(ExamBase):
# If it is a new question we need to for a question json refresh # If it is a new question we need to for a question json refresh
if q.json_creation_time is None: if q.json_creation_time is None:
q.get_json(q.pk) q.get_json(q.pk)
exam_questions[q.id] = q.json_creation_id exam_questions[q.id] = q.question_json_id
else: else:
# TODO: combine with question_json # TODO: combine with question_json
+10 -1
View File
@@ -45,11 +45,20 @@
</li> </li>
{% endfor %} {% endfor %}
</ol> </ol>
<div>
Author: {% for author in exam.author.all %}
{{ author }},
{% endfor %}
</div>
<p><button id='button-edit-order'>Edit exam order</button></p>
<div>
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
JSON creation id: {{exam.exam_json_id}}
</div>
<a href="{% url 'longs:exam_json' pk=exam.pk %}">JSON</a> <a href="{% url 'longs:exam_json' pk=exam.pk %}">JSON</a>
<a href="{% url 'longs:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a> <a href="{% url 'longs:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a>
<button id='button-open-access'>Make questions open access</button> <button id='button-open-access'>Make questions open access</button>
<button id='button-closed-access'>Make questions closed access</button> <button id='button-closed-access'>Make questions closed access</button>
<button id='button-edit-order'>Edit exam order</button>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
@@ -58,7 +58,7 @@
</div> </div>
<div> <div>
JSON creation time: {{question.json_creation_time}} ({{question.json_creation_time|date:"c"}}), JSON creation time: {{question.json_creation_time}} ({{question.json_creation_time|date:"c"}}),
JSON creation id: {{question.json_creation_id}} JSON creation id: {{question.question_json_id}}
</div> </div>
<a href="{% url 'longs:question_json' pk=question.pk %}">JSON</a> <a href="{% url 'longs:question_json' pk=question.pk %}">JSON</a>
<a href="{% url 'longs:question_json_recreate' pk=question.pk %}">Refresh JSON cache</a> <a href="{% url 'longs:question_json_recreate' pk=question.pk %}">Refresh JSON cache</a>
@@ -27,7 +27,3 @@ This series is not associated with any cases.
{{image.image.url}}, pos: {{image.position}}, {{image.upload_filename}}</br> {{image.image.url}}, pos: {{image.position}}, {{image.upload_filename}}</br>
{% endfor %} {% endfor %}
<div>
JSON creation time: {{question.json_creation_time}} ({{question.json_creation_time|date:"c"}}),
JSON creation id: {{question.json_creation_id}}
</div>
@@ -0,0 +1,18 @@
# Generated by Django 3.2.4 on 2021-08-01 08:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('physics', '0010_exam_json_creation_id'),
]
operations = [
migrations.RenameField(
model_name='exam',
old_name='json_creation_id',
new_name='exam_json_id',
),
]
@@ -0,0 +1,18 @@
# Generated by Django 3.2.4 on 2021-08-01 08:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('rapids', '0026_exam_json_creation_id'),
]
operations = [
migrations.RenameField(
model_name='exam',
old_name='json_creation_id',
new_name='exam_json_id',
),
]
+14 -4
View File
@@ -6,7 +6,8 @@
<div class="rapids"> <div class="rapids">
<a href="{% url 'rapids:exam_update' exam.id %}" title="Edit the Exam">Edit</a> <a href="{% url 'rapids:exam_update' exam.id %}" title="Edit the Exam">Edit</a>
<a href="{% url 'rapids:exam_delete' exam.id %}" title="Delete the Exam">Delete</a> <a href="{% url 'rapids:exam_delete' exam.id %}" title="Delete the Exam">Delete</a>
<a href="{% url 'admin:rapids_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin Edit</a> <a href="{% url 'admin:rapids_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin
Edit</a>
<h1>Exam: {{ exam.name }}</h1> <h1>Exam: {{ exam.name }}</h1>
This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.<br /> This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.<br />
Normal {{ exam.get_normal_abnormal_breakdown }}<br /> Normal {{ exam.get_normal_abnormal_breakdown }}<br />
@@ -14,10 +15,13 @@
{% if exam.exam_mode %} {% if exam.exam_mode %}
<div class="parent-help" title="Click to enable / disable the exam"> <div class="parent-help" title="Click to enable / disable the exam">
Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %}> <span class="help-text">[When checked the exam will be available to take in the test system]</span> Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %}> <span
class="help-text">[When checked the exam will be available to take in the test system]</span>
</div> </div>
<div class="parent-help" title="Click to enable / disable the exam results"> <div class="parent-help" title="Click to enable / disable the exam results">
Publish results: <input type="checkbox" id="exam-publish-results-switch" {% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will be available on this site]</span> Publish results: <input type="checkbox" id="exam-publish-results-switch"
{% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will
be available on this site]</span>
</div> </div>
{% endif %} {% endif %}
<p><a href="{% url 'rapids:mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p> <p><a href="{% url 'rapids:mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p>
@@ -39,7 +43,9 @@
<b>Normal</b> <b>Normal</b>
{% endif %} {% endif %}
<br /> <br />
Examination: {{ question.get_examinations }}, <a href="{% url 'rapids:question_detail' pk=question.pk %}">View</a>, <a href="{% url 'rapids:mark' pk=exam.pk sk=forloop.counter0 %}">Mark</a> Examination: {{ question.get_examinations }}, <a
href="{% url 'rapids:question_detail' pk=question.pk %}">View</a>, <a
href="{% url 'rapids:mark' pk=exam.pk sk=forloop.counter0 %}">Mark</a>
</li> </li>
{% endfor %} {% endfor %}
</ol> </ol>
@@ -49,6 +55,10 @@
{% endfor %} {% endfor %}
</div> </div>
<p><button id='button-edit-order'>Edit exam order</button></p> <p><button id='button-edit-order'>Edit exam order</button></p>
<div>
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
JSON creation id: {{exam.exam_json_id}}
</div>
<a href="{% url 'rapids:exam_json' pk=exam.pk %}">JSON</a> <a href="{% url 'rapids:exam_json' pk=exam.pk %}">JSON</a>
<a href="{% url 'rapids:exam_json_unbased' pk=exam.pk %}">JSON (unbased)</a> <a href="{% url 'rapids:exam_json_unbased' pk=exam.pk %}">JSON (unbased)</a>
<a href="{% url 'rapids:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a> <a href="{% url 'rapids:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a>
@@ -0,0 +1,18 @@
# Generated by Django 3.2.4 on 2021-08-01 08:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('sbas', '0002_auto_20210801_0918'),
]
operations = [
migrations.RenameField(
model_name='exam',
old_name='json_creation_id',
new_name='exam_json_id',
),
]