raiseQuestionException("Question %d from section %d (%s) is missing one of the keywords Question, Answer or Type"%(j,i,sec["Section"]))
self._gen_error(filename,"Question %d from section %d (%s) is missing one of the keywords Question, Answer or Type"%(j,i,sec["Section"]))
# check wether the question is a string (else we'll get display errors)
iftype(q["Question"])!=str:
raiseQuestionException("Question %d from section %d (%s) needs to have a string as question (put the Question in \"\")"%(j,i,sec["Section"]))
print(type(q["Question"]))
self._gen_error(filename,"Question %d from section %d (%s) needs to have a string as question (put the Question in \"\")"%(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))
self._gen_error(filename,"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 if 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"]))
self._gen_error(filename,"The Double-Jeopardy key from question %d from section %d (%s) must be either true or false"%(j,i,sec["Section"]))
# check Audio is a bool and is set to false if non-existant
if"Audio"notinq.keys():
q["Audio"]=False
eliftype(q["Audio"])!=bool:
raiseQuestionException("The Audio key from question %d from section %d (%s) must be either true or false"%(j,i,sec["Section"]))
self._gen_error(filename,"The Audio 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.QUESTION_TYPES)))
self._gen_error(filename,"Question %d from Section %d (%s) has an invalid type '%s' (valid types are %s)"%(j,i,sec["Section"],q["Type"],", ".join(self.QUESTION_TYPES)))