sakai-cle-test-api 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -3,12 +3,125 @@
3
3
  # Assessments pages - "Samigo", a.k.a., "Tests & Quizzes"
4
4
  #================
5
5
 
6
+ # This is a module containing methods that are
7
+ # common to all the question pages inside the
8
+ # Assessment section of a Site.
9
+ module QuestionHelpers
10
+ include PageObject
11
+ # Saves the question by clicking the Save button, then makes the determination
12
+ # whether to instantiate the EditAssessment class, or the EditQuestionPool class.
13
+ def save
14
+
15
+ quiz = frm.div(:class=>"portletBody").div(:index=>0).text
16
+ pool = frm.div(:class=>"portletBody").div(:index=>1).text
17
+
18
+ frm.button(:value=>"Save").click
19
+
20
+ if quiz =~ /^Assessments/
21
+ EditAssessment.new(@browser)
22
+ elsif pool =~ /^Question Pools/
23
+ EditQuestionPool.new(@browser)
24
+ else
25
+ puts "Unexpected text: "
26
+ p pool
27
+ p quiz
28
+ end
29
+
30
+ end
31
+
32
+ in_frame(:class=>"portletMainIframe") do |frame|
33
+ link(:assessments, :text=>"Assessments", :frame=>frame)
34
+ link(:assessment_types, :text=>"Assessment Types", :frame=>frame)
35
+ link(:question_pools, :text=>"Question Pools", :frame=>frame)
36
+ link(:questions, :text=>/Questions:/, :frame=>frame)
37
+ end
38
+
39
+ end
40
+
6
41
  # The Course Tools "Tests and Quizzes" page for a given site.
7
42
  # (Instructor view)
8
43
  class AssessmentsList
9
44
  include PageObject
10
45
  include ToolsMenu
11
- include AssessmentsListMethods
46
+
47
+ # This method reads the type of assessment selected for creation,
48
+ # then clicks the Create button and instantiates the proper class.
49
+ #
50
+ # If the assessment is going to be made in the builder, then
51
+ # EditAssessment is called. If from Markup text...
52
+ def create
53
+ builder_or_text = frm.radio(:value=>"1", :name=>"authorIndexForm:_id29").set?
54
+
55
+ frm.button(:value=>"Create").click
56
+
57
+ if builder_or_text == true
58
+ EditAssessment.new(@browser)
59
+ else
60
+ # Need to add Markup page class, then add the reference here.
61
+ end
62
+
63
+ end
64
+
65
+ # Clicks the Question Pools link, then instantiates
66
+ # the QuestionPoolsList class.
67
+ def question_pools
68
+ frm.link(:text=>"Question Pools").click
69
+ QuestionPoolsList.new(@browser)
70
+ end
71
+
72
+ # Collects the titles of the Assessments listed as "Pending"
73
+ # then returns them as an Array.
74
+ def pending_assessment_titles
75
+ titles =[]
76
+ pending_table = frm.table(:id=>"authorIndexForm:coreAssessments")
77
+ 1.upto(pending_table.rows.size-1) do |x|
78
+ titles << pending_table[x][1].span(:id=>/assessmentTitle/).text
79
+ end
80
+ return titles
81
+ end
82
+
83
+ # Collects the titles of the Assessments listed as "Published"
84
+ # then returns them as an Array.
85
+ def published_assessment_titles
86
+ titles =[]
87
+ published_table = frm.div(:class=>"tier2", :index=>2).table(:class=>"listHier", :index=>0)
88
+ 1.upto(published_table.rows.size-1) do |x|
89
+ titles << published_table[x][1].span(:id=>/publishedAssessmentTitle/).text
90
+ end
91
+ return titles
92
+ end
93
+
94
+ # Returns an Array of the inactive Assessment titles displayed
95
+ # in the list.
96
+ def inactive_assessment_titles
97
+ titles =[]
98
+ inactive_table = frm.div(:class=>"tier2", :index=>2).table(:id=>"authorIndexForm:inactivePublishedAssessments")
99
+ 1.upto(inactive_table.rows.size-1) do |x|
100
+ titles << inactive_table[x][1].span(:id=>/inactivePublishedAssessmentTitle/).text
101
+ end
102
+ return titles
103
+ end
104
+
105
+ # Opens the selected test for scoring
106
+ # then instantiates the AssessmentTotalScores class.
107
+ # @param test_title [String] the title of the test to be clicked.
108
+ def score_test(test_title)
109
+ frm.tbody(:id=>"authorIndexForm:_id88:tbody_element").row(:text=>/#{Regexp.escape(test_title)}/).link(:id=>/authorIndexToScore/).click
110
+ AssessmentTotalScores.new(@browser)
111
+ end
112
+
113
+ in_frame(:class=>"portletMainIframe") do |frame|
114
+ link(:assessment_types, :text=>"Assessment Types", :frame=>frame)
115
+ text_field(:title, :id=>"authorIndexForm:title", :frame=>frame)
116
+ radio_button(:create_using_builder) { |page| page.radio_button_element(:name=>"authorIndexForm:_id29", index=>0, :frame=>frame) }
117
+ radio_button(:create_using_text) { |page| page.radio_button_element(:name=>"authorIndexForm:_id29", :index=>$frame_index, :frame=>frame) }
118
+ select_list(:select_assessment_type, :id=>"authorIndexForm:assessmentTemplate", :frame=>frame)
119
+ button(:import, :id=>"authorIndexForm:import", :frame=>frame)
120
+ #(:, :=>"", :frame=>frame)
121
+ #(:, :=>"", :frame=>frame)
122
+
123
+ end
124
+
12
125
  end
13
126
 
14
127
  # Page that appears when previewing an assessment.
@@ -16,21 +129,201 @@ end
16
129
  class PreviewOverview
17
130
  include PageObject
18
131
  include ToolsMenu
19
- include PreviewOverviewMethods
132
+
133
+ # Scrapes the value of the due date from the page. Returns it as a string.
134
+ def due_date
135
+ frm.div(:class=>"tier2").table(:index=>0)[0][0].text
136
+ end
137
+
138
+ # Scrapes the value of the time limit from the page. Returns it as a string.
139
+ def time_limit
140
+ frm.div(:class=>"tier2").table(:index=>0)[3][0].text
141
+ end
142
+
143
+ # Scrapes the submission limit from the page. Returns it as a string.
144
+ def submission_limit
145
+ frm.div(:class=>"tier2").table(:index=>0)[6][0].text
146
+ end
147
+
148
+ # Scrapes the Feedback policy from the page. Returns it as a string.
149
+ def feedback
150
+ frm.div(:class=>"tier2").table(:index=>0)[9][0].text
151
+ end
152
+
153
+ # Clicks the Done button, then instantiates
154
+ # the EditAssessment class.
155
+ def done
156
+ frm.button(:name=>"takeAssessmentForm:_id5").click
157
+ EditAssessment.new(@browser)
158
+ end
159
+
160
+ in_frame(:class=>"portletMainIframe") do |frame|
161
+ button(:begin_assessment, :id=>"takeAssessmentForm:beginAssessment3", :frame=>frame)
162
+
163
+ end
164
+
20
165
  end
21
166
 
22
167
  # The Settings page for a particular Assessment
23
168
  class AssessmentSettings
24
169
  include PageObject
25
170
  include ToolsMenu
26
- include AssessmentSettingsMethods
171
+
172
+ # Scrapes the Assessment Type from the page and returns it as a string.
173
+ def assessment_type_title
174
+ frm.div(:class=>"tier2").table(:index=>0)[0][1].text
175
+ end
176
+
177
+ # Scrapes the Assessment Author information from the page and returns it as a string.
178
+ def assessment_type_author
179
+ frm.div(:class=>"tier2").table(:index=>0)[1][1].text
180
+ end
181
+
182
+ # Scrapes the Assessment Type Description from the page and returns it as a string.
183
+ def assessment_type_description
184
+ frm.div(:class=>"tier2").table(:index=>0)[2][1].text
185
+ end
186
+
187
+ # Clicks the Save Settings and Publish button
188
+ # then instantiates the PublishAssessment class.
189
+ def save_and_publish
190
+ frm.button(:value=>"Save Settings and Publish").click
191
+ PublishAssessment.new(@browser)
192
+ end
193
+
194
+ in_frame(:class=>"portletMainIframe") do |frame|
195
+ link(:open, :text=>"Open", :frame=>frame)
196
+ link(:close, :text=>"Close", :frame=>frame)
197
+ text_field(:title, :id=>"assessmentSettingsAction:intro:assessment_title", :frame=>frame)
198
+ text_field(:authors, :id=>"assessmentSettingsAction:intro:assessment_author", :frame=>frame)
199
+ text_area(:description, :id=>"assessmentSettingsAction:intro:_id44_textinput", :frame=>frame)
200
+ button(:add_attachments_to_intro, :name=>"assessmentSettingsAction:intro:_id90", :frame=>frame)
201
+ text_field(:available_date, :id=>"assessmentSettingsAction:startDate", :frame=>frame)
202
+ text_field(:due_date, :id=>"assessmentSettingsAction:endDate", :frame=>frame)
203
+ text_field(:retract_date, :id=>"assessmentSettingsAction:retractDate", :frame=>frame)
204
+ radio_button(:released_to_anonymous) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:_id117", :index=>$frame_index, :frame=>frame) }
205
+ radio_button(:released_to_site) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:_id117", :index=>$frame_index, :frame=>frame) }
206
+ text_area(:specified_ips, :name=>"assessmentSettingsAction:_id132", :frame=>frame)
207
+ text_field(:secondary_id, :id=>"assessmentSettingsAction:username", :frame=>frame)
208
+ text_field(:secondary_pw, :id=>"assessmentSettingsAction:password", :frame=>frame)
209
+ checkbox(:timed_assessment, :id=>"assessmentSettingsAction:selTimeAssess", :frame=>frame)
210
+ select_list(:limit_hour, :id=>"assessmentSettingsAction:timedHours", :frame=>frame)
211
+ select_list(:limit_mins, :id=>"assessmentSettingsAction:timedMinutes", :frame=>frame)
212
+ radio_button(:linear_access) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:itemNavigation", :index=>$frame_index, :frame=>frame) }
213
+ radio_button(:random_access) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:itemNavigation", :index=>$frame_index, :frame=>frame) }
214
+ radio_button(:question_per_page) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:assessmentFormat", :index=>$frame_index, :frame=>frame) }
215
+ radio_button(:part_per_page) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:assessmentFormat", :index=>$frame_index, :frame=>frame) }
216
+ radio_button(:assessment_per_page) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:assessmentFormat", :index=>2, :frame=>frame) }
217
+ radio_button(:continuous_numbering) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:itemNumbering", :index=>$frame_index, :frame=>frame) }
218
+ radio_button(:restart_per_part) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:itemNumbering", :index=>$frame_index, :frame=>frame) }
219
+ checkbox(:add_mark_for_review, :id=>"assessmentSettingsAction:markForReview1", :frame=>frame)
220
+ radio_button(:unlimited_submissions) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:unlimitedSubmissions", :index=>$frame_index, :frame=>frame) }
221
+ radio_button(:only_x_submissions) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:unlimitedSubmissions", :index=>$frame_index, :frame=>frame) }
222
+ text_field(:allowed_submissions, :id=>"assessmentSettingsAction:submissions_Allowed", :frame=>frame)
223
+ radio_button(:late_submissions_not_accepted) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:lateHandling", :index=>$frame_index, :frame=>frame) }
224
+ radio_button(:late_submissions_accepted) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:lateHandling", :index=>$frame_index, :frame=>frame) }
225
+ text_area(:submission_message, :id=>"assessmentSettingsAction:_id245_textinput", :frame=>frame)
226
+ text_field(:final_page_url, :id=>"assessmentSettingsAction:finalPageUrl", :frame=>frame)
227
+ radio_button(:question_level_feedback) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackAuthoring", :index=>$frame_index, :frame=>frame) }
228
+ radio_button(:selection_level_feedback) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackAuthoring", :index=>$frame_index, :frame=>frame) }
229
+ radio_button(:both_feedback_levels) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackAuthoring", :index=>2, :frame=>frame) }
230
+ radio_button(:immediate_feedback) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackDelivery", :index=>$frame_index, :frame=>frame) }
231
+ radio_button(:feedback_on_submission) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackDelivery", :index=>$frame_index, :frame=>frame) }
232
+ radio_button(:no_feedback) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackDelivery", :index=>2, :frame=>frame) }
233
+ radio_button(:feedback_on_date) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackDelivery", :index=>3, :frame=>frame) }
234
+ text_field(:feedback_date, :id=>"assessmentSettingsAction:feedbackDate", :frame=>frame)
235
+ radio_button(:only_release_scores) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackComponentOption", :index=>$frame_index, :frame=>frame) }
236
+ radio_button(:release_questions_and) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:feedbackComponentOption", :index=>$frame_index, :frame=>frame) }
237
+ checkbox(:release_student_response, :id=>"assessmentSettingsAction:feedbackCheckbox1", :frame=>frame)
238
+ checkbox(:release_correct_response, :id=>"assessmentSettingsAction:feedbackCheckbox3", :frame=>frame)
239
+ checkbox(:release_students_assessment_scores, :id=>"assessmentSettingsAction:feedbackCheckbox5", :frame=>frame)
240
+ checkbox(:release_students_question_and_part_scores, :id=>"assessmentSettingsAction:feedbackCheckbox7", :frame=>frame)
241
+ checkbox(:release_question_level_feedback, :id=>"assessmentSettingsAction:feedbackCheckbox2", :frame=>frame)
242
+ checkbox(:release_selection_level_feedback, :id=>"assessmentSettingsAction:feedbackCheckbox4", :frame=>frame)
243
+ checkbox(:release_graders_comments, :id=>"assessmentSettingsAction:feedbackCheckbox6", :frame=>frame)
244
+ checkbox(:release_statistics, :id=>"assessmentSettingsAction:feedbackCheckbox8", :frame=>frame)
245
+ radio_button(:student_ids_seen) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:anonymousGrading1", :index=>$frame_index, :frame=>frame) }
246
+ radio_button(:anonymous_grading) { |page| page.radio_button_element( :name=>"assessmentSettingsAction:anonymousGrading1", :index=>$frame_index, :frame=>frame) }
247
+ #radio_button(:no_gradebook_options) { |page| page.radio_button_element( :name=>"", :index=>$frame_index, :frame=>frame) }
248
+ #radio_button(:grades_sent_to_gradebook) { |page| page.radio_button_element( :name=>"", :index=>$frame_index, :frame=>frame) }
249
+ #radio_button(:record_highest_score) { |page| page.radio_button_element( :name=>"", :index=>$frame_index, :frame=>frame) }
250
+ #radio_button(:record_last_score) { |page| page.radio_button_element( :name=>"", :index=>$frame_index, :frame=>frame) }
251
+ #radio_button(:background_color) { |page| page.radio_button_element( :name=>"", :index=>$frame_index, :frame=>frame) }
252
+ #text_field(:color_value, :id=>"", :frame=>frame)
253
+ #radio_button(:background_image) { |page| page.radio_button_element( :name=>"", :index=>$frame_index, :frame=>frame) }
254
+ #text_field(:image_name, :=>"", :frame=>frame)
255
+ #text_field(:keywords, :=>"", :frame=>frame)
256
+ #text_field(:objectives, :=>"", :frame=>frame)
257
+ #text_field(:rubrics, :=>"", :frame=>frame)
258
+ #checkbox(:record_metadata_for_questions, :=>"", :frame=>frame)
259
+ button(:save, :name=>"assessmentSettingsAction:_id383", :frame=>frame)
260
+ button(:cancel, :name=>"assessmentSettingsAction:_id385", :frame=>frame)
261
+
262
+ end
263
+
27
264
  end
28
265
 
29
266
  # Instructor's view of Students' assessment scores
30
267
  class AssessmentTotalScores
31
268
  include PageObject
32
269
  include ToolsMenu
33
- include AssessmentTotalScoresMethods
270
+
271
+ # Gets the user ids listed in the
272
+ # scores table, returns them as an Array
273
+ # object.
274
+ #
275
+ # Note that this method is only appropriate when student
276
+ # identities are not being obscured on this page. If student
277
+ # submissions are set to be anonymous then this method will fail
278
+ # to return any ids.
279
+ def student_ids
280
+ ids = []
281
+ scores_table = frm.table(:id=>"editTotalResults:totalScoreTable").to_a
282
+ scores_table.delete_at(0)
283
+ scores_table.each { |row| ids << row[1] }
284
+ return ids
285
+ end
286
+
287
+ # Adds a comment to the specified student's comment box.
288
+ #
289
+ # Note that this method assumes that the student identities are not being
290
+ # obscured on this page. If they are, then this method will not work for
291
+ # selecting the appropriate comment box.
292
+ # @param student_id [String] the target student id
293
+ # @param comment [String] the text of the comment being made to the student
294
+ def comment_for_student(student_id, comment)
295
+ index_val = student_ids.index(student_id)
296
+ frm.text_field(:name=>"editTotalResults:totalScoreTable:#{index_val}:_id345").value=comment
297
+ end
298
+
299
+ # Clicks the Submit Date link in the table header to sort/reverse sort the list.
300
+ def sort_by_submit_date
301
+ frm.link(:text=>"Submit Date").click
302
+ end
303
+
304
+ # Enters the specified string into the topmost box listed on the page.
305
+ #
306
+ # This method is especially useful when the student identities are obscured, since
307
+ # in that situation you can't target a specific student's comment box, obviously.
308
+ # @param comment [String] the text to be entered into the Comment box
309
+ def comment_in_first_box=(comment)
310
+ frm.text_field(:name=>"editTotalResults:totalScoreTable:0:_id345").value=comment
311
+ end
312
+
313
+ # Clicks the Update button, then instantiates
314
+ # the AssessmentTotalScores class.
315
+ def update
316
+ frm.button(:value=>"Update").click
317
+ AssessmentTotalScores.new(@browser)
318
+ end
319
+
320
+ # Clicks the Assessments link on the page
321
+ # then instantiates the AssessmentsList class.
322
+ def assessments
323
+ frm.link(:text=>"Assessments").click
324
+ AssessmentsList.new(@browser)
325
+ end
326
+
34
327
  end
35
328
 
36
329
  # The page that appears when you're creating a new quiz
@@ -38,14 +331,176 @@ end
38
331
  class EditAssessment
39
332
  include PageObject
40
333
  include ToolsMenu
41
- include EditAssessmentMethods
334
+
335
+ # Allows insertion of a question at a specified
336
+ # point in the Assessment. Must include the
337
+ # part number, the question number, and the type of
338
+ # question. Question Type must match the Type
339
+ # value in the drop down.
340
+ #
341
+ # The method will instantiate the page class
342
+ # based on the selected question type.
343
+ def insert_question_after(part_num, question_num, qtype)
344
+ if question_num.to_i == 0
345
+ frm.select(:id=>"assesssmentForm:parts:#{part_num.to_i - 1}:changeQType").select(qtype)
346
+ else
347
+ frm.select(:id=>"assesssmentForm:parts:#{part_num.to_i - 1}:parts:#{question_num.to_i - 1}:changeQType").select(qtype)
348
+ end
349
+
350
+ page = case(qtype)
351
+ when "Multiple Choice" then MultipleChoice.new(@browser)
352
+ when "True False" then TrueFalse.new(@browser)
353
+ when "Survey" then Survey.new(@browser)
354
+ when "Short Answer/Essay" then ShortAnswer.new(@browser)
355
+ when "Fill in the Blank" then FillInBlank.new(@browser)
356
+ when "Numeric Response" then NumericResponse.new(@browser)
357
+ when "Matching" then Matching.new(@browser)
358
+ when "Audio Recording" then AudioRecording.new(@browser)
359
+ when "File Upload" then FileUpload.new(@browser)
360
+ else puts "#{qtype} is not a valid question type"
361
+ end
362
+
363
+ return page
364
+
365
+ end
366
+
367
+ # Allows removal of question by part number and question number.
368
+ # @param part_num [String] the Part number containing the question you want to remove
369
+ # @param question_num [String] the number of the question you want to remove
370
+ def remove_question(part_num, question_num)
371
+ frm.link(:id=>"assesssmentForm:parts:#{part_num.to_i-1}:parts:#{question_num.to_i-1}:deleteitem").click
372
+ end
373
+
374
+ # Allows editing of a question by specifying its part number
375
+ # and question number.
376
+ # @param part_num [String] the Part number containing the question you want
377
+ # @param question_num [String] the number of the question you want
378
+ def edit_question(part_num, question_num)
379
+ frm.link(:id=>"assesssmentForm:parts:#{part_num.to_i-1}:parts:#{question_num.to_i-1}:modify").click
380
+ end
381
+
382
+ # Allows copying an Assessment part to a Pool.
383
+ # @param part_num [String] the part number of the assessment you want
384
+ def copy_part_to_pool(part_num)
385
+ frm.link(:id=>"assesssmentForm:parts:#{part_num.to_i-1}:copyToPool").click
386
+ end
387
+
388
+ # Allows removing a specified
389
+ # Assessment part number.
390
+ # @param part_num [String] the part number of the assessment you want
391
+ def remove_part(part_num)
392
+ frm.link(:xpath, "//a[contains(@onclick, 'assesssmentForm:parts:#{part_num.to_i-1}:copyToPool')]").click
393
+ end
394
+
395
+ # Clicks the Add Part button, then
396
+ # instantiates the AddEditAssessmentPart page class.
397
+ def add_part
398
+ frm.link(:text=>"Add Part").click
399
+ AddEditAssessmentPart.new(@browser)
400
+ end
401
+
402
+ # Selects the desired question type from the
403
+ # drop down list, then instantiates the appropriate
404
+ # page class.
405
+ # @param qtype [String] the text of the item you want to select from the list
406
+ def select_question_type(qtype)
407
+ frm.select(:id=>"assesssmentForm:changeQType").select(qtype)
408
+
409
+ page = case(qtype)
410
+ when "Multiple Choice" then MultipleChoice.new(@browser)
411
+ when "True False" then TrueFalse.new(@browser)
412
+ when "Survey" then Survey.new(@browser)
413
+ when "Short Answer/Essay" then ShortAnswer.new(@browser)
414
+ when "Fill in the Blank" then FillInBlank.new(@browser)
415
+ when "Numeric Response" then NumericResponse.new(@browser)
416
+ when "Matching" then Matching.new(@browser)
417
+ when "Audio Recording" then AudioRecording.new(@browser)
418
+ when "File Upload" then FileUpload.new(@browser)
419
+ else puts "#{qtype} is not a valid question type"
420
+ end
421
+
422
+ return page
423
+
424
+ end
425
+
426
+ # Clicks the Preview button,
427
+ # then instantiates the PreviewOverview page class.
428
+ def preview
429
+ frm.link(:text=>"Preview").click
430
+ PreviewOverview.new(@browser)
431
+ end
432
+
433
+ # Clicks the Settings link, then
434
+ # instantiates the AssessmentSettings page class.
435
+ def settings
436
+ frm.link(:text=>"Settings").click
437
+ AssessmentSettings.new(@browser)
438
+ end
439
+
440
+ # Clicks the Publish button, then
441
+ # instantiates the PublishAssessment page class.
442
+ def publish
443
+ frm.link(:text=>"Publish").click
444
+ PublishAssessment.new(@browser)
445
+ end
446
+
447
+ # Clicks the Question Pools button, then
448
+ # instantiates the QuestionPoolsList page class.
449
+ def question_pools
450
+ frm.link(:text=>"Question Pools").click
451
+ QuestionPoolsList.new(@browser)
452
+ end
453
+
454
+ # Allows retrieval of a specified question's
455
+ # text, by part and question number.
456
+ # @param part_num [String] the Part number containing the question you want
457
+ # @param question_num [String] the number of the question you want
458
+ def get_question_text(part_number, question_number)
459
+ frm.table(:id=>"assesssmentForm:parts:#{part_number.to_i-1}:parts").div(:class=>"tier3", :index=>question_number.to_i-1).text
460
+ end
461
+
462
+ in_frame(:class=>"portletMainIframe") do |frame|
463
+ link(:assessments, :text=>"Assessments", :frame=>frame)
464
+ link(:assessment_types, :text=>"Assessment Types", :frame=>frame)
465
+ link(:print, :text=>"Print", :frame=>frame)
466
+ button(:update_points, :id=>"assesssmentForm:pointsUpdate", :frame=>frame)
467
+
468
+ end
469
+
42
470
  end
43
471
 
44
472
  # This is the page for adding and editing a part of an assessment
45
473
  class AddEditAssessmentPart
46
474
  include PageObject
47
475
  include ToolsMenu
48
- include AddEditAssessmentPartMethods
476
+
477
+ # Clicks the Save button, then instantiates
478
+ # the EditAssessment page class.
479
+ def save
480
+ frm.button(:name=>"modifyPartForm:_id89").click
481
+ EditAssessment.new(@browser)
482
+ end
483
+
484
+ in_frame(:class=>"portletMainIframe") do |frame|
485
+ text_field(:title, :id=>"modifyPartForm:title", :frame=>frame)
486
+ text_area(:information, :id=>"modifyPartForm:_id10_textinput", :frame=>frame)
487
+ button(:add_attachments, :name=>"modifyPartForm:_id54", :frame=>frame)
488
+ radio_button(:questions_one_by_one) { |page| page.radio_button_element(:index=>0, :name=>"modifyPartForm:_id60", :frame=>frame)}
489
+ radio_button(:random_draw) { |page| page.radio_button_element(:index=>1, :name=>"modifyPartForm:_id60", :frame=>frame) }
490
+ select_list(:pool_name, :id=>"modifyPartForm:assignToPool", :frame=>frame)
491
+ text_field(:number_of_questions, :id=>"modifyPartForm:numSelected", :frame=>frame)
492
+ text_field(:point_value_of_questions, :id=>"modifyPartForm:numPointsRandom", :frame=>frame)
493
+ text_field(:negative_point_value, :id=>"modifyPartForm:numDiscountRandom", :frame=>frame)
494
+ radio_button(:randomized_each_time) { |page| page.radio_button_element(:index=>0, :name=>"modifyPartForm:randomizationType", :frame=>frame) }
495
+ radio_button(:randomized_once) { |page| page.radio_button_element(:index=>1, :name=>"modifyPartForm:randomizationType", :frame=>frame) }
496
+ radio_button(:order_as_listed) { |page| page.radio_button_element(:index=>0, :name=>"modifyPartForm:_id81", :frame=>frame) }
497
+ radio_button(:random_within_part) { |page| page.radio_button_element(:index=>1, :name=>"modifyPartForm:_id81", :frame=>frame) }
498
+ text_field(:objective, :id=>"modifyPartForm:obj", :frame=>frame)
499
+ text_field(:keyword, :id=>"modifyPartForm:keyword", :frame=>frame)
500
+ text_field(:rubric, :id=>"modifyPartForm:rubric", :frame=>frame)
501
+ button(:cancel, :name=>"modifyPartForm:_id90", :frame=>frame)
502
+ end
503
+
49
504
  end
50
505
 
51
506
  # The review page once you've selected to Save and Publish
@@ -53,63 +508,229 @@ end
53
508
  class PublishAssessment
54
509
  include PageObject
55
510
  include ToolsMenu
56
- include PublishAssessmentMethods
511
+
512
+ # Clicks the Publish button, then
513
+ # instantiates the AssessmentsList page class.
514
+ def publish
515
+ frm.button(:value=>"Publish").click
516
+ AssessmentsList.new(@browser)
517
+ end
518
+
519
+ in_frame(:class=>"portletMainIframe") do |frame|
520
+ button(:cancel, :value=>"Cancel", :frame=>frame)
521
+ button(:edit, :name=>"publishAssessmentForm:_id23", :frame=>frame)
522
+ select_list(:notification, :id=>"publishAssessmentForm:number", :frame=>frame)
523
+
524
+ end
525
+
57
526
  end
58
527
 
59
528
  # The page for setting up a multiple choice question
60
529
  class MultipleChoice
61
530
  include PageObject
62
531
  include ToolsMenu
63
- include MultipleChoiceMethods
532
+ include QuestionHelpers
533
+
534
+ in_frame(:class=>"portletMainIframe") do |frame|
535
+ button(:cancel, :value=>"Cancel", :frame=>frame)
536
+ text_field(:answer_point_value, :id=>"itemForm:answerptr", :frame=>frame)
537
+ link(:whats_this, :text=>"(What's This?)", :frame=>frame)
538
+ radio_button(:single_correct) { |page| page.radio_button_element(:name=>"itemForm:chooseAnswerTypeForMC", :index=>0, :frame=>frame) }
539
+ radio_button(:enable_negative_marking) { |page| page.radio_button_element(:name=>"itemForm:partialCreadit_NegativeMarking", :index=>0, :frame=>frame) }
540
+
541
+ # Element present when negative marking selected:
542
+ text_field(:negative_point_value, :id=>"itemForm:answerdsc", :frame=>frame)
543
+
544
+ radio_button(:enable_partial_credit) { |page| page.radio_button_element(:name=>"itemForm:partialCreadit_NegativeMarking", :index=>1, :frame=>frame) }
545
+ link(:reset_to_default, :text=>"Reset to Default Grading Logic", :frame=>frame)
546
+ radio_button(:multi_single) {|page| page.radio_button_element(:name=>"itemForm:chooseAnswerTypeForMC", :index=>1, :frame=>frame) }
547
+ radio_button(:multi_multi) {|page| page.radio_button_element(:name=>"itemForm:chooseAnswerTypeForMC", :index=>2, :frame=>frame) }
548
+ text_area(:question_text, :id=>"itemForm:_id82_textinput", :frame=>frame)
549
+ button(:add_attachments, :name=>"itemForm:_id126", :frame=>frame)
550
+
551
+ text_area(:answer_a, :id=>"itemForm:mcchoices:0:_id140_textinput", :frame=>frame)
552
+ link(:remove_a, :id=>"itemForm:mcchoices:0:removelinkSingle", :frame=>frame)
553
+ text_area(:answer_b, :id=>"itemForm:mcchoices:1:_id140_textinput", :frame=>frame)
554
+ link(:remove_b, :id=>"itemForm:mcchoices:1:removelinkSingle", :frame=>frame)
555
+ text_area(:answer_c, :id=>"itemForm:mcchoices:2:_id140_textinput", :frame=>frame)
556
+ link(:remove_c, :id=>"itemForm:mcchoices:2:removelinkSingle", :frame=>frame)
557
+ text_area(:answer_d, :id=>"itemForm:mcchoices:3:_id140_textinput", :frame=>frame)
558
+ link(:remove_d, :id=>"itemForm:mcchoices:3:removelinkSingle", :frame=>frame)
559
+
560
+ # Radio buttons that appear when "single correct" is selected
561
+ radio_button(:a_correct, :name=>"itemForm:mcchoices:0:mcradiobtn", :frame=>frame)
562
+ radio_button(:b_correct, :name=>"itemForm:mcchoices:1:mcradiobtn", :frame=>frame)
563
+ radio_button(:c_correct, :name=>"itemForm:mcchoices:2:mcradiobtn", :frame=>frame)
564
+ radio_button(:d_correct, :name=>"itemForm:mcchoices:3:mcradiobtn", :frame=>frame)
565
+
566
+ # % Value fields that appear when "single correct" and "partial credit" selected
567
+ text_field(:a_value, :id=>"itemForm:mcchoices:0:partialCredit", :frame=>frame)
568
+ text_field(:b_value, :id=>"itemForm:mcchoices:1:partialCredit", :frame=>frame)
569
+ text_field(:c_value, :id=>"itemForm:mcchoices:2:partialCredit", :frame=>frame)
570
+ text_field(:d_value, :id=>"itemForm:mcchoices:3:partialCredit", :frame=>frame)
571
+
572
+ link(:reset_score_values, :text=>"Reset Score Values", :frame=>frame)
573
+
574
+ # Checkboxes that appear when "multiple correct" is selected
575
+ checkbox(:a_correct, :name=>"itemForm:mcchoices:0:mccheckboxes", :frame=>frame)
576
+ checkbox(:b_correct, :name=>"itemForm:mcchoices:1:mccheckboxes", :frame=>frame)
577
+ checkbox(:c_correct, :name=>"itemForm:mcchoices:2:mccheckboxes", :frame=>frame)
578
+ checkbox(:d_correct, :name=>"itemForm:mcchoices:3:mccheckboxes", :frame=>frame)
579
+
580
+ select_list(:insert_additional_answers, :id=>"itemForm:insertAdditionalAnswerSelectMenu", :frame=>frame)
581
+ radio_button(:randomize_answers_yes) {|page| page.radio_button_element(:index=>0, :name=>"itemForm:_id162", :frame=>frame) }
582
+ radio_button(:randomize_answers_no) {|page| page.radio_button_element(:index=>1, :name=>"itemForm:_id162", :frame=>frame) }
583
+ radio_button(:require_rationale_yes) {|page| page.radio_button_element(:index=>0, :name=>"itemForm:_id166", :frame=>frame) }
584
+ radio_button(:require_rationale_no) {|page| page.radio_button_element(:index=>1, :name=>"itemForm:_id166", :frame=>frame) }
585
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
586
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
587
+
588
+ end
589
+
64
590
  end
65
591
 
66
592
  # The page for setting up a Survey question
67
593
  class Survey
68
594
  include PageObject
69
595
  include ToolsMenu
70
- include SurveyMethods
596
+ include QuestionHelpers
597
+
598
+ in_frame(:class=>"portletMainIframe") do |frame|
599
+ button(:cancel, :id=>"itemForm:_id63", :frame=>frame)
600
+ text_area(:question_text, :id=>"itemForm:_id69_textinput", :frame=>frame)
601
+ button(:add_attachments, :id=>"itemForm:_id113", :frame=>frame)
602
+ radio_button(:yes_no) { |page| page.radio_button_element(:index=>0, :name=>"itemForm:selectscale", :frame=>frame) }
603
+ radio_button(:disagree_agree) {|page| page.radio_button_element(:index=>1, :name=>"itemForm:selectscale", :frame=>frame) }
604
+ radio_button(:disagree_undecided) {|page| page.radio_button_element(:index=>2, :name=>"itemForm:selectscale", :frame=>frame) }
605
+ radio_button(:below_above) {|page| page.radio_button_element(:index=>3, :name=>"itemForm:selectscale", :frame=>frame)}
606
+ radio_button(:strongly_agree) {|page| page.radio_button_element(:index=>4, :name=>"itemForm:selectscale", :frame=>frame)}
607
+ radio_button(:unacceptable_excellent) {|page| page.radio_button_element(:index=>5, :name=>"itemForm:selectscale", :frame=>frame)}
608
+ radio_button(:one_to_five) {|page| page.radio_button_element(:index=>6, :name=>"itemForm:selectscale", :frame=>frame)}
609
+ radio_button(:one_to_ten) {|page| page.radio_button_element(:index=>7, :name=>"itemForm:selectscale", :frame=>frame)}
610
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
611
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
612
+ end
613
+
71
614
  end
72
615
 
73
616
  # The page for setting up a Short Answer/Essay question
74
617
  class ShortAnswer
75
618
  include PageObject
76
619
  include ToolsMenu
77
- include ShortAnswerMethods
620
+ include QuestionHelpers
621
+
622
+ in_frame(:class=>"portletMainIframe") do |frame|
623
+ button(:cancel, :id=>"itemForm:_id63", :frame=>frame)
624
+ text_field(:answer_point_value, :id=>"itemForm:answerptr", :frame=>frame)
625
+ text_area(:question_text, :id=>"itemForm:_id69_textinput", :frame=>frame)
626
+ button(:add_attachments, :id=>"itemForm:_id113", :frame=>frame)
627
+ text_area(:model_short_answer, :id=>"itemForm:_id129_textinput", :frame=>frame)
628
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
629
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
630
+ end
631
+
78
632
  end
79
633
 
80
634
  # The page for setting up a Fill-in-the-blank question
81
635
  class FillInBlank
82
636
  include PageObject
83
637
  include ToolsMenu
84
- include FillInBlankMethods
638
+ include QuestionHelpers
639
+
640
+ in_frame(:class=>"portletMainIframe") do |frame|
641
+ button(:cancel, :id=>"itemForm:_id63", :frame=>frame)
642
+ text_field(:answer_point_value, :id=>"itemForm:answerptr", :frame=>frame)
643
+ text_area(:question_text, :id=>"itemForm:_id75_textinput", :frame=>frame)
644
+ checkbox(:case_sensitive, :name=>"itemForm:_id76", :frame=>frame)
645
+ checkbox(:mutually_exclusive, :name=>"itemForm:_id78", :frame=>frame)
646
+ button(:add_attachments, :id=>"itemForm:_id126", :frame=>frame)
647
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
648
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
649
+
650
+ end
651
+
85
652
  end
86
653
 
87
654
  # The page for setting up a numeric response question
88
655
  class NumericResponse
89
656
  include PageObject
90
657
  include ToolsMenu
91
- include NumericResponseMethods
658
+ include QuestionHelpers
659
+
660
+ in_frame(:class=>"portletMainIframe") do |frame|
661
+ button(:cancel, :id=>"itemForm:_id63", :frame=>frame)
662
+ text_field(:answer_point_value, :id=>"itemForm:answerptr", :frame=>frame)
663
+ text_area(:question_text, :id=>"itemForm:_id73_textinput", :frame=>frame)
664
+ button(:add_attachments, :id=>"itemForm:_id117", :frame=>frame)
665
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
666
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
667
+
668
+ end
669
+
92
670
  end
93
671
 
94
672
  # The page for setting up a matching question
95
673
  class Matching
96
674
  include PageObject
97
675
  include ToolsMenu
98
- include MatchingMethods
676
+ include QuestionHelpers
677
+
678
+ in_frame(:class=>"portletMainIframe") do |frame|
679
+ button(:cancel, :id=>"itemForm:_id63", :frame=>frame)
680
+ text_field(:answer_point_value, :id=>"itemForm:answerptr", :frame=>frame)
681
+ text_area(:question_text, :id=>"itemForm:_id78_textinput", :frame=>frame)
682
+ button(:add_attachments, :id=>"itemForm:_id122", :frame=>frame)
683
+ text_area(:choice, :id=>"itemForm:_id147_textinput", :frame=>frame)
684
+ text_area(:match, :id=>"itemForm:_id151_textinput", :frame=>frame)
685
+ button(:save_pairing, :name=>"itemForm:_id164", :frame=>frame)
686
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
687
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
688
+
689
+ end
690
+
99
691
  end
100
692
 
101
693
  # The page for setting up a True/False question
102
694
  class TrueFalse
103
695
  include PageObject
104
696
  include ToolsMenu
105
- include TrueFalseMethods
697
+ include QuestionHelpers
698
+
699
+ in_frame(:class=>"portletMainIframe") do |frame|
700
+ button(:cancel, :id=>"itemForm:_id63", :frame=>frame)
701
+ text_field(:answer_point_value, :id=>"itemForm:answerptr", :frame=>frame)
702
+ text_area(:question_text, :id=>"itemForm:_id77_textinput", :frame=>frame)
703
+ button(:add_attachments, :id=>"itemForm:_id121", :frame=>frame)
704
+ text_field(:negative_point_value, :id=>"itemForm:answerdsc", :frame=>frame)
705
+ radio_button(:answer_true) {|page| page.radio_button_element(:index=>0, :name=>"itemForm:TF", :frame=>frame)}
706
+ radio_button(:answer_false) {|page| page.radio_button_element(:index=>1, :name=>"itemForm:TF", :frame=>frame)}
707
+ radio_button(:required_rationale_yes) {|page| page.radio_button_element(:index=>0, :name=>"itemForm:rational", :frame=>frame)}
708
+ radio_button(:required_rationale_no) {|page| page.radio_button_element(:index=>1, :name=>"itemForm:rational", :frame=>frame)}
709
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
710
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
711
+
712
+ end
713
+
106
714
  end
107
715
 
108
716
  # The page for setting up a question that requires an audio response
109
717
  class AudioRecording
110
718
  include PageObject
111
719
  include ToolsMenu
112
- include AudioRecordingMethods
720
+ include QuestionHelpers
721
+
722
+ in_frame(:class=>"portletMainIframe") do |frame|
723
+ button(:cancel, :id=>"itemForm:_id63", :frame=>frame)
724
+ text_field(:answer_point_value, :id=>"itemForm:answerptr", :frame=>frame)
725
+ text_area(:question_text, :id=>"itemForm:_id69_textinput", :frame=>frame)
726
+ button(:add_attachments, :id=>"itemForm:_id113", :frame=>frame)
727
+ text_field(:time_allowed, :id=>"itemForm:timeallowed", :frame=>frame)
728
+ select_list(:number_of_attempts, :id=>"itemForm:noattempts", :frame=>frame)
729
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
730
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
731
+
732
+ end
733
+
113
734
  end
114
735
 
115
736
  # The page for setting up a question that requires
@@ -117,35 +738,140 @@ end
117
738
  class FileUpload
118
739
  include PageObject
119
740
  include ToolsMenu
120
- include FileUploadMethods
741
+ include QuestionHelpers
742
+
743
+ in_frame(:class=>"portletMainIframe") do |frame|
744
+ button(:cancel, :id=>"itemForm:_id63", :frame=>frame)
745
+ text_field(:answer_point_value, :id=>"itemForm:answerptr", :frame=>frame)
746
+ text_area(:question_text, :id=>"itemForm:_id69_textinput", :frame=>frame)
747
+ button(:add_attachments, :id=>"itemForm:_id113", :frame=>frame)
748
+ select_list(:assign_to_part, :id=>"itemForm:assignToPart", :frame=>frame)
749
+ select_list(:assign_to_pool, :id=>"itemForm:assignToPool", :frame=>frame)
750
+
751
+ end
752
+
121
753
  end
122
754
 
123
755
  # The page that appears when you are editing a type of assessment
124
756
  class EditAssessmentType
125
757
  include PageObject
126
758
  include ToolsMenu
127
- include EditAssessmentTypeMethods
759
+
128
760
  end
129
761
 
130
762
  # The Page that appears when adding a new question pool
131
763
  class AddQuestionPool
132
764
  include PageObject
133
765
  include ToolsMenu
134
- include AddQuestionPoolMethods
766
+ # Clicks the Save button, then
767
+ # instantiates the QuestionPoolsList page class.
768
+ def save
769
+ #10.times {frm.button(:id=>"questionpool:submit").flash}
770
+ frm.button(:id=>"questionpool:submit").click
771
+ #sleep 180
772
+ #frm.button(:value=>"Create").wait_until_present(120)
773
+ QuestionPoolsList.new(@browser)
774
+ end
775
+
776
+ def cancel
777
+ frm.button(:value=>"Cancel").click
778
+ QuestionPoolsList.new @browser
779
+ end
780
+
781
+ in_frame(:class=>"portletMainIframe") do |frame|
782
+ text_field(:pool_name, :id=>"questionpool:namefield", :frame=>frame)
783
+ text_field(:department_group, :id=>"questionpool:orgfield", :frame=>frame)
784
+ text_area(:description, :id=>"questionpool:descfield", :frame=>frame)
785
+ text_field(:objectives, :id=>"questionpool:objfield", :frame=>frame)
786
+ text_field(:keywords, :id=>"questionpool:keyfield", :frame=>frame)
787
+
788
+ end
135
789
  end
136
790
 
137
791
  # The Page that appears when editing an existing question pool
138
792
  class EditQuestionPool
139
793
  include PageObject
140
794
  include ToolsMenu
141
- include EditQuestionPoolMethods
795
+ # Clicks the Add Question link, then
796
+ # instantiates the SelectQuestionType class.
797
+ def add_question
798
+ frm.link(:id=>"editform:addQlink").click
799
+ SelectQuestionType.new(@browser)
800
+ end
801
+
802
+ # Clicks the Question Pools link, then
803
+ # instantiates the QuestionPoolsList class.
804
+ def question_pools
805
+ frm.link(:text=>"Question Pools").click
806
+ QuestionPoolsList.new(@browser)
807
+ end
808
+
809
+ in_frame(:class=>"portletMainIframe") do |frame|
810
+ text_field(:pool_name, :id=>"editform:namefield", :frame=>frame)
811
+ text_field(:department_group, :id=>"editform:orgfield", :frame=>frame)
812
+ text_area(:description, :id=>"editform:descfield", :frame=>frame)
813
+ text_field(:objectives, :id=>"editform:objfield", :frame=>frame)
814
+ text_field(:keywords, :id=>"editform:keyfield", :frame=>frame)
815
+ button(:update, :id=>"editform:Update", :frame=>frame)
816
+ button(:save, :id=>"questionpool:submit", :frame=>frame)
817
+ button(:cancel, :id=>"questionpool:_id11", :frame=>frame)
818
+
819
+ end
142
820
  end
143
821
 
144
822
  # The page with the list of existing Question Pools
145
823
  class QuestionPoolsList
146
824
  include PageObject
147
825
  include ToolsMenu
148
- include QuestionPoolsListMethods
826
+ # Clicks the edit button, then instantiates
827
+ # the EditQuestionPool page class.
828
+ # @param name [String] the name of the pool you want to edit
829
+ def edit_pool(name)
830
+ frm.span(:text=>name).fire_event("onclick")
831
+ EditQuestionPool.new(@browser)
832
+ end
833
+
834
+ # Clicks the Add New Pool link, then
835
+ # instantiates the AddQuestionPool page class.
836
+ def add_new_pool
837
+ #puts "clicking add new pool..."
838
+ #10.times {frm.link(:text=>"Add New Pool").flash}
839
+ frm.link(:text=>"Add New Pool").click
840
+ #puts "clicked..."
841
+ #frm.text_field(:id=>"questionpool:namefield").wait_until_present(200)
842
+ AddQuestionPool.new(@browser)
843
+ end
844
+
845
+ # Returns an array containing strings of the pool names listed
846
+ # on the page.
847
+ def pool_names
848
+ names= []
849
+ frm.table(:id=>"questionpool:TreeTable").rows.each do | row |
850
+ if row.span(:id=>/questionpool.+poolnametext/).exist?
851
+ names << row.span(:id=>/questionpool.+poolnametext/).text
852
+ end
853
+ end
854
+ return names
855
+ end
856
+
857
+ # Clicks "Import" and then instantiates the
858
+ # PoolImport page class.
859
+ def import
860
+ frm.link(:text=>"Import").click
861
+ PoolImport.new(@browser)
862
+ end
863
+
864
+ # Clicks the Assessments link and then
865
+ # instantiates the AssessmentsList page class.
866
+ def assessments
867
+ frm.link(:text=>"Assessments").click
868
+ AssessmentsList.new(@browser)
869
+ end
870
+
871
+ in_frame(:class=>"portletMainIframe") do |frame|
872
+ link(:assessment_types, :text=>"Assessment Types", :frame=>frame)
873
+
874
+ end
149
875
  end
150
876
 
151
877
  # The page that appears when you click to import
@@ -153,14 +879,57 @@ end
153
879
  class PoolImport
154
880
  include PageObject
155
881
  include ToolsMenu
156
- include PoolImportMethods
882
+ # Enters the target file into the Choose File
883
+ # file field. Including the file path separately is optional.
884
+ # @param file_name [String] the name of the file you want to choose. Can include path info, if desired.
885
+ # @param file_path [String] Optional. This is the path information for the file location.
886
+ def choose_file(file_name, file_path="")
887
+ frm.file_field(:name=>"importPoolForm:_id6.upload").set(file_path + file_name)
888
+ end
889
+
890
+ # Clicks the Import button, then
891
+ # instantiates the QuestionPoolsList
892
+ # page class.
893
+ def import
894
+ frm.button(:value=>"Import").click
895
+ QuestionPoolsList.new(@browser)
896
+ end
897
+
157
898
  end
158
899
 
159
900
  # This page appears when adding a question to a pool
160
901
  class SelectQuestionType
161
902
  include PageObject
162
903
  include ToolsMenu
163
- include SelectQuestionTypeMethods
904
+ # Selects the specified question type from the
905
+ # drop-down list, then instantiates the appropriate
906
+ # page class, based on the question type selected.
907
+ # @param qtype [String] the text of the question type you want to select from the drop down list.
908
+ def select_question_type(qtype)
909
+ frm.select(:id=>"_id1:selType").select(qtype)
910
+ frm.button(:value=>"Save").click
911
+
912
+ page = case(qtype)
913
+ when "Multiple Choice" then MultipleChoice.new(@browser)
914
+ when "True False" then TrueFalse.new(@browser)
915
+ when "Survey" then Survey.new(@browser)
916
+ when "Short Answer/Essay" then ShortAnswer.new(@browser)
917
+ when "Fill in the Blank" then FillInBlank.new(@browser)
918
+ when "Numeric Response" then NumericResponse.new(@browser)
919
+ when "Matching" then Matching.new(@browser)
920
+ when "Audio Recording" then AudioRecording.new(@browser)
921
+ when "File Upload" then FileUpload.new(@browser)
922
+ else puts "nothing selected"
923
+ end
924
+
925
+ return page
926
+
927
+ end
928
+
929
+ in_frame(:class=>"portletMainIframe") do |frame|
930
+ button(:cancel, :value=>"Cancel", :frame=>frame)
931
+
932
+ end
164
933
  end
165
934
 
166
935
  # Page of Assessments accessible to a student user
@@ -170,25 +939,159 @@ end
170
939
  class TakeAssessmentList
171
940
  include PageObject
172
941
  include ToolsMenu
173
- include TakeAssessmentListMethods
942
+ # Returns an array containing the assessment names that appear on the page.
943
+ def available_assessments
944
+ # define this later
945
+ end
946
+
947
+ # Method to get the titles of assessments that
948
+ # the student user has submitted. The titles are
949
+ # returned in an Array object.
950
+ def submitted_assessments
951
+ table_array = @browser.frame(:index=>1).table(:id=>"selectIndexForm:reviewTable").to_a
952
+ table_array.delete_at(0)
953
+ titles = []
954
+ table_array.each { |row|
955
+ unless row[0] == ""
956
+ titles << row[0]
957
+ end
958
+ }
959
+
960
+ return titles
961
+
962
+ end
963
+
964
+ # Clicks the specified assessment
965
+ # then instantiates the BeginAssessment
966
+ # page class.
967
+ # @param name [String] the name of the assessment you want to take
968
+ def take_assessment(name)
969
+ begin
970
+ frm.link(:text=>name).click
971
+ rescue Watir::Exception::UnknownObjectException
972
+ frm.link(:text=>CGI::escapeHTML(name)).click
973
+ end
974
+ BeginAssessment.new(@browser)
975
+ end
976
+
977
+ # TODO This method is in need of improvement to make it more generalized for finding the correct test.
978
+ #
979
+ def feedback(test_name)
980
+ test_table = frm.table(:id=>"selectIndexForm:reviewTable").to_a
981
+ test_table.delete_if { |row| row[3] != "Immediate" }
982
+ index_value = test_table.index { |row| row[0] == test_name }
983
+ frm.link(:text=>"Feedback", :index=>index_value).click
984
+ # Need to add a call to a New class here, when it's written
985
+ end
986
+
174
987
  end
175
988
 
176
989
  # The student view of the overview page of an Assessment
177
990
  class BeginAssessment
178
991
  include PageObject
179
992
  include ToolsMenu
180
- include BeginAssessmentMethods
993
+ # Clicks the Begin Assessment button.
994
+ def begin_assessment
995
+ frm.button(:value=>"Begin Assessment").click
996
+ end
997
+
998
+ # Clicks the Cancel button and instantiates the X Class.
999
+ def cancel
1000
+ # Define this later
1001
+ end
1002
+
1003
+ # Selects the specified radio button answer
1004
+ def multiple_choice_answer(letter)
1005
+ index = case(letter.upcase)
1006
+ when "A" then "0"
1007
+ when "B" then "1"
1008
+ when "C" then "2"
1009
+ when "D" then "3"
1010
+ when "E" then "4"
1011
+ end
1012
+ frm.radio(:name=>/takeAssessmentForm.+:deliverMultipleChoice.+:_id.+:#{index}/).click
1013
+ end
1014
+
1015
+ # Enters the answer into the specified blank number (1-based).
1016
+ # @param answer [String]
1017
+ def fill_in_blank_answer(answer, blank_number)
1018
+ index = blank_number.to_i-1
1019
+ frm.text_field(:name=>/deliverFillInTheBlank:_id.+:#{index}/).value=answer
1020
+ end
1021
+
1022
+ # Clicks either the True or the False radio button, as specified.
1023
+ def true_false_answer(answer)
1024
+ answer.upcase=~/t/i ? index = 0 : index = 1
1025
+ frm.radio(:name=>/deliverTrueFalse/, :index=>index).set
1026
+ end
1027
+
1028
+ # Enters the specified string into the Rationale text box.
1029
+ def true_false_rationale(text)
1030
+ frm.text_field(:name=>/:deliverTrueFalse:rationale/).value=text
1031
+ end
1032
+
1033
+ # Enters the specified text into the "Short Answer" field.
1034
+ def short_answer(answer)
1035
+ frm.text_field(:name=>/deliverShortAnswer/).value=answer
1036
+ end
1037
+
1038
+ # Selects the specified matching value, at the spot specified by the number (1-based counting).
1039
+ def match_answer(answer, number)
1040
+ index = number.to_i-1
1041
+ frm.select(:name=>/deliverMatching/, :index=>index).select(answer)
1042
+ end
1043
+
1044
+ # Enters the specified file name in the file field. You can include the path to the file
1045
+ # as an optional second parameter.
1046
+ def file_answer(file_name, file_path="")
1047
+ frm.file_field(:name=>/deliverFileUpload/).set(file_path + file_name)
1048
+ frm.button(:value=>"Upload").click
1049
+ end
1050
+
1051
+ # Clicks the Next button and instantiates the BeginAssessment Class.
1052
+ def next
1053
+ frm.button(:value=>"Next").click
1054
+ BeginAssessment.new(@browser)
1055
+ end
1056
+
1057
+ # Clicks the Submit for Grading button and instantiates the ConfirmSubmission Class.
1058
+ def submit_for_grading
1059
+ frm.button(:value=>"Submit for Grading").click
1060
+ ConfirmSubmission.new(@browser)
1061
+ end
181
1062
  end
182
1063
 
183
1064
  # The confirmation page that appears when submitting an Assessment.
184
1065
  # The last step before actually submitting the the Assessment.
185
1066
  class ConfirmSubmission
186
1067
  include ToolsMenu
187
- include ConfirmSubmissionMethods
1068
+ include PageObject
1069
+ # Clicks the Submit for Grading button and instantiates
1070
+ # the SubmissionSummary Class.
1071
+ def submit_for_grading
1072
+ frm.button(:value=>"Submit for Grading").click
1073
+ SubmissionSummary.new(@browser)
1074
+ end
1075
+
1076
+ in_frame(:class=>"portletMainIframe") do |frame|
1077
+ span(:validation, :class=>"validation", :frame=>frame)
1078
+
1079
+ end
188
1080
  end
189
1081
 
190
1082
  # The summary page that appears when an Assessment has been submitted.
191
1083
  class SubmissionSummary
192
1084
  include ToolsMenu
193
- include SubmissionSummaryMethods
194
- end
1085
+ include PageObject
1086
+ # Clicks the Continue button and instantiates
1087
+ # the TakeAssessmentList Class.
1088
+ def continue
1089
+ frm.button(:value=>"Continue").click
1090
+ TakeAssessmentList.new(@browser)
1091
+ end
1092
+
1093
+ in_frame(:class=>"portletMainIframe") do |frame|
1094
+ div(:summary_info, :class=>"tier1", :frame=>frame)
1095
+
1096
+ end
1097
+ end