This file is indexed.

/usr/lib/python2.7/dist-packages/schooltool/intervention/browser/ftests/README.txt is in python-schooltool.intervention 2.7.1-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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
=====================
Student Interventions
=====================

These are the functional tests for the intervention package.

First we need to set up the school.

    >>> from schooltool.intervention.browser.ftests import ftests
    >>> from schooltool.app.browser.ftests import setup
    >>> setup.setUpBasicSchool()
    >>> manager = setup.logIn('manager', 'schooltool')

We need to define a method that takes a browser instance and a username (plus
optional parent index for parents of the student) and returns the corresponding
checkbox control.

    >>> def choiceControl(browser, username, index=0):
    ...     resp = (browser.queryHTML("//input[@class='person_list']/@name") +
    ...            browser.queryHTML("//input[@class='changed_list']/@name"))
    ...     notif = browser.queryHTML("//input[@class='notified_list']/@name")
    ...     if index > 0:
    ...         return browser.getControl(name=notif[index])
    ...     for choice in resp + notif:
    ...         if choice.startswith('persons.' + username):
    ...             return browser.getControl(name=choice)
    ...     return None

Interventions
-------------

Now we come to the main intervention center that gives us access to all of the
intervention data associated with a given student for a given school year.
We'll create some teachers and students and put them in some sections.
We will also create a principal and guidance counselor and put them in the
adminstators group.  These users will show up as part of the list of persons
responsible for any student and will also have permission to work with the
intervention of any student.

    >>> from schooltool.intervention.browser.ftests.ftests import (
    ...     addPerson, addCourseSectionMembers, fillInContactInfo)

    >>> manager.getLink('Home').click()
    >>> fillInContactInfo('manager', email='manager@example.com')

    >>> addPerson('Teacher1', 'Teacher1', 'teacher1', 'pwd', groups=['teachers'])
    >>> addPerson('Teacher2', 'Teacher2', 'teacher2', 'pwd', groups=['teachers'])
    >>> addPerson('Student1', 'Student1', 'student1', 'pwd', groups=['students'])
    >>> addPerson('Student2', 'Student2', 'student2', 'pwd', groups=['students'])
    >>> addPerson('Student3', 'Student3', 'student3', 'pwd', groups=['students'])
    >>> addCourseSectionMembers('course1', 'section1', ['Teacher1'],
    ...     ['Student1', 'Student3'])
    >>> addCourseSectionMembers('course2', 'section2', ['Teacher2'],
    ...     ['Student2'])
    >>> addPerson('Counselor', 'Counselor', 'counselor', 'pwd', groups=['administrators'])
    >>> addPerson('Principal', 'Principal', 'principal', 'pwd', groups=['administrators'])
    >>> addPerson('Search Person', 'Person Search', 'sperson', 'pwd')

Let's add a parent contact and an advisor which will show up when adding goals
and messages.

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Student1').click()
    >>> manager.getLink('Contacts').click()
    >>> manager.getLink('Manage Contacts').click()
    >>> manager.getLink('Create new contact').click()
    >>> manager.getControl('First name').value = 'Parent1'
    >>> manager.getControl('Last name').value = 'Parent1'
    >>> manager.getControl('Email').value = 'parent@somewhere.com'
    >>> manager.getControl('Relationship').value = ['p-']
    >>> manager.getControl('Add').click()

    >>> manager.getLink('Advisors').click()
    >>> manager.getControl(name='add_item.teacher2').value = 'checked'
    >>> manager.getControl('Add').click()

To navigate to a student's intervention, a manager can navigate to the student
and click on the 'Intervention Center' action link.

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Student1').click()
    >>> manager.getLink('Intervention Center').click()
    >>> manager.printQuery("id('content-body')//table/tr/td[3]/a/text()")
    Student1 Student1
    >>> manager.printQuery("id('content-body')//legend/b")
    <b>Messages and Observations</b>
    <b>Goals and Interventions</b>
    <b>Report Sheets</b>
    <b>Change of Status Messages</b>
    >>> manager.printQuery("id('content-body')//fieldset//a/text()")
    New Message
    View All Messages
    New Goal
    View All Goals
    New Status Message
    View All Status Messages
    >>> manager.printQuery("id('content-body')//fieldset//li/text()")
    There are none.
    There are none.
    There are none.


Intervention Messages
---------------------

The first thing we'll add is a new message.  Calling up the add view, we'll
note that the list of possible recipients will include, in order, the student's
advisors, the school administrators, the student's teachers, the student,
and the student's parents.  Advisors and parents will have descriptors
after their names to make it easier for the user to pick them out.  Also,
the advisors will be pre-checked.

    >>> manager.getLink('New Message').click()
    >>> manager.printQuery("id('content-body')//input[@type='checkbox']")
    <input type="checkbox" class="person_list" checked="checked" name="persons.teacher2-..." />
    <input type="checkbox" class="person_list" name="persons.counselor-..." />
    <input type="checkbox" class="person_list" name="persons.principal-..." />
    <input type="checkbox" class="person_list" name="persons.teacher1-..." />
    <input type="checkbox" class="notified_list" name="persons.student1-..." />
    <input type="checkbox" class="notified_list" name="contacts.Contact-..." />
    >>> manager.printQuery("id('content-body')//span/b")
    <b>Teacher2 Teacher2 (advisor)</b>
    <b>Counselor Counselor</b>
    <b>Principal Principal</b>
    <b>Teacher1 Teacher1</b>
    <b>Student1 Student1</b>
    <b>Parent1 Parent1 (parent)</b>

We'll test how the add view handles missing input.  We'll need to uncheck the
advisor to make the recipients input cause the error.

    >>> choiceControl(manager, 'teacher2').value = False
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    >>> manager.printQuery("id('content-body')//fieldset/p[2]")
    <p> There are <strong>2</strong> input errors. </p>
    >>> manager.printQuery("id('content-body')//div[@class='error']")
    <div class="error">Required data was not supplied.</div>
    <div class="error">
      <span class="error">Required input is missing.</span>
    </div>

We'll fill in the required fields and hit the Add button.  Note that upon
successfully adding the message, an email will appear in the output.  This
is the result of the dummy mail sender that we use during testing that prints
emails that would otherwise be sent to the smtp mail server that a live
environment would have configured.  Also note that the parent's email address
will be picked up from the student's demos.

    >>> choiceControl(manager, 'teacher1').value = True
    >>> choiceControl(manager, 'student1', index=1).value = True
    >>> manager.getControl(name='field.body').value = 'hi\nthere'
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    From: manager@example.com
    To: parent@somewhere.com, teacher1@example.com
    Subject: INTERVENTION MESSAGE: Student1 Student1
    Default Manager writes:
    <BLANKLINE>
    hi
    there

Note that the successfully added message appears in the Intervention Center
with the username of the sender, in this case, manager.

    >>> manager.printQuery("id('content-body')//fieldset[1]//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/messages/1">Message from Default Manager sent ...</a>

Let's make sure we can view the message that we just added.  Note that the
message body will be broken into <p> tags, one for each line.

    >>> manager.getLink('Message from Default Manager').click()
    >>> manager.printQuery("id('content-body')//div//span")
    <span>Parent1 Parent1, Teacher1 Teacher1</span>
    >>> manager.printQuery("id('content-body')//p")
    <p>hi</p>
    <p>there</p>

We should be able to return to the Intervention Center with a link.

    >>> manager.getLink('Intervention Center').click()
    >>> manager.printQuery("id('content-body')//fieldset[1]//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/messages/1">Message from Default Manager sent ...</a>

We'll add a second message to test the system's handling of multiple
messages.  Messages are sorted by date.

    >>> manager.getLink('New Message').click()
    >>> choiceControl(manager, 'teacher1').value = True
    >>> manager.getControl(name='field.body').value = 'hello again'
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    From: manager@example.com
    To: teacher1@example.com, teacher2@example.com
    Subject: INTERVENTION MESSAGE: Student1 Student1
    Default Manager writes:
    <BLANKLINE>
    hello again
    >>> manager.printQuery("id('content-body')//fieldset[1]//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/messages/2">Message from Default Manager sent ...</a>
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/messages/1">Message from Default Manager sent ...</a>

There is a button that allows us to call up the report that presents all of
the messages together.  The messages are sorted by creation date.

    >>> manager.getLink('View All Messages').click()
    >>> manager.printQuery("id('content-body')//span")
    <span>Message sent by Default Manager on ...</span>
    <span>Teacher1 Teacher1, Teacher2 Teacher2</span>
    <span>Message sent by Default Manager on ...</span>
    <span>Parent1 Parent1, Teacher1 Teacher1</span>
    >>> manager.printQuery("id('content-body')//p")
    <p>hello again</p>
    <p>hi</p>
    <p>there</p>

We'll return the the Intervention Center.

    >>> manager.getLink('Intervention Center').click()
    >>> manager.printQuery("id('content-body')//legend/b")
    <b>Messages and Observations</b>
    <b>Goals and Interventions</b>
    <b>Report Sheets</b>
    <b>Change of Status Messages</b>

We need a test for canceling out of the add message view.  It should return
us back to the Intervention Center.

    >>> manager.getLink('New Message').click()
    >>> manager.getControl(name='CANCEL').click()
    >>> manager.printQuery("id('content-body')//legend/b")
    <b>Messages and Observations</b>
    <b>Goals and Interventions</b>
    <b>Report Sheets</b>
    <b>Change of Status Messages</b>


Intervention Goals
------------------

The next thing to start adding is Goals.  We'll test how the add view
handles missing input while we're at it.  To make the persons responsible
field have missing data, we'll need to uncheck the advisor that comes
pre-checked.

    >>> manager.getLink('New Goal').click()
    >>> manager.printQuery("id('content-body')//input[@type='checkbox']")
    <input type="checkbox" class="person_list" checked="checked" name="persons.teacher2-..." />
    <input type="checkbox" class="person_list" name="persons.counselor-..." />
    <input type="checkbox" class="person_list" name="persons.principal-..." />
    <input type="checkbox" class="person_list" name="persons.teacher1-..." />
    <input type="checkbox" class="notified_list" name="persons.student1-..." />
    <input type="checkbox" class="notified_list" name="contacts.Contact-..." />
    >>> manager.printQuery("id('content-body')//input[@type='radio']")
    <input type="radio" name="goal_met" value="No" checked="checked" />
    <input type="radio" name="goal_met" value="Yes" />

    >>> choiceControl(manager, 'teacher2').value = False
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    >>> manager.printQuery("id('content-body')//form/p[2]")
    <p> There are <strong>3</strong> input errors. </p>
    >>> manager.printQuery("id('content-body')//div[@class='error']")
    <div class="error">Required data was not supplied.</div>
    <div class="error">
      <span class="error">Required input is missing.</span>
    </div>
    <div class="error">
      <span class="error">Required input is missing.</span>
    </div>

Now we'll fill in the required fields.  We'll include the student and the
parent in the persons responsible list to demostrate how adding the goal
will split the email by staff and students/parents.  Students and parents
will not get a link back to the intervention center in their email.

    >>> from datetime import date
    >>> manager.getControl('Presenting concerns').value = 'Poor attendence'
    >>> manager.getControl(name='field.goal').value = 'Get student to come in more often'
    >>> manager.getControl('Strengths').value = 'Attentive when there'
    >>> manager.getControl('Indicators').value = 'Student appears at least 4 time a week'
    >>> manager.getControl('Intervention').value = 'Call parents to arrange better attendence'
    >>> manager.getControl('Timeline').value = str(date.today())
    >>> choiceControl(manager, 'teacher1').value = True
    >>> choiceControl(manager, 'student1').value = True
    >>> choiceControl(manager, 'student1', index=1).value = True
    >>> manager.getControl(name='goal_met').value = ['Yes']
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    From: manager@example.com
    To: teacher1@example.com
    Subject: INTERVENTION GOAL ADDED: Student1 Student1
    The following goal was added for Student1 Student1:
    <BLANKLINE>
    Presenting concerns
    -------------------
    <BLANKLINE>
    Poor attendence
    <BLANKLINE>
    Goal
    ----
    <BLANKLINE>
    Get student to come in more often
    <BLANKLINE>
    Strengths
    ---------
    <BLANKLINE>
    Attentive when there
    <BLANKLINE>
    Indicators
    ----------
    <BLANKLINE>
    Student appears at least 4 time a week
    <BLANKLINE>
    Intervention
    ------------
    <BLANKLINE>
    Call parents to arrange better attendence
    <BLANKLINE>
    Timeline
    --------
    <BLANKLINE>
    ...
    <BLANKLINE>
    Persons responsible
    -------------------
    <BLANKLINE>
    Parent1 Parent1
    Student1 Student1
    Teacher1 Teacher1
    <BLANKLINE>
    Intervention Center
    -------------------
    <BLANKLINE>
    http://localhost/schooltool.interventions/2005-2006/student1
    <BLANKLINE>
    From: manager@example.com
    To: parent@somewhere.com, student1@example.com
    Subject: INTERVENTION GOAL ADDED: Student1 Student1
    The following goal was added for Student1 Student1:
    <BLANKLINE>
    Presenting concerns
    -------------------
    <BLANKLINE>
    Poor attendence
    <BLANKLINE>
    Goal
    ----
    <BLANKLINE>
    Get student to come in more often
    <BLANKLINE>
    Strengths
    ---------
    <BLANKLINE>
    Attentive when there
    <BLANKLINE>
    Indicators
    ----------
    <BLANKLINE>
    Student appears at least 4 time a week
    <BLANKLINE>
    Intervention
    ------------
    <BLANKLINE>
    Call parents to arrange better attendence
    <BLANKLINE>
    Timeline
    --------
    <BLANKLINE>
    ...
    <BLANKLINE>
    Persons responsible
    -------------------
    <BLANKLINE>
    Parent1 Parent1
    Student1 Student1
    Teacher1 Teacher1

Note that the successfully added goal appears in the Intervention Center as
'Goal 1'.

    >>> manager.printQuery("id('content-body')//fieldset[2]//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/goals/1">Goal 1 - Added ... - Due ... - CLOSED</a>

We need a test for canceling out of the add goal view.  It should return
us back to the Intervention Center.

    >>> manager.getLink('New Goal').click()
    >>> manager.getControl(name='CANCEL').click()
    >>> manager.printQuery("id('content-body')//fieldset[2]//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/goals/1">Goal 1 - Added ... - Due ... - CLOSED</a>

Let's make sure we can view the goal that we just added.

    >>> manager.getLink('Goal 1').click()
    >>> manager.printQuery("id('content-body')/div//p")
    <p>Parent1 Parent1, Student1 Student1, Teacher1 Teacher1</p>
    <p>Poor attendence</p>
    <p>Get student to come in more often</p>
    <p>Attentive when there</p>
    <p>Student appears at least 4 time a week</p>
    <p>Call parents to arrange better attendence</p>
    <p>...</p>
    <p>Yes</p>
    <p></p>

Now that we've added a goal, let's edit it's strengths attribute and see that
the change is reflected in the goal's view.

    >>> manager.getLink('Edit').click()
    >>> manager.printQuery("id('content-body')//input[@type='checkbox']")
    <input type="checkbox" class="person_list" name="persons.teacher2-..." />
    <input type="checkbox" class="person_list" name="persons.counselor-..." />
    <input type="checkbox" class="person_list" name="persons.principal-..." />
    <input type="checkbox" class="person_list" checked="checked" name="persons.teacher1-..." />
    <input type="checkbox" class="notified_list" checked="checked" name="persons.student1-..." />
    <input type="checkbox" class="notified_list" checked="checked" name="contacts.Contact-..." />
    >>> manager.printQuery("id('content-body')//input[@type='radio']")
    <input type="radio" name="goal_met" value="No" />
    <input type="radio" name="goal_met" value="Yes" checked="checked" />
    >>> manager.printQuery("id('content-body')//textarea/text()")
    Poor attendence
    Get student to come in more often
    Attentive when there
    Student appears at least 4 time a week
    Call parents to arrange better attendence

    >>> manager.getControl('Strengths').value = 'Good listener'
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    >>> manager.printQuery("id('content-body')//p")
    <p>Parent1 Parent1, Student1 Student1, Teacher1 Teacher1</p>
    <p>Poor attendence</p>
    <p>Get student to come in more often</p>
    <p>Good listener</p>
    <p>Student appears at least 4 time a week</p>
    <p>Call parents to arrange better attendence</p>
    <p>...</p>
    <p>Yes</p>
    <p></p>

We should be able to return to the Intervention Center with a link.

    >>> manager.getLink('Intervention Center').click()
    >>> manager.printQuery("id('content-body')//fieldset[2]//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/goals/1">Goal 1 - Added ... - Due ... - CLOSED</a>

We can also cancel out of editing a goal which should return us back to the
goal's view.

    >>> manager.getLink('Goal 1').click()
    >>> manager.getLink('Edit').click()
    >>> manager.getControl(name='CANCEL').click()
    >>> manager.printQuery("id('content-body')/div//p")
    <p>Parent1 Parent1, Student1 Student1, Teacher1 Teacher1</p>
    <p>Poor attendence</p>
    <p>Get student to come in more often</p>
    <p>Good listener</p>
    <p>Student appears at least 4 time a week</p>
    <p>Call parents to arrange better attendence</p>
    <p>...</p>
    <p>Yes</p>
    <p></p>

Let's add a second goal to test our handling of multiple goals both in the
notification view and the goals report.

    >>> manager.getLink('Intervention Center').click()
    >>> manager.getLink('New Goal').click()
    >>> manager.getControl('Presenting concerns').value = 'Rude behavior'
    >>> manager.getControl(name='field.goal').value = 'Get student to be more polite'
    >>> manager.getControl('Strengths').value = 'Good grades'
    >>> manager.getControl('Indicators').value = 'Student no longer offends classmates'
    >>> manager.getControl('Intervention').value = 'Call parents to alert them to bad manners'
    >>> manager.getControl('Timeline').value = str(date.today())
    >>> choiceControl(manager, 'teacher2').value = False
    >>> choiceControl(manager, 'teacher1').value = True
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    From: manager@example.com
    To: teacher1@example.com
    Subject: INTERVENTION GOAL ADDED: Student1 Student1
    The following goal was added for Student1 Student1:
    <BLANKLINE>
    Presenting concerns
    -------------------
    <BLANKLINE>
    Rude behavior
    <BLANKLINE>
    Goal
    ----
    <BLANKLINE>
    Get student to be more polite
    <BLANKLINE>
    Strengths
    ---------
    <BLANKLINE>
    Good grades
    <BLANKLINE>
    Indicators
    ----------
    <BLANKLINE>
    Student no longer offends classmates
    <BLANKLINE>
    Intervention
    ------------
    <BLANKLINE>
    Call parents to alert them to bad manners
    <BLANKLINE>
    Timeline
    --------
    <BLANKLINE>
    ...
    <BLANKLINE>
    Persons responsible
    -------------------
    <BLANKLINE>
    Teacher1 Teacher1
    <BLANKLINE>
    Intervention Center
    -------------------
    <BLANKLINE>
    http://localhost/schooltool.interventions/2005-2006/student1
    >>> manager.printQuery("id('content-body')//fieldset[2]//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/goals/1">Goal 1 - Added ... - Due ... - CLOSED</a>
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/goals/2">Goal 2 - Added ... - Due ... - OPEN</a>

There is a button that allows us to call up the report that presents all of
the goals together.  Its output is a concatonation of what the view of goal 1
and the view of goal 2 would present.

    >>> manager.getLink('View All Goals').click()
    >>> manager.printQuery("id('content-body')//h3")
    <h3>Presenting concerns</h3>
    <h3>Goal</h3>
    <h3>Strengths</h3>
    <h3>Indicators</h3>
    <h3>Intervention</h3>
    <h3>Timeline</h3>
    <h3> Persons responsible: </h3>
    <h3>Goal met</h3>
    <h3>Follow up notes</h3>
    <h3>Presenting concerns</h3>
    <h3>Goal</h3>
    <h3>Strengths</h3>
    <h3>Indicators</h3>
    <h3>Intervention</h3>
    <h3>Timeline</h3>
    <h3> Persons responsible: </h3>
    <h3>Goal met</h3>
    <h3>Follow up notes</h3>
    >>> manager.printQuery("id('content-body')//span")
    <span>Parent1 Parent1</span>
    <span>Student1 Student1</span>
    <span>Teacher1 Teacher1</span>
    <span>Teacher1 Teacher1</span>
    >>> manager.printQuery("id('content-body')//p")
    <p>Poor attendence</p>
    <p>Get student to come in more often</p>
    <p>Good listener</p>
    <p>Student appears at least 4 time a week</p>
    <p>Call parents to arrange better attendence</p>
    <p>...</p>
    <p>Yes</p>
    <p></p>
    <p>Rude behavior</p>
    <p>Get student to be more polite</p>
    <p>Good grades</p>
    <p>Student no longer offends classmates</p>
    <p>Call parents to alert them to bad manners</p>
    <p>...</p>
    <p>No</p>
    <p></p>

We have a view that can be called up at any time that will send emails for
goals that have come due today (we set up our goals to be due today).  This
view will best be called automatically from a cron job making it a completely
automated system.  Note that student and parent entered in the first goal will
not receive this email.

    >>> manager.open('http://localhost/schooltool.interventions/notifyGoals.html')
    From: manager@example.com
    To: teacher1@example.com
    Subject: INTERVENTION GOAL DUE: Student1 Student1
    Please follow the link below to update the follow up notes and, if
    appropriate, the goal met status of the intervention goal for Student1 Student1.
    <BLANKLINE>
    http://localhost/schooltool.interventions/2005-2006/student1/goals/1/@@editGoal.html
    From: manager@example.com
    To: teacher1@example.com
    Subject: INTERVENTION GOAL DUE: Student1 Student1
    Please follow the link below to update the follow up notes and, if
    appropriate, the goal met status of the intervention goal for Student1 Student1.
    <BLANKLINE>
    http://localhost/schooltool.interventions/2005-2006/student1/goals/2/@@editGoal.html

    >>> manager.printQuery("id('content-body')//p")
    <p>The following goals had notifications sent to the persons responsible:</p>
    >>> manager.printQuery("id('content-body')//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/goals/1">Student1 Student1 goal 1</a>
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/goals/2">Student1 Student1 goal 2</a>

Now that the goals have been marked as notified, calling up the view again will
yield nothing.

    >>> manager.open('http://localhost/schooltool.interventions/notifyGoals.html')
    >>> manager.printQuery("id('content-body')//li")
    <li>There are no goals that need notification.</li>

Also, the notification flag will be reflected in the goal's view as well as
the view for all goals.

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Student1').click()
    >>> manager.getLink('Intervention Center').click()

    >>> manager.getLink('Goal 1').click()
    >>> manager.printQuery("id('content-body')//table/tr[1]/td[1]/h1")
    <h1> Persons responsible: notification sent </h1>

    >>> manager.getLink('Intervention Center').click()
    >>> manager.getLink('View All Goals').click()
    >>> manager.printQuery("id('content-body')//h3")
    <h3>Presenting concerns</h3>
    <h3>Goal</h3>
    <h3>Strengths</h3>
    <h3>Indicators</h3>
    <h3>Intervention</h3>
    <h3>Timeline</h3>
    <h3> Persons responsible: notification sent </h3>
    <h3>Goal met</h3>
    <h3>Follow up notes</h3>
    <h3>Presenting concerns</h3>
    <h3>Goal</h3>
    <h3>Strengths</h3>
    <h3>Indicators</h3>
    <h3>Intervention</h3>
    <h3>Timeline</h3>
    <h3> Persons responsible: notification sent </h3>
    <h3>Goal met</h3>
    <h3>Follow up notes</h3>

Change of Status Messages
-------------------------

There is a need for special change of status messages that would rarely be
sent and should be organized at the bottom part of the Intervention Center.
The most extreme example of changing a student's status would be to expel
the student from school.  Messages of that nature and less extreme can be
added using the separate 'Change of Status Messages' section of the student's
Intervention Center.

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Student1').click()
    >>> manager.getLink('Intervention Center').click()

    >>> manager.getLink('New Status Message').click()
    >>> choiceControl(manager, 'teacher2').value = False
    >>> choiceControl(manager, 'teacher1').value = True
    >>> manager.getControl(name='field.body').value = 'hello'
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    From: manager@example.com
    To: teacher1@example.com
    Subject: INTERVENTION STATUS CHANGE: Student1 Student1
    Default Manager writes:
    <BLANKLINE>
    hello

We see that it shows up in the intervention center.

    >>> manager.printQuery("id('content-body')//fieldset[4]//li/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/messages/3">Change of Status Message from Default Manager sent ...</a>

Let's make sure we can view the message that we just added.

    >>> manager.getLink('Change of Status Message from Default Manager').click()
    >>> manager.printQuery("id('content-body')//h3")
    <h3>Change of Status Message from: Default Manager sent ...</h3>
    >>> manager.printQuery("id('content-body')//span")
    <span>Teacher1 Teacher1</span>
    >>> manager.printQuery("id('content-body')//p")
    <p>hello</p>

There is a view for viewing all change of status messages together as there
is with normal messages.

    >>> manager.getLink('Intervention Center').click()
    >>> manager.getLink('View All Status Messages').click()
    >>> manager.printQuery("id('content-body')//h3")
    <h3>Change of Status Messages regarding Student1 Student1</h3>
    >>> manager.printQuery("id('content-body')//span")
    <span>Message sent by Default Manager on ...</span>
    <span>Teacher1 Teacher1</span>
    >>> manager.printQuery("id('content-body')//p")
    <p>hello</p>


SchoolYear Change
-----------------

For convenience we have a dropdown in the student intervention center to
change the schoolyear to a previous year.  Since we don't have a previous
year, we need to add one.

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('School Years').click()
    >>> manager.getLink('New School Year').click()
    >>> manager.getControl('Title').value = '2004-2005'
    >>> manager.getControl('First day').value = '2004-09-01'
    >>> manager.getControl('Last day').value = '2005-07-15'
    >>> manager.getControl('Add').click()

Now when we change the dropdown, we will see that we are at the intervention
center for the same student, but for the previous year.  Also, there are no
messages or goals because we never added any for that year.  Finally, there are
no buttons for adding messages or goals becuase adding them to an obsolete year
would not make sense.

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Student1').click()
    >>> manager.getLink('Intervention Center').click()
    >>> manager.getControl(name="schoolyear").value = ['2004-2005']
    >>> manager.getForm().submit()

    >>> manager.printQuery("id('content-body')//table/tr[1]/td[3]/a")
    <a href="http://localhost/persons/student1">Student1 Student1</a>
    >>> manager.printQuery("id('content-body')//form//select")
    <select name="schoolyear" onchange="this.form.submit()">
      <option value="2004-2005" selected="selected">2004-2005</option>
      <option value="2005-2006">2005-2006</option>
    </select>
    >>> manager.printQuery("id('content-body')//legend/b")
    <b>Messages and Observations</b>
    <b>Goals and Interventions</b>
    <b>Report Sheets</b>
    <b>Change of Status Messages</b>
    >>> manager.queryHTML("id('content-body')//fieldset[1]//li/a")
    []
    >>> manager.queryHTML("id('content-body')//fieldset[2]//li/a")
    []
    >>> manager.queryHTML("id('content-body')//fieldset[4]//li/a")
    []
    >>> manager.printQuery("id('content-body')//fieldset//a/text()")
    View All Messages
    View All Goals
    View All Status Messages


Section intervention view
-------------------------

The section intervention view gives quick access to various
intervention views for students in the section.

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('School Years').click()
    >>> manager.getLink('2005-2006').click()
    >>> manager.getLink('Spring').click()
    >>> manager.getLink('Sections').click()
    >>> manager.getLink('section1').click()
    >>> manager.getLink('Interventions').click()

The Messages tab is the default.  The provided links allow the teacher to
preview existing and compose new messages.  Note that status messages are
ignored when displaying message count for the student.

    >>> manager.printQuery("id('content-body')//div[@class='student_nav_link']/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/messages/allMessages.html">View Messages (2)</a>
    <a href="http://localhost/schoolyears/2005-2006/spring/sections/1/messages/student1/+/addMessage.html">Write New</a>
    <a href="http://localhost/schooltool.interventions/2005-2006/student3/messages/allMessages.html">View Messages (0)</a>
    <a href="http://localhost/schoolyears/2005-2006/spring/sections/1/messages/student3/+/addMessage.html">Write New</a>
    >>> manager.printQuery("id('content-body')//div[@class='tabmenu']/a")
    <a href="http://localhost/schoolyears/2005-2006/spring/sections/1/interventions.html?TAB=goals">Goals</a>
    >>> manager.printQuery("id('content-body')//td/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1">Student1 Student1</a>
    <a href="http://localhost/schooltool.interventions/2005-2006/student3">Student3 Student3</a>

We can add a new message from here by clicking on the 'Write New' link.  We'll
do this for Student3 to help set up dashboard tests.

    >>> manager.getLink('Write New', index=1).click()
    >>> choiceControl(manager, 'teacher1').value = True
    >>> manager.getControl(name='field.body').value = 'Message for Student3'
    >>> manager.getControl(name='UPDATE_SUBMIT').click()
    From: manager@example.com
    To: teacher1@example.com
    Subject: INTERVENTION MESSAGE: Student3 Student3
    Default Manager writes:
    <BLANKLINE>
    Message for Student3

The Goals tab provides shortcuts to viewing student goals.

    >>> manager.getLink('Goals').click()
    >>> manager.printQuery("id('content-body')//div[@class='student_nav_link']/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1/goals/allGoals.html">View Goals (2)</a>
    <a href="http://localhost/schooltool.interventions/2005-2006/student3/goals/allGoals.html">View Goals (0)</a>
    >>> manager.printQuery("id('content-body')//div[@class='tabmenu']/a")
    <a href="http://localhost/schoolyears/2005-2006/spring/sections/1/interventions.html?TAB=messages">Messages</a>
    >>> manager.printQuery("id('content-body')//td/a")
    <a href="http://localhost/schooltool.interventions/2005-2006/student1">Student1 Student1</a>
    <a href="http://localhost/schooltool.interventions/2005-2006/student3">Student3 Student3</a>


At One Time Responsible
-----------------------

We have a special case in the user interface for editing goals where one of
the persons_responsible is no longer either a teacher, advisor or administrator
of the student.  The security issues regarding this scenario are tested in
security.txt, but here we need to test the way it is handled in the UI.

First of all, we already have created a goal where teacher1 is responsible.
When we call up the edit view for the goal, we note that teacher1 appears
in the staff section of the person list, not the student section.  We also
note that he is checked.

    >>> manager.open('http://localhost/schooltool.interventions/2005-2006/student1/goals/2/editGoal.html')
    >>> manager.printQuery('//table//tr[2]//td[1]//span')
    <span>
      <b>Teacher2 Teacher2 (advisor)</b>
    </span>
    <span>
      <b>Counselor Counselor</b>
    </span>
    <span>
      <b>Principal Principal</b>
    </span>
    <span>
      <b>Teacher1 Teacher1</b>
    </span>
    >>> manager.printQuery('//table//tr[2]//td[1]//b')
    <b>Teacher2 Teacher2 (advisor)</b>
    <b>Counselor Counselor</b>
    <b>Principal Principal</b>
    <b>Teacher1 Teacher1</b>
    >>> manager.printQuery('//table//tr[2]//td[2]//b')
    <b>Student1 Student1</b>
    <b>Parent1 Parent1 (parent)</b>
    >>> manager.printQuery('//table//tr[2]//td[2]//b')
    <b>Student1 Student1</b>
    <b>Parent1 Parent1 (parent)</b>

We want to remove him from the section that gave him access to the student.

    >>> manager.getLink('2005-2006').click()
    >>> manager.getLink('Spring').click()
    >>> manager.getLink('Sections').click()
    >>> manager.getLink('section1').click()
    >>> manager.getLink('edit instructors').click()
    >>> manager.getControl(name='remove_item.teacher1').value = 'checked'
    >>> manager.getControl('Remove').click()

Now, let's edit the goal and note that there is a new section in the person
list labeled 'Changed Status' and that teacher1 is listed there and is still
checked.

    >>> manager.open('http://localhost/schooltool.interventions/2005-2006/student1/goals/2/editGoal.html')
    >>> manager.printQuery('//table//tr[2]//td[1]//b')
    <b>Teacher2 Teacher2 (advisor)</b>
    <b>Counselor Counselor</b>
    <b>Principal Principal</b>
    >>> manager.printQuery('//table//tr[2]//td[1]//b')
    <b>Teacher2 Teacher2 (advisor)</b>
    <b>Counselor Counselor</b>
    <b>Principal Principal</b>
    >>> manager.printQuery('//table//tr[2]//td[2]//span')
    <span>
      <b>Student1 Student1</b>
    </span>
    <span>
      <b>Parent1 Parent1 (parent)</b>
    </span>
    <span>Changed Status</span>
    <span>
      <b>Teacher1 Teacher1</b>
    </span>
    >>> manager.printQuery('//table//tr[2]//td[2]//input[@class="changed_list"]/@checked')
    checked

We'll go ahead and uncheck him, or course, checking another person in order
to successfully submit.

    >>> choiceControl(manager, 'teacher1').value = False
    >>> choiceControl(manager, 'teacher2').value = True
    >>> manager.getControl('Apply').click()

Now we see that the teacher is still in the 'Changed Status' section but not
checked.  This represents the scenario where the teacher no longer can
add goals for the student, nor can he even view this goal anymore.  However,
we keep him around in the goal.at_one_time_responsible list, and thus, he
will continue to appear in the person list in the special section.  Maybe we'll
want to put him back in the persons_responsible list at a later date.

    >>> manager.open('http://localhost/schooltool.interventions/2005-2006/student1/goals/2/editGoal.html')
    >>> manager.printQuery('//table//tr[2]//td[1]//b')
    <b>Teacher2 Teacher2 (advisor)</b>
    <b>Counselor Counselor</b>
    <b>Principal Principal</b>
    >>> manager.printQuery('//table//tr[2]//td[2]//span')
    <span>
      <b>Student1 Student1</b>
    </span>
    <span>
      <b>Parent1 Parent1 (parent)</b>
    </span>
    <span>Changed Status</span>
    <span>
      <b>Teacher1 Teacher1</b>
    </span>
    >>> manager.printQuery('//table//tr[2]//td[2]//input[@class="changed_list"]/@checked')

Finally, we'd like to make sure that when we make teacher1 again the teacher
of one of student1's sections, he will appear back in the original section
of the person list.

    >>> manager.getLink('2005-2006').click()
    >>> manager.getLink('Spring').click()
    >>> manager.getLink('Sections').click()
    >>> manager.getLink('section1').click()
    >>> manager.getLink('edit instructors').click()
    >>> manager.getControl(name='add_item.teacher1').value = 'checked'
    >>> manager.getControl('Add').click()

So now when we go back to edit the goal, teacher1 appears back in the original
section, unchecked.  Also, the 'Changed Status' section disappears.  It's like
he was never gone.

    >>> manager.open('http://localhost/schooltool.interventions/2005-2006/student1/goals/2/editGoal.html')
    >>> manager.printQuery('//table//tr[2]//td[1]//b')
    <b>Teacher2 Teacher2 (advisor)</b>
    <b>Counselor Counselor</b>
    <b>Principal Principal</b>
    <b>Teacher1 Teacher1</b>
    >>> manager.printQuery('//table//tr[2]//td[2]//span')
    <span>
      <b>Student1 Student1</b>
    </span>
    <span>
      <b>Parent1 Parent1 (parent)</b>
    </span>


Intervention CSV views
----------------------

We supply CSV views for extracting the messages and goals from a schooltool
instance.

    >>> manager.open('http://localhost/messages.csv')
    >>> print manager.contents
    "year","student","date","sender","recipients","body"
    "2005-2006","student1","...","manager","parent@somewhere.com, teacher1@example.com","hi\nthere"
    "2005-2006","student1","...","manager","teacher1@example.com, teacher2@example.com","hello again"
    "2005-2006","student1","...","manager","teacher1@example.com","hello"
    "2005-2006","student3","...","manager","teacher1@example.com","Message for Student3"

    >>> manager.open('http://localhost/goals.csv')
    >>> print manager.contents
    "year","student","created","creator","presenting_concerns","goal","strengths","indicators","intervention","timeline","persons_responsible","goal_met","follow_up_notes","notified"
    "2005-2006","student1","...","manager","Poor attendence","Get student to come in more often","Good listener","Student appears at least 4 time a week","Call parents to arrange better attendence","...","parent@somewhere.com, student1@example.com, teacher1@example.com","True","","True"
    "2005-2006","student1","...","manager","Rude behavior","Get student to be more polite","Good grades","Student no longer offends classmates","Call parents to alert them to bad manners","...","teacher2@example.com","False","","True"