Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds shortcut button to add exam evaluation #2050

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
Frederic Sadrieh committed Jun 3, 2024
commit f28e98c06785c0fb3c507eb77229456407a0c34b
14 changes: 6 additions & 8 deletions evap/staff/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
from django.forms import BaseForm, formset_factory
from django.forms.models import inlineformset_factory, modelformset_factory
from django.http import Http404, HttpRequest, HttpResponse, HttpResponseBadRequest, HttpResponseRedirect
from django.shortcuts import _get_queryset, get_object_or_404, redirect, render
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse, reverse_lazy
from django.utils.datastructures import MultiValueDictKeyError
from django.utils.html import format_html
from django.utils.translation import get_language
from django.utils.translation import gettext as _
Expand Down Expand Up @@ -1056,17 +1055,16 @@
@manager_required
@transaction.atomic
FSadrieh marked this conversation as resolved.
Show resolved Hide resolved
def create_exam_evaluation(request):
query_set = _get_queryset(Evaluation)
try:
evaluation = query_set.get(pk=request.POST["evaluation_id"])
except MultiValueDictKeyError:
return HttpResponseBadRequest()
evaluation = get_object_from_dict_pk_entry_or_logged_40x(Evaluation, request.POST, "evaluation_id")
if evaluation.is_single_result:
raise SuspiciousOperation("Creating an exam evaluation for a single result evaluation is not allowed")

if evaluation.has_exam:
raise SuspiciousOperation("An exam evaluation already exists for this course")
exam_datetime = request.POST.get("exam_date")
try:
exam_datetime = request.POST.get("exam_date")
except ValueError:
return HttpResponseBadRequest("Exam date missing or invalid.")

Check warning on line 1067 in evap/staff/views.py

View check run for this annotation

Codecov / codecov/patch

evap/staff/views.py#L1066-L1067

Added lines #L1066 - L1067 were not covered by tests

exam_datetime = datetime.combine(datetime.strptime(exam_datetime, "%Y-%m-%d"), datetime.min.time())

Expand Down