Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added let m&n>= question #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
10 changes: 9 additions & 1 deletion dynamic/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
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"}}
Expand All @@ -26,6 +28,7 @@
"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",
},
}

Expand Down Expand Up @@ -77,5 +80,10 @@ async def generate_num_of_functions_question(


@router.get(routes["comp2804"]["bitstrings-of-length"])
async def bitstrings_of_length_question():
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()