raiseQuestionException("Qestion %d from section %d (%s) has invalid keyword '%s'"%(j,i,sec["Section"],key))
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
# check Double-Jeopardy is a bool and is set to false if non-existant
if"Double-Jeopardy"notinq.keys():
if"Double-Jeopardy"notinq.keys():
q["Double-Jeopardy"]=False
q["Double-Jeopardy"]=False
eliftype(q["Double-Jeopardy"])!=bool:
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"]))
raiseQuestionException("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"]))
# check for broken question types
# check for broken question types
ifq["Type"]notinself.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)))
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)))
# check if file for music/image questions exist
# check if file for music/image questions exist
ifq["Type"]in("Music","Image"):
ifq["Type"]in("Music","Image", "Video"):
ifnotos.path.isfile(q["Question"]):
ifnotos.path.isfile(q["Question"]):
raiseQuestionException("File for question %d, section %d (%s) not found"%(j,i,sec["Section"]))
raiseQuestionException("File for question %d, section %d (%s) not found"%(j,i,sec["Section"]))