Beispiel #1
0
def _update_row(user, row, enrollments_managed_grouped, is_program_manager):
    xls_registration_id = _extract_registration_id(row)
    xls_learning_unit_acronym = row[col_learning_unit].value
    xls_score = _clean_value(row[col_score].value)
    xls_justification = _clean_value(row[col_justification].value)

    key = "{}_{}".format(xls_registration_id, xls_learning_unit_acronym)
    enrollments = enrollments_managed_grouped.get(key, [])

    if not enrollments:
        raise ValueError("%s!" % _('enrollment_activity_not_exist') % (xls_learning_unit_acronym))

    enrollment = enrollments[0]

    if score_encoding_list.is_deadline_reached(enrollment, is_program_manager):
        raise UploadValueError("%s" % _('deadline_reached'), messages.ERROR)

    if not is_program_manager and enrollment.is_final:
        raise UploadValueError("%s" % _('score_already_submitted'), messages.WARNING)

    if (xls_score or xls_score == 0) and xls_justification:
        raise UploadValueError("%s" % _('constraint_score_other_score'), messages.ERROR)

    if xls_justification and _is_informative_justification(enrollment, xls_justification, is_program_manager):
       return False

    enrollment.score_encoded = xls_score
    enrollment.justification_encoded = None
    if xls_justification:
        enrollment.justification_encoded = _get_justification_from_aliases(enrollment, xls_justification)
    return score_encoding_list.update_enrollment(
        enrollment=enrollment,
        user=user
    )
Beispiel #2
0
def _update_row(user, row, enrollments_managed_grouped, is_program_manager):
    xls_registration_id = _extract_registration_id(row)
    xls_learning_unit_acronym = row[col_learning_unit].value
    xls_score = _clean_value(row[col_score].value)
    xls_justification = _clean_value(row[col_justification].value)

    key = "{}_{}".format(xls_registration_id, xls_learning_unit_acronym)
    enrollments = enrollments_managed_grouped.get(key, [])

    if not enrollments:
        raise ValueError("%s!" %
                         _("The enrollment to the activity %(xls_learning_unit_acronym)s doesn't exist")
                         % xls_learning_unit_acronym)

    enrollment = enrollments[0]

    if score_encoding_list.is_deadline_reached(enrollment, is_program_manager):
        raise UploadValueError("%s" % _("Deadline reached"), messages.ERROR)

    if not is_program_manager and enrollment.is_final:
        raise UploadValueError("%s" % _("Score already submitted"), messages.WARNING)

    if (xls_score or xls_score == 0) and xls_justification:
        raise UploadValueError("%s" % _("You can't encode a 'score' and a 'justification' together"), messages.ERROR)

    if xls_justification and _is_informative_justification(enrollment, xls_justification, is_program_manager):
       return False

    enrollment.score_encoded = xls_score
    enrollment.justification_encoded = None
    if xls_justification:
        enrollment.justification_encoded = _get_justification_from_aliases(enrollment, xls_justification)
    return score_encoding_list.update_enrollment(
        enrollment=enrollment,
        user=user
    )