Exemple #1
0
def get_comment_value_by_assignment_id(marked_grade_cell: Cell,
                                       marked_comment_cells: Cell, row_number,
                                       ws: worksheet):
    """
        Helper method to find the corresponding comment value for a given grade_cell.
        Column index marked by assignment ID in upload_marker row. Row indexing by given row_number.
        The list of cells (marked_comment_cells) is cleaned before and do not contain the
        CommentMarkerPrefix anymore, but assignment IDs.

    :param marked_grade_cell: Grade cell marked by assignment ID in the upload_marker row.
    :param marked_comment_cells: List of all comment cells we want to find the assignment ID of marked_grade_cell in.
    :param row_number: Number of current row.
    :param ws: Worksheet to read from (data_only).
    :return: Empty string if cell value is None or if cell is not found.
    """
    if Config.get_behavior_comments_switch():
        for coment_cell in marked_comment_cells:
            # find matching assignment id
            if str(coment_cell.value) == str(marked_grade_cell.value):
                # extract coordinates (column index)
                column_index_of_comment_cell = column_index_from_string(
                    coordinate_from_string(coment_cell.coordinate)[0])
                # read value of cell
                comment_value = ws.cell(
                    row=row_number, column=column_index_of_comment_cell).value
                if not comment_value:  # normalize - we want string only as return type
                    comment_value = ''
                return comment_value

    if Config.get_behavior_log():
        print('Comment for grade cell ' + str(marked_grade_cell.coordinate) +
              ' not found!')
    return ''
Exemple #2
0
# Open workbook in data_only mode to read values only and no formulas.
# Workbook in data_only mode will return calculated values for formulas: value == internal_value
wb_grading_data = load_workbook(Config.get_grading_sheet_file_path(),
                                data_only=True)
ws_grading_data = wb_grading_data.active

# find upload_marker row
moodle_grade_column_marker_name = Config.get_column_mapping_upload_marker_name(
)
index_moodle_grade_marker_row = util.find_row_of_value_in_column(
    moodle_grade_column_marker_name,
    Config.get_column_mapping_upload_marker_column(), ws_grading_data)

# switch to enable grading including comments to accomplish advanced point systems to match with moodle simple point system
use_grading_comments = Config.get_behavior_comments_switch()

# Get column indexes as defined in config.ini
index_matrikel_col = column_index_from_string(
    Config.get_column_mapping_matrnr_column())
index_group_name_col = column_index_from_string(
    Config.get_column_mapping_group_name_column())

#default_email_domain = Config.get_email_default_email_domain_students()
current_course_id = Config.get_current_course_id()

# **********************************************************************************
# READ IN MARKED MOODLE GRADE COLUMNS (and comment columns), STUDENTS AND GROUP NAMES
# **********************************************************************************

# Get all moodle grade columns marked with assignment IDs by upload_marker row as configured in config.ini
Exemple #3
0
        row_counter += 1

# write grading markers
# add one blank line
row_counter += 1
# write UploadMarkerRowName
ws_grades.cell(row=row_counter, column=1).value = str(
    Config.get_column_mapping_upload_marker_name())

# write assignment IDs and comment marker prefixes into grading (and feedback) columns
column_counter = 8
for assignment in assignments:
    ws_grades.cell(row=row_counter,
                   column=column_counter).value = str(assignment['id'])
    if Config.get_behavior_comments_switch():
        ws_grades.cell(row=row_counter, column=column_counter + 1).value = str(
            Config.get_column_mapping_comment_marker_prefix()) + str(
                assignment['id'])
    column_counter += 2

# ****************************************************************
# END OF SCRIPT - BEAUTIFY AND SAVE WORKBOOK
# ****************************************************************

# beautify workbook
util.adjust_workbook_format(wb_out)

# save workbook in directory configured in config.ini
wb_out.save(Config.get_output_grading_sheet_file_path())