.
This commit is contained in:
+49
-33
@@ -88,41 +88,56 @@ def cid_scores(request, pk, passcode):
|
|||||||
print(cid_user.passcode)
|
print(cid_user.passcode)
|
||||||
|
|
||||||
# questions = exam.exam_questions.all()
|
# questions = exam.exam_questions.all()
|
||||||
physics_answers = PhysicsCidUserAnswer.objects.filter(cid=cid)
|
EXAM_ANSWER_MAP = {
|
||||||
anatomy_answers = AnatomyCidUserAnswer.objects.filter(cid=cid)
|
"physics" : (PhysicsCidUserAnswer, PhysicsExam),
|
||||||
rapids_answers = RapidsCidUserAnswer.objects.filter(cid=cid)
|
"anatomy" : (AnatomyCidUserAnswer, AnatomyExam),
|
||||||
longs_answers = LongsCidUserAnswer.objects.filter(cid=cid)
|
"rapids" : (RapidsCidUserAnswer, RapidsExam),
|
||||||
sbas_answers = SbasCidUserAnswer.objects.filter(cid=cid)
|
"longs" : (LongsCidUserAnswer, LongsExam),
|
||||||
|
"sbas" : (SbasCidUserAnswer, SbasExam),
|
||||||
# if (
|
}
|
||||||
# not physics_answers
|
|
||||||
# and not anatomy_answers
|
|
||||||
# and not rapids_answers
|
|
||||||
# and not longs_answers
|
|
||||||
# and not sbas_answers
|
|
||||||
# ):
|
|
||||||
# raise Http404("cid not found")
|
|
||||||
|
|
||||||
#kwargs = {"publish_results": True}
|
|
||||||
kwargs = {"exam_mode": True}
|
kwargs = {"exam_mode": True}
|
||||||
|
|
||||||
#if request.user.groups.filter(name="view_all_results").exists():
|
exams = []
|
||||||
# kwargs = {}
|
for exam_type in EXAM_ANSWER_MAP:
|
||||||
|
exam_answers = EXAM_ANSWER_MAP[exam_type].objects.filter(cid=cid)
|
||||||
|
exam_ids = exam_answers.values_list("exam").distinct()
|
||||||
|
exams.append((exam_type, PhysicsExam.objects.filter(id__in=exam_ids, **kwargs)))
|
||||||
|
|
||||||
physics_exam_ids = physics_answers.values_list("exam").distinct()
|
|
||||||
physics_exams = PhysicsExam.objects.filter(id__in=physics_exam_ids, **kwargs)
|
|
||||||
|
|
||||||
anatomy_exam_ids = anatomy_answers.values_list("exam").distinct()
|
#physics_answers = PhysicsCidUserAnswer.objects.filter(cid=cid)
|
||||||
anatomy_exams = AnatomyExam.objects.filter(id__in=anatomy_exam_ids, **kwargs)
|
#anatomy_answers = AnatomyCidUserAnswer.objects.filter(cid=cid)
|
||||||
|
#rapids_answers = RapidsCidUserAnswer.objects.filter(cid=cid)
|
||||||
|
#longs_answers = LongsCidUserAnswer.objects.filter(cid=cid)
|
||||||
|
#sbas_answers = SbasCidUserAnswer.objects.filter(cid=cid)
|
||||||
|
|
||||||
rapids_exam_ids = rapids_answers.values_list("exam").distinct()
|
## if (
|
||||||
rapid_exams = RapidsExam.objects.filter(id__in=rapids_exam_ids, **kwargs)
|
## not physics_answers
|
||||||
|
## and not anatomy_answers
|
||||||
|
## and not rapids_answers
|
||||||
|
## and not longs_answers
|
||||||
|
## and not sbas_answers
|
||||||
|
## ):
|
||||||
|
## raise Http404("cid not found")
|
||||||
|
|
||||||
longs_exam_ids = longs_answers.values_list("exam").distinct()
|
##kwargs = {"publish_results": True}
|
||||||
longs_exams = LongsExam.objects.filter(id__in=longs_exam_ids, **kwargs)
|
|
||||||
|
|
||||||
sbas_exam_ids = sbas_answers.values_list("exam").distinct()
|
##if request.user.groups.filter(name="view_all_results").exists():
|
||||||
sba_exams = SbasExam.objects.filter(id__in=sbas_exam_ids, **kwargs)
|
## kwargs = {}
|
||||||
|
|
||||||
|
#physics_exam_ids = physics_answers.values_list("exam").distinct()
|
||||||
|
#physics_exams = PhysicsExam.objects.filter(id__in=physics_exam_ids, **kwargs)
|
||||||
|
|
||||||
|
#anatomy_exam_ids = anatomy_answers.values_list("exam").distinct()
|
||||||
|
#anatomy_exams = AnatomyExam.objects.filter(id__in=anatomy_exam_ids, **kwargs)
|
||||||
|
|
||||||
|
#rapids_exam_ids = rapids_answers.values_list("exam").distinct()
|
||||||
|
#rapid_exams = RapidsExam.objects.filter(id__in=rapids_exam_ids, **kwargs)
|
||||||
|
|
||||||
|
#longs_exam_ids = longs_answers.values_list("exam").distinct()
|
||||||
|
#longs_exams = LongsExam.objects.filter(id__in=longs_exam_ids, **kwargs)
|
||||||
|
|
||||||
|
#sbas_exam_ids = sbas_answers.values_list("exam").distinct()
|
||||||
|
#sba_exams = SbasExam.objects.filter(id__in=sbas_exam_ids, **kwargs)
|
||||||
|
|
||||||
available_exams = cid_user.get_cid_exams()
|
available_exams = cid_user.get_cid_exams()
|
||||||
|
|
||||||
@@ -130,11 +145,12 @@ def cid_scores(request, pk, passcode):
|
|||||||
request,
|
request,
|
||||||
"cid_scores.html",
|
"cid_scores.html",
|
||||||
{
|
{
|
||||||
"physics_exams": physics_exams,
|
#"physics_exams": physics_exams,
|
||||||
"anatomy_exams": anatomy_exams,
|
#"anatomy_exams": anatomy_exams,
|
||||||
"rapid_exams": rapid_exams,
|
#"rapid_exams": rapid_exams,
|
||||||
"longs_exams": longs_exams,
|
#"longs_exams": longs_exams,
|
||||||
"sba_exams": sba_exams,
|
#"sba_exams": sba_exams,
|
||||||
|
"all_exams": exams,
|
||||||
"cid": cid,
|
"cid": cid,
|
||||||
"passcode": passcode,
|
"passcode": passcode,
|
||||||
"cid_user": cid_user,
|
"cid_user": cid_user,
|
||||||
|
|||||||
+23
-13
@@ -5,18 +5,28 @@
|
|||||||
<h2>CID: {{ cid }}</h2>
|
<h2>CID: {{ cid }}</h2>
|
||||||
<h3>Assigned exams</h3>
|
<h3>Assigned exams</h3>
|
||||||
<p>The following exams will be available to take when active.
|
<p>The following exams will be available to take when active.
|
||||||
{% for t, exams in available_exams %}
|
{% for t, exams in available_exams %}
|
||||||
<h4>{{t}}</h4>
|
<h4>{{t}}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
{% for e in exams %}
|
{% for e in exams %}
|
||||||
<li><a href="{{e.get_take_url}}?cid={{cid}}&passcode={{passcode}}" target="_blank">{{e.name}} {% if e.active %}[Active]{% endif %}</a></li>
|
<li><a href="{{e.get_take_url}}?cid={{cid}}&passcode={{passcode}}" target="_blank">{{e.name}} {% if e.active %}[Active]{% endif %}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<h3>Exam results</h3>
|
<h3>Exam results</h3>
|
||||||
The following exam results been found. Click to view answers (and scores when the results are published):
|
The following exam results been found. Click to view answers (and scores when the results are published):
|
||||||
{% if physics_exams %}
|
{% for exam_type, exams in all_exams %}
|
||||||
|
{% if exams %}
|
||||||
|
<h4>{{exam_type}}</h4>
|
||||||
|
<ul>
|
||||||
|
{% for exam in exams %}
|
||||||
|
<li><a href="{% url '{{exam_type}}:exam_scores_cid_user' pk=exam.pk sk=cid passcode=passcode %}">{{exam.name}}</a> {% if exam.active %}[Active]{% endif %} {% if exam.publish_results %}[Results Published]{% endif %}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% comment %} {% if physics_exams %}
|
||||||
<h4>Physics</h4>
|
<h4>Physics</h4>
|
||||||
<ul>
|
<ul>
|
||||||
{% for exam in physics_exams %}
|
{% for exam in physics_exams %}
|
||||||
@@ -55,6 +65,6 @@
|
|||||||
<li><a href="{% url 'sbas:exam_scores_cid_user' pk=exam.pk sk=cid passcode=passcode %}">{{exam.name}}</a> {% if exam.active %}[Active]{% endif %} {% if exam.publish_results %}[Results Published]{% endif %}</li>
|
<li><a href="{% url 'sbas:exam_scores_cid_user' pk=exam.pk sk=cid passcode=passcode %}">{{exam.name}}</a> {% if exam.active %}[Active]{% endif %} {% if exam.publish_results %}[Results Published]{% endif %}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %} {% endcomment %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user