208
208
# (Assessable worksheets only, mandatory problems only)
209
209
problems_done = 0
210
210
problems_total = 0
211
for worksheet_from_xml in ctx['worksheets']:
212
worksheet = ivle.database.Worksheet.get_by_name(req.store,
213
subject, worksheet_from_xml.id)
211
ctx['worksheetz'] = []
212
for worksheet in ctx['worksheets']:
213
stored_worksheet = ivle.database.Worksheet.get_by_name(req.store,
214
subject, worksheet.id)
214
215
# If worksheet is not in database yet, we'll simply not display
215
216
# data about it yet (it should be added as soon as anyone visits
216
217
# the worksheet itself).
217
if worksheet is not None:
218
if stored_worksheet is not None:
218
219
# If the assessable status of this worksheet has changed,
220
221
# (Note: This fails the try block if the worksheet is not yet
221
222
# in the DB, which is fine. The author should visit the
222
223
# worksheet page to get it into the DB).
223
if worksheet.assessable != worksheet_from_xml.assessable:
224
if worksheet.assessable != stored_worksheet.assessable:
224
225
# XXX If statement to avoid unnecessary database writes.
225
226
# Is this necessary, or will Storm check for us?
226
worksheet.assessable = worksheet_from_xml.assessable
227
stored_worksheet.assessable = worksheet.assessable
227
228
req.store.commit()
228
229
if worksheet.assessable:
229
230
# Calculate the user's score for this worksheet
230
231
mand_done, mand_total, opt_done, opt_total = (
231
232
ivle.worksheet.calculate_score(req.store, req.user,
233
234
if opt_total > 0:
234
235
optional_message = " (excluding optional exercises)"