30 from google.appengine.ext import db |
30 from google.appengine.ext import db |
31 |
31 |
32 from django.utils.translation import ugettext |
32 from django.utils.translation import ugettext |
33 |
33 |
34 import soc.models.work |
34 import soc.models.work |
|
35 from soc.models.program import Program |
35 |
36 |
36 |
37 |
37 class SurveyContent(db.Expando): |
38 class SurveyContent(db.Expando): |
38 """Fields (questions) and schema representation of a Survey. |
39 """Fields (questions) and schema representation of a Survey. |
39 |
40 |
93 SURVEY_ACCESS = ['admin', 'restricted', 'member', 'user'] |
94 SURVEY_ACCESS = ['admin', 'restricted', 'member', 'user'] |
94 |
95 |
95 # these are GSoC specific, so eventually we can subclass this |
96 # these are GSoC specific, so eventually we can subclass this |
96 SURVEY_TAKING_ACCESS = ['student', |
97 SURVEY_TAKING_ACCESS = ['student', |
97 'mentor', |
98 'mentor', |
98 'student evaluation', |
|
99 'mentor evaluation', |
|
100 'org_admin', |
99 'org_admin', |
101 'user', |
100 'user', |
102 'public'] |
101 'public'] |
103 GRADE_OPTIONS = {'midterm':['mid_term_passed', 'mid_term_failed'], |
102 GRADE_OPTIONS = {'midterm':['mid_term_passed', 'mid_term_failed'], |
104 'final':['final_passed', 'final_failed'], |
103 'final':['final_passed', 'final_failed'], |
105 'N/A':[] } |
104 'N/A':[] } |
|
105 |
106 prefix = db.StringProperty(default='program', required=True, |
106 prefix = db.StringProperty(default='program', required=True, |
107 choices=['site', 'club', 'sponsor', 'program', 'org', 'user'], |
107 choices=['site', 'club', 'sponsor', 'program', 'org', 'user'], |
108 verbose_name=ugettext('Prefix')) |
108 verbose_name=ugettext('Prefix')) |
109 prefix.help_text = ugettext( |
109 prefix.help_text = ugettext( |
110 'Indicates the prefix of the survey,' |
110 'Indicates the prefix of the survey,' |
154 ' cannot be taken.') |
154 ' cannot be taken.') |
155 |
155 |
156 #: Referenceproperty that specifies the content of this survey. |
156 #: Referenceproperty that specifies the content of this survey. |
157 survey_content = db.ReferenceProperty(SurveyContent, |
157 survey_content = db.ReferenceProperty(SurveyContent, |
158 collection_name="survey_parent") |
158 collection_name="survey_parent") |
|
159 |
|
160 #: Survey kind, a helper for handling the different classes on creation. |
|
161 survey_kind = db.StringProperty(default='', required=False, |
|
162 choices=('', 'project', 'grading')) |
|
163 |
|
164 def getRecords(self): |
|
165 """Returns all SurveyRecords belonging to this survey. |
|
166 """ |
|
167 return self.survey_records |
|
168 |
|
169 |
|
170 class ProjectSurvey(Survey): |
|
171 """Survey for Students that have a StudentProject. |
|
172 """ |
|
173 |
|
174 def __init__(self, *args, **kwargs): |
|
175 super(ProjectSurvey, self).__init__(*args, **kwargs) |
|
176 self.prefix = 'program' |
|
177 self.taking_access = 'student' |
|
178 self.scope = Program.get_by_key_name(self.scope_path) |
|
179 |
|
180 def getRecords(self): |
|
181 """Returns all ProjectSurveyRecords belonging to this survey. |
|
182 """ |
|
183 return self.project_survey_records |
|
184 |
|
185 |
|
186 class GradingProjectSurvey(ProjectSurvey): |
|
187 """Survey for Mentors that have a StudentProject. |
|
188 """ |
|
189 |
|
190 def __init__(self, *args, **kwargs): |
|
191 super(GradingProjectSurvey, self).__init__(*args, **kwargs) |
|
192 self.taking_access = 'mentor' |
|
193 |
|
194 def getRecords(self): |
|
195 """Returns all GradingProjectSurveyRecords belonging to this survey. |
|
196 """ |
|
197 return self.grading_survey_records |