.
This commit is contained in:
@@ -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
@@ -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
@@ -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
@@ -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
|
||||||
|
|||||||
@@ -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',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -6,18 +6,22 @@
|
|||||||
<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 />
|
||||||
Exam mode: {{ exam.exam_mode }}<br/>
|
Exam mode: {{ exam.exam_mode }}<br />
|
||||||
|
|
||||||
{% 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>
|
||||||
@@ -27,9 +31,9 @@
|
|||||||
|
|
||||||
<li data-question_pk={{question.pk}}>
|
<li data-question_pk={{question.pk}}>
|
||||||
<a href="{% url 'rapids:exam_question_detail' pk=exam.pk sk=forloop.counter0 %}">
|
<a href="{% url 'rapids:exam_question_detail' pk=exam.pk sk=forloop.counter0 %}">
|
||||||
{% for image in question.get_images %}
|
{% for image in question.get_images %}
|
||||||
<img src="{{ image|thumbnail_url:'exam-list' }}" alt="thumbail" />
|
<img src="{{ image|thumbnail_url:'exam-list' }}" alt="thumbail" />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</a>
|
</a>
|
||||||
{% if not question.normal %}
|
{% if not question.normal %}
|
||||||
<b>Abnormality:</b> {{ question.get_abnormalities }} <b>Region:</b> {{ question.get_regions }}
|
<b>Abnormality:</b> {{ question.get_abnormalities }} <b>Region:</b> {{ question.get_regions }}
|
||||||
@@ -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>
|
||||||
@@ -61,20 +71,20 @@
|
|||||||
// send request to change the is_private state on customSwitches toggle
|
// send request to change the is_private state on customSwitches toggle
|
||||||
$("#exam-active-switch").on("change", function () {
|
$("#exam-active-switch").on("change", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'rapids:exam_toggle_active' pk=exam.pk %}",
|
url: "{% url 'rapids:exam_toggle_active' pk=exam.pk %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
active: this.checked // true if checked else false
|
active: this.checked // true if checked else false
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.status == "success") {
|
if (data.status == "success") {
|
||||||
toastr.info('Exam state changed.')
|
toastr.info('Exam state changed.')
|
||||||
}
|
}
|
||||||
// show some message according to the response.
|
// show some message according to the response.
|
||||||
// For eg. A message box showing that the status has been changed
|
// For eg. A message box showing that the status has been changed
|
||||||
@@ -85,20 +95,20 @@
|
|||||||
})
|
})
|
||||||
$("#exam-publish-results-switch").on("change", function () {
|
$("#exam-publish-results-switch").on("change", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'rapids:exam_toggle_results_published' pk=exam.pk %}",
|
url: "{% url 'rapids:exam_toggle_results_published' pk=exam.pk %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
publish_results: this.checked // true if checked else false
|
publish_results: this.checked // true if checked else false
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.status == "success") {
|
if (data.status == "success") {
|
||||||
toastr.info('Publish results state changed.')
|
toastr.info('Publish results state changed.')
|
||||||
}
|
}
|
||||||
// show some message according to the response.
|
// show some message according to the response.
|
||||||
// For eg. A message box showing that the status has been changed
|
// For eg. A message box showing that the status has been changed
|
||||||
@@ -109,14 +119,14 @@
|
|||||||
})
|
})
|
||||||
$("#button-open-access").click(function () {
|
$("#button-open-access").click(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
set_open_access: true,
|
set_open_access: true,
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
@@ -129,7 +139,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail((e) => {
|
.fail((e) => {
|
||||||
toastr.warning(`Error, ${e}`);
|
toastr.warning(`Error, ${e}`);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
@@ -137,14 +147,14 @@
|
|||||||
})
|
})
|
||||||
$("#button-closed-access").click(function () {
|
$("#button-closed-access").click(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
set_open_access: false,
|
set_open_access: false,
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
@@ -157,7 +167,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail((e) => {
|
.fail((e) => {
|
||||||
toastr.warning(`Error, ${e}`);
|
toastr.warning(`Error, ${e}`);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
@@ -168,30 +178,30 @@
|
|||||||
sortable('.sortable');
|
sortable('.sortable');
|
||||||
|
|
||||||
$("#full-question-list").append($("<button>Save exam order</button>").click(() => {
|
$("#full-question-list").append($("<button>Save exam order</button>").click(() => {
|
||||||
new_order = [];
|
new_order = [];
|
||||||
$("#full-question-list li").each((n, el) => {
|
$("#full-question-list li").each((n, el) => {
|
||||||
new_order.push(el.dataset.question_pk)
|
new_order.push(el.dataset.question_pk)
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
set_exam_order: JSON.stringify(new_order),
|
set_exam_order: JSON.stringify(new_order),
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.status == "success") {
|
if (data.status == "success") {
|
||||||
toastr.info('Exam order changed.')
|
toastr.info('Exam order changed.')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
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',
|
||||||
|
),
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user