~fkfd/hamrs

e82e0c299a784ba6b3c8cb98764f2093f86d0090 — Frederick Yin 5 months ago e8a6136 main
Move print_horizontal to util
2 files changed, 13 insertions(+), 5 deletions(-)

M src/quiz.rs
M src/util.rs
M src/quiz.rs => src/quiz.rs +6 -5
@@ 96,7 96,11 @@ pub fn begin_exam(pool: &Pool, log: &mut Log) -> () {
    if review {
        for (i, answer) in missed {
            let question = &exam_pool[i];
            print_horizontal();
            print!("{BOLD}");
            print_wrap("Q: ", &question.question);
            println!("{RESET}");

            let user_option = &question.options[abcd_to_0123(answer.choice)];
            let correct_option = &correct_answer(question);
            println!("You chose:{RED}");


@@ 111,11 115,8 @@ pub fn begin_exam(pool: &Pool, log: &mut Log) -> () {

// print question and options, read user input, then give feedback unless in exam mode
fn ask_question(question: &Question, exam_mode: bool) -> Answer {
    // print a solid row of ========
    let equal_signs = iter::repeat('=').take(MAX_COLUMNS);
    let divider = String::from_iter(equal_signs);
    print!("{divider}\n{BOLD}");

    print_horizontal();
    print!("{BOLD}");
    print_wrap("Q: ", &question.question);
    println!("{RESET}");
    print_wrap("A. ", &question.options[0]);

M src/util.rs => src/util.rs +7 -0
@@ 45,3 45,10 @@ pub fn print_wrap(heading: &str, body: &str) -> () {
    // flush final line
    println!("{line}");
}

// print a solid row of ========
pub fn print_horizontal() -> () {
    let equal_signs = iter::repeat('=').take(MAX_COLUMNS);
    let divider = String::from_iter(equal_signs);
    println!("{divider}");
}