Skip to main content

A simple library to create latex exam in python

Project description

pytexexam

A simple library for writing and printing exam in Python.

Installation

pip install pytexexam

How to use

from pytexexam.question import Question
from pytexexam.exam import Exam
from pytexexam.latexexam import LatexExam

# Create questions, answers and solution.
question = Question("Question 1 ?")
question.answer_a("Answer 1", True)
question.answer_b("Answer 2")
question.answer_c("Answer 3")
question.answer_d("Answer 4")
question.shuffle_answer()
question.solution("""
This is the detailed answer of the first question.
""")

# Another way to enter answer options.
question2 = Question("Question 2 ?")
question2.answers(true_answer="A", answer_dict={
    "A": "Answer 1",
    "B": "Answer 2",
    "C": "Answer 3",
    "D": "Answer 4"
})
question2.solution("""
This is the detailed answer of the second question.
""")
question2.set_answer_column(2)
question2.shuffle_answer()

# One more question.
question3 = Question("Question 3 ?")
question3.answer_a("Answer 1", True)
question3.answer_b("Answer 2")
question3.answer_c("Answer 3")
question3.answer_d("Answer 4")
question3.set_answer_column(4)
question3.shuffle_answer()

# Create a exam from existing questions.
exam = Exam([question, question2, question3])

# Shuffle the questions.
exam.shuffle_question()

# Create a LatexExam object to export a question as a tex or pdf file (with latex pre-installed)
latex_exam = LatexExam("Simple exam", exam)
# Add AMS math packages, if needed.
latex_exam.add_ams_math_preamble()

# Export exam.
latex_exam.export_tex_exam("test1.tex")
latex_exam.export_pdf_exam("test1.pdf")

# Export answer keys
latex_exam.export_tex_answer("answer1.tex")
latex_exam.export_pdf_answer("answer1.pdf")

# Export solutions.
latex_exam.export_tex_solution("solution1.pdf")
latex_exam.export_pdf_solution("solution1.pdf")

All package API.

If you want to see all the functions included in this library, you can find the pytexexam.pdf file in the docs directory

Contribution.

Contribution are welcome. Create a pull request.

Buy me a coffee.

If you find this project useful, you can buy me coffee through Flattr Flattr this git repo

License

Apache License, Version 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytexexam-1.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytexexam-1.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file pytexexam-1.2.tar.gz.

File metadata

  • Download URL: pytexexam-1.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5rc1

File hashes

Hashes for pytexexam-1.2.tar.gz
Algorithm Hash digest
SHA256 bc13add239c1f5b1ccd7ef1e2566dd169a60443dbd9c294bd07c550a2637551f
MD5 af0a507109684f88a07d6b99d78a3074
BLAKE2b-256 7fa8a4ca2c929bb790fdd5d99976043f1508921495ca12842b467ced8208d9e0

See more details on using hashes here.

File details

Details for the file pytexexam-1.2-py3-none-any.whl.

File metadata

  • Download URL: pytexexam-1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5rc1

File hashes

Hashes for pytexexam-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cafec7c87e9772168eb3c102d8568121ea6e446bbbb05853d09beec71350e3f3
MD5 04af7701ca1964864c11c4fc3a2cf4e7
BLAKE2b-256 a7c73f993b5d40dcf19a0ff059cdd5cacfe30e653a1b1b924e9349cef5ed722d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page