Report sheets
-------------

Import helper to print the gradebook:

    >>> from schooltool.gradebook.browser.ftests import printGradebook

Log in as manager:

    >>> manager = Browser('manager', 'schooltool')

Add two schoolyear:

    >>> from schooltool.app.browser.ftests import setup
    >>> setup.addSchoolYear('2011', '2011-01-01', '2011-12-31')
    >>> setup.addSchoolYear('2012', '2012-01-01', '2012-12-31')

Add two terms to the 2011 schoolyear:

    >>> setup.addTerm('Term1', '2011-01-01', '2011-06-30', '2011')
    >>> setup.addTerm('Term2', '2011-07-01', '2011-12-31', '2011')

and one term to the 2012 schoolyear:

    >>> setup.addTerm('Single Term', '2012-01-01', '2012-12-31', '2012')

Set up three courses for both years:

    >>> setup.addCourse('Soccer', '2011')
    >>> setup.addCourse('Baseball', '2011')
    >>> setup.addCourse('Swimming', '2011')

    >>> setup.addCourse('Soccer', '2012')
    >>> setup.addCourse('Baseball', '2012')
    >>> setup.addCourse('Swimming', '2012')

Set up persons:

    >>> from schooltool.basicperson.browser.ftests.setup import addPerson
    >>> addPerson('Mario', 'Tejada', 'mario', 'pwd', browser=manager)
    >>> addPerson('Camila', 'Cerna', 'camila', 'pwd', browser=manager)
    >>> addPerson('Nestor', 'Guzman', 'nestor', 'pwd', browser=manager)
    >>> addPerson('William', 'Mejia', 'william', 'pwd', browser=manager)

Set up two sections for the first term of 2011 and one for the second
term:

    >>> setup.addSection('Soccer', '2011', 'Term1',
    ...                  instructors=['William'],
    ...                  members=['Mario', 'Camila', 'Nestor'])
    >>> setup.addSection('Baseball', '2011', 'Term1',
    ...                  instructors=['William'],
    ...                  members=['Mario', 'Camila', 'Nestor'])
    >>> setup.addSection('Swimming', '2011', 'Term2',
    ...                  instructors=['William'],
    ...                  members=['Mario', 'Camila', 'Nestor'])

And one section for 2012:

    >>> setup.addSection('Soccer', '2012', 'Single Term',
    ...                  instructors=['William'],
    ...                  members=['Mario', 'Camila', 'Nestor'])

Go to the management view for report sheet templates:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Report Sheet Templates').click()
    >>> manager.printQuery('//h1/text()')
    Report Sheet Templates

Test the Cancel button of the New Report Sheet view:

    >>> manager.getLink('New Report Sheet').click()
    >>> manager.getControl('Cancel').click()
    >>> manager.printQuery('//h1/text()')
    Report Sheet Templates

Add four report sheet templates:

    >>> manager.getLink('New Report Sheet').click()
    >>> manager.getControl('Title').value = 'Report Sheet 1'
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Report Sheet').click()
    >>> manager.getControl('Title').value = 'Report Sheet 2'
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Report Sheet').click()
    >>> manager.getControl('Title').value = 'Report Sheet 3'
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Report Sheet').click()
    >>> manager.getControl('Title').value = 'Report Sheet 4'
    >>> manager.getControl('Add').click()

After adding a report sheet template, we get back to the management
view for report sheet templates:

    >>> manager.printQuery('//h1/text()')
    Report Sheet Templates
    >>> manager.printQuery('//form//div/a/text()')
    Report Sheet 1
    Report Sheet 2
    Report Sheet 3
    Report Sheet 4

We can change the order of the report sheets. Let's put the 'Report
Sheet 3' at the beginning of the list:

    >>> manager.getControl(name='pos.ReportWorksheet-3').displayValue = ['1']
    >>> manager.getForm().submit()

    >>> manager.printQuery('//h1/text()')
    Report Sheet Templates
    >>> manager.printQuery('//form//div/a/text()')
    Report Sheet 3
    Report Sheet 1
    Report Sheet 2
    Report Sheet 4

and we can delete them:

    >>> manager.getControl(name='delete:list').value = ['ReportWorksheet-4']
    >>> manager.getControl('Delete').click()

    >>> manager.printQuery('//h1/text()')
    Report Sheet Templates
    >>> manager.printQuery('//form//div/a/text()')
    Report Sheet 3
    Report Sheet 1
    Report Sheet 2

Now, let's add four report activities to the Report Sheet 1
template. We'll also test the Cancel button of the New Report Activity
form:

    >>> manager.getLink('Report Sheet 1').click()

    >>> manager.printQuery('//h1/text()')
    Activities of Report Sheet 1

    >>> manager.getLink('New Report Activity').click()
    >>> manager.getControl('Cancel').click()
    >>> manager.printQuery('//h1/text()')
    Activities of Report Sheet 1

    >>> manager.getLink('New Report Activity').click()
    >>> manager.printQuery('//h3/text()')
    Add new report activity
    >>> manager.getControl('Title').value = 'Report Activity 1.1.3'
    >>> manager.getControl('Label').value = 'RA1.1'
    >>> manager.getControl('Score System').displayValue = ['Comment']
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Report Activity').click()
    >>> manager.getControl('Title').value = 'Report Activity 1.2'
    >>> manager.getControl('Score System').displayValue = ['Extended Letter Grade']
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Report Activity').click()
    >>> manager.getControl('Title').value = 'Report Activity 1.3'
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Report Activity').click()
    >>> manager.getControl('Title').value = 'Report Activity 1.4'
    >>> manager.getControl('Score System').displayValue = ['100 Points']
    >>> manager.getControl('Label').value = 'RA1.4'
    >>> manager.getControl('Add').click()

    >>> manager.printQuery('//h1/text()')
    Activities of Report Sheet 1
    >>> manager.printQuery('//form/div/a/text()')
    Report Activity 1.1.3
    Report Activity 1.2
    Report Activity 1.3
    Report Activity 1.4

Report activities can be reordered in a report sheet template:

    >>> manager.getControl(name='pos.ReportActivity').displayValue = ['3']
    >>> manager.getForm().submit()
    >>> manager.printQuery('//h1/text()')
    Activities of Report Sheet 1
    >>> manager.printQuery('//form/div/a/text()')
    Report Activity 1.2
    Report Activity 1.3
    Report Activity 1.1.3
    Report Activity 1.4

They can also be edited. We'll test the Cancel button in that form
too:

    >>> manager.getLink('Report Activity 1.1.3').click()
    >>> manager.getControl('Cancel').click()
    >>> manager.getLink('Report Activity 1.1.3').click()
    >>> manager.getControl('Title').value = 'Report Activity 1.1'
    >>> manager.getControl('Apply').click()

And deleted:

    >>> manager.getControl(name='delete:list').value = ['ReportActivity-3']
    >>> manager.getControl('Delete').click()

    >>> manager.printQuery('//h1/text()')
    Activities of Report Sheet 1
    >>> manager.printQuery('//form/div/a/text()')
    Report Activity 1.2
    Report Activity 1.1
    Report Activity 1.4

Let's edit one:

    >>> manager.getLink('Report Activity 1.4').click()
    >>> manager.getControl('Title').value = 'REPORT ACTIVITY 1.3'
    >>> manager.getControl('Apply').click()

    >>> manager.printQuery('//h1/text()')
    Activities of Report Sheet 1
    >>> manager.printQuery('//form/div/a/text()')
    Report Activity 1.2
    Report Activity 1.1
    REPORT ACTIVITY 1.3

Now, let's add two activities to the Report Sheet 2 template:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Report Sheet Templates').click()
    >>> manager.getLink('Report Sheet 2').click()
    >>> manager.printQuery('//h1/text()')
    Activities of Report Sheet 2

    >>> manager.getLink('New Report Activity').click()
    >>> manager.getControl('Title').value = 'Report Activity 2-1'
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Report Activity').click()
    >>> manager.getControl('Title').value = 'Report Activity 2-2'
    >>> manager.getControl('Add').click()

And one activity to the Report Sheet 3 template:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Report Sheet Templates').click()
    >>> manager.getLink('Report Sheet 3').click()
    >>> manager.printQuery('//h1/text()')
    Activities of Report Sheet 3

    >>> manager.getLink('New Report Activity').click()
    >>> manager.getControl('Title').value = 'Report Activity 3_1'
    >>> manager.getControl('Label').value = 'REPACT31'
    >>> manager.getControl('Add').click()

Before deploying our report sheet templates, let's login as teacher
and visit the Soccer Term1 section. The teacher should have a default
worksheet:

    >>> teacher = Browser('william', 'pwd')
    >>> teacher.getLink('Gradebook').click()
    >>> teacher.printQuery('//select[@name="currentTerm"]/option[@selected="selected"]/text()')
    2011 / Term1
    >>> teacher.printQuery('//select[@name="currentSection"]/option[@selected="selected"]/text()')
    Soccer - Soccer (1)
    >>> printGradebook(teacher.contents)
    +----------+
    | *Sheet1* |
    +----------+
    +----------------+-------+------+
    | Name           | Total | Ave. |
    +----------------+-------+------+
    | Cerna, Camila  | 0.0   | N/A  |
    | Guzman, Nestor | 0.0   | N/A  |
    | Tejada, Mario  | 0.0   | N/A  |
    +----------------+-------+------+

Now, let's deploy our report sheet templates so sections can use
them. Let's deploy the first template in the 2011 schoolyear, the
second one in the first term only and the third template in the second
term of 2011:

    >>> manager.getLink('2011').click()
    >>> manager.getLink('Deploy Report Sheet').click()
    >>> manager.printQuery('//h1/text()')
    Deploy Report Worksheet Template
    >>> manager.getControl('Template').displayValue = ['Report Sheet 1']
    >>> manager.getControl('Deploy').click()

    >>> manager.getLink('Term1').click()
    >>> manager.getLink('Deploy Report Sheet').click()
    >>> manager.printQuery('//h1/text()')
    Deploy Report Worksheet Template
    >>> manager.getControl('Cancel').click()
    >>> manager.getLink('Deploy Report Sheet').click()
    >>> manager.getControl('Template').displayValue = ['Report Sheet 2']
    >>> manager.getControl('Deploy').click()

    >>> manager.getLink('2011').click()
    >>> manager.getLink('Term2').click()
    >>> manager.getLink('Deploy Report Sheet').click()
    >>> manager.printQuery('//h1/text()')
    Deploy Report Worksheet Template
    >>> manager.getLink('Deploy Report Sheet').click()
    >>> manager.getControl('Template').displayValue = ['Report Sheet 3']
    >>> manager.getControl('Deploy').click()

Now that the report sheet templates have been deployed, they should be
available for sections.

Let's visit again our Soccer section for Term1 of 2011:

    >>> teacher.reload()
    >>> teacher.getLink('Gradebook').click()
    >>> teacher.printQuery('//select[@name="currentTerm"]/option[@selected="selected"]/text()')
    2011 / Term1
    >>> teacher.printQuery('//select[@name="currentSection"]/option[@selected="selected"]/text()')
    Soccer - Soccer (1)

and we see our default Sheet1 worksheet we used before, the report
sheet deployed in the 2011 schoolyear and the report sheet deployed
for Term1:

    >>> printGradebook(teacher.contents)
    +----------+----------------+----------------+
    | *Sheet1* | Report Sheet 1 | Report Sheet 2 |
    +----------+----------------+----------------+
    +----------------+-------+------+
    | Name           | Total | Ave. |
    +----------------+-------+------+
    | Cerna, Camila  | 0.0   | N/A  |
    | Guzman, Nestor | 0.0   | N/A  |
    | Tejada, Mario  | 0.0   | N/A  |
    +----------------+-------+------+

The 2011 report sheet, Report Sheet 1, should have three activities,
and like all deployed sheets it has no totals or average columns:

    >>> teacher.getLink('Report Sheet 1').click()
    >>> printGradebook(teacher.contents)
    +--------+------------------+----------------+
    | Sheet1 | *Report Sheet 1* | Report Sheet 2 |
    +--------+------------------+----------------+
    +----------------+---------+-------+---------+
    | Name           | Repor   | RA1.1 | RA1.4   |
    +----------------+---------+-------+---------+
    | Cerna, Camila  | [_____] |       | [_____] |
    | Guzman, Nestor | [_____] |       | [_____] |
    | Tejada, Mario  | [_____] |       | [_____] |
    +----------------+---------+-------+---------+

Note that the 'Report Activity 1 (RA1.1)' cannot be graded directly in
the worksheet nor on it's own. That's because it uses a Comment score
system. To grade such activities, we have to use the student
gradebook. Let's grade Nestor's activities:

    >>> teacher.getLink('>', index=1).click()
    >>> teacher.printQuery("id('form')/div[1]/h3")
    <h3>Enter grades for Guzman, Nestor</h3>
    >>> teacher.printQuery('id("form")//fieldset//label/span/text()')
    Report Activity 1.2 (A+)
    Report Activity 1.1
    REPORT ACTIVITY 1.3 (100)
    >>> teacher.getControl('Report Activity 1.1').value = '<p>This is the report for Nestor for:</p><p>&nbsp;</p><p><strong>Report Activity 1.1</strong></p><p>&nbsp;</p><p>His teacher.</p>'
    >>> teacher.getControl('REPORT ACTIVITY 1.3').value = '87'

and now for Camila:

    >>> teacher.getControl('Previous').click()
    >>> url = teacher.url
    >>> teacher.printQuery("id('form')/div[1]/h3")
    <h3>Enter grades for Cerna, Camila</h3>
    >>> teacher.printQuery('id("form")//fieldset//label/span/text()')
    Report Activity 1.2 (A+)
    Report Activity 1.1
    REPORT ACTIVITY 1.3 (100)
    >>> teacher.getControl('Report Activity 1.2').value = 'A-'
    >>> teacher.getControl('Report Activity 1.1').value = '<p>This is the report for Camila for:</p><p>&nbsp;</p><p><strong>Report Activity 1.1</strong></p><p>&nbsp;</p><p>Her teacher.</p>'
    >>> teacher.getControl('REPORT ACTIVITY 1.3').value = '78'
    >>> teacher.getControl('Apply').click()

We get back to the 'Report Sheet 1' sheet:

    >>> printGradebook(teacher.contents)
    +--------+------------------+----------------+
    | Sheet1 | *Report Sheet 1* | Report Sheet 2 |
    +--------+------------------+----------------+
    +----------------+---------+-------+---------+
    | Name           | Repor   | RA1.1 | RA1.4   |
    +----------------+---------+-------+---------+
    | Cerna, Camila  | [A-___] | ...   | [78___] |
    | Guzman, Nestor | [_____] | ...   | [87___] |
    | Tejada, Mario  | [_____] |       | [_____] |
    +----------------+---------+-------+---------+

Let's check the Report Sheet 2 sheet:

    >>> teacher.getLink('Report Sheet 2').click()
    >>> printGradebook(teacher.contents)
    +--------+----------------+------------------+
    | Sheet1 | Report Sheet 1 | *Report Sheet 2* |
    +--------+----------------+------------------+
    +----------------+---------+---------+
    | Name           | Repor   | Repor   |
    +----------------+---------+---------+
    | Cerna, Camila  | [_____] | [_____] |
    | Guzman, Nestor | [_____] | [_____] |
    | Tejada, Mario  | [_____] | [_____] |
    +----------------+---------+---------+

Now, if we go to the other section in this term, we should see these
same report sheets and activities deployed:

    >>> teacher.getControl(name='currentSection').displayValue = ['Baseball - Baseball (2)']
    >>> teacher.getForm().submit()

    >>> teacher.printQuery('//select[@name="currentTerm"]/option[@selected="selected"]/text()')
    2011 / Term1
    >>> teacher.printQuery('//select[@name="currentSection"]/option[@selected="selected"]/text()')
    Baseball - Baseball (2)

    >>> printGradebook(teacher.contents)
    +------------------+----------------+
    | *Report Sheet 1* | Report Sheet 2 |
    +------------------+----------------+
    +----------------+---------+-------+---------+
    | Name           | Repor   | RA1.1 | RA1.4   |
    +----------------+---------+-------+---------+
    | Cerna, Camila  | [_____] |       | [_____] |
    | Guzman, Nestor | [_____] |       | [_____] |
    | Tejada, Mario  | [_____] |       | [_____] |
    +----------------+---------+-------+---------+

    >>> teacher.getLink('Report Sheet 2').click()
    >>> printGradebook(teacher.contents)
    +----------------+------------------+
    | Report Sheet 1 | *Report Sheet 2* |
    +----------------+------------------+
    +----------------+---------+---------+
    | Name           | Repor   | Repor   |
    +----------------+---------+---------+
    | Cerna, Camila  | [_____] | [_____] |
    | Guzman, Nestor | [_____] | [_____] |
    | Tejada, Mario  | [_____] | [_____] |
    +----------------+---------+---------+

And if we go to the other term, Term2, in this schoolyear, we'll see
that the 'Report Sheet 1' sheet is common for both terms and we'll see
the other 'Report Sheet 3' deployed only for that term:

    >>> teacher.getControl(name='currentTerm').displayValue = ['2011 / Term2']
    >>> teacher.getForm().submit()

    >>> teacher.printQuery('//select[@name="currentTerm"]/option[@selected="selected"]/text()')
    2011 / Term2
    >>> teacher.printQuery('//select[@name="currentSection"]/option[@selected="selected"]/text()')
    Swimming - Swimming (1)

    >>> printGradebook(teacher.contents)
    +------------------+----------------+
    | *Report Sheet 1* | Report Sheet 3 |
    +------------------+----------------+
    +----------------+---------+-------+---------+
    | Name           | Repor   | RA1.1 | RA1.4   |
    +----------------+---------+-------+---------+
    | Cerna, Camila  | [_____] |       | [_____] |
    | Guzman, Nestor | [_____] |       | [_____] |
    | Tejada, Mario  | [_____] |       | [_____] |
    +----------------+---------+-------+---------+

    >>> teacher.getLink('Report Sheet 3').click()
    >>> printGradebook(teacher.contents)
    +----------------+------------------+
    | Report Sheet 1 | *Report Sheet 3* |
    +----------------+------------------+
    +----------------+---------+
    | Name           | REPAC   |
    +----------------+---------+
    | Cerna, Camila  | [_____] |
    | Guzman, Nestor | [_____] |
    | Tejada, Mario  | [_____] |
    +----------------+---------+

And now, if we go to the section in the 2012 schoolyear, we won't see
any common report sheet deployed, just the default worksheet:

    >>> teacher.getControl(name='currentTerm').displayValue = ['2012 / Single Term']
    >>> teacher.getForm().submit()

    >>> teacher.getLink('Gradebook').click()
    >>> teacher.printQuery('//select[@name="currentTerm"]/option[@selected="selected"]/text()')
    2012 / Single Term
    >>> teacher.printQuery('//select[@name="currentSection"]/option[@selected="selected"]/text()')
    Soccer - Soccer (1)

    >>> printGradebook(teacher.contents)
    +----------+
    | *Sheet1* |
    +----------+
    +----------------+-------+------+
    | Name           | Total | Ave. |
    +----------------+-------+------+
    | Cerna, Camila  | 0.0   | N/A  |
    | Guzman, Nestor | 0.0   | N/A  |
    | Tejada, Mario  | 0.0   | N/A  |
    +----------------+-------+------+

Now, let's visit the unreachable 'view.html' view for Camila's Report Sheet 1 grades:

    >>> teacher.open(url + '/view.html')
    >>> teacher.printQuery('//h1/text()')
    Report Sheet 1 for Camila Cerna in Soccer - Soccer (1)
    >>> teacher.printQuery('//div[@class="info-block"]')
    <div class="info-block">
      <h3>Report Activity 1.2</h3>
      <p>A-</p>
    </div>
    <div class="info-block">
      <h3>Report Activity 1.1</h3>
      <p>This is the report for Camila for:</p>
      <p> </p>
      <p><strong>Report Activity 1.1</strong></p>
      <p> </p>
      <p>Her teacher.</p>
    </div>
    <div class="info-block">
      <h3>REPORT ACTIVITY 1.3</h3>
      <p>78</p>
    </div>

Now, let's log in as a student and check the mygrades view:

    >>> student = Browser('camila', 'pwd')
    >>> student.getLink('Gradebook').click()

We get to the first section of the 2011 / Term1 term:

    >>> student.printQuery('//select[@name="currentTerm"]/option[@selected="selected"]/text()')
    2011 / Term1
    >>> student.printQuery('//select[@name="currentSection"]/option[@selected="selected"]/text()')
    Soccer - Soccer (1)

and we see the three worksheets, the first one with no grades:

    >>> student.printQuery('//table[@class="schooltool_gradebook"][1]/tr/td')
    <td class="active_tab">
      <span style="font-weight: bold;">Sheet1</span>
    </td>
    <td class="active_tab">
      <a href="http://localhost/schoolyears/2011/term1/sections/1/activities/2011_term1/mygrades">Report Sheet 1</a>
    </td>
    <td class="active_tab">
      <a href="http://localhost/schoolyears/2011/term1/sections/1/activities/2011_term1-2/mygrades">Report Sheet 2</a>
    </td>

    >>> student.printQuery('//table[@class="student_gradebook"]/tr[1]/td')
    <td colspan="2" class="odd student_cell">
      <div>Nothing Graded</div>
    </td>
    >>> student.printQuery('//table[@class="student_gradebook"]/tr[position()>1]/*[1]/div/text()')
    Activity
    >>> student.printQuery('//table[@class="student_gradebook"]/tr[position()>1]/*[2]/div/text()')
    Grade

the second with three graded report activities:

    >>> student.getLink('Report Sheet 1').click()

    >>> student.printQuery('//table[@class="schooltool_gradebook"][1]/tr/td')
    <td class="active_tab">
      <a href="http://localhost/schoolyears/2011/term1/sections/1/activities/Worksheet/mygrades">Sheet1</a>
    </td>
    <td class="active_tab">
      <span style="font-weight: bold;">Report Sheet 1</span>
    </td>
    <td class="active_tab">
      <a href="http://localhost/schoolyears/2011/term1/sections/1/activities/2011_term1-2/mygrades">Report Sheet 2</a>
    </td>
    
    >>> student.printQuery('//table[@class="student_gradebook"]/tr/*[1]/div/text()')
    Activity
    Report Activity 1.2
    Report Activity 1.1
    REPORT ACTIVITY 1.3
    >>> student.printQuery('//table[@class="student_gradebook"]/tr/*[2]')
    <th class="cell student_header">
      <div>Grade</div>
    </th>
    <td class="odd student_cell">
      <div>3.7 / A+</div>
    </td>
    <td class="even student_cell">
      <p>This is the report for Camila for:</p>
      <p> </p>
      <p><strong>Report Activity 1.1</strong></p>
      <p> </p>
      <p>Her teacher.</p>
    </td>
    <td class="odd student_cell">
      <div>78 / 100</div>
    </td>

and the third with two report activities with no grades:

    >>> student.getLink('Report Sheet 2').click()

    >>> student.printQuery('//table[@class="schooltool_gradebook"][1]/tr/td')
    <td class="active_tab">
      <a href="http://localhost/schoolyears/2011/term1/sections/1/activities/Worksheet/mygrades">Sheet1</a>
    </td>
    <td class="active_tab">
      <a href="http://localhost/schoolyears/2011/term1/sections/1/activities/2011_term1/mygrades">Report Sheet 1</a>
    </td>
    <td class="active_tab">
      <span style="font-weight: bold;">Report Sheet 2</span>
    </td>

    >>> student.printQuery('//table[@class="student_gradebook"]/tr/*[1]/div/text()')
    Activity
    Report Activity 2-1
    Report Activity 2-2
    >>> student.printQuery('//table[@class="student_gradebook"]/tr/*[2]/div/text()')
    Grade

Note that the last two worksheets have no average.

Let's check the report sheets for the other graded student:

    >>> other_student = Browser('nestor', 'pwd')
    >>> other_student.getLink('Gradebook').click()
    >>> other_student.getLink('Report Sheet 1').click()

    >>> other_student.printQuery('//table[@class="schooltool_gradebook"][1]/tr/td')
    <td class="active_tab">
      <a href="http://localhost/schoolyears/2011/term1/sections/1/activities/Worksheet/mygrades">Sheet1</a>
    </td>
    <td class="active_tab">
      <span style="font-weight: bold;">Report Sheet 1</span>
    </td>
    <td class="active_tab">
      <a href="http://localhost/schoolyears/2011/term1/sections/1/activities/2011_term1-2/mygrades">Report Sheet 2</a>
    </td>
    
    >>> other_student.printQuery('//table[@class="student_gradebook"]/tr/*[1]/div/text()')
    Activity
    Report Activity 1.2
    Report Activity 1.1
    REPORT ACTIVITY 1.3
    >>> other_student.printQuery('//table[@class="student_gradebook"]/tr/*[2]')
    <th class="cell student_header">
      <div>Grade</div>
    </th>
    <td class="odd student_cell">
      <div></div>
    </td>
    <td class="even student_cell">
      <p>This is the report for Nestor for:</p>
      <p> </p>
      <p><strong>Report Activity 1.1</strong></p>
      <p> </p>
      <p>His teacher.</p>
    </td>
    <td class="odd student_cell">
      <div>87 / 100</div>
    </td>


Hiding deployed report sheets
-----------------------------

We allow the manager to hide deployed report sheets.  We only support this
for a term because some combinations of term and full year deployments would
leave it confusing have the user hide deployed report sheets by year

    >>> manager.getLink('2011').click()
    >>> manager.getLink('Term1').click()
    >>> manager.getLink('Hide Report Sheet').click()

We see the title and select field with the two report sheets deployed in
Term1.

    >>> manager.printQuery('//h1/text()')
    Hide Deployed Report Sheet
    >>> manager.printQuery('//select[@name="reportWorksheet"]/option')
    <option value="2011_term1">Report Sheet 1</option>
    <option value="2011_term1-2">Report Sheet 2</option>

If the user hits cancel, they are returned to the term view.

    >>> manager.getControl('Cancel').click()
    >>> manager.url
    'http://localhost/schoolyears/2011/term1'

If they go again and hit Hide, a confirmation view comes up.

    >>> manager.getLink('Hide Report Sheet').click()
    >>> manager.getControl(name='reportWorksheet').displayValue = ['Report Sheet 2']
    >>> manager.getControl('Hide').click()
    >>> manager.printQuery('//form/p/text()')
    Are you sure you want to hide the report sheet, 'Report Sheet 2' in every
    section of term, 'Term1'?  If so, hit the 'Hide' button again to confirm.

If the user hits cancel, they are returned to the term view.

    >>> manager.getControl('Cancel').click()
    >>> manager.url
    'http://localhost/schoolyears/2011/term1'

This time, the user will conform the action by hitting Hide a second time.

    >>> manager.getLink('Hide Report Sheet').click()
    >>> manager.getControl(name='reportWorksheet').displayValue = ['Report Sheet 2']
    >>> manager.getControl('Hide').click()
    >>> manager.getControl('Hide').click()

Now, returning the hide view, we see that only Report Sheet 1 is available
for hiding.

    >>> manager.getLink('Hide Report Sheet').click()
    >>> manager.printQuery('//select[@name="reportWorksheet"]/option')
    <option value="2011_term1">Report Sheet 1</option>

To confirm that the report sheet was hidden, we'll have the teacher view
their gradebook for one of the sections in Term1.

    >>> teacher.getLink('Gradebook').click()
    >>> teacher.getControl(name='currentTerm').displayValue = ['2011 / Term1']
    >>> teacher.getForm().submit()
    >>> printGradebook(teacher.contents)
    +----------+----------------+
    | *Sheet1* | Report Sheet 1 |
    +----------+----------------+
    +----------------+-------+------+
    | Name           | Total | Ave. |
    +----------------+-------+------+
    | Cerna, Camila  | 0.0   | N/A  |
    | Guzman, Nestor | 0.0   | N/A  |
    | Tejada, Mario  | 0.0   | N/A  |
    +----------------+-------+------+

We can also unhide report sheets that we have hidden.  We see that the one
we just hid is available for unhiding.

    >>> manager.getLink('Unhide Report Sheet').click()
    >>> manager.printQuery('//h1/text()')
    Unhide Deployed Report Sheet
    >>> manager.printQuery('//select[@name="reportWorksheet"]/option')
    <option value="2011_term1-2">Report Sheet 2</option>

If the user hits cancel, they are returned to the term view.

    >>> manager.getControl('Cancel').click()
    >>> manager.url
    'http://localhost/schoolyears/2011/term1'

If they go again and hit Unhide, a confirmation view comes up.

    >>> manager.getLink('Unhide Report Sheet').click()
    >>> manager.getControl(name='reportWorksheet').displayValue = ['Report Sheet 2']
    >>> manager.getControl('Unhide').click()
    >>> manager.printQuery('//form/p/text()')
    Are you sure you want to unhide the report sheet, 'Report Sheet 2' in every
    section of term, 'Term1'?  If so, hit the 'Unhide' button again to confirm.

If the user hits cancel, they are returned to the term view.

    >>> manager.getControl('Cancel').click()
    >>> manager.url
    'http://localhost/schoolyears/2011/term1'

This time, the user will conform the action by hitting Unhide a second time.

    >>> manager.getLink('Unhide Report Sheet').click()
    >>> manager.getControl(name='reportWorksheet').displayValue = ['Report Sheet 2']
    >>> manager.getControl('Unhide').click()
    >>> manager.getControl('Unhide').click()

Now we see that both report sheets are available again for hiding.

    >>> manager.getLink('Hide Report Sheet').click()
    >>> manager.printQuery('//select[@name="reportWorksheet"]/option')
    <option value="2011_term1">Report Sheet 1</option>
    <option value="2011_term1-2">Report Sheet 2</option>

The teacher can see Report Sheet 2 again.  We'll click on the tab to make
sure it's still ok.

    >>> teacher.reload()
    >>> teacher.getLink('Report Sheet 2').click()
    >>> printGradebook(teacher.contents)
    +--------+----------------+------------------+
    | Sheet1 | Report Sheet 1 | *Report Sheet 2* |
    +--------+----------------+------------------+
    +----------------+---------+---------+
    | Name           | Repor   | Repor   |
    +----------------+---------+---------+
    | Cerna, Camila  | [_____] | [_____] |
    | Guzman, Nestor | [_____] | [_____] |
    | Tejada, Mario  | [_____] | [_____] |
    +----------------+---------+---------+

Finally, we need the hide and unhide views to handle the case where there
are no report sheets to hide or unhide.  Presently there are no report sheets
in Term1 to unhide.

    >>> manager.getLink('Unhide Report Sheet').click()
    >>> manager.printQuery('//form/p/text()')
    There are no hidden deployed report sheets to unhide.

We also see that there is only the Cancel button to click which still takes
the user back to the term view.

    >>> manager.printQuery('//input[@type="submit"]')
    <input type="submit" class="button-cancel" name="CANCEL" value="Cancel" />
    >>> manager.getControl('Cancel').click()
    >>> manager.url
    'http://localhost/schoolyears/2011/term1'

If we go ahead and hide both report sheets again, we'll see the same is
true for the hide view.

    >>> manager.getLink('Hide Report Sheet').click()
    >>> manager.getControl('Hide').click()
    >>> manager.getControl('Hide').click()
    >>> manager.getLink('Hide Report Sheet').click()
    >>> manager.getControl('Hide').click()
    >>> manager.getControl('Hide').click()

    >>> manager.getLink('Hide Report Sheet').click()
    >>> manager.printQuery('//form/p/text()')
    There are no deployed report sheets to hide.
    >>> manager.printQuery('//input[@type="submit"]')
    <input type="submit" class="button-cancel" name="CANCEL" value="Cancel" />
    >>> manager.getControl('Cancel').click()
    >>> manager.url
    'http://localhost/schoolyears/2011/term1'

