Skip to content

Commit

Permalink
Added support for split multiple choice questions when not doing a qu…
Browse files Browse the repository at this point in the history
…iz and fixed formatting when the questions weren't split.
  • Loading branch information
jsb2092 committed Nov 6, 2024
1 parent be6bda5 commit 5f6fd3b
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions mkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class MKT:
# quiz mode has no cover page
quiz = False

# whether to split multiple choice questions into multiple columns (this is a default for quizzes)
splitMultipleChoice = False

# add an ID to the test
id = False

Expand Down Expand Up @@ -116,6 +119,13 @@ def __init__(self, args):

if "quiz" in config and config["quiz"].lower() == "true":
self.quiz = True
self.splitMultipleChoice = True

if "splitMultipleChoice" in config:
if config["splitMultipleChoice"].lower() == "true":
self.splitMultipleChoice = True
else:
self.splitMultipleChoice = False

if "includeID" in config and config["includeID"].lower() == "true":
self.id = True
Expand Down Expand Up @@ -491,7 +501,7 @@ def parseTestSettings(self, c, config):
if c in ["test", "instructor", "courseName", "courseNumber", "term", "note",
"school", "department", "nameOnEveryPage", "defaultPoints",
"defaultSolutionSpace", "useCheckboxes", "defaultLineLength",
"includeID", "useClassicTF", "quiz"]:
"includeID", "useClassicTF", "quiz", "splitMultipleChoice"]:
if not self.mainSettingsStored:
self.mainSettingsStored = True
self.config = config
Expand Down Expand Up @@ -904,7 +914,7 @@ def createMultipleChoiceQuestions(self, of, questions, bonus=None):
answers = self.shuffle(list(answers.items()))

if self.config["useCheckboxes"].lower() == "true":
if self.quiz:
if self.splitMultipleChoice:
of.write("\\\\ \\begin{oneparcheckboxes}\n")

else:
Expand All @@ -913,16 +923,16 @@ def createMultipleChoiceQuestions(self, of, questions, bonus=None):
align = "\\makebox[5cm][l]{"
lineBreakOnEach = False
for a, b in answers:
if len(a) > 15:
if len(a) > 30:
lineBreakOnEach = True

for a, b in answers:
count+=1
of.write("\\%s %s %s}\n" % (b, align, a))
if (count % 2==0 or lineBreakOnEach) and not count == len(answers):
if (count % 2==0 or lineBreakOnEach) and not count == len(answers) and (self.splitMultipleChoice):
of.write("\\\\")

if self.quiz:
if self.splitMultipleChoice:
of.write("\\end{oneparcheckboxes}\n")
else:
of.write("\\end{checkboxes}\n\n\n")
Expand Down

0 comments on commit 5f6fd3b

Please sign in to comment.