raiseQuestionException("Question %d from section %d (%s) is missing one of the keywords Question, Answer or Type"%(j,i,sec["Section"]))
# check for keys we do not know
forkeyinq.keys():
ifkeynotinself.QUESTION_KEYS:
raiseQuestionException("Qestion %d from section %d (%s) has invalid keyword '%s'"%(j,i,sec["Section"],key))
# check Double-Jeopardy is a bool and is set to false it non-existant
if"Double-Jeopardy"notinq.keys():
q["Double-Jeopardy"]=False
eliftype(q["Double-Jeopardy"])!=bool:
raiseQuestionException("The Double-Jeopardy key from question %d from section %d (%s) must be either true or false"%(j,i,sec["Section"]))
# check for broken question types
ifq["Type"]notinself.QUESTION_TYPES:
raiseQuestionException("Question %d from Section %d (%s) has an invalid type '%s' (valid types are %s)"%(j,i,sec["Section"],q["Type"],", ".join(self.VALID_TYPES)))
# check if file for music/image questions exist
ifq["Type"]in("Music","Image"):
ifnotos.path.isfile(q["Question"]):
raiseQuestionException("File for question %d, section %d (%s) not found"%(j,i,sec["Section"]))
# check if this section has enough questions
ifj!=5:
raiseQuestionException("Section %d (%s) needs to have exactly %d questions (has %d)"%(i,sec["Section"],5,j))