Example #1
0
def generate_exam():
    """Generate an exam with multiple questions, with solutions for each question!

    It's quite simple for now.
    """

    cur_dir = os.path.split(__file__)[0]
    questions_dir = os.path.join(cur_dir, 'maths', 'questions')
    question_paths = api.get_question_paths(questions_dir)

    question_modules = api.import_question_modules(question_paths)

    with open('exam.tex', 'w') as exam_file:
        latex.begin_tex_document(exam_file)

        for question in question_modules:
            possible_questions = relationships.parse_structure(question)

            for i in possible_questions:
                i.write_question(exam_file)

                latex.decrement_question_counter(exam_file)

                i.write_solution(exam_file)
                latex.new_page(exam_file)

        latex.end_tex_document(exam_file)
Example #2
0
def random_question():
    """Serve a random question along with its solution.
    """

    questions_dir = get_questions_dir()
    question_paths = get_question_paths(questions_dir)
    question_modules = import_question_modules(question_paths)

    choice = random.choice(question_modules)
    built_question = relationships.parse_structure(choice)[0]

    return {
        'question': built_question.question_statement(),
        'solution': built_question.solution_statement()
    }
Example #3
0
def random_question():
    """Serve a random question along with its solution.
    """

    questions_dir = get_questions_dir()
    question_paths = get_question_paths(questions_dir)
    question_modules = import_question_modules(question_paths)

    choice = random.choice(question_modules)
    built_question = relationships.parse_structure(choice)[0]

    return {
        'question': built_question.question_statement(),
        'solution': built_question.solution_statement()
    }
import importlib
from maths.questions import relationships
from maths.questions.tests import question_tester


if __name__ == '__main__':
    module_path = sys.argv[1]
    project_path = sys.argv[2]

    module_name = os.path.split(module_path)[1]
    module_name = os.path.splitext(module_name)[0]

    relative_path = os.path.relpath(module_path, __file__)
    relative_path = os.path.split(relative_path)[0]
    relative_path = relative_path.replace('..', '.')
    relative_path = relative_path.replace('/', '')

    script_name = os.path.relpath(module_path, project_path).replace('/', '.')[:-3]
    module = importlib.import_module(script_name)

    question = relationships.parse_structure(module)

    try:
        with open(os.devnull, 'w') as fnull:
            # raises EV_IS_DOCUMENT error due to a bug in evince, which is fixed in an upcoming version of evince
            # https://bugs.launchpad.net/ubuntu/+source/evince/+bug/1247208
            subprocess.call(['killall', 'evince'], stdout=fnull, stderr=fnull)
        question_tester.question_tester(question, view_output=True)
    except Exception as e:
        raise e
Example #5
0
def test_linear_approximation():
    question = relationships.parse_structure(linear_approximation)
    question_tester(question)
Example #6
0
def test_simple_trig_solve():
    question = relationships.parse_structure(simple_trig_solve)
    question_tester(question)
Example #7
0
def test_piecewise():
    question = relationships.parse_structure(piecewise)
    question_tester(question)
Example #8
0
import importlib
from maths.questions import relationships
from maths.questions.tests import question_tester

if __name__ == '__main__':
    module_path = sys.argv[1]
    project_path = sys.argv[2]

    module_name = os.path.split(module_path)[1]
    module_name = os.path.splitext(module_name)[0]

    relative_path = os.path.relpath(module_path, __file__)
    relative_path = os.path.split(relative_path)[0]
    relative_path = relative_path.replace('..', '.')
    relative_path = relative_path.replace('/', '')

    script_name = os.path.relpath(module_path, project_path).replace('/',
                                                                     '.')[:-3]
    module = importlib.import_module(script_name)

    question = relationships.parse_structure(module)

    try:
        with open(os.devnull, 'w') as fnull:
            # raises EV_IS_DOCUMENT error due to a bug in evince, which is fixed in an upcoming version of evince
            # https://bugs.launchpad.net/ubuntu/+source/evince/+bug/1247208
            subprocess.call(['killall', 'evince'], stdout=fnull, stderr=fnull)
        question_tester.question_tester(question, view_output=True)
    except Exception as e:
        raise e
Example #9
0
def test_piecewise_prob_density_function():
    question = relationships.parse_structure(piecewise_prob_density_function)
    question_tester(question)
Example #10
0
def test_simple_inverse():
    question = relationships.parse_structure(simple_inverse)
    question_tester(question)
def test_simple_definite_integral():
    question = relationships.parse_structure(simple_definite_integral)
    question_tester(question)
Example #12
0
def test_trig_properties():
    question = relationships.parse_structure(trig_properties)
    question_tester(question)
Example #13
0
def test_sketch_misc():
    question = relationships.parse_structure(sketch_misc)
    question_tester(question)
Example #14
0
def test_MarkovChain():
    question = relationships.parse_structure(markov_chain)
    question_tester(question)
Example #15
0
def test_definite_integral_equality():
    question = relationships.parse_structure(definite_integral_equality)
    question_tester(question)
Example #16
0
def test_log_misc():
    question = relationships.parse_structure(log_misc)
    question_tester(question)
Example #17
0
def test_prob_table_unknown():
    question = relationships.parse_structure(prob_table_unknown)
    question_tester(question)
Example #18
0
def test_worded_definite_integral():
    question = relationships.parse_structure(worded_definite_integral)
    question_tester(question)
Example #19
0
def test_simple_diff():
    question = relationships.parse_structure(simple_diff)
    question_tester(question)
Example #20
0
def test_antiderivative():
    question = relationships.parse_structure(antiderivative)
    question_tester(question)