.
This commit is contained in:
+2
-2
@@ -362,7 +362,7 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
True if request.POST.get("publish_results") == "true" else False
|
True if request.POST.get("publish_results") == "true" else False
|
||||||
)
|
)
|
||||||
exam.save()
|
exam.save()
|
||||||
data = {"status": "success", "publish_results": exam.publish_results, "name": exam.name}
|
data = {"status": "success", "publish_results": exam.publish_results, "name": exam.name, "id": exam.id}
|
||||||
return JsonResponse(data, status=200)
|
return JsonResponse(data, status=200)
|
||||||
else:
|
else:
|
||||||
data = {"status": "error"}
|
data = {"status": "error"}
|
||||||
@@ -376,7 +376,7 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
|
|
||||||
exam.active = True if request.POST.get("active") == "true" else False
|
exam.active = True if request.POST.get("active") == "true" else False
|
||||||
exam.save()
|
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)
|
return JsonResponse(data, status=200)
|
||||||
else:
|
else:
|
||||||
data = {"status": "error"}
|
data = {"status": "error"}
|
||||||
|
|||||||
@@ -12,9 +12,12 @@
|
|||||||
{% if marking %}<a href="{% url app_name|add:':mark_overview' pk=exam.pk %}" class="flex-col">Mark</a>{% endif %}
|
{% 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_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>
|
<a href="{% url app_name|add:':exam_scores_cid' pk=exam.pk %}" class="flex-col">Scores</a>
|
||||||
<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 %}"
|
<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 %}>
|
{% if exam.publish_results %}checked{% endif %}>
|
||||||
<label for="{{exam.pk}}-pub" class="flex-col icon-container published-icon">Results Published</label>
|
<label for="published-{{exam.pk}}" class="flex-col icon-container published-icon" title="Click to toggle published state">Results Published</label>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -48,7 +51,7 @@
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.published-icon {
|
.published-icon, .active-icon {
|
||||||
border: 1px dotted gray;
|
border: 1px dotted gray;
|
||||||
opacity: 20%;
|
opacity: 20%;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@@ -58,10 +61,17 @@
|
|||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.published-icon:hover {
|
.published-icon:hover, .active-icon:hover {
|
||||||
opacity: 100%;
|
opacity: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.exam-publish-results-switch:checked + .published-icon {
|
||||||
|
border: 1px solid green;
|
||||||
|
color: purple;
|
||||||
|
opacity: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.exam-publish-results-switch:checked + .published-icon {
|
.exam-publish-results-switch:checked + .published-icon {
|
||||||
border: 1px solid purple;
|
border: 1px solid purple;
|
||||||
color: purple;
|
color: purple;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// 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 (evt) {
|
$("#exam-active-switch, .exam-active-switch").on("change", function (evt) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: evt.currentTarget.dataset.posturl,
|
url: evt.currentTarget.dataset.posturl,
|
||||||
data: {
|
data: {
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.status == "success") {
|
if (data.status == "success") {
|
||||||
toastr.info(`Exam: ${data.name}
|
toastr.info(`Exam: ${data.name} [${data.id}]
|
||||||
Published state changed to: ${data.publish_results}.`)
|
Published state changed to: ${data.publish_results}.`)
|
||||||
}
|
}
|
||||||
// show some message according to the response.
|
// show some message according to the response.
|
||||||
|
|||||||
Reference in New Issue
Block a user