93 'grading_project_surveys_total': grading_survey_count, |
96 'grading_project_surveys_total': grading_survey_count, |
94 'grading_project_surveys_completed': grading_record_count} |
97 'grading_project_surveys_completed': grading_record_count} |
95 |
98 |
96 return info |
99 return info |
97 return wrapper |
100 return wrapper |
|
101 |
|
102 |
|
103 def getProjectSurveyInfoForProject(project_entity, survey_params): |
|
104 """Returns a function that returns info for listing Surveys and if possible |
|
105 their accompanying record. |
|
106 |
|
107 Args: |
|
108 project_entity: a StudentProject entity |
|
109 survey_params: params for the view of the type of Survey that is listed |
|
110 """ |
|
111 |
|
112 survey_logic = survey_params['logic'] |
|
113 record_logic = survey_logic.getRecordLogic() |
|
114 |
|
115 def wrapper(survey_entity, _): |
|
116 """Wrapper method. |
|
117 |
|
118 Args: |
|
119 survey_entity: a ProjectSurvey (or subclass) entity |
|
120 """ |
|
121 |
|
122 # try to retrieve the SurveyRecord for the given Survey and Project |
|
123 fields = {'survey': survey_entity, |
|
124 'project': project_entity} |
|
125 record_entity = record_logic.getForFields(fields, unique=True) |
|
126 |
|
127 info = {'record': record_entity} |
|
128 |
|
129 if record_entity: |
|
130 # SurveyRecord has been found store the import data in info |
|
131 info['taken_by'] = record_entity.user.name |
|
132 info['taken_on'] = record_entity.modified |
|
133 else: |
|
134 info['taken_by'] = 'No Record Available' |
|
135 info['taken_on'] = 'No Record Available' |
|
136 |
|
137 take_redirect_info = {'survey': survey_entity, |
|
138 'params': survey_params} |
|
139 info['take_url'] = redirects.getTakeProjectSurveyRedirect( |
|
140 project_entity, take_redirect_info) |
|
141 |
|
142 return info |
|
143 return wrapper |