This file is indexed.

/usr/lib/python2.7/dist-packages/schooltool/gradebook/browser/stests/weighting_categories.txt is in python-schooltool.gradebook 2.6.3-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
Category Weighting
------------------

Log in as manager:

    >>> manager = browsers.manager
    >>> manager.ui.login('manager', 'schooltool')

Administrator checks activity categories available for teachers:

    >>> manager.query.link('School').click()
    >>> manager.query.link('Activity Categories').click()
    >>> for category in manager.query_all.css('tbody tr span'):
    ...     print category.text
    Assignment
    Essay
    Exam
    Homework
    Journal
    Lab
    Presentation
    Project

Now, set up a school year (2005-2006) with a single term (Year):

    >>> manager.ui.schoolyear.add('2005-2006', '2005-09-01', '2006-07-15')
    >>> manager.ui.term.add('2005-2006', 'Year', '2005-09-01', '2006-07-15')

Set up a course:

    >>> manager.ui.course.add('2005-2006', 'Physics I')

Set up persons:

    >>> manager.ui.person.add('Paul', 'Carduner', 'paul', 'pwd')
    >>> manager.ui.person.add('Tom', 'Hoffman', 'tom', 'pwd')
    >>> manager.ui.person.add('Claudia', 'Richter', 'claudia', 'pwd')
    >>> manager.ui.person.add('Stephan', 'Richter', 'stephan', 'pwd')

Set up a section with instructor and students:

    >>> manager.ui.section.add('2005-2006', 'Year', 'Physics I')
    >>> manager.ui.section.instructors.add('2005-2006', 'Year', 'Physics I (1)',
    ...                                    ['stephan'])
    >>> manager.ui.section.students.add('2005-2006', 'Year', 'Physics I (1)',
    ...                                 ['tom', 'claudia', 'paul'])

Log in as teacher and go to his gradebook:

    >>> stephan = browsers.stephan
    >>> stephan.ui.login('stephan', 'pwd')
    >>> stephan.query.link('Gradebook').click()

Add some activities to the default worksheet:

    >>> stephan.query.link('Activity').click()
    >>> stephan.query.id('form-widgets-title').ui.set_value('HW 1')
    >>> stephan.query.id('form-widgets-category').ui.set_value('Homework')
    >>> stephan.query.id('form-widgets-max').clear()
    >>> stephan.query.id('form-widgets-max').ui.set_value('50')
    >>> stephan.query.id('form-buttons-add').click()

    >>> stephan.query.link('Activity').click()
    >>> stephan.query.id('form-widgets-title').ui.set_value('Quiz 1')
    >>> stephan.query.id('form-widgets-category').ui.set_value('Exam')
    >>> stephan.query.id('form-buttons-add').click()

    >>> stephan.query.link('Activity').click()
    >>> stephan.query.id('form-widgets-title').ui.set_value('HW 2')
    >>> stephan.query.id('form-widgets-category').ui.set_value('Homework')
    >>> stephan.query.id('form-widgets-max').clear()
    >>> stephan.query.id('form-widgets-max').ui.set_value('50')
    >>> stephan.query.id('form-buttons-add').click()

    >>> stephan.query.link('Activity').click()
    >>> stephan.query.id('form-widgets-title').ui.set_value('Quiz 2')
    >>> stephan.query.id('form-widgets-category').ui.set_value('Exam')
    >>> stephan.query.id('form-buttons-add').click()

Add grades for the first three activities for Paul:

    >>> stephan.ui.gradebook.worksheet.score('Paul Carduner', 'HW1', '40')
    >>> stephan.ui.gradebook.worksheet.score('Paul Carduner', 'Quiz1', '90')
    >>> stephan.ui.gradebook.worksheet.score('Paul Carduner', 'HW2', '45')

Add grades for the first three activities for Tom:

    >>> stephan.ui.gradebook.worksheet.score('Tom Hoffman', 'HW1', '45')
    >>> stephan.ui.gradebook.worksheet.score('Tom Hoffman', 'Quiz1', '80')
    >>> stephan.ui.gradebook.worksheet.score('Tom Hoffman', 'HW2', '50')

Add grades for the first three activities for Claudia:

    >>> stephan.ui.gradebook.worksheet.score('Claudia Richter', 'HW1', '50')
    >>> stephan.ui.gradebook.worksheet.score('Claudia Richter', 'Quiz1', '95')
    >>> stephan.ui.gradebook.worksheet.score('Claudia Richter', 'HW2', '50')

    >>> stephan.query.name('UPDATE_SUBMIT').click()

By default the Average column is calculated normally:

    >>> stephan.ui.gradebook.worksheet.pprint()
    +----------+
    | *Sheet1* |
    +----------+
    +-----------+------------+-----+-------+-----+-------+-------+-------+
    | Last Name | First Name | HW1 | Quiz1 | HW2 | Quiz2 | Total | Ave.  |
    |           |            | 50  | 100   | 50  | 100   |       |       |
    +-----------+------------+-----+-------+-----+-------+-------+-------+
    | Carduner  | Paul       | 40  | 90    | 45  |       | 175.0 | 87.5% |
    | Hoffman   | Tom        | 45  | 80    | 50  |       | 175.0 | 87.5% |
    | Richter   | Claudia    | 50  | 95    | 50  |       | 195.0 | 97.5% |
    +-----------+------------+-----+-------+-----+-------+-------+-------+

Let's create some category weights for the current worksheet. Note
that the categories are ordered alphabetically.

    >>> def format_category_weight(label, value):
    ...     return "%s: %s" % (label, repr(value))
    >>> def print_category_weights(browser):
    ...     for row in browser.query_all.css('fieldset .row'):
    ...         label = row.query.css('.label span').text
    ...         value = row.query.tag('input').get_attribute('value')
    ...         print format_category_weight(label, value)

    >>> stephan.query.link('Category Weights').click()
    >>> print stephan.query.css('.page .header h2').text
    Edit Category Weights
    >>> print_category_weights(stephan)
    Assignment: u''
    Essay: u''
    Exam: u''
    Homework: u''
    Journal: u''
    Lab: u''
    Presentation: u''
    Project: u''

First we'll show what happens when a value is invalid.  The only valid weights
will be numbers between 0 and 100.

    >>> stephan.query.id('assignment').ui.set_value('bad value')
    >>> stephan.query.name('UPDATE_SUBMIT').click()
    >>> print stephan.query.css('.ui-state-error').text
    icon
    bad value is not a valid weight.

    >>> stephan.query.id('assignment').clear()
    >>> stephan.query.id('assignment').ui.set_value('-1')
    >>> stephan.query.name('UPDATE_SUBMIT').click()
    >>> print stephan.query.css('.ui-state-error').text
    icon
    -1 is not a valid weight.

    >>> stephan.query.id('assignment').clear()
    >>> stephan.query.id('assignment').ui.set_value('101')
    >>> stephan.query.name('UPDATE_SUBMIT').click()
    >>> print stephan.query.css('.ui-state-error').text
    icon
    101 is not a valid weight.

We'll fill in valid values for Assignment, Homework and Exam. Hitting
'Submit' will succeed and return us to the gradebook.  There we will
note the effect of the weighting in the Average column.

    >>> stephan.query.id('assignment').clear()
    >>> stephan.query.id('assignment').ui.set_value('20')
    >>> stephan.query.id('exam').clear()
    >>> stephan.query.id('exam').ui.set_value('50')
    >>> stephan.query.id('homework').clear()
    >>> stephan.query.id('homework').ui.set_value('30')
    >>> stephan.query.name('UPDATE_SUBMIT').click()
    >>> stephan.ui.gradebook.worksheet.pprint()
    +----------+
    | *Sheet1* |
    +----------+
    +-----------+------------+-----+-------+-----+-------+-------+-------+
    | Last Name | First Name | HW1 | Quiz1 | HW2 | Quiz2 | Total | Ave.  |
    |           |            | 50  | 100   | 50  | 100   |       |       |
    +-----------+------------+-----+-------+-----+-------+-------+-------+
    | Carduner  | Paul       | 40  | 90    | 45  |       | 175.0 | 88.1% |
    | Hoffman   | Tom        | 45  | 80    | 50  |       | 175.0 | 85.6% |
    | Richter   | Claudia    | 50  | 95    | 50  |       | 195.0 | 96.9% |
    +-----------+------------+-----+-------+-----+-------+-------+-------+

Finally, we'll test hitting the 'Cancel' button.  It should return to the
gradebook without changing the weights.

    >>> stephan.query.link('Category Weights').click()
    >>> print_category_weights(stephan)
    Assignment: u'20'
    Essay: u''
    Exam: u'50'
    Homework: u'30'
    Journal: u''
    Lab: u''
    Presentation: u''
    Project: u''
    >>> stephan.query.id('exam').clear()
    >>> stephan.query.id('exam').ui.set_value('85')
    >>> stephan.query.name('CANCEL').click()
    >>> stephan.query.link('Category Weights').click()
    >>> print_category_weights(stephan)
    Assignment: u'20'
    Essay: u''
    Exam: u'50'
    Homework: u'30'
    Journal: u''
    Lab: u''
    Presentation: u''
    Project: u''
    >>> stephan.query.name('CANCEL').click()

Let's add a new Assignment activity:

    >>> stephan.query.link('Activity').click()
    >>> stephan.query.id('form-widgets-title').ui.set_value('Experiment')
    >>> stephan.query.id('form-widgets-category').ui.set_value('Assignment')
    >>> stephan.query.id('form-widgets-max').clear()
    >>> stephan.query.id('form-widgets-max').ui.set_value('10')
    >>> stephan.query.id('form-buttons-add').click()

Let's grade the new assignment for Paul and Tom:

    >>> stephan.ui.gradebook.worksheet.score('Paul Carduner', 'Exper', '9')
    >>> stephan.ui.gradebook.worksheet.score('Tom Hoffman', 'Exper', '7')
    >>> stephan.query.name('UPDATE_SUBMIT').click()

Note how the Average changed for Paul and Tom, but not for Claudia:

    >>> stephan.ui.gradebook.worksheet.pprint()
    +----------+
    | *Sheet1* |
    +----------+
    +-----------+------------+-----+-------+-----+-------+-------+-------+-------+
    | Last Name | First Name | HW1 | Quiz1 | HW2 | Quiz2 | Exper | Total | Ave.  |
    |           |            | 50  | 100   | 50  | 100   | 10    |       |       |
    +-----------+------------+-----+-------+-----+-------+-------+-------+-------+
    | Carduner  | Paul       | 40  | 90    | 45  |       | 9     | 184.0 | 88.5% |
    | Hoffman   | Tom        | 45  | 80    | 50  |       | 7     | 182.0 | 82.5% |
    | Richter   | Claudia    | 50  | 95    | 50  |       |       | 195.0 | 96.9% |
    +-----------+------------+-----+-------+-----+-------+-------+-------+-------+

Now, let's give Homeworks the 100% of weight:

    >>> stephan.query.link('Category Weights').click()
    >>> stephan.query.id('assignment').clear()
    >>> stephan.query.id('exam').clear()
    >>> stephan.query.id('homework').clear()
    >>> stephan.query.id('homework').ui.set_value('100')
    >>> stephan.query.name('UPDATE_SUBMIT').click()

Let's go back to check that the values of the weights were stored
correctly:

    >>> stephan.query.link('Category Weights').click()
    >>> print_category_weights(stephan)
    Assignment: u''
    Essay: u''
    Exam: u''
    Homework: u'100'
    Journal: u''
    Lab: u''
    Presentation: u''
    Project: u''
    >>> stephan.query.name('CANCEL').click()

The Averages have changed:

    >>> stephan.ui.gradebook.worksheet.pprint()
    +----------+
    | *Sheet1* |
    +----------+
    +-----------+------------+-----+-------+-----+-------+-------+-------+--------+
    | Last Name | First Name | HW1 | Quiz1 | HW2 | Quiz2 | Exper | Total | Ave.   |
    |           |            | 50  | 100   | 50  | 100   | 10    |       |        |
    +-----------+------------+-----+-------+-----+-------+-------+-------+--------+
    | Carduner  | Paul       | 40  | 90    | 45  |       | 9     | 184.0 | 85.0%  |
    | Hoffman   | Tom        | 45  | 80    | 50  |       | 7     | 182.0 | 95.0%  |
    | Richter   | Claudia    | 50  | 95    | 50  |       |       | 195.0 | 100.0% |
    +-----------+------------+-----+-------+-----+-------+-------+-------+--------+

Let's test that explicit zeros are saved:

    >>> stephan.query.link('Category Weights').click()
    >>> stephan.query.id('assignment').clear()
    >>> stephan.query.id('assignment').ui.set_value('0.0')
    >>> stephan.query.id('essay').clear()
    >>> stephan.query.id('essay').ui.set_value('0.0')
    >>> stephan.query.id('exam').clear()
    >>> stephan.query.id('lab').clear()
    >>> stephan.query.id('lab').ui.set_value('0.0')
    >>> stephan.query.id('project').clear()
    >>> stephan.query.id('project').ui.set_value('0.0')
    >>> stephan.query.name('UPDATE_SUBMIT').click()

    >>> stephan.query.link('Category Weights').click()
    >>> print_category_weights(stephan)
    Assignment: u'0'
    Essay: u'0'
    Exam: u''
    Homework: u'100'
    Journal: u''
    Lab: u'0'
    Presentation: u''
    Project: u'0'
    >>> stephan.query.name('CANCEL').click()

Since all these weights are zero, they shouldn't affect the averages:

    >>> stephan.ui.gradebook.worksheet.pprint()
    +----------+
    | *Sheet1* |
    +----------+
    +-----------+------------+-----+-------+-----+-------+-------+-------+--------+
    | Last Name | First Name | HW1 | Quiz1 | HW2 | Quiz2 | Exper | Total | Ave.   |
    |           |            | 50  | 100   | 50  | 100   | 10    |       |        |
    +-----------+------------+-----+-------+-----+-------+-------+-------+--------+
    | Carduner  | Paul       | 40  | 90    | 45  |       | 9     | 184.0 | 85.0%  |
    | Hoffman   | Tom        | 45  | 80    | 50  |       | 7     | 182.0 | 95.0%  |
    | Richter   | Claudia    | 50  | 95    | 50  |       |       | 195.0 | 100.0% |
    +-----------+------------+-----+-------+-----+-------+-------+-------+--------+

Divide by zero bug
------------------

Until we fixed the bug, there was a case that crashed the gradebook where there
was a score for a non-weighted category but no score for a weighted one.  To
prove that the bug has been fixed, we will remove all the scores for Claudia
and add one for the 'Experiment' activity whose category, 'Assignment', has a
weight of zero.

    >>> stephan.ui.gradebook.worksheet.score('Claudia Richter', 'HW1', '0')
    >>> stephan.ui.gradebook.worksheet.score('Claudia Richter', 'Quiz1', '0')
    >>> stephan.ui.gradebook.worksheet.score('Claudia Richter', 'HW2', '0')
    >>> stephan.ui.gradebook.worksheet.score('Claudia Richter', 'Exper', '50')
    >>> stephan.query.name('UPDATE_SUBMIT').click()

It didn't crash.  We see that Claudia has an average of zero even though she
has a score for 'Experiment' because it has a weight of zero.

    >>> stephan.ui.gradebook.worksheet.pprint()
    +----------+
    | *Sheet1* |
    +----------+
    +-----------+------------+-----+-------+-----+-------+-------+-------+-------+
    | Last Name | First Name | HW1 | Quiz1 | HW2 | Quiz2 | Exper | Total | Ave.  |
    |           |            | 50  | 100   | 50  | 100   | 10    |       |       |
    +-----------+------------+-----+-------+-----+-------+-------+-------+-------+
    | Carduner  | Paul       | 40  | 90    | 45  |       | 9     | 184.0 | 85.0% |
    | Hoffman   | Tom        | 45  | 80    | 50  |       | 7     | 182.0 | 95.0% |
    | Richter   | Claudia    | 0   | 0     | 0   |       | 50    | 50.0  | 0.0%  |
    +-----------+------------+-----+-------+-----+-------+-------+-------+-------+