Menu

Sheet

Nicolas Hainaux

The abstract class sheet.S_Structure contains all methods to write the texts and the answers of its Exercises to the output. The main method is __str__() which turns the entire sheet into a string.

The instanciable Sheets should all be a copy of sheet.Model. They reimplement only the __init__() method (which makes a call to sheet.S_Structure.__init__()), which defines which exercises must be created and added to the field exercises_list of the sheet.

Finally, each Sheet has some global variables which should be defined. More details about them: (this should be checked again...)

  • FONT_SIZE_OFFSET: will fix the reference size of the font (0 is the default value, it you put more, all fonts will be relatively larger, if you put a negative value, then all fonts will be relatively tinier).
  • SHEET_LAYOUT_TYPE: can be 'std'|'short_test'|'mini_test'|'mini_training'|'equations'
    -'std' will just reproduce the layout as defined in SHEET_LAYOUT
    -'short_test' will follow the layout as defined in SHEET_LAYOUT and reproduce it twice. On the sheet there will be first exercises' texts of the first subject, then the ones of the second subject; then the answers of first subject's exercises and then answers of the second subject.
    -'mini_test' is like 'short_test' but there are three subjects
    -'mini_training' is like 'short_test' but there are six subjects
    -'equations' will define a special layout to use the space more properly for the answers.

  • SHEET_LAYOUT_UNIT: defines the unit in which the numbers in SHEET_LAYOUT are given

  • SHEET_LAYOUT: defines precisely the layout of the exercises' texts and answers.

Example from the code:

    # ------------------------  lines_nb    col_widths   exercises
    #SHEET_LAYOUT = { 'exc' : [ [1,         6, 15],      (1, 1),
    #                            None,                    1
    #                         ],
    #                 'ans' : [ [1,         6.5, 12],    (1, 1),
    #                            'jump',                 'next_page',
    #                            None,                    1
    #                         ]
    #               }
    # NOTE THAT FOR SHORT_TEST SHEETS, THE LAYOUT HAS TO BE GIVEN ONLY ONCE
    # AND IT WILL BE DUPLICATED FOR THE SECOND SET OF EXERCISES

    # EXPLANATION ABOUT THE EXAMPLE OF SHEET_LAYOUT :
    # [1, 6, 15] means a table of 1 line with columns widths 6 and 15.
    # (1, 1) means one exercise in each of these two cells.
    # This tuple should contains as many numbers as nb of lines × nb of cols.
    # To leave one cell empty, just write 0.
    # None means no tabular and the following 1 means for the 1 next exercise.
    # 'all' and 'all_left' are synonym
    # 'jump' and 'next_page' will include a jump to next page before the next ones

The instructions for use are all written in S_Model.py
S_Structure in the doc
S_Model in the doc


Related

Doc for dev: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.