Class: AssignmentStudent

Inherits:
BasePage show all
Defined in:
lib/sakai-cle-test-api/page_objects/assignments.rb

Overview

A Student user’s page for editing/submitting/view an assignment.

Constant Summary collapse

@@file_number =

This class variable allows adding an arbitrary number of files to the page, as long as the adding steps alternate between selecting the file and clicking the add more files button

0

Instance Method Summary collapse

Methods inherited from BasePage

basic_page_elements, frame_element

Methods inherited from PageMaker

element, expected_element, expected_title, #initialize, #method_missing, page_url

Constructor Details

This class inherits a constructor from PageMaker

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PageMaker

Instance Method Details

#assignment_text=(text) ⇒ Object

Enters the specified text into the Assignment Text FCKEditor.



460
461
462
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 460

def assignment_text=(text)
  frm.frame(:id, "Assignment.view_submission_text___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(text)
end

#back_to_listObject

Clicks the Back to list button, then instantiates the AssignmentList page class.



549
550
551
552
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 549

def back_to_list
  frm.button(:value=>"Back to list").click
  AssignmentsList.new(@browser)
end

#cancelObject

Clicks the Cancel button and instantiates the AssignmentsList Class.



556
557
558
559
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 556

def cancel
  frm.button(:value=>"Cancel").click
  AssignmentsList.new(@browser)
end

#headerObject

Returns the text content of the page header



440
441
442
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 440

def header
  frm.div(:class=>"portletBody").h3.text
end

#instructor_commentsObject

Grabs the instructor comments text.



455
456
457
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 455

def instructor_comments
  frm.div(:class=>"portletBody").div(:class=>"textPanel", :index=>2).text
end

#item_summaryObject

Returns a hash object containing the contents of the Item Summary table. The hash’s Key is the header column and the value is the content column.



446
447
448
449
450
451
452
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 446

def item_summary
  hash = {}
  frm.table(:class=>"itemSummary").rows.each do |row|
    hash.store(row.th.text, row.td.text)
  end
  return hash
end

#previewObject

Clicks the Preview button, then instantiates the AssignmentStudentPreview page class.

Resets @@file_number to zero so that file uploads will work if this page is visited again in the same script.



525
526
527
528
529
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 525

def preview
  frm.button(:value=>"Preview").click
  @@file_number=0
  AssignmentStudentPreview.new(@browser)
end

#remove_assignment_textObject

Clears out any existing text from the Assignment Text FCKEditor.



465
466
467
468
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 465

def remove_assignment_text
  frm.frame(:id, "Assignment.view_submission_text___Frame").div(:title=>"Select All").fire_event("onclick")
  frm.frame(:id, "Assignment.view_submission_text___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys :backspace
end

#resubmitObject

Clicks the Resubmit button, then instantiates the appropriate page class, based on the page that gets loaded.

Resets @@file_number to zero so that file uploads will work if this page is visited again in the same script.



508
509
510
511
512
513
514
515
516
517
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 508

def resubmit
  frm.button(:value=>"Resubmit").click
  @@file_number=0
  if frm.link(:text=>"Assignment title").exist?
    puts "list..."
    AssessmentsList.new(@browser)
  else
    SubmissionConfirmation.new(@browser)
  end
end

#save_draftObject

Clicks the Save Draft button, then instantiates the SubmissionConfirmation page class.



534
535
536
537
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 534

def save_draft
  frm.button(:value=>"Save Draft").click
  SubmissionConfirmation.new(@browser)
end

#select_file(file_name, file_path = "") ⇒ Object

Enters the specified file name into the file field. Entering the path separately is optional. Once the filename is entered in the field, the @@file_number class variable is increased by one in case any more files need to be added to the upload list.



481
482
483
484
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 481

def select_file(file_name, file_path="")
  frm.file_field(:id=>"clonableUpload", :name=>"upload#{@@file_number}").set(file_path + file_name)
  @@file_number += 1
end

#select_more_files_from_workspaceObject

Clicks the link to select more files from the Workspace. Then instantiates the AssignmentAttachments page class.



542
543
544
545
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 542

def select_more_files_from_workspace
  frm.link(:id=>"attach").click
  AssignmentAttachments.new(@browser)
end

#submitObject

Clicks the Submit button, then instantiates the appropriate page class, based on the page that gets loaded.



489
490
491
492
493
494
495
496
497
498
499
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 489

def submit
  frm.button(:value=>"Submit").click
  @@file_number=0
  if frm.div(:class=>"portletBody").h3.text=~/Submission Confirmation/
    SubmissionConfirmation.new(@browser)
  elsif frm.button(:value=>"Back to list").exist?
    SubmissionConfirmation.new(@browser)
  else
    AssessmentsList.new(@browser)
  end
end