kuali-sakai-common-lib 0.0.1 → 0.0.6

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