Parser of berki style problems and generator of latex file
Samo Penic
2018-11-21 64376f493ac225954912f9419480518ebe4b373a
Fixes in loading templates.
2 files modified
54 ■■■■■ changed files
GenerateTests.py 52 ●●●●● patch | view | raw | blame | history
setup.py 2 ●●●●● patch | view | raw | blame | history
GenerateTests.py
@@ -1,44 +1,34 @@
from aoi_gen.BerkiParse import BerkiParse
from aoi_gen.Problem import ProblemSource, Problem
from aoi_gen.Exam import Exam
import pkg_resources
import os
if pkg_resources.resource_dir is not None:
    template_path = os.path.join(pkg_resources.resource_dir, "/textemplates")
else:
    template_path = "aoi_gen/textemplates"
if __name__ == "__main__":
    # from glob import glob
    #
    # # THIS IS TO BE READ FROM THE DATABASE
    # filelist = glob("testcases/*")
    # naloge = []
    # for i, f in enumerate(filelist):
    #     with open(f) as fd:
    #         cont = fd.read()
    #     naloge.append((i, cont))
    # source=[]
    # for nal in naloge:
    #     par=BerkiParse(nal[1])
    #     par.parseSections()
    #     source.append(ProblemSource(parser=par))
    settings = {
        'exam_title': "Naslov izpita",
        'date': "27.10.2018",
        'faculty_name': "Fakulteta test",
        'faculty_id': 0,
        'exam_id': 0,
        'last_line': "Empty line",
        'start_number': 100,
        'sid_prefill': "11x0xxxx", }
        "exam_title": "Naslov izpita",
        "date": "27.10.2018",
        "faculty_name": "Fakulteta test",
        "faculty_id": 0,
        "exam_id": 0,
        "last_line": "Empty line",
        "start_number": 100,
        "sid_prefill": "11x0xxxx",
    }
    student_list=[
        ("64990162", "Samo Penic"),
    ]
    student_list = [("64990162", "Samo Penic")]
    exam=Exam(settings=settings, student_list=student_list, number_of_papers=5)
    exam = Exam(settings=settings, student_list=student_list, number_of_papers=5, template=template_path)
    exam.loadProblemsFromDirectory("testcases/*.txt")
    exam.generatePapers()
    text=exam.exam_to_template()
    #print(text)
    exam_matrix=exam.get_answers()
    text = exam.exam_to_template()
    # print(text)
    exam_matrix = exam.get_answers()
    print(exam_matrix)
    with open('preverjanje.tex','w') as problem_fd:
    with open("preverjanje.tex", "w") as problem_fd:
        problem_fd.write(text)
setup.py
@@ -9,4 +9,6 @@
    author_email="samo.penic@gmail.com",
    url="",
    packages=["aoi_gen"],
    include_package_data=True,
    package_data={'aoi_gen': ['textemplates/*.tpl']},
)