allow logged in users to assign user groups
This commit is contained in:
+4
-3
@@ -63,12 +63,13 @@ class ExamFormMixin:
|
||||
def __init__(self, *args, user, **kwargs) -> None:
|
||||
super(ModelForm, self).__init__(*args, **kwargs)
|
||||
|
||||
if user.is_superuser or user.groups.filter(name="cid_manager").exists():
|
||||
if user.is_superuser or user.groups.filter(name="cid_user_manager").exists():
|
||||
cid_user_group_queryset = CidUserGroup.objects.all()
|
||||
user_user_group_queryset = UserUserGroup.objects.all()
|
||||
else:
|
||||
cid_user_group_queryset = CidUserGroup.objects.none()
|
||||
user_user_group_queryset = UserUserGroup.objects.none()
|
||||
|
||||
user_user_group_queryset = UserUserGroup.objects.all()
|
||||
|
||||
self.fields["cid_user_groups"] = ModelMultipleChoiceField(
|
||||
required=False,
|
||||
queryset=cid_user_group_queryset,
|
||||
|
||||
@@ -7,21 +7,26 @@
|
||||
User answer scores are cached, if you update or change an answer you will need to <a href="{% url exam.app_name|add:':exam_scores_refresh' exam.pk %}">refresh the scores</a>.
|
||||
{% endif %}
|
||||
|
||||
{% if missing_cids %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
The following CIDs results have not been submitted:
|
||||
{% for cid in missing_cids %}
|
||||
{{cid}},
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if missing_users %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
The following users results have not been submitted:
|
||||
{% for user in missing_users %}
|
||||
{{user}} ({{user.id}}),
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if missing_cids or missing_users %}
|
||||
<details>
|
||||
<summary>This exam has candidates / users with unsubmitted results</summary>
|
||||
{% if missing_cids %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
The following CIDs results have not been submitted:
|
||||
{% for cid in missing_cids %}
|
||||
{{cid}},
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if missing_users %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
The following users results have not been submitted:
|
||||
{% for user in missing_users %}
|
||||
{{user}} ({{user.id}}),
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</details>
|
||||
{% endif %}
|
||||
{% if unmarked %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
@@ -71,15 +76,15 @@
|
||||
{% for cid in cids %}
|
||||
{% comment %} <th><a href="{% url exam.app_name|add:':exam_scores_cid_user' exam.pk cid %}">{{cid}}</a></th> {% endcomment %}
|
||||
<th>
|
||||
|
||||
|
||||
{% if cid|slice:":1" == "u" %}
|
||||
<a href="{% url exam.app_name|add:':exam_scores_user_admin' exam.pk cid|slice:'2:' %}">
|
||||
{% else %}
|
||||
<a href="{% url exam.app_name|add:':exam_scores_user_admin' exam.pk cid|slice:'2:' %}">
|
||||
{% else %}
|
||||
|
||||
<a href="{% url exam.app_name|add:':exam_scores_cid_user_admin' exam.pk cid|slice:'2:' %}">
|
||||
<a href="{% url exam.app_name|add:':exam_scores_cid_user_admin' exam.pk cid|slice:'2:' %}">
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{{cids_user_id_map|get_item:cid}}</a></th>
|
||||
{% endfor %}
|
||||
|
||||
@@ -117,21 +122,21 @@
|
||||
<summary>Email results</summary>
|
||||
User results emailed: {{exam.exam_results_emailed|default:"Never"}}<br/>
|
||||
<button id="email-results-button"
|
||||
title="Email results to users and their supervisor"
|
||||
hx-get="{% url exam.app_name|add:':exam_report_email' exam_id=exam.pk %}"
|
||||
hx-target="#user-details"
|
||||
hx-confirm="This will email results, please make sure scores have been refreshed before continuing"
|
||||
hx-prompt="Please enter an additional email to send to (user and supervisor will automatically be used if available) if required"
|
||||
title="Email results to users and their supervisor"
|
||||
hx-get="{% url exam.app_name|add:':exam_report_email' exam_id=exam.pk %}"
|
||||
hx-target="#user-details"
|
||||
hx-confirm="This will email results, please make sure scores have been refreshed before continuing"
|
||||
hx-prompt="Please enter an additional email to send to (user and supervisor will automatically be used if available) if required"
|
||||
>Email user results</button>
|
||||
<button id="email-unsent-results-button" title="Email results to users and their supervisor"
|
||||
hx-get="{% url exam.app_name|add:':exam_report_email_unsent' exam_id=exam.pk %}"
|
||||
hx-target="#user-details"
|
||||
hx-confirm="This will email results, please make sure scores have been refreshed before continuing"
|
||||
hx-prompt="Please enter an additional email to send to (user and supervisor will automatically be used if available) if required"
|
||||
hx-get="{% url exam.app_name|add:':exam_report_email_unsent' exam_id=exam.pk %}"
|
||||
hx-target="#user-details"
|
||||
hx-confirm="This will email results, please make sure scores have been refreshed before continuing"
|
||||
hx-prompt="Please enter an additional email to send to (user and supervisor will automatically be used if available) if required"
|
||||
>Email unsent user results</button>
|
||||
<button id="email-results-check-button" title="Check the status of emailed results"
|
||||
hx-get="{% url exam.app_name|add:':exam_report_email_status' exam_id=exam.pk %}"
|
||||
hx-target="#user-details">Check email status</button>
|
||||
hx-get="{% url exam.app_name|add:':exam_report_email_status' exam_id=exam.pk %}"
|
||||
hx-target="#user-details">Check email status</button>
|
||||
<p>Note: currently only works with registered users</p>
|
||||
<div id="user-details"></div>
|
||||
</details>
|
||||
@@ -145,16 +150,16 @@
|
||||
$(document).ready(() => {
|
||||
let question_number = document.getElementById("question-number").innerHTML;
|
||||
console.log(question_number)
|
||||
$(".candidate-row").each((index, el) => {
|
||||
console.log(index, el)
|
||||
if (el.dataset.answerCount != question_number) {
|
||||
$(el).addClass("missing-answers")
|
||||
}
|
||||
$(".candidate-row").each((index, el) => {
|
||||
console.log(index, el)
|
||||
if (el.dataset.answerCount != question_number) {
|
||||
$(el).addClass("missing-answers")
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.missing-answers td:first-child:before {
|
||||
|
||||
Reference in New Issue
Block a user