sakai-cle-test-api 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/lib/sakai-cle-test-api.rb +7 -2
  2. data/lib/sakai-cle-test-api/add_files.rb +198 -0
  3. data/lib/sakai-cle-test-api/admin_page_elements.rb +7 -3
  4. data/lib/sakai-cle-test-api/announcements.rb +274 -7
  5. data/lib/sakai-cle-test-api/assessments.rb +930 -27
  6. data/lib/sakai-cle-test-api/assignments.rb +769 -13
  7. data/lib/sakai-cle-test-api/basic_lti.rb +5 -1
  8. data/lib/sakai-cle-test-api/blogs.rb +54 -2
  9. data/lib/sakai-cle-test-api/calendar.rb +423 -8
  10. data/lib/sakai-cle-test-api/chat_room.rb +0 -0
  11. data/lib/sakai-cle-test-api/common_page_elements.rb +69 -172
  12. data/lib/sakai-cle-test-api/core-ext.rb +90 -0
  13. data/lib/sakai-cle-test-api/data_objects/announcement.rb +38 -0
  14. data/lib/sakai-cle-test-api/data_objects/assessment.rb +32 -0
  15. data/lib/sakai-cle-test-api/data_objects/assignment.rb +62 -0
  16. data/lib/sakai-cle-test-api/data_objects/event.rb +86 -0
  17. data/lib/sakai-cle-test-api/data_objects/lesson.rb +137 -0
  18. data/lib/sakai-cle-test-api/data_objects/resource.rb +174 -0
  19. data/lib/sakai-cle-test-api/data_objects/site.rb +213 -0
  20. data/lib/sakai-cle-test-api/data_objects/syllabus.rb +7 -0
  21. data/lib/sakai-cle-test-api/data_objects/topic.rb +0 -0
  22. data/lib/sakai-cle-test-api/data_objects/web_content_tool.rb +52 -0
  23. data/lib/sakai-cle-test-api/data_objects/wiki.rb +7 -0
  24. data/lib/sakai-cle-test-api/drop_box.rb +21 -0
  25. data/lib/sakai-cle-test-api/email_archive.rb +15 -1
  26. data/lib/sakai-cle-test-api/forums.rb +282 -8
  27. data/lib/sakai-cle-test-api/gem_ext.rb +45 -0
  28. data/lib/sakai-cle-test-api/gradebook.rb +19 -1
  29. data/lib/sakai-cle-test-api/gradebook2.rb +15 -1
  30. data/lib/sakai-cle-test-api/lessons.rb +440 -0
  31. data/lib/sakai-cle-test-api/messages.rb +551 -15
  32. data/lib/sakai-cle-test-api/news.rb +3 -1
  33. data/lib/sakai-cle-test-api/polls.rb +65 -3
  34. data/lib/sakai-cle-test-api/profile.rb +36 -2
  35. data/lib/sakai-cle-test-api/profile2.rb +315 -6
  36. data/lib/sakai-cle-test-api/resources.rb +138 -0
  37. data/lib/sakai-cle-test-api/rich_text.rb +13 -0
  38. data/lib/sakai-cle-test-api/sections.rb +198 -8
  39. data/lib/sakai-cle-test-api/site_page_elements.rb +4 -441
  40. data/lib/sakai-cle-test-api/syllabus.rb +149 -7
  41. data/lib/sakai-cle-test-api/tools_menu.rb +3 -20
  42. data/lib/sakai-cle-test-api/utilities.rb +260 -0
  43. data/sakai-cle-test-api.gemspec +2 -3
  44. metadata +21 -19
File without changes
@@ -143,11 +143,12 @@ class EditEvaluationAssignment
143
143
  end
144
144
 
145
145
  def check_group(title)
146
+ frm.table(:class=>"listHier lines nolines").wait_until_present
146
147
  frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(title)}/).checkbox(:name=>"selectedGroupIDs").set
147
148
  end
148
149
 
149
150
  in_frame(:class=>"portletMainIframe") do |frame|
150
-
151
+ link(:assign_to_evaluation_groups, :text=>"Assign to Evaluation Groups", :frame=>frame)
151
152
  end
152
153
  end
153
154
 
@@ -226,11 +227,6 @@ class Home
226
227
  button(:update_announcements, :name=>"eventSubmit_doUpdate", :frame=>frame)
227
228
  end
228
229
 
229
- # The Home class should be instantiated whenever the user
230
- # context is a given Site or the Administration Workspace.
231
- # In that context, the frame index is 1.
232
- $frame_index=1
233
-
234
230
  # Gets the text of the displayed announcements, for
235
231
  # test case verification
236
232
  def announcements_list
@@ -302,135 +298,7 @@ class MyWorkspace
302
298
 
303
299
  end
304
300
 
305
- #================
306
- # Resources Pages
307
- #================
308
-
309
- # New class template. For quick class creation...
310
- class ResourcesUploadFiles
311
-
312
- include ToolsMenu
313
-
314
- @@filex=0
315
-
316
- # Enters the specified folder/filename value into
317
- # the file field on the page. Note that files are
318
- # assumed to be in the relative path ../../data/sakai-cle-test-api
319
- # The method will throw an error if the specified file
320
- # is not found.
321
- #
322
- # This method is designed to be able to use
323
- # multiple times, but it assumes
324
- # that the add_another_file method is used
325
- # before it, every time except before the first time.
326
- def file_to_upload(file_name, file_path="")
327
- frm.file_field(:id, "content_#{@@filex}").set(file_path + file_name)
328
- @@filex+=1
329
- end
330
-
331
- # Clicks the Upload Files Now button, resets the
332
- # @@filex class variable back to zero, and instantiates
333
- # the Resources page class.
334
- def upload_files_now
335
- frm.button(:value=>"Upload Files Now").click
336
- @@filex=0
337
- Resources.new(@browser)
338
- end
339
-
340
- # Clicks the Add Another File link.
341
- def add_another_file
342
- frm.link(:text=>"Add Another File").click
343
- end
344
-
345
- end
346
-
347
- class EditFileDetails
348
-
349
- include ToolsMenu
350
-
351
- # Clicks the Update button, then instantiates
352
- # the Resources page class.
353
- def update
354
- frm.button(:value=>"Update").click
355
- Resources.new(@browser)
356
- end
357
-
358
- # Enters the specified string into the title field.
359
- def title=(title)
360
- frm.text_field(:id=>"displayName_0").set(title)
361
- end
362
-
363
- # Enters the specified string into the description field.
364
- def description=(description)
365
- frm.text_field(:id=>"description_0").set(description)
366
- end
367
-
368
- # Sets the radio button for publically viewable.
369
- def select_publicly_viewable
370
- frm.radio(:id=>"access_mode_public_0").set
371
- end
372
-
373
- # Checks the checkbox for showing only on the specifed
374
- # condition.
375
- def check_show_only_if_condition
376
- frm.checkbox(:id=>"cbCondition_0")
377
- end
378
-
379
- # Selects the specified Gradebook item value in the
380
- # select list.
381
- def gradebook_item=(item)
382
- frm.select(:id=>"selectResource_0").select(item)
383
- end
384
-
385
- # Selects the specified value in the item condition
386
- # field.
387
- def item_condition=(condition)
388
- frm.select(:id=>"selectCondition_0").select(condition)
389
- end
390
-
391
- # Sets the Grade field to the specified value.
392
- def assignment_grade=(grade)
393
- frm.text_field(:id=>"assignment_grade_0").set(grade)
394
- end
395
- end
396
-
397
- class CreateFolders #FIXME - Need to add functions for adding multiple folders
398
-
399
- include ToolsMenu
400
-
401
- # Clicks the Create Folders Now button, then
402
- # instantiates the Resources page class.
403
- def create_folders_now
404
- frm.button(:value=>"Create Folders Now").click
405
- Resources.new(@browser)
406
- end
407
-
408
- # Enters the specified string in the Folder Name
409
- # text field.
410
- def folder_name=(name)
411
- frm.text_field(:id=>"content_0").set(name)
412
- end
413
-
414
- end
415
-
416
- # Resources page for a given Site, in the Course Tools menu
417
- class Resources < AddFiles
418
301
 
419
- include ToolsMenu
420
-
421
- def initialize(browser)
422
- @browser = browser
423
-
424
- @@classes = {
425
- :this=> "Resources",
426
- :parent => "Resources",
427
- :file_details => "EditFileDetails",
428
- :create_folders => "CreateFolders",
429
- :upload_files => "ResourcesUploadFiles"
430
- }
431
- end
432
-
433
- end
434
302
 
435
303
  #================
436
304
  # Administrative Search Pages
@@ -514,7 +382,11 @@ class SiteSetup
514
382
 
515
383
  include PageObject
516
384
  include ToolsMenu
517
-
385
+
386
+ def search_field
387
+ frm.text_field(:id, "search")
388
+ end
389
+
518
390
  # Clicks the "New" link on the Site Setup page.
519
391
  # instantiates the SiteType class.
520
392
  def new
@@ -527,7 +399,7 @@ class SiteSetup
527
399
  # Then clicks the Edit button and instantiates
528
400
  # The SiteSetupEdit class.
529
401
  def edit(site_name)
530
- frm.text_field(:id, "search").value=Regexp.escape(site_name)
402
+ search_field.value=Regexp.escape(site_name)
531
403
  frm.button(:value=>"Search").click
532
404
  frm.div(:class=>"portletBody").checkbox(:name=>"selectedMembers").set
533
405
  frm.div(:class=>"portletBody").link(:text, "Edit").click
@@ -538,7 +410,7 @@ class SiteSetup
538
410
  # field, clicks the Search button, then reinstantiates
539
411
  # the Class due to the page refresh.
540
412
  def search(site_name)
541
- frm.text_field(:id, "search").set site_name
413
+ search_field.set site_name
542
414
  frm.button(:value, "Search").click
543
415
  SiteSetup.new(@browser)
544
416
  end
@@ -547,7 +419,7 @@ class SiteSetup
547
419
  # checks the site, clicks the delete button,
548
420
  # and instantiates the DeleteSite class.
549
421
  def delete(site_name)
550
- frm.text_field(:id, "Search").value=site_name
422
+ search_field.value=site_name
551
423
  frm.button(:value=>"Search").click
552
424
  frm.checkbox(:name=>"selectedMembers").set
553
425
  frm.div(:class=>"portletBody").link(:text, "Delete").click
@@ -603,11 +475,17 @@ class SiteEditor
603
475
  frm.button(:value=>"Update Participants").click
604
476
  SiteEditor.new(@browser)
605
477
  end
606
-
478
+
479
+ def return_button
480
+ frm.button(:name=>"back")
481
+ end
482
+
483
+ def return_to_sites_list
484
+ return_button.click
485
+ end
486
+
607
487
  in_frame(:class=>"portletMainIframe") do |frame|
608
488
  button(:previous, :name=>"previous", :frame=>frame)
609
- button(:return_to_sites_list, :name=>"", :frame=>frame)
610
- button(:next, :name=>"", :frame=>frame)
611
489
  link(:printable_version, :text=>"Printable Version", :frame=>frame)
612
490
  select_list(:select_page_size, :name=>"selectPageSize", :frame=>frame)
613
491
  button(:next, :name=>"eventSubmit_doList_next", :frame=>frame)
@@ -816,20 +694,8 @@ class EditSiteTools
816
694
  include PageObject
817
695
  include ToolsMenu
818
696
 
819
- # Clicks the Continue button, then instantiates
820
- # the appropriate class for the page that apears.
821
- def continue
822
- frm.button(:value=>"Continue").click
823
- # Logic for determining the new page class...
824
- if frm.div(:class=>"portletBody").text =~ /^Add Multiple Tool/
825
- AddMultipleTools.new(@browser)
826
- elsif frm.div(:class=>"portletBody").text =~ /^Confirming site tools edits for/
827
- ConfirmSiteToolsEdits.new(@browser)
828
- else
829
- puts "Something is wrong"
830
- puts frm.div(:class=>"portletBody").text
831
- end
832
- end
697
+ # Clicks the Continue button.
698
+ action(:continue) { |b| b.frm.button(:value=>"Continue").click }
833
699
 
834
700
  in_frame(:class=>"portletMainIframe") do |frame|
835
701
  # This is a comprehensive list of all checkboxes and
@@ -894,16 +760,46 @@ class EditSiteTools
894
760
 
895
761
  end
896
762
 
763
+ class ReUseMaterial
764
+
765
+ include PageObject
766
+ include ToolsMenu
767
+
768
+ thing(:announcements_checkbox) { |b| b.frm.checkbox(name: "sakai.announcements") }
769
+ thing(:calendar_checkbox) { |b| b.frm.checkbox(name: "sakai.schedule") }
770
+ thing(:discussion_forums_checkbox) { |b| b.frm.checkbox(name: "sakai.jforum.tool") }
771
+ thing(:forums_checkbox) { |b| b.frm.checkbox(name: "sakai.forums") }
772
+ thing(:chat_room_checkbox) { |b| b.frm.checkbox(name: "sakai.chat") }
773
+ thing(:polls_checkbox) { |b| b.frm.checkbox(name: "sakai.poll") }
774
+ thing(:syllabus_checkbox) { |b| b.frm.checkbox(name: "sakai.syllabus") }
775
+ thing(:lessons_checkbox) { |b| b.frm.checkbox(name: "sakai.melete") }
776
+ thing(:resources_checkbox) { |b| b.frm.checkbox(name: "sakai.resources") }
777
+ thing(:assignments_checkbox) { |b| b.frm.checkbox(name: "sakai.assignment.grades") }
778
+ thing(:tests_and_quizzes_checkbox) { |b| b.frm.checkbox(name: "sakai.samigo") }
779
+ thing(:gradebook_checkbox) { |b| b.frm.checkbox(name: "sakai.gradebook.tool") }
780
+ thing(:gradebook2_checkbox) { |b| b.frm.checkbox(name: "sakai.gradebook.gwt.rpc") }
781
+ thing(:wiki_checkbox) { |b| b.frm.checkbox(name: "sakai.rwiki") }
782
+ thing(:news_checkbox) { |b| b.frm.checkbox(name: "sakai.news") }
783
+ thing(:web_content_checkbox) { |b| b.frm.checkbox(name: "sakai.iframe") }
784
+ thing(:site_statistics_checkbox) { |b| b.frm.checkbox(name: "sakai.sitestats") }
785
+ action(:continue) { |b| b.frm.button(name: "eventSubmit_doContinue").click }
786
+
787
+ end
788
+
897
789
  # Confirmation page when editing site tools in Site Setup
898
790
  class ConfirmSiteToolsEdits
899
791
 
900
792
  include PageObject
901
793
  include ToolsMenu
902
-
794
+
795
+ def finish_button
796
+ frm.button(:value=>"Finish")
797
+ end
798
+
903
799
  # Clicks the Finish button, then instantiates
904
800
  # the SiteSetupEdit class.
905
801
  def finish
906
- frm.button(:value=>"Finish").click
802
+ finish_button.click
907
803
  SiteEditor.new(@browser)
908
804
  end
909
805
 
@@ -993,20 +889,8 @@ class AddMultipleTools
993
889
  include PageObject
994
890
  include ToolsMenu
995
891
 
996
- # Clicks the Continue button, then instantiates
997
- # the appropriate Class, based on the page that
998
- # appears.
999
- def continue
1000
- frm.button(:value=>"Continue").click
1001
- # Logic to determine the new page class
1002
- if frm.div(:class=>"portletBody").text =~ /Course Site Access/
1003
- SiteAccess.new(@browser)
1004
- elsif frm.div(:class=>"portletBody").text =~ /^Confirming site tools edits/
1005
- ConfirmSiteToolsEdits.new(@browser)
1006
- else
1007
- puts "There's another path to define"
1008
- end
1009
- end
892
+ # Clicks the Continue button.
893
+ action(:continue) { |b| b.frm.button(:value=>"Continue").click }
1010
894
 
1011
895
  in_frame(:class=>"portletMainIframe") do |frame|
1012
896
  # Note that the text field definitions included here
@@ -1142,7 +1026,20 @@ class CourseSiteInfo
1142
1026
 
1143
1027
  include PageObject
1144
1028
  include ToolsMenu
1145
-
1029
+ include FCKEditor
1030
+
1031
+ def editor
1032
+ frm.frame(:id=>"description___Frame")
1033
+ end
1034
+
1035
+ def description=(text)
1036
+ editor.td(:id, "xEditingArea").frame(:index=>0).send_keys text
1037
+ end
1038
+
1039
+ def source=(text)
1040
+ editor.td(:id, "xEditingArea").text_field(:class=>"SourceField").set text
1041
+ end
1042
+
1146
1043
  # Clicks the Continue button, then
1147
1044
  # instantiates the EditSiteTools Class.
1148
1045
  def continue
@@ -0,0 +1,90 @@
1
+ class Time
2
+
3
+ # Using the :year_range option (or no option), this method creates a
4
+ # Time object of a random value, within
5
+ # the year range specified (default is 5 years in the past).
6
+ #
7
+ # Using the :series option, this method returns an array
8
+ # containing a randomized Time object as its first element (limited by
9
+ # the specified :year_range value). Subsequent elements will be Time objects
10
+ # with values putting them later than the prior element, within the specified
11
+ # range value (see examples).
12
+ #
13
+ # Usage Examples:
14
+ # @example
15
+ # a random date...
16
+ # ?> Time.random
17
+ # => Tue Aug 05 00:00:00 EDT 2007
18
+ #
19
+ # birthdays, anyone?...
20
+ # 5.times { p Time.random(:year_range=>80) }
21
+ # Wed Feb 06 00:00:00 EDT 1974
22
+ # Tue Dec 22 00:00:00 EST 1992
23
+ # Fri Apr 14 00:00:00 EWT 1944
24
+ # Thu Jul 01 00:00:00 EDT 1993
25
+ # Wed Oct 02 00:00:00 EDT 2002
26
+ #
27
+ # A series of dates are useful for account-related info...
28
+ # ?> Time.random(:series=>[20.days, 3.years])
29
+ # => [Sat Jan 22 00:00:00 EST 2005,
30
+ # Sat Jan 29 12:58:45 EST 2005,
31
+ # Fri Sep 08 09:34:58 EDT 2006]
32
+ #
33
+ # or maybe to simulate events during an hour?...
34
+ # ?> Time.random(:series=>[1.hour,1.hour,1.hour])
35
+ # => [Wed Apr 21 00:00:00 EDT 2004,
36
+ # Wed Apr 21 00:45:59 EDT 2004,
37
+ # Wed Apr 21 01:02:47 EDT 2004,
38
+ # Wed Apr 21 01:31:00 EDT 2004]
39
+ def self.random(params={})
40
+ years_back = params[:year_range] || 5
41
+ year = (rand * (years_back)).ceil + (Time.now.year - years_back)
42
+ month = (rand * 12).ceil
43
+ day = (rand * 31).ceil
44
+ series = [date = Time.local(year, month, day)]
45
+ if params[:series]
46
+ params[:series].each do |some_time_after|
47
+ series << series.last + (rand * some_time_after).ceil
48
+ end
49
+ return series
50
+ end
51
+ date
52
+ end
53
+
54
+ end # Time
55
+
56
+ module Enumerable
57
+
58
+ # Use for getting a natural sort order instead of the ASCII
59
+ # sort order.
60
+ def alphabetize
61
+ sort { |a, b| grouped_compare(a, b) }
62
+ end
63
+
64
+ # Use for sorting an Enumerable object in place.
65
+ def alphabetize!
66
+ sort! { |a, b| grouped_compare(a, b) }
67
+ end
68
+
69
+ private
70
+ def grouped_compare(a, b)
71
+ loop {
72
+ a_chunk, a = extract_alpha_or_number_group(a)
73
+ b_chunk, b = extract_alpha_or_number_group(b)
74
+ ret = a_chunk <=> b_chunk
75
+ return -1 if a_chunk == ''
76
+ return ret if ret != 0
77
+ }
78
+ end
79
+
80
+ def extract_alpha_or_number_group(item)
81
+ test_item = item.downcase
82
+ matchdata = /([a-z]+|[\d]+)/.match(test_item)
83
+ if matchdata.nil?
84
+ ["", ""]
85
+ else
86
+ [matchdata[0], test_item = test_item[matchdata.offset(0)[1] .. -1]]
87
+ end
88
+ end
89
+
90
+ end # Enumerable
@@ -0,0 +1,38 @@
1
+ class AnnouncementObject
2
+
3
+ include PageObject
4
+ include Utilities
5
+ include ToolsMenu
6
+
7
+ attr_accessor :title, :body, :site, :link
8
+
9
+ def initialize(browser, opts={})
10
+ @browser = browser
11
+
12
+ defaults = {
13
+ :title=>random_alphanums,
14
+ :body=>random_multiline(500, 10, :alpha)
15
+ }
16
+ options = defaults.merge(opts)
17
+ @title=options[:title]
18
+ @body=options[:body]
19
+ @site=options[:site]
20
+ raise "You must specify a Site for the announcement" if @site==nil
21
+ end
22
+
23
+ def create
24
+ my_workspace.open_my_site_by_name @site unless @browser.title=~/#{@site}/
25
+ announcements unless @browser.title=~/Announcements$/
26
+ on_page Announcements do |page|
27
+ page.add
28
+ end
29
+ on_page AddEditAnnouncements do |page|
30
+ page.title=@title
31
+ page.body=@body
32
+ page.add_announcement
33
+ end
34
+ on_page Announcements do |page|
35
+ @link = page.href(@title)
36
+ end
37
+ end
38
+ end