Class: ActivityOffering

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

#go_to_academic_calendar, #go_to_calendar_search, #go_to_create_course_offerings, #go_to_create_population, #go_to_display_schedule_of_classes, #go_to_holiday_calendar, #go_to_manage_course_offerings, #go_to_manage_population, #go_to_perform_rollover, #go_to_rollover_details, #log_in, #logged_in_user

Constructor Details

#initialize(browser, code) ⇒ ActivityOffering

Returns a new instance of ActivityOffering.



21
22
23
24
25
26
27
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 21

def initialize(browser, code)
  @browser = browser
  @seat_pool_list = {}
  @actual_delivery_logistics_list = {}
  @requested_delivery_logistics_list = {}

end

Instance Attribute Details

#activity_typeObject

Returns the value of attribute activity_type.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def activity_type
  @activity_type
end

#actual_delivery_logistics_listObject

Returns the value of attribute actual_delivery_logistics_list.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def actual_delivery_logistics_list
  @actual_delivery_logistics_list
end

#codeObject

Returns the value of attribute code.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def code
  @code
end

#course_urlObject

Returns the value of attribute course_url.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def course_url
  @course_url
end

#evaluationObject

Returns the value of attribute evaluation.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def evaluation
  @evaluation
end

#formatObject

Returns the value of attribute format.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def format
  @format
end

#honors_courseObject

Returns the value of attribute honors_course.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def honors_course
  @honors_course
end

#max_enrollmentObject

Returns the value of attribute max_enrollment.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def max_enrollment
  @max_enrollment
end

#personnel_listObject

Returns the value of attribute personnel_list.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def personnel_list
  @personnel_list
end

#requested_delivery_logistics_listObject

Returns the value of attribute requested_delivery_logistics_list.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def requested_delivery_logistics_list
  @requested_delivery_logistics_list
end

#seat_pool_listObject

Returns the value of attribute seat_pool_list.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def seat_pool_list
  @seat_pool_list
end

#seat_remaining_percentObject

Returns the value of attribute seat_remaining_percent.



8
9
10
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 8

def seat_remaining_percent
  @seat_remaining_percent
end

Instance Method Details

#create(opts = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
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
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 29

def create(opts = {})

  default_seat_pool_hash = {"random"=> (make SeatPool)}
  default_rdl_hash = {"default"=> (make DeliveryLogistics)}

  defaults = {
      :format => "Lecture",
      :activity_type => "Lecture",
      :max_enrollment => 100,
      :actual_delivery_logistics_list => {},
      :requested_delivery_logistics_list => default_rdl_hash,
      :personnel_list => Array.new(1){make Personnel} ,
      :seat_pool_list => default_seat_pool_hash,
      #:seat_pool_list => Array.new(1){make SeatPool},
      :course_url => "www.test_course.com",
      :evaluation => true,
      :honors_course => true
  }
  options = defaults.merge(opts)

  @format = options[:format]
  @activity_type = options[:activity_type]

  on ManageCourseOfferings do |page|
    #if page.codes_list.length == 0
    sleep 2
    page.format.select @format
    page.loading.wait_while_present
    sleep 2
    page.activity_type.select @activity_type
    page.quantity.set "1"
    page.add
    #end
    @code = page.codes_list[0]
  end

  on ManageCourseOfferings do |page|
    page.edit @code
  end

  edit(options)
end

#edit(opts = {}) ⇒ Object



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
100
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 73

def edit opts={}

  defaults = {
      :max_enrollment => @max_enrollment,
      :actual_delivery_logistics_list => @actual_delivery_logistics_list,
      :requested_delivery_logistics_list => @requested_delivery_logistics_list,
      :personnel_list => @personnel_list ,
      :seat_pool_list => @seat_pool_list,
      :course_url => @course_url,
      :evaluation => @evaluation,
      :honors_course => @honors_course
  }

  options=defaults.merge(opts)

  if options[:max_enrollment] != @max_enrollment
    on ActivityOfferingMaintenance do |page|
      page.total_maximum_enrollment.set options[:max_enrollment]
      page.total_maximum_enrollment.fire_event "onchange"
      @max_enrollment = options[:max_enrollment]
    end
  end

  #TODO: comparison could be more robust
  if options[:requested_delivery_logistics_list].keys != @requested_delivery_logistics_list.keys
    if options[:requested_delivery_logistics_list].length > 0
      on ActivityOfferingMaintenance do |page|
        page.revise_logistics
      end
      #'save' vs 'save and process' determined by first rdl
      first_rdl = options[:requested_delivery_logistics_list].values[0]
      #list of requests added with updated keys
      requests_added = {}

      options[:requested_delivery_logistics_list].values.each do |request|
        request.add_logistics_request()
        requests_added["#{request.days}#{request.start_time}#{request.start_time_ampm.upcase}".delete(' ')] = request
      end

      if first_rdl.process
        @actual_delivery_logistics_list.merge!(requests_added)
        first_rdl.save_and_process()
      else
        @requested_delivery_logistics_list.merge(requests_added)
        first_rdl.save()
      end
    end
  end

  on ActivityOfferingMaintenance do |page|
    if options[:course_url] != @course_url
      page.course_url.set options[:course_url]
      @course_url = options[:course_url]
    end

    if options[:evaluation] != @evaluation
      if options[:evaluation]
        page.requires_evaluation.set
      else
        page.requires_evaluation.clear
      end
      @evaluation =  options[:evaluation]
    end

    if options[:honors_course] != @honors_course
      if options[:honors_course]
        page.honors_flag.set
      else
        page.honors_flag.clear
      end
      @honors_course = options[:honors_course]
    end
  end
  if options[:personnel_list] != @personnel_list
    options[:personnel_list].each do |person|
      person.add_personnel
    end
    @personnel_list = options[:personnel_list]
  end

  #TODO: comparison could be more robust
  if options[:seat_pool_list].keys != @seat_pool_list.keys
    options[:seat_pool_list].each do |key,seat_pool|
      seat_pool.add_seatpool
      @seat_pool_list[key] = seat_pool unless !seat_pool.exp_add_succeed?
    end
  end
end

#edit_seatpool(opts = {}) ⇒ Object



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 206

def edit_seatpool opts = {}

  sp_key = opts[:seatpool_key]
  sp_key = @seat_pool_list.keys[0] unless sp_key != nil

  defaults = {
      :priority => @seat_pool_list[sp_key].priority,
      :seats => @seat_pool_list[sp_key].seats,
      :expiration_milestone => @seat_pool_list[sp_key].expiration_milestone,
      :remove => false,
      :priority_after_reseq => @seat_pool_list[sp_key].priority_after_reseq
  }
  options=defaults.merge(opts)
  update_pop_name = @seat_pool_list[sp_key].population_name

  on ActivityOfferingMaintenance do |page|
    page.update_seats(update_pop_name, options[:seats])
    @seat_pool_list[sp_key].seats = options[:seats]
  end


  if options[:priority] != @seat_pool_list[sp_key].priority
    on ActivityOfferingMaintenance do |page|
      page.update_priority(update_pop_name,options[:priority])
      @seat_pool_list[sp_key].priority = options[:priority]
    end
  end

  if options[:expiration_milestone] != @seat_pool_list[sp_key].expiration_milestone
    on ActivityOfferingMaintenance do |page|
      page.update_expiration_milestone(update_pop_name,options[:expiration_milestone])
      @seat_pool_list[sp_key].expiration_milestone = options[:expiration_milestone]
    end
  end

  if options[:priority_after_reseq] != @seat_pool_list[sp_key].priority_after_reseq
    @seat_pool_list[sp_key].priority_after_reseq = options[:priority_after_reseq]
  end

  #remove has to be last...
  if options[:remove]
    on ActivityOfferingMaintenance do |page|
      page.remove_seatpool(update_pop_name)
      @seat_pool_list.delete(sp_key)
    end
  end
end

#remove_seatpool(seatpool_key) ⇒ Object



182
183
184
185
186
187
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 182

def remove_seatpool(seatpool_key)
  on ActivityOfferingMaintenance do |page|
    page.remove_seatpool(@seat_pool_list[seatpool_key].population_name)
  end
  @seat_pool_list.delete(seatpool_key)
end

#remove_seatpoolsObject



189
190
191
192
193
194
195
196
197
198
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 189

def remove_seatpools()
  @seat_pool_list.each do |seatpool_key|
    if @seat_pool_list[seatpool_key].remove
      on ActivityOfferingMaintenance do |page|
        page.remove_seatpool(@seat_pool_list[seatpool_key].population_name)
      end
      @seat_pool_list.delete(seatpool_key)
    end
  end
end

#resequence_seatpoolsObject



200
201
202
203
204
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 200

def resequence_seatpools()
  @seat_pool_list.values.each do |seatpool|
    seatpool.priority = seatpool.priority_after_reseq
  end
end

#saveObject



168
169
170
171
172
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 168

def save()
  on ActivityOfferingMaintenance do |page|
    page.submit
  end
end

#seats_remainingObject



174
175
176
177
178
179
180
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 174

def seats_remaining
  seats_used = 0
  @seat_pool_list.each do |key,seat_pool|
    seats_used += seat_pool.seats.to_i
  end
  [@max_enrollment - seats_used , 0].max
end

#updateObject



162
163
164
165
166
# File 'lib/sambal-kuali/data_objects/activity_offering.rb', line 162

def update()
  on ActivityOfferingMaintenance do |page|
    page.submit
  end
end