def parse_exam(self): """ Parse an exam definition from the given source """ try: builder = ExamBuilder() self.exam = builder.exam_from_string(self.options.source) self.examXML = self.exam.tostring() self.resources = self.exam.resources self.extensions = self.exam.extensions self.custom_part_types = self.exam.custom_part_types except ExamError as err: raise CompileError('Error constructing exam:\n%s' % err) except examparser.ParseError as err: raise CompileError("Failed to compile exam due to parsing error.\n%s" % err) except: raise CompileError('Failed to compile exam.')