Exercises - AriosJentu/TestingDocumentGenerator GitHub Wiki
There is some information about exercises.
Classes
There is only one class with possibility to generate exercises:
Exercise— class of exercises which containing list of objects ofTasksInformation.
Usage in Assignment definitions
Exercises can be obtained with importing Imports module from Modules:
import Modules.Imports as Imports
Main class contained in Imports.Exercises module.
Exercises
Exercise
Exercise can generate exercises with presented tasks. It also contains title of the exercise. Tasks can be shuffled, title can be updated with title-updater-function for exercise.
exercise1 = Imports.Exercises.Exercise([tasksinfo1, tasksinfo2])
exercise2 = Imports.Exercises.Exercise([tasksinfo3], title="Title of the exercise")
This example generates two exercises with two tasks information. First exercise haven't title, second has a title Title of the exercise. Also, available method append to append tasks information into exercise.
For exercises there is exist formatting string, if exercise needs to use non-default formatting string. Argument for formatting string named exercise_format, but can be set and get with methods set_exercise_format and get_exercise_format. Formatting string needs to contain {title} and {tasks} substrings for formatting.
exercise3 = Imports.Exercises.Exercise([tasksinfo4], title="Title of the exercise", exercise_format="{title}")
exercise3.set_exercise_format("Exercise 3: {title}\n{tasks}")
This example creates exercise with only-title generation, but next line set new exercise format for two lines - title with string at the beginning Exercise 3 and all exercise tasks.
To shuffle tasks (by default there is no shuffling) in exercise, use method set_shuffle_state with boolean argument:
exercise.set_shuffle_state(True)
Updater-function
Exercises has function to update title of the exercises. This function represents as function of one argument — str, and returns str — updated title of the exercise.
Usage:
def exercise_update_title(title):
return title.replace("12", "14")
exercise = Imports.Exercises.Exercise([tasksinfo1, tasksinfo2], title="Title #12")
exercise.set_title_updater_function(exercise_update_title)
This example generates exercise with title, which in generation will be updated with function exercise_update_title. It can be used in different situations, where exercise can use different titles.