Пример #1
0
def toggle_no_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    course = get_object_or_404(Course, id=course_id)

    if request.method == 'POST':
        course.gets_no_grade_documents = not course.gets_no_grade_documents
        course.save()

        if course.gets_no_grade_documents:
            if course.state == 'reviewed':
                course.publish()
                course.save()
                send_publish_notifications(evaluation_results_courses=[course])
            messages.success(
                request,
                _("Successfully confirmed that no grade documents will be provided."
                  ))
        else:
            messages.success(
                request,
                _("Successfully confirmed that grade documents will be provided later on."
                  ))
        return redirect('grades:semester_view', semester_id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
        )
        return render(request, "toggle_no_grades.html", template_data)
Пример #2
0
    def update_courses(cls):
        logger.info("update_courses called. Processing courses now.")
        from evap.evaluation.tools import send_publish_notifications
        today = datetime.date.today()

        courses_new_in_evaluation = []
        evaluation_results_courses = []

        for course in cls.objects.all():
            try:
                if course.state == "approved" and course.vote_start_date <= today:
                    course.evaluation_begin()
                    course.save()
                    courses_new_in_evaluation.append(course)
                elif course.state == "inEvaluation" and course.vote_end_date < today:
                    course.evaluation_end()
                    if course.is_fully_reviewed():
                        course.review_finished()
                        if not course.is_graded or course.final_grade_documents.exists() or course.gets_no_grade_documents:
                            course.publish()
                            evaluation_results_courses.append(course)
                    course.save()
            except Exception:
                logger.exception(('An error occured when updating the state of course "{}" (id {}).').format(course, course.id))

        EmailTemplate.send_evaluation_started_notifications(courses_new_in_evaluation)
        send_publish_notifications(evaluation_results_courses=evaluation_results_courses)
        logger.info("update_courses finished.")
Пример #3
0
def helper_semester_course_operation_publish(request, courses):
    for course in courses:
        course.publish()
        course.save()
    messages.success(request, ungettext("Successfully published %(courses)d course.",
        "Successfully published %(courses)d courses.", len(courses)) % {'courses': len(courses)})
    send_publish_notifications(evaluation_results_courses=courses)
Пример #4
0
    def update_courses(cls):
        logger.info("update_courses called. Processing courses now.")
        from evap.evaluation.tools import send_publish_notifications

        courses_new_in_evaluation = []
        evaluation_results_courses = []

        for course in cls.objects.all():
            try:
                if course.state == "approved" and course.vote_start_datetime <= datetime.now():
                    course.evaluation_begin()
                    course.last_modified_user = UserProfile.objects.cronjob_user()
                    course.save()
                    courses_new_in_evaluation.append(course)
                elif course.state == "in_evaluation" and datetime.now() >= course.vote_end_datetime:
                    course.evaluation_end()
                    if course.is_fully_reviewed:
                        course.review_finished()
                        if not course.is_graded or course.final_grade_documents.exists() or course.gets_no_grade_documents:
                            course.publish()
                            evaluation_results_courses.append(course)
                    course.last_modified_user = UserProfile.objects.cronjob_user()
                    course.save()
            except Exception:
                logger.exception('An error occured when updating the state of course "{}" (id {}).'.format(course, course.id))

        template = EmailTemplate.objects.get(name=EmailTemplate.EVALUATION_STARTED)
        EmailTemplate.send_to_users_in_courses(template, courses_new_in_evaluation, [EmailTemplate.ALL_PARTICIPANTS], use_cc=False, request=None)
        send_publish_notifications(evaluation_results_courses)
        logger.info("update_courses finished.")
Пример #5
0
    def update_courses(cls):
        logger.info("update_courses called. Processing courses now.")
        from evap.evaluation.tools import send_publish_notifications

        today = datetime.date.today()

        courses_new_in_evaluation = []
        evaluation_results_courses = []

        for course in cls.objects.all():
            try:
                if course.state == "approved" and course.vote_start_date <= today:
                    course.evaluation_begin()
                    course.save()
                    courses_new_in_evaluation.append(course)
                elif course.state == "inEvaluation" and course.vote_end_date < today:
                    course.evaluation_end()
                    if course.is_fully_reviewed():
                        course.review_finished()
                        if (
                            not course.is_graded
                            or course.final_grade_documents.exists()
                            or course.gets_no_grade_documents
                        ):
                            course.publish()
                            evaluation_results_courses.append(course)
                    course.save()
            except Exception:
                logger.exception(
                    ('An error occured when updating the state of course "{}" (id {}).').format(course, course.id)
                )

        EmailTemplate.send_evaluation_started_notifications(courses_new_in_evaluation)
        send_publish_notifications(evaluation_results_courses=evaluation_results_courses)
        logger.info("update_courses finished.")
Пример #6
0
    def update_courses(cls):
        logger.info("update_courses called. Processing courses now.")
        from evap.evaluation.tools import send_publish_notifications

        courses_new_in_evaluation = []
        evaluation_results_courses = []

        for course in cls.objects.all():
            try:
                if course.state == "approved" and course.vote_start_datetime <= datetime.now():
                    course.evaluation_begin()
                    course.last_modified_user = UserProfile.objects.cronjob_user()
                    course.save()
                    courses_new_in_evaluation.append(course)
                elif course.state == "in_evaluation" and datetime.now() >= course.vote_end_datetime:
                    course.evaluation_end()
                    if course.is_fully_reviewed:
                        course.review_finished()
                        if not course.is_graded or course.final_grade_documents.exists() or course.gets_no_grade_documents:
                            course.publish()
                            evaluation_results_courses.append(course)
                    course.last_modified_user = UserProfile.objects.cronjob_user()
                    course.save()
            except Exception:
                logger.exception('An error occured when updating the state of course "{}" (id {}).'.format(course, course.id))

        template = EmailTemplate.objects.get(name=EmailTemplate.EVALUATION_STARTED)
        EmailTemplate.send_to_users_in_courses(template, courses_new_in_evaluation, [EmailTemplate.ALL_PARTICIPANTS], use_cc=False, request=None)
        send_publish_notifications(evaluation_results_courses)
        logger.info("update_courses finished.")
Пример #7
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)
Пример #8
0
def helper_semester_course_operation_publish(request, courses, send_email):
    for course in courses:
        course.publish()
        course.save()
    messages.success(request, ungettext("Successfully published %(courses)d course.",
        "Successfully published %(courses)d courses.", len(courses)) % {'courses': len(courses)})
    if send_email:
        send_publish_notifications(courses)
Пример #9
0
def helper_semester_course_operation_publish(request, courses):
    for course in courses:
        course.publish()
        course.save()
    messages.success(
        request,
        ungettext("Successfully published %(courses)d course.",
                  "Successfully published %(courses)d courses.", len(courses))
        % {'courses': len(courses)})
    send_publish_notifications(evaluation_results_courses=courses)
Пример #10
0
def helper_semester_course_operation_publish(request, courses, send_email):
    for course in courses:
        course.publish()
        course.save()
    messages.success(
        request,
        ungettext("Successfully published %(courses)d course.",
                  "Successfully published %(courses)d courses.", len(courses))
        % {'courses': len(courses)})
    if send_email:
        send_publish_notifications(courses)
Пример #11
0
def toggle_no_grades(request):
    course_id = request.POST.get("course_id")
    course = get_object_or_404(Course, id=course_id)

    course.gets_no_grade_documents = not course.gets_no_grade_documents
    course.save()
    if course.gets_no_grade_documents:
        if course.state == 'reviewed':
            course.publish()
            course.save()
            send_publish_notifications([course])

    return HttpResponse()  # 200 OK
Пример #12
0
def toggle_no_grades(request):
    course_id = request.POST.get("course_id")
    course = get_object_or_404(Course, id=course_id)

    course.gets_no_grade_documents = not course.gets_no_grade_documents
    course.save()
    if course.gets_no_grade_documents:
        if course.state == 'reviewed':
            course.publish()
            course.save()
            send_publish_notifications([course])

    return HttpResponse()  # 200 OK
Пример #13
0
def toggle_no_grades(request):
    course_id = request.POST.get("course_id")
    course = get_object_or_404(Course, id=course_id)
    if course.semester.grade_documents_are_deleted:
        raise PermissionDenied

    course.gets_no_grade_documents = not course.gets_no_grade_documents
    course.save()
    if course.gets_no_grade_documents:
        if course.evaluation.state == 'reviewed':
            course.evaluation.publish()
            course.evaluation.save()
            send_publish_notifications([course.evaluation])

    return HttpResponse()  # 200 OK
Пример #14
0
def toggle_no_grades(request):
    course_id = request.POST.get("course_id")
    course = get_object_or_404(Course, id=course_id)
    if course.semester.grade_documents_are_deleted:
        raise PermissionDenied

    course.gets_no_grade_documents = not course.gets_no_grade_documents
    course.save()
    evaluations = course.evaluations.all()
    if course.gets_no_grade_documents and all(evaluation.state == 'reviewed' for evaluation in evaluations):
        for evaluation in evaluations:
            evaluation.publish()
            evaluation.save()
        send_publish_notifications(evaluations)

    return HttpResponse()  # 200 OK
Пример #15
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)
Пример #16
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)
Пример #17
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)
Пример #18
0
def toggle_no_grades(request, semester_id, course_id):
    semester = get_object_or_404(Semester, id=semester_id)
    course = get_object_or_404(Course, id=course_id)

    if request.method == 'POST':
        course.gets_no_grade_documents = not course.gets_no_grade_documents
        course.save()

        if course.gets_no_grade_documents:
            if course.state == 'reviewed':
                course.publish()
                course.save()
                send_publish_notifications(evaluation_results_courses=[course])
            messages.success(request, _("Successfully confirmed that no grade documents will be provided."))
        else:
            messages.success(request, _("Successfully confirmed that grade documents will be provided later on."))
        return redirect('grades:semester_view', semester_id)
    else:
        template_data = dict(
            semester=semester,
            course=course,
        )
        return render(request, "toggle_no_grades.html", template_data)
Пример #19
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)