From: davismr <svn...@pl...> - 2006-07-24 17:23:37
|
Author: davismr Date: Mon Jul 24 17:23:32 2006 New Revision: 26395 Modified: PloneSurvey/trunk/content/Survey.py PloneSurvey/trunk/content/SurveyMatrix.py PloneSurvey/trunk/skins/plone_survey/question_matrix_macro.pt PloneSurvey/trunk/skins/plone_survey/survey_view_results.pt PloneSurvey/trunk/skins/plone_survey/validate_survey.vpy Log: Add mnethods and fixes for survey matrix Modified: PloneSurvey/trunk/content/Survey.py ============================================================================== --- PloneSurvey/trunk/content/Survey.py (original) +++ PloneSurvey/trunk/content/Survey.py Mon Jul 24 17:23:32 2006 @@ -243,6 +243,21 @@ full_objects=True) return questions + security.declareProtected(CMFCorePermissions.View, 'getQuestionsForAnswers') + def getQuestionsForAnswers(self): + """Return the questions for this part of the survey""" + questions = self.getFolderContents( + contentFilter={'portal_type':[ + 'Survey Question', + 'Survey Likert Question', + 'Survey Matrix', + 'Survey Matrix Question', + 'Survey Select Question', + 'Survey Text Question', + ]}, + full_objects=True) + return questions + security.declareProtected(CMFCorePermissions.View, 'getAllQuestions') def getAllQuestions(self): """Return all the questions in the survey""" Modified: PloneSurvey/trunk/content/SurveyMatrix.py ============================================================================== --- PloneSurvey/trunk/content/SurveyMatrix.py (original) +++ PloneSurvey/trunk/content/SurveyMatrix.py Mon Jul 24 17:23:32 2006 @@ -6,8 +6,9 @@ from Products.CMFCore.utils import getToolByName from Products.PloneSurvey.config import SELECT_INPUT_TYPE +from Products.PloneSurvey.content.BaseQuestion import BaseQuestion, BaseQuestionSchema -schema = BaseSchema + Schema(( +schema = BaseQuestionSchema + Schema(( StringField('abstract', searchable=1, @@ -54,7 +55,7 @@ )) -class SurveyMatrix(OrderedBaseFolder): +class SurveyMatrix(BaseQuestion, OrderedBaseFolder): """A matrix of questions within a survey""" schema = schema #actions = Actions @@ -78,6 +79,11 @@ def setAbstract(self, val, **kw): self.setDescription(val) + security.declareProtected(CMFCorePermissions.View, 'getRequired') + def getRequired(self): + """Return nothing to sidestep validation""" + return 0 + security.declareProtected(CMFCorePermissions.View, 'getQuestions') def getQuestions(self): """Return the questions for this part of the survey""" Modified: PloneSurvey/trunk/skins/plone_survey/question_matrix_macro.pt ============================================================================== --- PloneSurvey/trunk/skins/plone_survey/question_matrix_macro.pt (original) +++ PloneSurvey/trunk/skins/plone_survey/question_matrix_macro.pt Mon Jul 24 17:23:32 2006 @@ -6,7 +6,8 @@ tal:define="matrix_questions question/getQuestions; qid question/getId; helpid string:${qid}_help; - error errors/?qid|nothing"> + error errors/?qid|nothing" + tal:condition="matrix_questions"> <label tal:attributes="for qid" tal:content="question/Title" /> @@ -20,7 +21,8 @@ <div tal:content="error" /> - <table tal:define="hasOptions python: hasattr(question, 'getAnswerOptions') and len(question.getAnswerOptions()) > 0; + <table border="1" + tal:define="hasOptions python: hasattr(question, 'getAnswerOptions') and len(question.getAnswerOptions()) > 0; options question/getAnswerOptions; input_type question/getInputType"> <tr> Modified: PloneSurvey/trunk/skins/plone_survey/survey_view_results.pt ============================================================================== --- PloneSurvey/trunk/skins/plone_survey/survey_view_results.pt (original) +++ PloneSurvey/trunk/skins/plone_survey/survey_view_results.pt Mon Jul 24 17:23:32 2006 @@ -59,7 +59,7 @@ </tal:help> <table> <tr> - <td tal:condition="python:question.meta_type != 'SurveyTextQuestion'"> + <td tal:condition="python:question.meta_type not in ['SurveyTextQuestion', 'SurveyMatrix']"> <div metal:use-macro="here/question_barchart/macros/barchart" /> </td> <td valign="top"> Modified: PloneSurvey/trunk/skins/plone_survey/validate_survey.vpy ============================================================================== --- PloneSurvey/trunk/skins/plone_survey/validate_survey.vpy (original) +++ PloneSurvey/trunk/skins/plone_survey/validate_survey.vpy Mon Jul 24 17:23:32 2006 @@ -4,7 +4,7 @@ #incNumbers = [] _ = context.translate -for q in context.getQuestions(): +for q in context.getQuestionsForAnswers(): value = form.get(q.getId(), '') if q.getRequired() and not value: state.setError(q.getId(), 'Please provide an answer for this question') |