Class: StudentListController

Inherits:
Object
  • Object
show all
Defined in:
lib/files/student_list_controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ StudentListController

Returns a new instance of StudentListController.



10
11
12
13
14
15
16
17
# File 'lib/files/student_list_controller.rb', line 10

def initialize(view)
  self.view = view
  self.list = Basic_list.new
  self.list.format = Student_list_DB.new
  self.load_list
  self.data_list_student_short = self.list.get_k_n_student_short_list(k:0, n:self.table_row_count)
  self.data_list_student_short.view = self.view
end

Instance Method Details

#cur_pageObject



19
20
21
22
23
# File 'lib/files/student_list_controller.rb', line 19

def cur_page
  if @cur_page.nil? or @cur_page <= 1 or @cur_page > self.page_count then @cur_page = 1 end

  @cur_page
end

#del_selectedObject



25
26
27
28
29
30
# File 'lib/files/student_list_controller.rb', line 25

def del_selected
  id_array = self.data_list_student_short.get_selected
  id_array.each do |id|
    self.list.delete_byID(id: id)
  end
end

#next_pageObject



48
49
50
# File 'lib/files/student_list_controller.rb', line 48

def next_page
  self.cur_page += 1
end

#page_countObject



40
41
42
43
44
45
46
# File 'lib/files/student_list_controller.rb', line 40

def page_count
  if !self.list.nil? then
    (self.list.get_student_short_count.to_f / self.table_row_count).ceil
  else
    1
  end
end

#prev_pageObject



52
53
54
# File 'lib/files/student_list_controller.rb', line 52

def prev_page
  self.cur_page -= 1
end

#refresh_data(reload: false) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/files/student_list_controller.rb', line 56

def refresh_data(reload: false)
  if (reload) then
    self.load_list()
  end

  self.list.get_k_n_student_short_list(k:self.cur_page - 1, n:self.table_row_count, data_list: data_list_student_short)

  self.data_list_student_short.notify
end

#select(id) ⇒ Object



36
37
38
# File 'lib/files/student_list_controller.rb', line 36

def select(id)
  self.data_list_student_short.select(id)
end

#sortObject



66
67
68
# File 'lib/files/student_list_controller.rb', line 66

def sort
  self.list.sort_si
end

#unselectObject



32
33
34
# File 'lib/files/student_list_controller.rb', line 32

def unselect
  self.data_list_student_short.unselect
end