コード例 #1
0
ファイル: views.py プロジェクト: schumannd/EvaP
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)
コード例 #2
0
ファイル: views.py プロジェクト: jmunden1/EvaP
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)
コード例 #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, semester=semester)

    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)
コード例 #4
0
ファイル: views.py プロジェクト: janno42/EvaP
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)
コード例 #5
0
ファイル: views.py プロジェクト: fsr-itse/EvaP
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)