Class: AssignmentObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, DateFactory, Foundry, StringFactory, Workflows
Defined in:
lib/sambal-cle/data_objects/assignment.rb

Overview

This data object is strictly the assignment as created by an instructor for Student submissions of an assignment, use AssignmentSubmissionObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

menu_link, #open_my_site_by_name, #reset

Constructor Details

#initialize(browser, opts = {}) ⇒ AssignmentObject

Returns a new instance of AssignmentObject.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sambal-cle/data_objects/assignment.rb', line 20

def initialize(browser, opts={})
  @browser = browser

  defaults = {
      :title=>random_alphanums,
      :instructions=>random_multiline(250, 10, :string),
      :resubmission=>{},
      :open=>{},
      :due=>{},
      :accept_until=>{}
  }
  options = defaults.merge(opts)

  set_options(options)
  requires @site
  raise "You must specify max points if your grade scale is 'points'" if @max_points==nil && @grade_scale=="Points"
end

Instance Attribute Details

#accept_untilObject

Returns the value of attribute accept_until.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def accept_until
  @accept_until
end

#add_due_dateObject

Returns the value of attribute add_due_date.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def add_due_date
  @add_due_date
end

#add_open_announcementObject

Returns the value of attribute add_open_announcement.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def add_open_announcement
  @add_open_announcement
end

#add_to_gradebookObject

Returns the value of attribute add_to_gradebook.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def add_to_gradebook
  @add_to_gradebook
end

#allow_resubmissionObject

Returns the value of attribute allow_resubmission.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def allow_resubmission
  @allow_resubmission
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def description
  @description
end

#direct_urlObject

Returns the value of attribute direct_url.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def direct_url
  @direct_url
end

#dueObject

Returns the value of attribute due.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def due
  @due
end

#grade_scaleObject

Returns the value of attribute grade_scale.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def grade_scale
  @grade_scale
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def id
  @id
end

#instructionsObject

Returns the value of attribute instructions.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def instructions
  @instructions
end

Returns the value of attribute link.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def link
  @link
end

#max_pointsObject

Returns the value of attribute max_points.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def max_points
  @max_points
end

#num_resubmissionsObject

Returns the value of attribute num_resubmissions.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def num_resubmissions
  @num_resubmissions
end

#open=(value) ⇒ Object

Sets the attribute open

Parameters:

  • value

    the value to set the attribute open to.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def open=(value)
  @open = value
end

#portal_urlObject

Returns the value of attribute portal_url.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def portal_url
  @portal_url
end

#resubmissionObject

Returns the value of attribute resubmission.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def resubmission
  @resubmission
end

#retract_timeObject

Returns the value of attribute retract_time.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def retract_time
  @retract_time
end

#siteObject

Returns the value of attribute site.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def site
  @site
end

#statusObject

Returns the value of attribute status.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def status
  @status
end

#student_submissionsObject

Returns the value of attribute student_submissions.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def student_submissions
  @student_submissions
end

#time_createdObject

Returns the value of attribute time_created.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def time_created
  @time_created
end

#time_dueObject

Returns the value of attribute time_due.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def time_due
  @time_due
end

#time_modifiedObject

Returns the value of attribute time_modified.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def time_modified
  @time_modified
end

#titleObject Also known as: name

Returns the value of attribute title.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def title
  @title
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/sambal-cle/data_objects/assignment.rb', line 11

def url
  @url
end

Instance Method Details

#createObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/sambal-cle/data_objects/assignment.rb', line 40

def create
  open_my_site_by_name @site

  # Go to assignments page
  assignments

  on_page AssignmentsList do |list|
    list.add
  end
  on_page AssignmentAdd do |add|
    @allow_resubmission==nil ? @allow_resubmission=checkbox_setting(add.allow_resubmission) : add.allow_resubmission.send(@allow_resubmission)
    if @allow_resubmission==:set
      add.num_resubmissions.wait_until_present
      @num_resubmissions=get_or_select(@num_resubmissions, add.num_resubmissions)
      @resubmission[:MON]=get_or_select(@resubmission[:MON], add.resub_until_month)
      @resubmission[:day_of_month]=get_or_select(@resubmission[:day_of_month], add.resub_until_day)
      @resubmission[:year]=get_or_select(@resubmission[:year], add.resub_until_year)
      @resubmission[:hour]=get_or_select(@resubmission[:hour], add.resub_until_hour)
      @resubmission[:minute_rounded]=get_or_select(@resubmission[:minute_rounded], add.resub_until_minute)
      @resubmission[:MERIDIAN]=get_or_select(@resubmission[:MERIDIAN], add.resub_until_meridian)
    end
    add.title.set @title
    add.instructions=@instructions
    @student_submissions=get_or_select(@student_submissions, add.student_submissions)
    @grade_scale=get_or_select(@grade_scale, add.grade_scale)
    @open[:MON]=get_or_select(@open[:MON], add.open_month)
    add.max_points.set(@max_points) unless @max_points==nil
    @open[:year]=get_or_select(@open[:year], add.open_year)
    @open[:day_of_month]=get_or_select(@open[:day_of_month], add.open_day)
    @open[:hour]=get_or_select(@open[:hour], add.open_hour)
    @open[:minute_rounded]=get_or_select(@open[:minute_rounded], add.open_minute)
    @open[:MERIDIAN]=get_or_select(@open[:MERIDIAN], add.open_meridian)
    @add_due_date==nil ? @add_due_date=checkbox_setting(add.add_due_date) : add.add_due_date.send(@add_due_date)
    @add_open_announcement==nil ? @add_open_announcement=checkbox_setting(add.add_open_announcement) : add.add_open_announcement.send(@add_open_announcement)
    @add_to_gradebook==nil ? @add_to_gradebook=radio_setting(add.add_to_gradebook) : add.add_to_gradebook.send(@add_to_gradebook)
    @due[:MON]=get_or_select(@due[:MON], add.due_month)
    @due[:year]=get_or_select(@due[:year], add.due_year)
    @due[:day_of_month]=get_or_select(@due[:day_of_month], add.due_day)
    @due[:hour]=get_or_select(@due[:hour], add.due_hour)
    @due[:minute_rounded]=get_or_select(@due[:minute_rounded], add.due_minute)
    @due[:MERIDIAN]=get_or_select(@due[:MERIDIAN], add.due_meridian)
    @accept_until[:MON]=get_or_select(@accept_until[:MON], add.accept_month)
    @accept_until[:year]=get_or_select(@accept_until[:year], add.accept_year)
    @accept_until[:day_of_month]=get_or_select(@accept_until[:day_of_month], add.accept_day)
    @accept_until[:hour]=get_or_select(@accept_until[:hour], add.accept_hour)
    @accept_until[:minute_rounded]=get_or_select(@accept_until[:minute_rounded], add.accept_minute)
    @accept_until[:MERIDIAN]=get_or_select(@accept_until[:MERIDIAN], add.accept_meridian)
    #@do_not_add_to_gradebook==nil ? @do_not_add_to_gradebook=radio_setting(add.do_not_add_gradebook.set?) :
    if @status=="Draft"
      add.save_draft
    else
      add.post
    end
  end
  on_page AssignmentsList do |list|
    @id = list.get_assignment_id @title
    @link = list.assignment_href @title
    @status = list.status_of @title
  end
end

#duplicateObject



182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/sambal-cle/data_objects/assignment.rb', line 182

def duplicate
  open_my_site_by_name @site
  assignments
  reset
  on AssignmentsList do |list|
    list.duplicate @title
  end

  duplicate_assignment = self
  duplicate_assignment.title="Draft - #{self.title} - Copy"
  duplicate_assignment.status="Draft"
  duplicate_assignment
end

#edit(opts = {}) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/sambal-cle/data_objects/assignment.rb', line 101

def edit opts={}
  open_my_site_by_name @site
  assignments
  on AssignmentsList do |list|
    if @status=="Draft"
      list.edit_assignment "Draft - #{@title}"
    else
      list.edit_assignment @title
    end
  end

  on AssignmentAdd do |edit|
    edit.title.fit opts[:title]
    unless opts[:instructions]==nil
      edit.enter_source_text edit.editor, opts[:instructions]
    end
    edit.grade_scale.fit opts[:grade_scale]
    #if edit.max_points.enabled?
      edit.max_points.fit opts[:max_points]
    #end
    #TODO: All the rest goes here

    # This should be one of the last items edited...
    edit.add_to_gradebook.send(opts[:add_to_gradebook]) unless opts[:add_to_gradebook]==nil

    if (@status=="Draft" && opts[:status]==nil) || opts[:status]=="Draft"
      edit.save_draft
    elsif opts[:status]=="Editing"
      # Stay on the page
    else
      edit.post
    end
  end
  set_options(opts)

  unless opts[:status]=="Editing"
    on AssignmentsList do |list|
      @status=list.status_of @title
    end
  end
end

#get_infoObject



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/sambal-cle/data_objects/assignment.rb', line 143

def get_info
  open_my_site_by_name @site
  assignments
  on AssignmentsList do |list|
    @id = list.get_assignment_id @title
    @status=list.status_of @title
    @link=list.assignment_href @title
    if @status=="Draft"
      list.open_assignment "Draft - #{@title}"
    else
      list.edit_assignment @title
    end
  end

  # TODO: Add more stuff here as needed...

  on AssignmentAdd do |edit|

    @instructions=edit.get_source_text edit.editor
    edit.source edit.editor
    edit.entity_picker(edit.editor)
  end
  on EntityPicker do |info|
    info.view_assignment_details @title
    @retract_time=info.retract_time
    @time_due=info.time_due
    @time_modified=info.time_modified
    @url=info.url
    @portal_url=info.portal_url
    @description=info.description
    @time_created=info.time_created
    @direct_url=info.direct_link
    info.close_picker
  end
  on AssignmentAdd do |edit|
    edit.cancel
  end
end

#view_submissionObject Also known as: open

Use this method to open a submitted assignment for viewing the page.



202
203
204
205
206
207
208
209
# File 'lib/sambal-cle/data_objects/assignment.rb', line 202

def view_submission
  open_my_site_by_name @site
  assignments
  reset
  on AssignmentsList do |list|
    list.open_assignment @title
  end
end

#view_submissionsObject



196
197
198
# File 'lib/sambal-cle/data_objects/assignment.rb', line 196

def view_submissions
  # TODO: Create this method
end