| Module | GroupsHelper |
| In: |
app/helpers/groups_helper.rb
|
Given a student and all students belonging to an assignment (assignment_memberships), constructs a table row to be insterted into the students FilterTable in the groups view. Called whenever it is necessary to update the students table.
# File app/helpers/groups_helper.rb, line 57
57: def construct_student_table_row(student, students_in_assignment)
58: table_row = {}
59:
60: table_row[:id] = student.id
61: table_row[:filter_table_row_contents] = render_to_string :partial => 'groups/table_row/filter_table_student_row', :locals => {:student => student}
62:
63: table_row[:user_name] = student.user_name
64: table_row[:first_name] = student.first_name
65: table_row[:last_name] = student.last_name
66: table_row[:filter_student_assigned] = students_in_assignment.include?(student)
67:
68: return table_row
69: end
Given a list of students and an assignment, constructs an array of table rows to be insterted into the students FilterTable in the groups view. Called whenever it is necessary to update the students table with multiple changes.
# File app/helpers/groups_helper.rb, line 19
19: def construct_student_table_rows(students, assignment)
20: student_memberships = StudentMembership.all(:conditions => {:grouping_id => assignment.groupings, :user_id => students})
21: students_in_assignment = student_memberships.collect do |membership|
22: membership.user
23: end
24: result = {}
25: students.each do |student|
26: result[student.id] = construct_student_table_row(student, students_in_assignment)
27: end
28: return result
29: end
Given a grouping and an assignment, constructs a table row to be insterted into the groupings FilterTable in the groups view. Called whenever it is necessary to update the groupings table.
# File app/helpers/groups_helper.rb, line 34
34: def construct_table_row(grouping, assignment)
35: table_row = {}
36:
37: table_row[:id] = grouping.id
38: table_row[:filter_table_row_contents] = render_to_string :partial => 'groups/table_row/filter_table_row', :locals => {:grouping => grouping, :assignment => assignment}
39:
40: table_row[:name] = grouping.group.group_name
41:
42: table_row[:members] = grouping.students.collect{ |student| student.user_name}.join(',')
43:
44: # used for searching
45: table_row[:student_names] = grouping.students.collect{ |student| "#{student.first_name} #{student.last_name}"}.join(',')
46:
47: table_row[:valid] = grouping.is_valid?
48: table_row[:filter_valid] = grouping.is_valid?
49:
50: return table_row
51: end
Given a list of groupings and an assignment, constructs an array of table rows to be insterted into the groupings FilterTable in the groups view. Called whenever it is necessary to update the groupings table with multiple changes.
# File app/helpers/groups_helper.rb, line 7
7: def construct_table_rows(groupings, assignment)
8: result = {}
9: groupings.each do |grouping|
10: result[grouping.id] = construct_table_row(grouping, assignment)
11: end
12: return result
13: end