mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
support worksheets with multiple tasks in them
This commit is contained in:
13
README.md
13
README.md
@@ -30,8 +30,19 @@ problem, solution = mathgen.genById(0)
|
||||
|
||||
`genById(id)` generates a problem, solution set with generator id `id` in the form of a list in the format `[problem, solution]`
|
||||
|
||||
`makePdf(id, count)` creates a printable pdf worksheet with `count` problems generated by the generator with id `id`.
|
||||
`make_pdf(id, count)` creates a printable pdf worksheet with `count` problems generated by the generator with id `id`.
|
||||
|
||||
### More complicated worksheets
|
||||
|
||||
```
|
||||
import sys
|
||||
from mathgenerator import mathgen
|
||||
|
||||
worksheet = mathgen.make_worksheet("2020-11-29")
|
||||
mathgen.add_section_with_task_to_worksheet(worksheet, 105, 5)
|
||||
mathgen.add_section_with_task_to_worksheet(worksheet, 2, 5)
|
||||
mathgen.write_pdf(worksheet)
|
||||
```
|
||||
|
||||
## List of Generators
|
||||
|
||||
|
||||
@@ -11,10 +11,28 @@ def genById(id):
|
||||
return (generator())
|
||||
|
||||
|
||||
def makePdf(id, count):
|
||||
generator = genList[id][2]
|
||||
title = genList[id][1]
|
||||
ws = Worksheet(title=title)
|
||||
def make_worksheet(title):
|
||||
return Worksheet(title=title)
|
||||
|
||||
|
||||
def write_pdf(worksheet):
|
||||
worksheet.write_pdf()
|
||||
|
||||
def add_section_title(worksheet, task_id):
|
||||
title = genList[task_id][1]
|
||||
worksheet.add_instruction(title)
|
||||
|
||||
def add_task_to_worksheet(worksheet, task_id, count):
|
||||
generator = genList[task_id][2]
|
||||
for i in range(count):
|
||||
ws.add_problem(generator()[0])
|
||||
ws.write_pdf()
|
||||
worksheet.add_problem(generator()[0])
|
||||
|
||||
def add_section_with_task_to_worksheet(worksheet, task_id, count):
|
||||
add_section_title(worksheet, task_id)
|
||||
add_task_to_worksheet(worksheet, task_id, count)
|
||||
|
||||
def make_pdf(task_id, count):
|
||||
title = genList[task_id][1]
|
||||
worksheet = make_worksheet(title)
|
||||
add_task_to_worksheet(worksheet, task_id, count)
|
||||
write_pdf(worksheet)
|
||||
|
||||
Reference in New Issue
Block a user