Giter VIP home page Giter VIP logo

pytexexam's Introduction

pytexexam

A simple library for writing and printing exam in Python. Run on Repl.it

Installation

pip install pytexexam

How to use

from pytexexam import Question, Exam, LatexExam, latexexamutil

# 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_user_preamble(latexexamutil.ams_math_package())

# 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.