def _importedXml(self, evaluation, params): """ Importation of an evaluation. Note: original 'isVisible' and the dates are kept. """ try: xmlString = params["xmlFile"].file.read() except AttributeError: #no file given self._redirect( urlHandlers.UHConfModifEvaluationSetup.getURL(self._conf)) return try: doc = parseString(xmlString) except: raise MaKaCError( _("""System can't import an evaluation from your file. Be sure to import the right XML file."""), _("evaluation")) #parse begins evalNode = self._getElement(doc, "evaluation") if params.get("configOption", "") == "imported": #parse node /evaluation/ title = self._getValue(evalNode, "title") announcement = self._getValue(evalNode, "announcement") submissionsLimit = self._getValue(evalNode, "submissionsLimit") contactInfo = self._getValue(evalNode, "contactInfo") mandatoryAccount = self._getValue(evalNode, "mandatoryAccount") mandatoryParticipant = self._getValue(evalNode, "mandatoryParticipant") anonymous = self._getValue(evalNode, "anonymous") evaluation.setTitle(title) evaluation.setAnnouncement(announcement) evaluation.setSubmissionsLimit(submissionsLimit) evaluation.setContactInfo(contactInfo) evaluation.setMandatoryAccount(mandatoryAccount) evaluation.setMandatoryParticipant(mandatoryParticipant) if anonymous.strip() == "": evaluation.setAnonymous(True) else: evaluation.setAnonymous(anonymous) #parse node /evaluation/notifications/ notificationsNode = self._getElement(evalNode, "notifications") evaluation.removeAllNotifications() for notificationNode in notificationsNode.childNodes: if isinstance(notificationNode, Element): from MaKaC.registration import Notification notification = Notification() toList = self._getValue(notificationNode, "toList") ccList = self._getValue(notificationNode, "ccList") notification.setToList(utils.getEmailList(toList)) notification.setCCList(utils.getEmailList(ccList)) evaluation.setNotification(notificationNode.tagName, notification) if params.get("questionsOption", "") != "current": # in ["imported", "both"] if params.get("questionsOption", "") == "imported": evaluation.removeAllQuestions() #parse node /evaluation/questions/ questionsNode = self._getElement(evalNode, "questions") for questionNode in questionsNode.childNodes: if isinstance(questionNode, Element): questionValue = self._getValue(questionNode, "questionValue") keyword = self._getValue(questionNode, "keyword") required = self._getValue(questionNode, "required") description = self._getValue(questionNode, "description") help = self._getValue(questionNode, "help") try: question = eval(questionNode.tagName)() if isinstance(question, Question): question.setQuestionValue(questionValue) question.setKeyword(keyword) question.setRequired(required) question.setDescription(description) question.setHelp(help) evaluation.insertQuestion(question) except NameError: raise MaKaCError( _("""xml parse error: unknown question type "%s" """) % questionNode.tagName, _("evaluation")) if isinstance(question, Box): defaultAnswer = self._getValue(questionNode, "defaultAnswer") question.setDefaultAnswer(defaultAnswer) elif isinstance(question, Choice): #parse node /evaluation/questions/*/choiceItems/ choiceItemsNode = self._getElement( questionNode, "choiceItems") for choiceItemNode in choiceItemsNode.childNodes: if isinstance(choiceItemNode, Element): itemText = self._getValue( choiceItemNode, "itemText") if itemText.strip() != "": isSelected = self._getValue( choiceItemNode, "isSelected") question.insertChoiceItem( itemText, isSelected)
def _importedXml(self, evaluation, params): """ Importation of an evaluation. Note: original 'isVisible' and the dates are kept. """ try: xmlString = params["xmlFile"].file.read() except AttributeError: #no file given self._redirect(urlHandlers.UHConfModifEvaluationSetup.getURL(self._conf)) return try: doc = parseString(xmlString) except: raise MaKaCError( _("""System can't import an evaluation from your file. Be sure to import the right XML file."""), _("evaluation")) #parse begins evalNode = self._getElement(doc,"evaluation") if params.get("configOption","")=="imported": #parse node /evaluation/ title = self._getValue(evalNode,"title") announcement = self._getValue(evalNode,"announcement") submissionsLimit = self._getValue(evalNode,"submissionsLimit") contactInfo = self._getValue(evalNode,"contactInfo") mandatoryAccount = self._getValue(evalNode,"mandatoryAccount") mandatoryParticipant = self._getValue(evalNode,"mandatoryParticipant") anonymous = self._getValue(evalNode,"anonymous") evaluation.setTitle(title) evaluation.setAnnouncement(announcement) evaluation.setSubmissionsLimit(submissionsLimit) evaluation.setContactInfo(contactInfo) evaluation.setMandatoryAccount(mandatoryAccount) evaluation.setMandatoryParticipant(mandatoryParticipant) if anonymous.strip()=="" : evaluation.setAnonymous(True) else : evaluation.setAnonymous(anonymous) #parse node /evaluation/notifications/ notificationsNode = self._getElement(evalNode, "notifications") evaluation.removeAllNotifications() for notificationNode in notificationsNode.childNodes : if isinstance(notificationNode, Element) : from MaKaC.registration import Notification notification = Notification() toList = self._getValue(notificationNode,"toList") ccList = self._getValue(notificationNode,"ccList") notification.setToList( utils.getEmailList(toList) ) notification.setCCList( utils.getEmailList(ccList) ) evaluation.setNotification(notificationNode.tagName, notification) if params.get("questionsOption","")!="current" : # in ["imported", "both"] if params.get("questionsOption","")=="imported" : evaluation.removeAllQuestions() #parse node /evaluation/questions/ questionsNode = self._getElement(evalNode,"questions") for questionNode in questionsNode.childNodes : if isinstance(questionNode, Element): questionValue= self._getValue(questionNode,"questionValue") keyword = self._getValue(questionNode,"keyword") required = self._getValue(questionNode,"required") description = self._getValue(questionNode,"description") help = self._getValue(questionNode,"help") try: question = eval(questionNode.tagName)() if isinstance(question, Question): question.setQuestionValue(questionValue) question.setKeyword(keyword) question.setRequired(required) question.setDescription(description) question.setHelp(help) evaluation.insertQuestion(question) except NameError: raise MaKaCError( _("""xml parse error: unknown question type "%s" """)%questionNode.tagName, _("evaluation")) if isinstance(question, Box): defaultAnswer= self._getValue(questionNode,"defaultAnswer") question.setDefaultAnswer(defaultAnswer) elif isinstance(question, Choice): #parse node /evaluation/questions/*/choiceItems/ choiceItemsNode = self._getElement(questionNode,"choiceItems") for choiceItemNode in choiceItemsNode.childNodes : if isinstance(choiceItemNode, Element): itemText = self._getValue(choiceItemNode,"itemText") if itemText.strip()!="" : isSelected = self._getValue(choiceItemNode,"isSelected") question.insertChoiceItem(itemText, isSelected)
).getParticipation().getParticipantList(): email = participant.getEmail() if email not in evaluationStartNotifyTo: evaluationStartNotifyTo.append(email) else: #Event == Conference for registrant in evaluation.getConference( ).getRegistrantsList(): email = registrant.getEmail() if email not in evaluationStartNotifyTo: evaluationStartNotifyTo.append(email) if len(evaluationStartNotifyTo + evaluationStartNotifyCc) < 1: evaluation.removeNotification(Evaluation._EVALUATION_START) else: evaluationStartNotification = Notification() evaluationStartNotification.setToList(evaluationStartNotifyTo) evaluationStartNotification.setCCList(evaluationStartNotifyCc) evaluation.setNotification(Evaluation._EVALUATION_START, evaluationStartNotification) if len(newSubmissionNotifyTo + newSubmissionNotifyCc) < 1: evaluation.removeNotification(Evaluation._NEW_SUBMISSION) else: newSubmissionNotification = Notification() newSubmissionNotification.setToList(newSubmissionNotifyTo) newSubmissionNotification.setCCList(newSubmissionNotifyCc) evaluation.setNotification(Evaluation._NEW_SUBMISSION, newSubmissionNotification) #redirecting... self._redirect( urlHandlers.UHConfModifEvaluationSetup.getURL(self._conf))
if self.getWebFactory()!=None : #Event == Meeting/Lecture for participant in evaluation.getConference().getParticipation().getParticipantList() : email = participant.getEmail() if email not in evaluationStartNotifyTo : evaluationStartNotifyTo.append(email) else : #Event == Conference for registrant in evaluation.getConference().getRegistrantsList() : email = registrant.getEmail() if email not in evaluationStartNotifyTo : evaluationStartNotifyTo.append(email) if len( evaluationStartNotifyTo + evaluationStartNotifyCc ) < 1 : evaluation.removeNotification(Evaluation._EVALUATION_START) else : evaluationStartNotification = Notification() evaluationStartNotification.setToList(evaluationStartNotifyTo) evaluationStartNotification.setCCList(evaluationStartNotifyCc) evaluation.setNotification(Evaluation._EVALUATION_START, evaluationStartNotification) if len( newSubmissionNotifyTo + newSubmissionNotifyCc ) < 1 : evaluation.removeNotification(Evaluation._NEW_SUBMISSION) else : newSubmissionNotification = Notification() newSubmissionNotification.setToList(newSubmissionNotifyTo) newSubmissionNotification.setCCList(newSubmissionNotifyCc) evaluation.setNotification(Evaluation._NEW_SUBMISSION, newSubmissionNotification) #redirecting... self._redirect(urlHandlers.UHConfModifEvaluationSetup.getURL(self._conf)) class RHEvaluationEdit(RHEvaluationBase): """Edition of questions of an Evaluation."""