From 5f6fd3b80b837873522a9819f057327842299232 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Wed, 6 Nov 2024 08:04:38 -0500 Subject: [PATCH] Added support for split multiple choice questions when not doing a quiz and fixed formatting when the questions weren't split. --- mkt.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mkt.py b/mkt.py index 6b65dc2f..a8489b21 100755 --- a/mkt.py +++ b/mkt.py @@ -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 @@ -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 @@ -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 @@ -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: @@ -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")