Skip to content

Commit

Permalink
added let m&n>= question
Browse files Browse the repository at this point in the history
  • Loading branch information
saileshp56 committed Jan 12, 2022
1 parent efd5d9b commit d413041
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 13 deletions.
Empty file.
71 changes: 71 additions & 0 deletions dynamic/generators/comp2804/let_m_and_n/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import random


def generate_question():
# generate required data
k = random.randint(2, 4) # value of k, m and n

# generate required content

question_body = (
"Let $m \geq "
+ str(k)
+ "$ and $n \geq "
+ str(k)
+ "$ be integers. What does $${{m}\choose{"
+ str(k)
+ "}} + {{n}\choose{"
+ str(k)
+ "}} + m\cdot n$$ count?"
)

answer_options = [
"The number of ways to choose a subset from a set consisting of $m + n$ elements.",
"The number of ways to choose an ordered pair of {} elements from a set consisting of $m + n$ elements.".format(
k
),
"The number of ways to choose a {}-element subset from a set consisting of $m + n$ elements.".format(
k
),
"None of the above.",
]
for answer in answer_options:
if "-element" in answer:
correct_answer = answer

# return generated question
return {
"title": "set_theory_question",
"body": question_body,
"bodyFormat": "text",
"pseudocode": "",
"multipleChoiceAnswers": [
{
"body": answer_options[0],
"bodyFormat": "mathjax",
"correct": "true",
},
{
"body": answer_options[1],
"bodyFormat": "mathjax",
"correct": "false",
},
{
"body": correct_answer,
"bodyFormat": "mathjax",
"correct": "false",
},
{
"body": answer_options[3],
"bodyFormat": "mathjax",
"correct": "false",
},
],
}


def call():
return generate_question()


print(call())
31 changes: 18 additions & 13 deletions dynamic/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
import generators.comp2804.set_theory_question.main as set_theory_question_generator
import generators.comp2804.num_of_functions.main as num_of_functions_generator
import generators.comp2804.bitstrings_of_length.main as bitstrings_of_length_generator
import generators.comp2804.let_m_and_n.main as m_and_n_generator


router = APIRouter(
prefix="/api", tags=["generate"], responses={404: {"description": "Not found"}}
)


routes = {
'demo': {
'graph_theory': "/demo/graph-theory"
"demo": {"graph_theory": "/demo/graph-theory"},
"comp2804": {
"bitstrings-of-length": "/comp2804/bitstrings-of-length",
"set-theory-question": "/comp2804/set-theory",
"num-of-functions": "/comp2804/num-of-functions",
"let-m-and-n-question": "/comp2804/let-m-and-n",
},
'comp2804': {
'bitstrings-of-length': "/comp2804/bitstrings-of-length",
'set-theory-question': "/comp2804/set-theory",
'num-of-functions': "/comp2804/num-of-functions"
}

}


Expand All @@ -27,23 +27,28 @@ async def get_generators():
return routes


@router.get(routes['demo']['graph_theory'])
@router.get(routes["demo"]["graph_theory"])
async def generate_graph_theory_question():
return graph_theory_question_generator.call()


@router.get(routes['comp2804']['set-theory-question'])
@router.get(routes["comp2804"]["set-theory-question"])
async def generate_set_theory_question():
return set_theory_question_generator.call()


@router.get(routes['comp2804']['num-of-functions'])
@router.get(routes["comp2804"]["num-of-functions"])
async def generate_num_of_functions_question(
lower_range: int = 0, upper_range: int = 10
):
return num_of_functions_generator.call(lower_range, upper_range)


@router.get(routes['comp2804']['bitstrings-of-length'])
async def bitstrings_of_length_question():
@router.get(routes["comp2804"]["bitstrings-of-length"])
async def generate_bitstrings_of_length_question():
return bitstrings_of_length_generator.call()


@router.get(routes["comp2804"]["let-m-and-n-question"])
async def generate_m_and_n_question():
return m_and_n_generator.call()

0 comments on commit d413041

Please sign in to comment.