Beispiel #1
0
def edit_grades(request, semester_id, course_id, grade_document_id):
    semester = get_object_or_404(Semester, id=semester_id)
    if semester.grade_documents_are_deleted:
        raise PermissionDenied
    course = get_object_or_404(Course, id=course_id, semester=semester)
    grade_document = get_object_or_404(GradeDocument,
                                       id=grade_document_id,
                                       course=course)

    form = GradeDocumentForm(request.POST or None,
                             request.FILES or None,
                             instance=grade_document)

    if form.is_valid():
        form.save(modifying_user=request.user)
        messages.success(request, _("Successfully updated grades."))
        return redirect('grades:course_view', semester.id, course.id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
            form=form,
            show_automated_publishing_info=False,
        )
        return render(request, "grades_upload_form.html", template_data)
Beispiel #2
0
def edit_grades(request, semester_id, course_id, grade_document_id):
    semester = get_object_or_404(Semester, id=semester_id)
    if semester.grade_documents_are_deleted:
        raise PermissionDenied
    course = get_object_or_404(Course, id=course_id, semester=semester)
    grade_document = get_object_or_404(GradeDocument,
                                       id=grade_document_id,
                                       course=course)

    form = GradeDocumentForm(request.POST or None,
                             request.FILES or None,
                             instance=grade_document)

    final_grades = (grade_document.type == GradeDocument.Type.FINAL_GRADES
                    )  # if parameter is not given, assume midterm grades

    if form.is_valid():
        form.save(modifying_user=request.user)
        messages.success(request, _("Successfully updated grades."))
        return redirect("grades:course_view", semester.id, course.id)

    template_data = dict(
        semester=semester,
        course=course,
        form=form,
        show_automated_publishing_info=False,
        final_grades=final_grades,
    )
    return render(request, "grades_upload_form.html", template_data)
Beispiel #3
0
def upload_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    course = get_object_or_404(Course, id=course_id)

    final_grades = request.GET.get('final', 'false') # default: midterm grades
    final_grades = {'true': True, 'false': False}.get(final_grades.lower()) # convert parameter to boolean

    form = GradeDocumentForm(request.POST or None, request.FILES or None, course=course, final_grades=final_grades, user=request.user)

    if form.is_valid():
        form.save()
        if final_grades and course.state == 'reviewed':
            course.publish()
            course.save()
            send_publish_notifications(grade_document_courses=[course], evaluation_results_courses=[course])
        else:
            send_publish_notifications(grade_document_courses=[course])            

        messages.success(request, _("Successfully uploaded grades."))
        return redirect('grades:course_view', semester.id, course.id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
            form=form,
            final_grades=final_grades,
            show_automated_publishing_info=final_grades,
        )
        return render(request, "grades_upload_form.html", template_data)
Beispiel #4
0
def upload_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    if semester.grade_documents_are_deleted:
        raise PermissionDenied
    course = get_object_or_404(Course, id=course_id, semester=semester)

    final_grades = request.GET.get(
        'final') == 'true'  # if parameter is not given, assume midterm grades

    grade_document = GradeDocument(course=course)
    if final_grades:
        grade_document.type = GradeDocument.Type.FINAL_GRADES
        grade_document.description_en = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_DE
    else:
        grade_document.type = GradeDocument.Type.MIDTERM_GRADES
        grade_document.description_en = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_DE

    form = GradeDocumentForm(request.POST or None,
                             request.FILES or None,
                             instance=grade_document)

    if form.is_valid():
        form.save(modifying_user=request.user)
        evaluations = course.evaluations.all()
        if final_grades and all(evaluation.state == 'reviewed'
                                for evaluation in evaluations):
            for evaluation in evaluations:
                evaluation.publish()
                evaluation.save()

            EmailTemplate.send_participant_publish_notifications(evaluations)
            EmailTemplate.send_contributor_publish_notifications(evaluations)

        messages.success(request, _("Successfully uploaded grades."))
        return redirect('grades:course_view', semester.id, course.id)

    template_data = dict(
        semester=semester,
        course=course,
        form=form,
        final_grades=final_grades,
        show_automated_publishing_info=final_grades,
    )
    return render(request, "grades_upload_form.html", template_data)
Beispiel #5
0
def upload_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    course = get_object_or_404(Course, id=course_id)

    final_grades = request.GET.get('final', 'false')  # default: midterm grades
    final_grades = {
        'true': True,
        'false': False
    }.get(final_grades.lower())  # convert parameter to boolean

    grade_document = GradeDocument(course=course)
    if final_grades:
        grade_document.type = GradeDocument.FINAL_GRADES
        grade_document.description = settings.DEFAULT_FINAL_GRADES_DESCRIPTION
    else:
        grade_document.type = GradeDocument.MIDTERM_GRADES
        grade_document.description = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION

    form = GradeDocumentForm(request.POST or None,
                             request.FILES or None,
                             instance=grade_document)

    if form.is_valid():
        form.save(modifying_user=request.user)
        if final_grades and course.state == 'reviewed':
            course.publish()
            course.save()
            send_publish_notifications(grade_document_courses=[course],
                                       evaluation_results_courses=[course])
        else:
            send_publish_notifications(grade_document_courses=[course])

        messages.success(request, _("Successfully uploaded grades."))
        return redirect('grades:course_view', semester.id, course.id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
            form=form,
            final_grades=final_grades,
            show_automated_publishing_info=final_grades,
        )
        return render(request, "grades_upload_form.html", template_data)
Beispiel #6
0
def edit_grades(request, semester_id, course_id, grade_document_id):
    semester = get_object_or_404(Semester, id=semester_id)
    course = get_object_or_404(Course, id=course_id, semester=semester)
    grade_document = get_object_or_404(GradeDocument, id=grade_document_id, course=course)

    form = GradeDocumentForm(request.POST or None, request.FILES or None, instance=grade_document)

    if form.is_valid():
        form.save(modifying_user=request.user)
        messages.success(request, _("Successfully updated grades."))
        return redirect('grades:course_view', semester.id, course.id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
            form=form,
            show_automated_publishing_info=False,
        )
        return render(request, "grades_upload_form.html", template_data)
Beispiel #7
0
def upload_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    if semester.grade_documents_are_deleted:
        raise PermissionDenied
    course = get_object_or_404(Course, id=course_id, semester=semester)

    final_grades = request.GET.get(
        "final") == "true"  # if parameter is not given, assume midterm grades

    grade_document = GradeDocument(course=course)
    if final_grades:
        grade_document.type = GradeDocument.Type.FINAL_GRADES
        grade_document.description_en = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_DE
    else:
        grade_document.type = GradeDocument.Type.MIDTERM_GRADES
        grade_document.description_en = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_DE

    form = GradeDocumentForm(request.POST or None,
                             request.FILES or None,
                             instance=grade_document)

    if form.is_valid():
        form.save(modifying_user=request.user)

        if final_grades:
            on_grading_process_finished(course)

        messages.success(request, _("Successfully uploaded grades."))
        return redirect("grades:course_view", semester.id, course.id)

    template_data = dict(
        semester=semester,
        course=course,
        form=form,
        final_grades=final_grades,
        show_automated_publishing_info=final_grades,
    )
    return render(request, "grades_upload_form.html", template_data)
Beispiel #8
0
def upload_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    course = get_object_or_404(Course, id=course_id, semester=semester)

    final_grades = request.GET.get(
        'final') == 'true'  # if parameter is not given, assume midterm grades

    grade_document = GradeDocument(course=course)
    if final_grades:
        grade_document.type = GradeDocument.FINAL_GRADES
        grade_document.description_en = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_DE
    else:
        grade_document.type = GradeDocument.MIDTERM_GRADES
        grade_document.description_en = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_DE

    form = GradeDocumentForm(request.POST or None,
                             request.FILES or None,
                             instance=grade_document)

    if form.is_valid():
        form.save(modifying_user=request.user)
        if final_grades and course.state == 'reviewed':
            course.publish()
            course.save()
            send_publish_notifications([course])

        messages.success(request, _("Successfully uploaded grades."))
        return redirect('grades:course_view', semester.id, course.id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
            form=form,
            final_grades=final_grades,
            show_automated_publishing_info=final_grades,
            is_grade_publisher=request.user.is_grade_publisher,
        )
        return render(request, "grades_upload_form.html", template_data)
Beispiel #9
0
def upload_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    if semester.grade_documents_are_deleted:
        raise PermissionDenied
    course = get_object_or_404(Course, id=course_id, semester=semester)

    final_grades = request.GET.get('final') == 'true'  # if parameter is not given, assume midterm grades

    grade_document = GradeDocument(course=course)
    if final_grades:
        grade_document.type = GradeDocument.FINAL_GRADES
        grade_document.description_en = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_DE
    else:
        grade_document.type = GradeDocument.MIDTERM_GRADES
        grade_document.description_en = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_DE

    form = GradeDocumentForm(request.POST or None, request.FILES or None, instance=grade_document)

    if form.is_valid():
        form.save(modifying_user=request.user)
        evaluations = course.evaluations.all()
        if final_grades and all(evaluation.state == 'reviewed' for evaluation in evaluations):
            for evaluation in evaluations:
                evaluation.publish()
                evaluation.save()
            send_publish_notifications(evaluations)

        messages.success(request, _("Successfully uploaded grades."))
        return redirect('grades:course_view', semester.id, course.id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
            form=form,
            final_grades=final_grades,
            show_automated_publishing_info=final_grades,
        )
        return render(request, "grades_upload_form.html", template_data)
Beispiel #10
0
def upload_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    course = get_object_or_404(Course, id=course_id)

    final_grades = request.GET.get('final', 'false') # default: midterm grades
    final_grades = {'true': True, 'false': False}.get(final_grades.lower()) # convert parameter to boolean

    grade_document = GradeDocument(course=course)
    if final_grades:
        grade_document.type = GradeDocument.FINAL_GRADES
        grade_document.description_en = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_FINAL_GRADES_DESCRIPTION_DE
    else:
        grade_document.type = GradeDocument.MIDTERM_GRADES
        grade_document.description_en = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_EN
        grade_document.description_de = settings.DEFAULT_MIDTERM_GRADES_DESCRIPTION_DE

    form = GradeDocumentForm(request.POST or None, request.FILES or None, instance=grade_document)

    if form.is_valid():
        form.save(modifying_user=request.user)
        if final_grades and course.state == 'reviewed':
            course.publish()
            course.save()
            send_publish_notifications([course])

        messages.success(request, _("Successfully uploaded grades."))
        return redirect('grades:course_view', semester.id, course.id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
            form=form,
            final_grades=final_grades,
            show_automated_publishing_info=final_grades,
        )
        return render(request, "grades_upload_form.html", template_data)