Merge branch 'master' of ssh://git.xkjq.uk:30001/ross/rad

This commit is contained in:
Ross
2022-01-04 13:50:08 +00:00
14 changed files with 136 additions and 156 deletions
-18
View File
@@ -587,24 +587,6 @@ table.longs .user-answer-score- {
background-color: red;
}
.published-icon {
border: 1px dotted gray;
opacity: 20%;
border-radius: 4px;
display: none;
}
.published-icon:hover {
opacity: 100%;
}
.published-icon.published {
border: 1px solid purple;
color: purple;
opacity: 100%;
display: inline-block;
}
textarea,
input {
border-radius: 2px;
+1
View File
@@ -664,6 +664,7 @@ def exam_scores_cid_user(request, pk, cid, passcode):
"total_score": total_score,
"max_score": max_score,
"answers_and_marks": answers_and_marks,
"view_all_results": view_all_results,
},
)
@@ -0,0 +1,7 @@
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
{% if view_all_results %}
<div class="alert alert-info" role="alert">
Exam state: Active [{{exam.active}}] / Published [{{exam.publish_results}}]
</div>
{% endif %}
+2 -2
View File
@@ -362,7 +362,7 @@ class ExamViews(View, LoginRequiredMixin):
True if request.POST.get("publish_results") == "true" else False
)
exam.save()
data = {"status": "success", "publish_results": exam.publish_results}
data = {"status": "success", "publish_results": exam.publish_results, "name": exam.name, "id": exam.id}
return JsonResponse(data, status=200)
else:
data = {"status": "error"}
@@ -376,7 +376,7 @@ class ExamViews(View, LoginRequiredMixin):
exam.active = True if request.POST.get("active") == "true" else False
exam.save()
data = {"status": "success", "active": exam.active}
data = {"status": "success", "active": exam.active, "name": exam.name, "id": exam.id}
return JsonResponse(data, status=200)
else:
data = {"status": "error"}
+2 -1
View File
@@ -1121,8 +1121,9 @@ def exam_scores_cid_user(request, pk, cid, passcode):
"total_score": total_score,
"normalised_score": normalised_score,
"max_score": max_score,
"answer_text": answer_text
"answer_text": answer_text,
# "answers_and_marks": answers_and_marks,
"view_all_results": view_all_results,
},
)
+4 -1
View File
@@ -8,7 +8,10 @@
{% for exam in exams %}
{% if exam.active %}
<li>
<a href="{% url 'physics:exam_overview' pk=exam.pk %}" class="flex-col">{{exam.name}}</a> <a href="{% url 'physics:exam_scores_cid' pk=exam.pk %}" class="flex-col">Scores</a> <span class="flex-col icon-container"><span class="published-icon {% if exam.publish_results %}published{% endif %}">Results Published</span></span>
<a href="{% url 'physics:exam_overview' pk=exam.pk %}" class="flex-col">{{exam.name}}</a> <a href="{% url 'physics:exam_scores_cid' pk=exam.pk %}" class="flex-col">Scores</a> <span class="flex-col icon-container"><span class="published-icon {% if exam.publish_results %}published{% endif %}">Results Published</span>
Publish results: <input type="checkbox" class="exam-publish-results-switch" data-posturl="{% url 'physics:exam_toggle_results_published' pk=exam.pk %}"
{% if exam.publish_results %}checked{% endif %}>
</span>
</li>
{% endif %}
{% endfor %}
+58 -104
View File
@@ -2,113 +2,67 @@
{% block content %}
{% load thumbnail %}
<div class="physics">
{% if can_edit %}
<a href="{% url 'physics:exam_update' exam.id %}" title="Edit the Exam">Edit</a>
<a href="{% url 'physics:exam_delete' exam.id %}" title="Delete the Exam">Delete</a>
<a href="{% url 'physics:exam_clone' exam.id %}" title="Clone the Exam">Clone</a>
{% endif %}
{% if request.user.is_superuser %}
<a href="{% url 'admin:physics_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin Edit</a>
{% endif %}
<h1>Exam: {{ exam.name }}</h1>
{% load thumbnail %}
<div class="physics">
{% if can_edit %}
<a href="{% url 'physics:exam_update' exam.id %}" title="Edit the Exam">Edit</a>
<a href="{% url 'physics:exam_delete' exam.id %}" title="Delete the Exam">Delete</a>
<a href="{% url 'physics:exam_clone' exam.id %}" title="Clone the Exam">Clone</a>
{% endif %}
{% if request.user.is_superuser %}
<a href="{% url 'admin:physics_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin
Edit</a>
{% endif %}
<h1>Exam: {{ exam.name }}</h1>
{% include 'exam_notes.html' %}
{% include 'exam_notes.html' %}
<p>This exam has {{question_number}} questions.</p>
Open access: {{ exam.open_access }}<br />
<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>
</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>
</div>
This exam will be available to take <a href="{% url 'physics:exam_start' pk=exam.pk %}">here</a> (when active).
{% autoescape off %}
<ol id="full-question-list-physics">
{% for question in questions.all %}
<li>
{{ question.stem }}
<ol type="a" class="abcde">
<li>
{{ question.a }}: {{ question.a_answer }}
</li>
<li>
{{ question.b }}: {{ question.b_answer }}
</li>
<li>
{{ question.c }}: {{ question.c_answer }}
</li>
<li>
{{ question.d }}: {{ question.d_answer }}
</li>
<li>
{{ question.e }}: {{ question.e_answer }}
</li>
</ol>
Category: {{ question.category }}, <a href="{% url 'physics:question_detail' pk=question.pk %}">View</a> <a href="{% url 'admin:physics_question_change' question.id %}">Edit</a>
</li>
{% endfor %}
</ol>
{% endautoescape %}
<p>This exam has {{question_number}} questions.</p>
Open access: {{ exam.open_access }}<br />
<div class="parent-help" title="Click to enable / disable the exam">
Exam active: <input type="checkbox" id="exam-active-switch" data-posturl="{% url 'physics:exam_toggle_active' pk=exam.pk %}"
{% if exam.active %}checked{% endif %}> <span
class="help-text">[When checked the exam will be available to take in the test system]</span>
</div>
<script type="text/javascript">
$(document).ready(function () {
// send request to change the is_private state on customSwitches toggle
$("#exam-active-switch").on("change", function () {
$.ajax({
url: "{% url 'physics: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);
<div class="parent-help" title="Click to enable / disable the exam results">
Publish results: <input type="checkbox" id="exam-publish-results-switch" data-posturl="{% url 'physics:exam_toggle_results_published' pk=exam.pk %}"
{% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will
be available on this site]</span>
</div>
This exam will be available to take <a href="{% url 'physics:exam_start' pk=exam.pk %}">here</a> (when active).
if (data.status == "success") {
toastr.info('Exam state changed.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
})
$("#exam-publish-results-switch").on("change", function () {
$.ajax({
url: "{% url 'physics: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);
{% autoescape off %}
<ol id="full-question-list-physics">
{% for question in questions.all %}
if (data.status == "success") {
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
})
.always(function () {
console.log('[Done]');
})
})
});
</script>
{% endblock %}
<li>
{{ question.stem }}
<ol type="a" class="abcde">
<li>
{{ question.a }}: {{ question.a_answer }}
</li>
<li>
{{ question.b }}: {{ question.b_answer }}
</li>
<li>
{{ question.c }}: {{ question.c_answer }}
</li>
<li>
{{ question.d }}: {{ question.d_answer }}
</li>
<li>
{{ question.e }}: {{ question.e_answer }}
</li>
</ol>
Category: {{ question.category }}, <a href="{% url 'physics:question_detail' pk=question.pk %}">View</a> <a
href="{% url 'admin:physics_question_change' question.id %}">Edit</a>
</li>
{% endfor %}
</ol>
{% endautoescape %}
</div>
{% include 'exam_overview_js.html' %}
{% endblock %}
@@ -2,8 +2,8 @@
{% block content %}
<div class="physics">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
{% include 'generic/user_scores_header.html' %}
Answers:
<ul>
{% for question, ans in answers_and_marks %}
+1
View File
@@ -146,6 +146,7 @@ def exam_scores_cid_user(request, pk, cid, passcode):
"total_score": total_score,
"max_score": max_score,
"answers_and_marks": answers_and_marks,
"view_all_results": view_all_results,
},
)
+1
View File
@@ -1038,6 +1038,7 @@ def exam_scores_cid_user(request, pk, cid, passcode):
"normalised_score": normalised_score,
"max_score": max_score,
"answers_and_marks": answers_and_marks,
"view_all_results": view_all_results,
},
)
+1
View File
@@ -138,6 +138,7 @@ def exam_scores_cid_user(request, pk, cid, passcode):
"total_score": total_score,
"max_score": max_score,
"answers_and_marks": answers_and_marks,
"view_all_results": view_all_results,
},
)
-18
View File
@@ -587,24 +587,6 @@ table.longs .user-answer-score- {
background-color: red;
}
.published-icon {
border: 1px dotted gray;
opacity: 20%;
border-radius: 4px;
display: none;
}
.published-icon:hover {
opacity: 100%;
}
.published-icon.published {
border: 1px solid purple;
color: purple;
opacity: 100%;
display: inline-block;
}
textarea,
input {
border-radius: 2px;
+51 -6
View File
@@ -7,12 +7,15 @@
<ul class="exam-list">
{% for exam in exams %}
{% if exam.active %}
<li>
<a href="{% url app_name|add:':exam_overview' pk=exam.pk %}" class="flex-col">{{exam.name}}</a>
<li class="exam-item">
<a href="{% url app_name|add:':exam_overview' pk=exam.pk %}" class="flex-col-2">{{exam.name}}</a>
{% if marking %}<a href="{% url app_name|add:':mark_overview' pk=exam.pk %}" class="flex-col">Mark</a>{% endif %}
<a href="{% url app_name|add:':exam_cids' exam_id=exam.pk %}" class="flex-col">Candidates</a>
<a href="{% url app_name|add:':exam_scores_cid' pk=exam.pk %}" class="flex-col">Scores</a>
<span class="flex-col icon-container"><span class="published-icon {% if exam.publish_results %}published{% endif %}">Results Published</span></span>
<input type="checkbox" id="active-{{exam.pk}}" class="exam-active-switch" data-posturl="{% url app_name|add:':exam_toggle_active' pk=exam.pk %}" {% if exam.active %}checked{% endif %}>
<label for="active-{{exam.pk}}" class="flex-col icon-container active-icon" title="Click to toggle active state">Exam Active</label>
<input type="checkbox" id="published-{{exam.pk}}" class="exam-publish-results-switch" data-posturl="{% url app_name|add:':exam_toggle_results_published' pk=exam.pk %}" {% if exam.publish_results %}checked{% endif %}>
<label for="published-{{exam.pk}}" class="flex-col icon-container published-icon" title="Click to toggle published state">Results Published</label>
</li>
{% endif %}
{% endfor %}
@@ -22,12 +25,15 @@
<ul class="exam-list">
{% for exam in exams %}
{% if not exam.active %}
<li>
<a href="{% url app_name|add:':exam_overview' pk=exam.pk %}" class="flex-col">{{exam.name}}</a>
<li class="exam-item">
<a href="{% url app_name|add:':exam_overview' pk=exam.pk %}" class="flex-col-2">{{exam.name}}</a>
{% if marking %}<a href="{% url app_name|add:':mark_overview' pk=exam.pk %}" class="flex-col">Mark</a>{% endif %}
<a href="{% url app_name|add:':exam_cids' exam_id=exam.pk %}" class="flex-col">Candidates</a>
<a href="{% url app_name|add:':exam_scores_cid' pk=exam.pk %}" class="flex-col">Scores</a>
<span class="flex-col icon-container"><span class="published-icon {% if exam.publish_results %}published{% endif %}">Results Published</span></span>
<input type="checkbox" id="active-{{exam.pk}}" class="exam-active-switch" data-posturl="{% url app_name|add:':exam_toggle_active' pk=exam.pk %}" {% if exam.active %}checked{% endif %}>
<label for="active-{{exam.pk}}" class="flex-col icon-container active-icon" title="Click to toggle active state">Exam Active</label>
<input type="checkbox" id="{{exam.pk}}-pub" class="exam-publish-results-switch" data-posturl="{% url app_name|add:':exam_toggle_results_published' pk=exam.pk %}" {% if exam.publish_results %}checked{% endif %}>
<label for="{{exam.pk}}-pub" class="flex-col icon-container published-icon">Results Published</label>
</li>
{% endif %}
{% endfor %}
@@ -40,4 +46,43 @@
<a href="{% url app_name|add:':exam_list_all' %}">View all</a>
{% endif %}
</div>
{% include 'exam_overview_js.html' %}
<style>
.published-icon, .active-icon {
border: 1px dotted gray;
opacity: 20%;
border-radius: 4px;
display: inline-block;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
text-align: center;
}
.published-icon:hover, .active-icon:hover {
opacity: 100%;
}
.exam-active-switch:checked + .active-icon {
border: 1px solid green;
color: green;
opacity: 100%;
display: inline-block;
}
.exam-publish-results-switch:checked + .published-icon {
border: 1px solid purple;
color: purple;
opacity: 100%;
display: inline-block;
}
.exam-publish-results-switch, .exam-active-switch {
display: none;
}
</style>
{% endblock %}
+6 -4
View File
@@ -1,7 +1,7 @@
<script type="text/javascript">
$(document).ready(function () {
// send request to change the is_private state on customSwitches toggle
$("#exam-active-switch").on("change", function (evt) {
$("#exam-active-switch, .exam-active-switch").on("change", function (evt) {
$.ajax({
url: evt.currentTarget.dataset.posturl,
data: {
@@ -16,7 +16,8 @@
console.log(data);
if (data.status == "success") {
toastr.info('Exam state changed.')
toastr.info(`Exam: ${data.name} [${data.id}]
Active state changed to: ${data.publish_results}.`)
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
@@ -25,7 +26,7 @@
console.log('[Done]');
})
})
$("#exam-publish-results-switch").on("change", function (evt) {
$("#exam-publish-results-switch, .exam-publish-results-switch").on("change", function (evt) {
$.ajax({
url: evt.currentTarget.dataset.posturl,
data: {
@@ -40,7 +41,8 @@
console.log(data);
if (data.status == "success") {
toastr.info('Publish results state changed.')
toastr.info(`Exam: ${data.name} [${data.id}]
Published state changed to: ${data.publish_results}.`)
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed