Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added multiple flags to moodle #20

Merged
merged 8 commits into from
Oct 28, 2024
Merged

Added multiple flags to moodle #20

merged 8 commits into from
Oct 28, 2024

Conversation

PootisHunter
Copy link
Collaborator

Closes #17

-Added multiple flag support for answers and a test that shows functionality (test_multiple_flags)

  • Current separator for flags: ";"

  • Using itertools crate to implement combinations and permutations for flags

Generating answers for 3 flags currently adds total 6+12+12 = 30 answers

  • 6 answers for 33 fraction ( 3 flag_string and 3 encase_flag answers)
  • 12 answers for 67 fraction ( 6 flag_string and 6 encase_flag answers)
  • 12 answers for 100 fraction ( 6 flag_string and 6 encase_flag answers)

@PootisHunter PootisHunter requested a review from Nicceboy October 11, 2024 15:38
src/moodle.rs Show resolved Hide resolved
src/moodle.rs Outdated Show resolved Hide resolved
src/moodle.rs Show resolved Hide resolved
@PootisHunter PootisHunter requested a review from Nicceboy October 23, 2024 12:39
src/moodle.rs Show resolved Hide resolved
Comment on lines +179 to +228
for answer in answers {
match answer.fraction {
33 => {
assert!(
answer.text.contains("task4_prefix:")
|| answer.text.contains("task5_prefix:")
|| answer.text.contains("task6_prefix:")
);
}
67 => {
assert!(
(answer.text.contains("task4_prefix:")
&& answer.text.contains("task5_prefix:"))
|| (answer.text.contains("task6_prefix:")
&& answer.text.contains("task5_prefix:"))
|| (answer.text.contains("task6_prefix:")
&& answer.text.contains("task4_prefix:"))
);
}
100 => {
assert!(
(answer.text.contains("task4_prefix:")
&& answer.text.contains("task5_prefix:")
&& answer.text.contains("task6_prefix:"))
);
}
_ => {
unreachable!("Unexpected fraction value encountered in test")
}
}
}
for answer in answers2 {
assert!(answer.fraction == 100);
assert!(answer.text.contains("task1:"));
}
for answer in answers3 {
match answer.fraction {
50 => {
assert!(answer.text.contains("task2:") || answer.text.contains("task3:"));
}
100 => {
assert!(answer.text.contains("task2:") && answer.text.contains("task3:"));
}
_ => {
unreachable!("Unexpected fraction value encountered in test")
}
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. This does not ensure that there are no duplicates but maybe we can trust the logic of itertools. However, tests should always ensure that if we made changes in the code, the end functionality remains and we get confidence that system still works, so tests should be strict enough.

@Nicceboy Nicceboy merged commit 1983606 into main Oct 28, 2024
1 check passed
@Nicceboy Nicceboy deleted the multiple_flags branch October 28, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moodle exam generation should support multiple flags in a single exam question
2 participants