def add_student(gb): first = ui.get_string(gb, "Enter First Name") last = ui.get_string(gb, "Enter Last Name") email = ui.get_string(gb, "Enter Email") gb.add_student(first, last, email) gb.students.sort(key=lambda s: s.name()) gb.actives = None menus.set_student_options(gb) menus.set_student_last_first_options(gb)
def edit_course(gb): gb.name = ui.get_string(gb, "Enter Course Name", gb.name) gb.term = ui.get_string(gb, "Enter Quarter", gb.term) gb.global_added_pct = ui.get_valid_float(gb, "Global Added Pct.", 0, 100, gb.global_added_pct) gb.letter_plus_minus_pct = ui.get_valid_float(gb, "Letter +/- Pct.", 0, 9, gb.letter_plus_minus_pct) gb.audible_warnings = ui.get_bool(gb, "Audible Warnings?", gb.audible_warnings) if gb.audible_warnings: ui.say(gb, "Audible warnings are on") menus.set_main_options(gb)
def edit_student(gb): first = ui.get_string(gb, "Enter First Name", gb.cur_student.first) last = ui.get_string(gb, "Enter Last Name", gb.cur_student.last) email = ui.get_string(gb, "Enter Email", gb.cur_student.email) is_active = ui.get_bool(gb, "Is the Student Active? (y/n)", gb.cur_student.is_active) gb.cur_student.first = first gb.cur_student.last = last gb.cur_student.email = email gb.cur_student.is_active = is_active gb.students.sort(key=lambda s: s.name()) gb.actives = None menus.set_student_options(gb) menus.set_student_last_first_options(gb)
def edit_gradeable(gb): cg = gb.cur_gradeable name = ui.get_string(gb, "Enter Graded Item Name", cg.name) def_sel = gb.categories.index(cg.category) + 1 cat = ui.get_int_from_list(gb, "Select a numbered category", [c.name for c in gb.categories], def_sel) category = gb.categories[cat - 1] pts = [q.points for q in cg.questions] prev_tot = sum(pts) bonus = prev_tot - cg.total_pts if not cg.has_scores(): fpts = ui.get_space_separated_floats( gb, "Enter question point values separated by whitespace", pts) total_pts = ui.get_valid_float(gb, "Total Points", sum(fpts)/2.0, sum(fpts), \ cg.total_pts if prev_tot == sum(fpts) else sum(fpts) - bonus) else: print("Question points: ", pts) total_pts = ui.get_valid_float(gb, "Total Points", prev_tot / 2, prev_tot, cg.total_pts) sub_pct = ui.get_valid_float(gb, "Retake Sub-percent", 0, 100, cg.sub_pct) added_pts = ui.get_valid_float(gb, "Added Points", 0, 10000, cg.added_pts) added_pct = ui.get_valid_float(gb, "Added Percent", 0, 100, cg.added_pct) cg.name = name or cg.name cg.category = category cg.total_pts = total_pts cg.sub_pct = sub_pct cg.added_pts = added_pts cg.added_pct = added_pct if not cg.has_scores(): cg.questions = [Question(cg, p) for p in fpts] menus.set_gradeable_options(gb)
def append_student_note(gb): notes = ui.get_string(gb, "Append Notes", gb.cur_student.notes, is_append=True) if notes: if gb.cur_student.notes: gb.cur_student.notes += ' ' gb.cur_student.notes += notes
def add_category(gb): name = ui.get_string(gb, "Enter Category Name") pct_of_grade = ui.get_valid_float(gb, "Percent of Grade", 0, 100) drop_low_n = ui.get_valid_int(gb, "Drop Lowest n", 0, 3, 0) est_ct = ui.get_valid_int(gb, "Estimated Items", 0, 100, 0) combine_pts = ui.get_bool(gb, "Combine Points instead of Percents?", 0) gradeable_pcts = ui.get_space_separated_floats(gb, "If weights for items in this category" \ " should based on student scores,\n"+ \ " enter their percents separated by whitespace. Enter 'N' to clear") cat = Category(gb, name, pct_of_grade, drop_low_n, est_ct, combine_pts, gradeable_pcts) gb.categories.append(cat) menus.set_category_options(gb)
def edit_category(gb): name = ui.get_string(gb, "Enter Category Name", gb.cur_category.name) gb.cur_category.name = name or gb.cur_category.name gb.cur_category.pct_of_grade = ui.get_valid_float( gb, "Percent of Grade", 0, 100, gb.cur_category.pct_of_grade) gb.cur_category.drop_low_n = ui.get_valid_int(gb, "Drop Lowest n", 0, 3, gb.cur_category.drop_low_n) gb.cur_category.est_ct = ui.get_valid_int(gb, "Estimated Items", 0, 100, gb.cur_category.est_ct) gb.cur_category.combine_pts = ui.get_bool( gb, "Combine Points instead of Percents?", gb.cur_category.combine_pts) pcts = ui.get_space_separated_floats(gb, \ "If weights for items in this category should based on best scores,\n"+ \ " enter their percents separated by whitespace. Enter 'N' to clear.", gb.cur_category.gradeable_pcts, n_as_none=True) gb.cur_category.set_gradeable_pcts(pcts) menus.set_category_options(gb)
def add_gradeable(gb): if not gb.categories: ui.pause( "Can't create a graded item until there is at least one category.") return name = ui.get_string(gb, "Enter Graded Item Name") cat = ui.get_int_from_list(gb, "Select a numbered category", [c.name for c in gb.categories]) category = gb.categories[cat - 1] fpts = ui.get_space_separated_floats( gb, "Enter question point values separated by whitespace") total_pts = ui.get_valid_float(gb, "Total Points", sum(fpts) / 2, sum(fpts), sum(fpts)) gradeable = Gradeable(gb, name, category, total_pts) questions = [Question(gradeable, p) for p in fpts] gradeable.questions = questions gb.gradeables.append(gradeable) menus.set_gradeable_options(gb)