~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/tutorial/service.py

Fix retrieval of old exercise attempts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
        if user is None:
132
132
            raise NotFound()
133
133
 
134
 
        #try:
135
 
        #    date = datetime.datetime.strptime(date, TIMESTAMP_FORMAT)
136
 
        #except ValueError:
137
 
        #    raise NotFound()
 
134
        try:
 
135
            date = datetime.datetime.strptime(date, TIMESTAMP_FORMAT)
 
136
        except ValueError:
 
137
            raise NotFound()
138
138
 
139
139
        worksheet_exercise = req.store.find(WorksheetExercise,
140
140
            WorksheetExercise.exercise_id == exercise,
147
147
            Semester.year == year,
148
148
            Semester.semester == semester).one()
149
149
            
150
 
        attempt = req.store.find(ExerciseAttempt,
151
 
            ExerciseAttempt.user_id == user.id,
152
 
            ExerciseAttempt.ws_ex_id == worksheet_exercise.id,
153
 
            ExerciseAttempt.date == date
154
 
        ).one()
 
150
        attempt = ivle.worksheet.get_exercise_attempt(req.store, user,
 
151
                        worksheet_exercise, as_of=date,
 
152
                        allow_inactive=HISTORY_ALLOW_INACTIVE) 
155
153
 
156
154
        if attempt is None:
157
155
            raise NotFound()