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