From 27082cc2997f2a4a83ddd82b50dd88655c336d0b Mon Sep 17 00:00:00 2001 From: lukew3 Date: Fri, 20 Nov 2020 14:05:48 -0500 Subject: [PATCH] added makePdf function, documentation, new version --- README.md | 7 +++++++ mathgenerator/mathgen.py | 9 +++++++++ setup.py | 4 ++-- test.py | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c4b295..f3c42cc 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,13 @@ problem, solution = mathgen.addition() #another way to generate an addition problem using genById() problem, solution = mathgen.genById(0) ``` +## Documentation +`getGenList()` returns a list of all generators in the repository in the format `[id, title, self, funcname]` + +`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`. + ## List of Generators diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1a09015..25608cd 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -1,5 +1,6 @@ from .funcs import * from .__init__ import getGenList +from worksheetgen.wg import Worksheet genList = getGenList() @@ -8,3 +9,11 @@ genList = getGenList() def genById(id): generator = genList[id][2] return (generator()) + +def makePdf(id, count): + generator = genList[id][2] + title = genList[id][1] + ws = Worksheet(title=title) + for i in range(count): + ws.add_problem(generator()[0]) + ws.write_pdf() diff --git a/setup.py b/setup.py index af12642..65b6250 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,12 @@ from setuptools import setup, find_packages setup(name='mathgenerator', - version='1.1.5', + version='1.1.6', description='An open source solution for generating math problems', url='https://github.com/lukew3/mathgenerator', author='Luke Weiler', author_email='lukew25073@gmail.com', license='MIT', packages=find_packages(), - install_requires=['sympy', 'numpy', 'scipy'], + install_requires=['sympy', 'numpy', 'scipy', 'worksheetgen'], entry_points={}) diff --git a/test.py b/test.py index 7432e8a..4dd774f 100644 --- a/test.py +++ b/test.py @@ -11,3 +11,6 @@ for item in list: # print(mathgen.getGenList()) print(mathgen.genById(111)) + +#Make a pdf with 10 problems of generator id 1 +mathgen.makePdf(0, 10)