reoorganise atlas modules

This commit is contained in:
Ross
2023-07-24 09:19:08 +01:00
parent 9a5088c03a
commit e6469e70f0
10 changed files with 275 additions and 114 deletions
@@ -7,6 +7,12 @@
: {{case.title}}
{% endif %}
{% if collection.publish_results or cid_user_exam.completed %}
review
{% endif %}
</h2>
{% if show_description and case.description %}
@@ -72,7 +78,7 @@
<form method="POST" class="post-form">{% csrf_token %}
{% if collection.collection_type == "REP" %}
<div class="form-contents">
<fieldset {% if collection.publish_results %}disabled="disabled"{% endif %}>
<fieldset {% if collection.publish_results or cid_user_exam.completed %}disabled="disabled"{% endif %}>
{{form}}
</fieldset>
</div>
@@ -6,6 +6,7 @@
Publish results: {{collection.publish_results}}<br />
Active: {{collection.active}}<br />
Collection Type: {{collection.collection_type}}<br />
Self review: {{collection.self_review}}<br />
</div>
<h3>Cases</h3>
<ul>
@@ -1,53 +0,0 @@
{% extends 'atlas/base.html' %}
{% block content %}
<h2>{{collection.name}}
<h2>Start: {{exam.name}}</h2>
{% if request.user.is_authenticated and valid_user %}
<a href="{% url 'atlas:collection_case_view_take_user' pk=collection.pk case_number=0 %}">Start</a>
{% else %}
Enter your CID and passcode in the below boxes.<br />
<p><input id="cid-box" type="text" value="Candidate ID"></p>
<p><input id="passcode-box" type="text" value="Passcode"></p>
<button>Start</button>
<script type="text/javascript">
$(document).ready(function () {
window.location.search.substr(1).split("&").forEach((item) =>
{
s = item.split("=");
if (s[0] == "cid") {
$("#cid-box").val(s[1]);
}
if (s[0] == "passcode") {
$("#passcode-box").val(s[1]);
}
});
$("#cid-box, #passcode-box").keypress(function(e) {
// Enter pressed?
console.log(e)
if(e.which == 10 || e.which == 13) {
$("button").click();
}
});
$("button").click(() => {
let cid = $("#cid-box").val();
let passcode = $("#passcode-box").val();
if (Number.isInteger(parseInt(cid))) {
window.location.replace("{% url 'atlas:collection_case_view_take' pk=collection.pk case_number=0 cid='0000000' passcode='ZZZZZZ' %}".replace("0000000", cid).replace("ZZZZZZ", passcode));
} else {
alert("Please enter a valid Candidate ID (CID).")
}
});
});
</script>
{% endif %}
{% endblock %}
@@ -5,7 +5,12 @@
CID: {{cid}}
{% endif %}
<h2>Collection: {{collection.name}}</h2>
<h2>Collection: {{collection.name}}
{% if collection.publish_results or cid_user_exam.completed %}
review
{% endif %}
</h2>
<div><p>Questions</p></div>
{{answer_count}} out of {{collection_length}} cases answered. Click to go to case.
@@ -31,7 +36,25 @@
Start time: {{cid_user_exam.start_time}}
<p>Completed: {{cid_user_exam.completed}}</p>
{% if collection.self_review %}
<p>Completed: <span id="completed-state">{{cid_user_exam.completed}}</span></p>
{% if not cid_user_exam.completed %}
<form hx-post=""
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete
hx-confirm="Finish session?"
hx-target="#completed-state"
_="on htmx:afterOnLoad remove me"
>
<button type="submit" name="finish" value="finish">Finish</button>
</form>
{% endif %}
{% endif %}
{% endblock %}
@@ -0,0 +1,61 @@
{% extends 'atlas/base.html' %}
{% block content %}
<h2>Start: {{collection.name}}</h2>
{% if request.user.is_authenticated and valid_user %}
User: {{request.user}}<br/>
{% if cid_exam %}
Started: {{cid_exam.start_time}} <br/>
{% endif %}
<a href="{% url 'atlas:collection_case_view_take_user' pk=collection.pk case_number=0 %}">
<button>Start</button>
</a>
{% else %}
Enter your CID and passcode in the below boxes.<br />
<p><input id="cid-box" type="text" value="Candidate ID"></p>
<p><input id="passcode-box" type="text" value="Passcode"></p>
<button>Start</button>
<script type="text/javascript">
$(document).ready(function () {
window.location.search.substr(1).split("&").forEach((item) =>
{
s = item.split("=");
if (s[0] == "cid") {
$("#cid-box").val(s[1]);
}
if (s[0] == "passcode") {
$("#passcode-box").val(s[1]);
}
});
$("#cid-box, #passcode-box").keypress(function(e) {
// Enter pressed?
console.log(e)
if(e.which == 10 || e.which == 13) {
$("button").click();
}
});
$("button").click(() => {
let cid = $("#cid-box").val();
let passcode = $("#passcode-box").val();
if (Number.isInteger(parseInt(cid))) {
window.location.replace("{% url 'atlas:collection_case_view_take' pk=collection.pk case_number=0 cid='0000000' passcode='ZZZZZZ' %}".replace("0000000", cid).replace("ZZZZZZ", passcode));
} else {
alert("Please enter a valid Candidate ID (CID).")
}
});
});
</script>
{% endif %}
{% endblock %}