Step 4: Default question files

Default question files

We can do the same thing for question files. For example, we can move the all question fields (except question_groups) to a default file.

Task

Move all fields of the questions that are equal to the question.yaml file in the defaults folder. For example:

---
builtin_constants: # all constants will be disabled
  e: false
  pi: false
  i: false
custom_constants: []
variables: {}
grouped_variables: none
variables_test:
  condition: ""
  max_runs: 1
functions: {}
preamble:
  css: ""
  js: ""
navigation:
  can_regenerate: false
  show_title_page: false
  confirm_when_leaving: false
extensions:
  jsx_graph: false
  stats: false
  geogebra: false
  eukleides: false
  chemistry: false
  download_text_file: false
  graphs: false
  linear_algebra: false
  linear_codes: false
  optimisation: false
  permutations: false
  polynomials: false
  quantities: false
  random_person: false
  written_number: false
  sqlite: false
  text: false
diagnostic_topic_names: []
resources: []
custom_part_types: []
rulesets: {}

We also add the variables field in here and set it to an empty hash by default. This is because we will be able to override the variables field in the question files that do use variables.

Task

Remove the fields from the question files.

Task

Try compiling the exams again. You should see that the compilation works and that the questions are still the same within the exams.

Our question files are now a lot smaller. Our question with variables is now:

---
type: normal
statement: How much is 9 * {a}?
advice: You could calculate 10 * {a} and then subtract {a}. This yields {a} * 10 - {a} = {a * 10} - {a} = {a*9} # this changed
parts:
  - type: number_entry
    prompt: Enter your answer in the inputbox
    marks: 5 
    answer: a * 9
    show_correct_answer: true
    show_feedback_icon: true
    display_correct_as_fraction: false
    allow_fractions: false
    fractions_must_be_reduced: false
    fractions_must_be_reduced_hint: false
    partial_credit_if_fraction_not_reduced: 0
    display_correct_in_style: &style english-plain
    allowed_notation_styles:
      - *style
    custom_marking: none
    steps: []
    steps_penalty: 0
    adaptive_marking: none
    part_name: none
variables:
  a: 3

Default question part files

There is still some duplication of settings within the number_entry question parts. We can move the settings of the number_entry question parts to a default file.

Task

Move all fields of the number_entry question parts that are equal to the questionpart.number_entry.yaml file in the defaults folder. For example:

---
show_correct_answer: true
show_feedback_icon: true
display_correct_as_fraction: false
allow_fractions: false
fractions_must_be_reduced: false
fractions_must_be_reduced_hint: false
partial_credit_if_fraction_not_reduced: 0
display_correct_in_style: &style english-plain
allowed_notation_styles:
  - *style
custom_marking: none
steps: []
steps_penalty: 0
adaptive_marking: none
part_name: none

Info

For each questionpart type you can specify such a default file.

Our question files are now even smaller. Our question with variables is now:

---
type: normal
statement: How much is 9 * {a}?
advice: You could calculate 10 * {a} and then subtract {a}. This yields {a} * 10 - {a} = {a * 10} - {a} = {a*9} # this changed
parts:
  - type: number_entry
    prompt: Enter your answer in the inputbox
    marks: 5 
    answer: a * 9
variables:
  a: 3