def createDummy(self): """ currently logged-in user must be manager level """ portal = self.portal # dummy = ECQuiz(oid='dummy') # # put dummy in context of portal # dummy = dummy.__of__(portal) # portal.dummy = dummy # dummy.initializeArchetype() # return dummy dummy = self.createEmptyQuiz() # Create an MC question mcq = createObject(dummy, 'ECQMCQuestion', 'mcq') # Set up the question's properties setProps(mcq, (('allowMultipleSelection', False), ('randomOrder', False), ('numberOfRandomAnswers', 0), ('points', 666), ('tutorGraded', False), )) # Create MC answers for uid, comm, corr, answ in (('mca1', 'Correct comment', True, 'This is correct.'), ('mca2', 'Wrong comment', False, 'This is wrong.' ), ): mca = createObject(mcq, 'ECQMCAnswer', uid) # Set up the answer's properties setProps(mca, (('comment', comm), ('correct', corr), ('answer', answ), )) # publish the thing wtool = portal.portal_workflow wtool.doActionFor(dummy, 'publish') return dummy
def createDummy(self): self.login("manager") portal = self.portal # dummy = ECQuiz(oid='dummy') # # put dummy in context of portal # dummy = dummy.__of__(portal) # portal.dummy = dummy # dummy.initializeArchetype() # return dummy dummy = createObject(self.portal, "ECQuiz", "dummy") portal.dummy = dummy # Set up the test's properties setProps( dummy, ( ("instantFeedback", False), ("allowRepetition", False), ("onePerPage", False), ("onePerPageNav", False), ("scoringFunction", "cruel"), # ('gradingScale', ()), ("directions", "Please answer these questions!"), ("randomOrder", False), ("numberOfRandomQuestions", 0), ), ) # Create an MC question mcq = createObject(dummy, "ECQMCQuestion", "mcq") # Set up the question's properties setProps( mcq, ( ("allowMultipleSelection", False), ("randomOrder", False), ("numberOfRandomAnswers", 0), ("points", 666), ("tutorGraded", False), ), ) # Create MC answers for uid, comm, corr, answ in ( ("mca1", "Correct comment", True, "This is correct."), ("mca2", "Wrong comment", False, "This is wrong."), ): mca = createObject(mcq, "ECQMCAnswer", uid) # Set up the answer's properties setProps(mca, (("comment", comm), ("correct", corr), ("answer", answ))) # publish the thing wtool = portal.portal_workflow wtool.doActionFor(dummy, "publish") return dummy
def createEmptyQuiz(self): """ currently logged-in user must be manager level """ portal = self.portal dummy = createObject(self.portal, 'ECQuiz', 'dummy') portal.dummy = dummy # Set up the test's properties setProps(dummy, (('instantFeedback', False), ('allowRepetition', False), ('onePerPage', False), ('onePerPageNav', False), ('scoringFunction', 'cruel'), #('gradingScale', ()), ('directions', 'Please answer these questions!'), ('randomOrder', False), ('numberOfRandomQuestions', 0),)) return dummy