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 %}
</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 'anatomy:exam_json' pk=exam.pk %}">JSON</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>
+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_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(
# 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,
"eid": "{}/{}".format(self.question_type, exam.pk),
"json_creation_time": creation_time,
"json_creation_id": exam.creation_id
"exam_json_id": exam.exam_json_id
}
if self.question_type == "long":
@@ -410,7 +410,7 @@ class ExamViews(View, LoginRequiredMixin):
# Generate json if needed
if question.json_creation_time is None:
question.get_json(question.pk)
h[question.pk] = question.json_creation_id
h[question.pk] = question.question_json_id
obj["multi_question_json"] = h
active_exams["exams"].append( obj )
@@ -477,12 +477,12 @@ class ExamViews(View, LoginRequiredMixin):
time = datetime.now()
exam.json_creation_id += 1
exam.exam_json_id += 1
with open(path, "w+") as f:
exam_json = exam.get_exam_json()
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))
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_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)
@@ -214,7 +214,7 @@ class Long(models.Model):
url= "{0}longs/questions/{1}.json".format(settings.MEDIA_URL, question_id)
timestamp = datetime.datetime.now()
q.json_creation_id += 1
q.question_json_id += 1
with open(path, "w+") as f:
@@ -224,7 +224,7 @@ class Long(models.Model):
"type": "long",
"generated": "{}",
"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 q.json_creation_time is None:
q.get_json(q.pk)
exam_questions[q.id] = q.json_creation_id
exam_questions[q.id] = q.question_json_id
else:
# TODO: combine with question_json
+10 -1
View File
@@ -45,11 +45,20 @@
</li>
{% endfor %}
</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_recreate' pk=exam.pk %}">Refresh JSON cache</a>
<button id='button-open-access'>Make questions open access</button>
<button id='button-closed-access'>Make questions closed access</button>
<button id='button-edit-order'>Edit exam order</button>
</div>
<script type="text/javascript">
@@ -58,7 +58,7 @@
</div>
<div>
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>
<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>
@@ -26,8 +26,4 @@ This series is not associated with any cases.
{% for image in series.images.all %}
{{image.image.url}}, pos: {{image.position}}, {{image.upload_filename}}</br>
{% endfor %}
<div>
JSON creation time: {{question.json_creation_time}} ({{question.json_creation_time|date:"c"}}),
JSON creation id: {{question.json_creation_id}}
</div>
{% endfor %}
@@ -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',
),
]
+81 -71
View File
@@ -6,18 +6,22 @@
<div class="rapids">
<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 '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>
This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.<br/>
Normal {{ exam.get_normal_abnormal_breakdown }}<br/>
Exam mode: {{ exam.exam_mode }}<br/>
This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.<br />
Normal {{ exam.get_normal_abnormal_breakdown }}<br />
Exam mode: {{ exam.exam_mode }}<br />
{% if exam.exam_mode %}
<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 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>
{% endif %}
<p><a href="{% url 'rapids:mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p>
@@ -27,9 +31,9 @@
<li data-question_pk={{question.pk}}>
<a href="{% url 'rapids:exam_question_detail' pk=exam.pk sk=forloop.counter0 %}">
{% for image in question.get_images %}
<img src="{{ image|thumbnail_url:'exam-list' }}" alt="thumbail" />
{% endfor %}
{% for image in question.get_images %}
<img src="{{ image|thumbnail_url:'exam-list' }}" alt="thumbail" />
{% endfor %}
</a>
{% if not question.normal %}
<b>Abnormality:</b> {{ question.get_abnormalities }} <b>Region:</b> {{ question.get_regions }}
@@ -39,7 +43,9 @@
<b>Normal</b>
{% endif %}
<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>
{% endfor %}
</ol>
@@ -49,6 +55,10 @@
{% 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 '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_recreate' pk=exam.pk %}">Refresh JSON cache</a>
@@ -61,20 +71,20 @@
// send request to change the is_private state on customSwitches toggle
$("#exam-active-switch").on("change", function () {
$.ajax({
url: "{% url 'rapids:exam_toggle_active' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
active: this.checked // true if checked else false
},
type: "POST",
dataType: "json",
})
url: "{% url 'rapids:exam_toggle_active' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
active: this.checked // true if checked else false
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Exam state changed.')
toastr.info('Exam state changed.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
@@ -85,20 +95,20 @@
})
$("#exam-publish-results-switch").on("change", function () {
$.ajax({
url: "{% url 'rapids:exam_toggle_results_published' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
publish_results: this.checked // true if checked else false
},
type: "POST",
dataType: "json",
})
url: "{% url 'rapids:exam_toggle_results_published' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
publish_results: this.checked // true if checked else false
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Publish results state changed.')
toastr.info('Publish results state changed.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
@@ -109,14 +119,14 @@
})
$("#button-open-access").click(function () {
$.ajax({
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_open_access: true,
},
type: "POST",
dataType: "json",
})
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_open_access: true,
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
@@ -128,8 +138,8 @@
toastr.info(data.status);
}
})
.fail((e) => {
toastr.warning(`Error, ${e}`);
.fail((e) => {
toastr.warning(`Error, ${e}`);
})
.always(function () {
console.log('[Done]');
@@ -137,14 +147,14 @@
})
$("#button-closed-access").click(function () {
$.ajax({
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_open_access: false,
},
type: "POST",
dataType: "json",
})
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_open_access: false,
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
@@ -156,8 +166,8 @@
toastr.info(data.status);
}
})
.fail((e) => {
toastr.warning(`Error, ${e}`);
.fail((e) => {
toastr.warning(`Error, ${e}`);
})
.always(function () {
console.log('[Done]');
@@ -168,30 +178,30 @@
sortable('.sortable');
$("#full-question-list").append($("<button>Save exam order</button>").click(() => {
new_order = [];
$("#full-question-list li").each((n, el) => {
new_order.push(el.dataset.question_pk)
})
$.ajax({
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_exam_order: JSON.stringify(new_order),
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
new_order = [];
$("#full-question-list li").each((n, el) => {
new_order.push(el.dataset.question_pk)
})
$.ajax({
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_exam_order: JSON.stringify(new_order),
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Exam order changed.')
}
})
.always(function () {
console.log('[Done]');
})
if (data.status == "success") {
toastr.info('Exam order changed.')
}
})
.always(function () {
console.log('[Done]');
})
}));
});
@@ -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',
),
]