gestion 1.9.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +48 -0
- data/.project +14 -0
- data/Binaries/adduser_to_buzz +15 -0
- data/Binaries/backup +7 -0
- data/Binaries/check_gestion +8 -0
- data/Binaries/gestion.gnumail +22 -0
- data/Binaries/gestion.logrotate +34 -0
- data/Binaries/gestion.service +12 -0
- data/Binaries/gestion_update.rb +183 -0
- data/Binaries/gestion_update.service +10 -0
- data/Binaries/get_compta +11 -0
- data/Binaries/kill_gestion +16 -0
- data/Binaries/ldap/add_indexes +51 -0
- data/Binaries/ldap/backup +2 -0
- data/Binaries/ldap/install_ldap +92 -0
- data/Binaries/ldap/restore +7 -0
- data/Binaries/lib_backup +5 -0
- data/Binaries/log_scan_errors +8 -0
- data/Binaries/loop_gestion +64 -0
- data/Binaries/onetimers/sync_courses_from_compta.rb +74 -0
- data/Binaries/onetimers/transfer_cash_from_ldap_to_csv +26 -0
- data/Binaries/reboot +5 -0
- data/Binaries/restore +3 -0
- data/Binaries/restore_do +22 -0
- data/Binaries/sort_events +31 -0
- data/Binaries/start_gestion +18 -0
- data/Binaries/swipe_gestion +18 -0
- data/Binaries/update_africompta +21 -0
- data/Binaries/update_users +3 -0
- data/Diplomas.src/accredited.odg +0 -0
- data/Diplomas.src/diploma.odg +0 -0
- data/Diplomas.src/label.odg +0 -0
- data/Diplomas.src/presence_sheet.ods +0 -0
- data/Diplomas.src/presence_sheet_small.ods +0 -0
- data/Diplomas.src/student_card.odg +0 -0
- data/Doc/130514-it-ideas.odt +0 -0
- data/Doc/Compta-cash.mm +179 -0
- data/Doc/General.odt +0 -0
- data/Entities/AccessGroups.rb +117 -0
- data/Entities/Activity.rb +178 -0
- data/Entities/ChatMsg.rb +142 -0
- data/Entities/Classroom.rb +11 -0
- data/Entities/Client.rb +19 -0
- data/Entities/Computer.rb +21 -0
- data/Entities/ConfigBase.rb +280 -0
- data/Entities/Course.rb +1588 -0
- data/Entities/CourseType.rb +171 -0
- data/Entities/DFiles.rb +466 -0
- data/Entities/FilesManage.rb +226 -0
- data/Entities/Grade.rb +186 -0
- data/Entities/Internet.rb +300 -0
- data/Entities/Netdev.rb +10 -0
- data/Entities/Person.rb +1175 -0
- data/Entities/Plug.rb +98 -0
- data/Entities/Quiz.rb +33 -0
- data/Entities/Recharges.rb +37 -0
- data/Entities/Report.rb +136 -0
- data/Entities/Room.rb +12 -0
- data/Entities/SMS.rb +30 -0
- data/Entities/ScheduleType.rb +33 -0
- data/Entities/Share.rb +120 -0
- data/Entities/Task.rb +51 -0
- data/Entities/Ticket.rb +72 -0
- data/Entities/Usage.rb +143 -0
- data/Entities/Worker.rb +29 -0
- data/Files/apache-profeda.conf +36 -0
- data/Files/label.erb +121 -0
- data/Files/label_notfound.erb +64 -0
- data/Files/label_notpassed.erb +84 -0
- data/Files/mobileinfo.erb +115 -0
- data/Files/smb.conf +333 -0
- data/Files/timetable.html +36 -0
- data/Files/timetable.js +239 -0
- data/Gemfile +12 -0
- data/Gemfile.dev +12 -0
- data/Gemfile.dev.lock +127 -0
- data/Gemfile.lock +127 -0
- data/Gemfile.prod +8 -0
- data/Gestion +35 -0
- data/Gestion.rb +220 -0
- data/INSTALL +40 -0
- data/Images/connection.xcf +0 -0
- data/Images/connection_no.png +0 -0
- data/Images/connection_wait.png +0 -0
- data/Images/connection_yes.png +0 -0
- data/Paths/Exas.rb +13 -0
- data/Paths/Files.rb +19 -0
- data/Paths/GetDiplomas.rb +20 -0
- data/Paths/Info.rb +114 -0
- data/Paths/Label.rb +187 -0
- data/Paths/MobileInfo.rb +19 -0
- data/Paths/internetCash.rb +34 -0
- data/Paths/internetWifi.rb +54 -0
- data/README.md +60 -0
- data/Rakefile +13 -0
- data/TODO +1391 -0
- data/Test/.gitignore +3 -0
- data/Test/Diplomas/base_gestion.odt +0 -0
- data/Test/Diplomas/base_report.odt +0 -0
- data/Test/Diplomas/carte_etudiant.odg +0 -0
- data/Test/Diplomas/exam_language.odt +0 -0
- data/Test/Diplomas/label.odg +0 -0
- data/Test/Diplomas/presence_sheet.ods +0 -0
- data/Test/Diplomas/presence_sheet_small.ods +0 -0
- data/Test/Diplomas/student_card.odg +0 -0
- data/Test/Manual/testMerge +18 -0
- data/Test/config_test.yaml +26 -0
- data/Test/db.testGestion +0 -0
- data/Test/dfiles/descs/avg-rescue.desc +10 -0
- data/Test/dfiles/descs/avg.desc +8 -0
- data/Test/dfiles/descs/driver.desc +8 -0
- data/Test/dfiles/descs/linuxmint.desc +7 -0
- data/Test/dfiles/files/avg-160203.exe +1 -0
- data/Test/dfiles/files/avg.iso +1 -0
- data/Test/dfiles/files/driver.exe +1 -0
- data/Test/dfiles/index_post.html +3 -0
- data/Test/dfiles/index_pre.html +8 -0
- data/Test/dfiles/priorities +5 -0
- data/Test/ge_activity.rb +124 -0
- data/Test/ge_chat.rb +106 -0
- data/Test/ge_compta.rb +67 -0
- data/Test/ge_configbase.rb +54 -0
- data/Test/ge_course.rb +1114 -0
- data/Test/ge_dfiles.rb +121 -0
- data/Test/ge_filesmanage.rb +180 -0
- data/Test/ge_info.rb +27 -0
- data/Test/ge_internet.rb +246 -0
- data/Test/ge_login.rb +55 -0
- data/Test/ge_person.rb +373 -0
- data/Test/ge_qvinfo.rb +28 -0
- data/Test/ge_report.rb +97 -0
- data/Test/ge_share.rb +27 -0
- data/Test/ge_sms.rb +34 -0
- data/Test/ge_tasks.rb +19 -0
- data/Test/ge_usage.rb +168 -0
- data/Test/ge_view.rb +46 -0
- data/Test/multiconf-captive +29 -0
- data/Test/test.conf +7 -0
- data/Test/test.rb +49 -0
- data/Test/test_bytes.png +0 -0
- data/VERSION +140 -0
- data/Views/Admin/Backup.rb +91 -0
- data/Views/Admin/Configuration.rb +44 -0
- data/Views/Admin/Credit.rb +32 -0
- data/Views/Admin/FilesManage.rb +219 -0
- data/Views/Admin/Function.rb +39 -0
- data/Views/Admin/Power.rb +49 -0
- data/Views/Admin/Printer.rb +37 -0
- data/Views/Admin/Server.rb +252 -0
- data/Views/Admin/Tabs.rb +5 -0
- data/Views/Admin/Update.rb +73 -0
- data/Views/Admin/UpdateSystem.rb +26 -0
- data/Views/Cashbox/Activity.rb +191 -0
- data/Views/Cashbox/Course.rb +141 -0
- data/Views/Cashbox/Credit.rb +79 -0
- data/Views/Cashbox/Report.rb +115 -0
- data/Views/Cashbox/Service.rb +105 -0
- data/Views/Cashbox/Tabs.rb +10 -0
- data/Views/Compta/Accounts.rb +36 -0
- data/Views/Compta/Course.rb +96 -0
- data/Views/Compta/Show.rb +6 -0
- data/Views/Compta/Transfer.rb +66 -0
- data/Views/Course/Diploma.rb +203 -0
- data/Views/Course/Grade.rb +401 -0
- data/Views/Course/Modify.rb +447 -0
- data/Views/Course/Print.rb +94 -0
- data/Views/Course/Responsible.rb +44 -0
- data/Views/Course/Stats.rb +76 -0
- data/Views/Course/Students.rb +92 -0
- data/Views/Course/Tabs.rb +220 -0
- data/Views/Internet/Access.rb +134 -0
- data/Views/Internet/ClassEdit.rb +24 -0
- data/Views/Internet/ClassUsers.rb +81 -0
- data/Views/Internet/Config.rb +32 -0
- data/Views/Internet/Mobile.rb +213 -0
- data/Views/Internet/Recharges.rb +49 -0
- data/Views/Internet/Tabs.rb +6 -0
- data/Views/Inventory/Computer.rb +24 -0
- data/Views/Inventory/Room.rb +18 -0
- data/Views/Inventory/Tabs.rb +9 -0
- data/Views/Inventory/TicketClosed.rb +7 -0
- data/Views/Inventory/TicketOpen.rb +23 -0
- data/Views/Library/Person.rb +36 -0
- data/Views/Library/Tabs.rb +7 -0
- data/Views/Network/Block.rb +87 -0
- data/Views/Network/Netdevs.rb +21 -0
- data/Views/Network/Restriction.rb +37 -0
- data/Views/Network/Share.rb +167 -0
- data/Views/Network/Tables.rb +28 -0
- data/Views/Network/Tabs.rb +6 -0
- data/Views/Person/Admin.rb +99 -0
- data/Views/Person/Center.rb +48 -0
- data/Views/Person/Course.rb +72 -0
- data/Views/Person/Modify.rb +153 -0
- data/Views/Person/Tabs.rb +162 -0
- data/Views/Report/ComptaExecutive.rb +221 -0
- data/Views/Report/ComptaFlat.rb +79 -0
- data/Views/Report/ReportCourse.rb +47 -0
- data/Views/Report/Tabs.rb +8 -0
- data/Views/Report/Usage.rb +52 -0
- data/Views/Report/UsageCases.rb +59 -0
- data/Views/Self/Cash.rb +67 -0
- data/Views/Self/Chat.rb +55 -0
- data/Views/Self/Concours.rb +109 -0
- data/Views/Self/Email.rb +34 -0
- data/Views/Self/Internet.rb +255 -0
- data/Views/Self/Results.rb +17 -0
- data/Views/Self/Services.rb +85 -0
- data/Views/Self/Show.rb +47 -0
- data/Views/Self/Tabs.rb +5 -0
- data/Views/Special/DFileEdit.rb +13 -0
- data/Views/Special/PlugEdit.rb +56 -0
- data/Views/Special/Tabs.rb +6 -0
- data/Views/Special/Vnc.rb +39 -0
- data/Views/Task/Client.rb +21 -0
- data/Views/Task/Edit.rb +33 -0
- data/Views/Task/List.rb +55 -0
- data/Views/Task/Tabs.rb +9 -0
- data/Views/Task/Worker.rb +30 -0
- data/Views/Template/Activity.rb +33 -0
- data/Views/Template/CourseType.rb +63 -0
- data/Views/Template/ScheduleType.rb +29 -0
- data/Views/Template/Tabs.rb +5 -0
- data/Views/Welcome.rb +121 -0
- data/config.yaml.default +36 -0
- data/po/Gestion-ar.po +2356 -0
- data/po/Gestion-en.mo +0 -0
- data/po/Gestion-en.po +4363 -0
- data/po/Gestion-fr.mo +0 -0
- data/po/Gestion-fr.po +4345 -0
- data/po/traduction-ar.rtf +76 -0
- metadata +381 -0
@@ -0,0 +1,401 @@
|
|
1
|
+
# Manages grades of a course
|
2
|
+
# - Add or change grades
|
3
|
+
# - Print out grades
|
4
|
+
|
5
|
+
class CourseGrade < View
|
6
|
+
def layout
|
7
|
+
set_data_class :Courses
|
8
|
+
|
9
|
+
@update = true
|
10
|
+
@order = 20
|
11
|
+
|
12
|
+
# gui_vboxgl do
|
13
|
+
gui_hboxg do
|
14
|
+
gui_vboxg :nogroup do
|
15
|
+
show_table :students, headings: %w(Name Grade Files Status),
|
16
|
+
widths: [250, 40, 40, 50], callback: :click,
|
17
|
+
height: 350, width: 390, single: true
|
18
|
+
#show_list_single :students, :width => 300, :callback => true, :flexheight => 1
|
19
|
+
show_str_ro :last_synched
|
20
|
+
show_button :prepare_files, :fetch_files, :transfer_files, :sync_server
|
21
|
+
end
|
22
|
+
gui_vbox :nogroup do
|
23
|
+
gui_vbox :nogroup do
|
24
|
+
show_str :first_name, :width => 150
|
25
|
+
show_str :family_name
|
26
|
+
show_list_drop :gender, '%w( male female n/a )'
|
27
|
+
show_int_ro :files_saved
|
28
|
+
show_str :remark
|
29
|
+
show_table :grades, :headings => %w(Label grade), :widths => [150, 50],
|
30
|
+
:columns => %w(0 align_right), :callback => :edit,
|
31
|
+
:edit => [1], :height => 200
|
32
|
+
end
|
33
|
+
gui_vbox :nogroup do
|
34
|
+
show_html :name_file_direct
|
35
|
+
show_upload :upload_direct, :callback => true
|
36
|
+
show_button :save, :upload
|
37
|
+
end
|
38
|
+
end
|
39
|
+
gui_window :transfer do
|
40
|
+
show_html :txt
|
41
|
+
show_upload :files
|
42
|
+
show_button :close
|
43
|
+
end
|
44
|
+
|
45
|
+
gui_window :sync do
|
46
|
+
show_html :synching
|
47
|
+
show_button :close
|
48
|
+
end
|
49
|
+
|
50
|
+
gui_window :upload_files do
|
51
|
+
show_html :name_file_1
|
52
|
+
show_upload :upload_file_1, :callback => true
|
53
|
+
show_html :name_file_2
|
54
|
+
show_upload :upload_file_2, :callback => true
|
55
|
+
show_html :name_file_3
|
56
|
+
show_upload :upload_file_3, :callback => true
|
57
|
+
show_html :name_file_4
|
58
|
+
show_upload :upload_file_4, :callback => true
|
59
|
+
show_html :name_file_5
|
60
|
+
show_upload :upload_file_5, :callback => true
|
61
|
+
show_button :close
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def rpc_update(session)
|
67
|
+
super(session) +
|
68
|
+
reply(:empty_nonlists, [:students]) +
|
69
|
+
[:prepare_files, :fetch_files, :transfer_files,
|
70
|
+
:last_synched, :sync_server, :upload, :files_saved,
|
71
|
+
:upload_direct, :name_file_direct, :remark].collect { |b|
|
72
|
+
reply(:hide, b)
|
73
|
+
}.flatten
|
74
|
+
end
|
75
|
+
|
76
|
+
def update_files_saved(course, student)
|
77
|
+
reply(:update, :files_saved =>
|
78
|
+
"#{course.exam_files(student).count}/#{course.ctype.files_nbr}")
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_grades(ct, grades)
|
82
|
+
means = grades ? grades.means : [''] * ct.tests_nbr.to_i
|
83
|
+
i = 0
|
84
|
+
ct.tests_arr.zip(means).collect { |t, m|
|
85
|
+
[i += 1, [t, m.to_s]]
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
def update_grade(data)
|
90
|
+
c_id, p_name = data._courses[0], data._students[0]
|
91
|
+
if p_name and c_id
|
92
|
+
person = Persons.match_by_login_name(p_name)
|
93
|
+
course = Courses.match_by_course_id(c_id)
|
94
|
+
grade = Entities.Grades.match_by_course_person(c_id, p_name)
|
95
|
+
reply(:update, :grades => get_grades(course.ctype, grade)) +
|
96
|
+
reply(:empty_update, :remark => (grade ? grade.remark : ''))+
|
97
|
+
update_form_data(person) +
|
98
|
+
update_files_saved(course, p_name)
|
99
|
+
else
|
100
|
+
[]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def update_students_table(course)
|
105
|
+
reply_table_columns_visible(course.ctype.files_nbr.to_i > 0, students: [2]) +
|
106
|
+
reply_table_columns_visible(course.ctype.diploma_type == %w(accredited),
|
107
|
+
students: [3]) +
|
108
|
+
reply(:update,
|
109
|
+
students:
|
110
|
+
course.students.collect { |s|
|
111
|
+
if person = Persons.match_by_login_name(s)
|
112
|
+
mean, random = if grade = Grades.match_by_course_person(course, person)
|
113
|
+
[grade.mean, grade.random]
|
114
|
+
else
|
115
|
+
['--', nil]
|
116
|
+
end
|
117
|
+
[s, [person.full_name, mean, course.exam_files(person).length,
|
118
|
+
random ? 'OK' : 'do_sync']]
|
119
|
+
end
|
120
|
+
}.compact.sort_by { |a, b| b[0] })
|
121
|
+
end
|
122
|
+
|
123
|
+
def rpc_list_choice(session, name, data)
|
124
|
+
dputs(3) { "rpc_list_choice with #{name} - #{data.inspect}" }
|
125
|
+
ret = []
|
126
|
+
course_id = data._courses[0]
|
127
|
+
course = Courses.match_by_course_id(course_id)
|
128
|
+
case name
|
129
|
+
when 'courses'
|
130
|
+
if course
|
131
|
+
dputs(3) { 'replying' }
|
132
|
+
ret = rpc_update(session) +
|
133
|
+
reply(:empty_nonlists, :students) +
|
134
|
+
reply(:update, courses: [course_id]) +
|
135
|
+
update_students_table(course)
|
136
|
+
|
137
|
+
dputs(3) { "CType is #{course.ctype.inspect} - #{course.ctype.files_nbr.inspect}" }
|
138
|
+
buttons = []
|
139
|
+
if (nbr = course.ctype.files_nbr.to_i) > 0
|
140
|
+
dputs(3) { 'Putting buttons' }
|
141
|
+
buttons.push :transfer_files, :files_saved
|
142
|
+
buttons.push(if nbr > 1
|
143
|
+
:upload
|
144
|
+
else
|
145
|
+
ret += reply(:update,
|
146
|
+
upload_direct: course.ctype.files_arr.first) +
|
147
|
+
reply(:update, name_file_direct: 'chose student')
|
148
|
+
[:upload_direct, :name_file_direct]
|
149
|
+
end)
|
150
|
+
if Shares.match_by_name('CourseFiles')
|
151
|
+
buttons.push :prepare_files, :fetch_files
|
152
|
+
end
|
153
|
+
end
|
154
|
+
if course.students.size > 0 && course.list_students.size > 0
|
155
|
+
first = course.list_students[0][0]
|
156
|
+
ret += reply(:select, students: [first]) +
|
157
|
+
rpc_table_students(session, data.merge(students: [first]))
|
158
|
+
end
|
159
|
+
if course.ctype.diploma_type[0] == 'accredited' and
|
160
|
+
ConfigBase.has_function?(:course_client)
|
161
|
+
buttons.push :sync_server
|
162
|
+
end
|
163
|
+
buttons.each { |b|
|
164
|
+
ret += reply(:unhide, b)
|
165
|
+
}
|
166
|
+
ret += reply_visible(course.ctype.remark.to_s == '[true]', :remark)
|
167
|
+
|
168
|
+
dputs(4) { "Course is #{course} - ret is #{ret.inspect}" }
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
ret
|
173
|
+
end
|
174
|
+
|
175
|
+
def rpc_button_save(session, data)
|
176
|
+
dputs(3) { "Data is #{data.inspect}" }
|
177
|
+
c_id, p_name = data._courses.first, data._students.first
|
178
|
+
course = Courses.match_by_course_id(c_id)
|
179
|
+
student = Entities.Persons.match_by_login_name(p_name)
|
180
|
+
grade = Entities.Grades.match_by_course_person(c_id, p_name)
|
181
|
+
if course and student
|
182
|
+
means = new_grades(course.ctype, grade, data._grades.first)
|
183
|
+
Entities.Grades.save_data({:course => course,
|
184
|
+
:student => student,
|
185
|
+
:means => means,
|
186
|
+
:remark => data._remark})
|
187
|
+
log_msg :grades, "#{session.owner.login_name} added grades #{means.inspect} " +
|
188
|
+
"to #{student.login_name} from #{course.name} with remark -#{data._remark}-"
|
189
|
+
if data._first_name
|
190
|
+
Entities.Persons.save_data({:person_id => student.person_id,
|
191
|
+
:first_name => data._first_name,
|
192
|
+
:family_name => data._family_name,
|
193
|
+
:gender => data._gender})
|
194
|
+
end
|
195
|
+
|
196
|
+
grades = data._grades.first
|
197
|
+
element = grades ? grades._element_id.to_i : 0
|
198
|
+
|
199
|
+
update_students_table(course) +
|
200
|
+
if element >= course.ctype.tests_nbr.to_i
|
201
|
+
# Find next student
|
202
|
+
course = course.to_hash
|
203
|
+
if saved = course[:students].index { |i|
|
204
|
+
i[0] == data._students[0]
|
205
|
+
}
|
206
|
+
dputs(3) { "Found student at #{saved}" }
|
207
|
+
data._students = course[:students][(saved + 1) % course[:students].size]
|
208
|
+
dputs(3) { "Next student is #{data._students.inspect}" }
|
209
|
+
reply(:select, students: [data._students[0]]) +
|
210
|
+
rpc_table_students(session, data)
|
211
|
+
else
|
212
|
+
[]
|
213
|
+
end
|
214
|
+
else
|
215
|
+
update_grade(data) +
|
216
|
+
reply(:focus, {table: 'grades', row: element, col: 1}) +
|
217
|
+
reply(:select, students: [data._students[0]])
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def rpc_button_transfer_files(session, data)
|
223
|
+
ret = reply(:update, :txt => 'no students') +
|
224
|
+
reply(:hide, :upload)
|
225
|
+
if course = Courses.match_by_course_id(data._courses[0])
|
226
|
+
if file = course.zip_create
|
227
|
+
ret = reply(:update, :txt => 'Download skeleton: ' +
|
228
|
+
"<a target='other' href='/tmp/#{file}'>#{file}</a>") +
|
229
|
+
reply(:unhide, :upload)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
reply(:window_show, :transfer) +
|
233
|
+
ret
|
234
|
+
end
|
235
|
+
|
236
|
+
def rpc_button_prepare_files(session, data)
|
237
|
+
if course = Courses.match_by_course_id(data._courses[0])
|
238
|
+
course.exas_prepare_files
|
239
|
+
end
|
240
|
+
update_grade(data)
|
241
|
+
end
|
242
|
+
|
243
|
+
def rpc_button_fetch_files(session, data)
|
244
|
+
if course = Courses.match_by_course_id(data._courses[0])
|
245
|
+
course.exas_fetch_files
|
246
|
+
end
|
247
|
+
update_grade(data)
|
248
|
+
end
|
249
|
+
|
250
|
+
def rpc_button_close(session, data)
|
251
|
+
if course = Courses.match_by_course_id(data._courses[0])
|
252
|
+
course.zip_read
|
253
|
+
reply(:window_hide) +
|
254
|
+
update_grade(data) +
|
255
|
+
reply(:auto_update, 0)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def rpc_update_with_values(session, data)
|
260
|
+
ret = []
|
261
|
+
if course = Courses.match_by_course_id(data._courses[0])
|
262
|
+
ret = reply(:update, :synching => 'Sync-state:<ul>' + course.sync_state)
|
263
|
+
if course.sync_state =~ /(finished|Error:)/
|
264
|
+
ret += reply(:auto_update, 0) +
|
265
|
+
update_students_table(course)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
ret
|
269
|
+
end
|
270
|
+
|
271
|
+
def rpc_button_sync_server(session, data)
|
272
|
+
log_msg :grade, 'Syncing with server'
|
273
|
+
if course = Courses.match_by_course_id(data._courses[0])
|
274
|
+
course.sync_start
|
275
|
+
|
276
|
+
reply(:window_show, :sync) +
|
277
|
+
reply(:auto_update, -1) +
|
278
|
+
rpc_update_with_values(session, data)
|
279
|
+
else
|
280
|
+
reply(:window_show, :sync) +
|
281
|
+
reply(:update, :synching => 'Please chose a course first')
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def rpc_button_upload(session, data, window_show = true)
|
286
|
+
data.to_sym!
|
287
|
+
course = Courses.match_by_course_id(data._courses[0])
|
288
|
+
student = Persons.match_by_login_name(data._students[0])
|
289
|
+
ctype = course.ctype
|
290
|
+
files_nbr = ctype.files_nbr.to_i
|
291
|
+
exam_files = course.exam_files(student)
|
292
|
+
dputs(3) { "Exam-files = #{exam_files.inspect}" }
|
293
|
+
ret = window_show ? reply(:window_show, :upload_files) : []
|
294
|
+
ret + (1..5).collect { |i|
|
295
|
+
show = :hide
|
296
|
+
ret = []
|
297
|
+
if i <= files_nbr
|
298
|
+
show = :unhide
|
299
|
+
file_nb = exam_files.index { |f| f =~ /^#{i}-/ }
|
300
|
+
file = file_nb ? exam_files[file_nb] : ''
|
301
|
+
ret += reply(:update, "name_file_#{i}" =>
|
302
|
+
"file ##{i}: #{exam_file_to_href(course, student, file)}") +
|
303
|
+
reply(:update, "upload_file_#{i}" => ctype.files_arr[i-1])
|
304
|
+
end
|
305
|
+
dputs(3) { "Return is #{ret.inspect}" }
|
306
|
+
ret +
|
307
|
+
reply(show, "name_file_#{i}") +
|
308
|
+
reply(show, "upload_file_#{i}")
|
309
|
+
}.flatten
|
310
|
+
end
|
311
|
+
|
312
|
+
def rpc_button(session, name, data)
|
313
|
+
if name =~ /^upload_file_/
|
314
|
+
number = name.sub(/.*_/, '').to_i
|
315
|
+
|
316
|
+
data.to_sym!
|
317
|
+
course = Courses.match_by_course_id(data._courses[0])
|
318
|
+
student = data._students[0]
|
319
|
+
dputs(4) { "Course is #{course} - filename is #{data._filename} " +
|
320
|
+
"student is #{student}" }
|
321
|
+
if course and student and data._filename
|
322
|
+
files_nbr = course.ctype.files_nbr.to_i
|
323
|
+
|
324
|
+
course.check_students_dir
|
325
|
+
filename = UploadFiles.escape_chars(data._filename)
|
326
|
+
src = "/tmp/#{filename}"
|
327
|
+
dst = "#{Courses.dir_exams}/#{course.name}/#{student}"
|
328
|
+
dputs(3) { "Moving #{src} to #{dst}" }
|
329
|
+
FileUtils.rm Dir.glob("#{dst}/#{number}-*")
|
330
|
+
FileUtils.mv src, "#{dst}/#{number}-#{filename}"
|
331
|
+
|
332
|
+
ret = rpc_button_upload(session, data, false) +
|
333
|
+
update_files_saved(course, student)
|
334
|
+
if (number == files_nbr) and
|
335
|
+
(files_nbr == course.exam_files(student).count)
|
336
|
+
ret += reply(:window_hide) + rpc_button_save(session, data)
|
337
|
+
end
|
338
|
+
dputs(3) { "Return is #{ret.inspect}" }
|
339
|
+
return ret
|
340
|
+
end
|
341
|
+
else
|
342
|
+
return super(session, name, data)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def new_grades(ct, grade, new_grades)
|
347
|
+
return [] unless new_grades
|
348
|
+
means = grade ? grade.means : []
|
349
|
+
i = 0
|
350
|
+
ct.tests_arr.zip(means).collect { |t, m|
|
351
|
+
i+= 1
|
352
|
+
if i == new_grades._element_id.to_i then
|
353
|
+
new_grades._grade.sub(/,/, '.').to_f
|
354
|
+
else
|
355
|
+
m ? m : 0
|
356
|
+
end
|
357
|
+
}
|
358
|
+
end
|
359
|
+
|
360
|
+
def rpc_table_grades(session, data)
|
361
|
+
c_id, p_name = data._courses.first, data._students.first
|
362
|
+
course = Courses.match_by_course_id(c_id)
|
363
|
+
student = Entities.Persons.match_by_login_name(p_name)
|
364
|
+
grade = Entities.Grades.match_by_course_person(c_id, p_name)
|
365
|
+
return unless grades = data._grades.first
|
366
|
+
return unless element = grades._element_id.to_i
|
367
|
+
|
368
|
+
if course and student
|
369
|
+
means = new_grades(course.ctype, grade, grades)
|
370
|
+
Entities.Grades.save_data({:course => course,
|
371
|
+
:student => student,
|
372
|
+
:means => means,
|
373
|
+
:remark => data._remark})
|
374
|
+
end
|
375
|
+
if element == course.ctype.tests_nbr.to_i
|
376
|
+
rpc_button_save(session, data)
|
377
|
+
else
|
378
|
+
reply(:focus, {table: 'grades', row: element, col: 1})
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
def rpc_table_students(session, data)
|
383
|
+
course_id = data._courses[0]
|
384
|
+
course = Courses.match_by_course_id(course_id)
|
385
|
+
student = Entities.Persons.match_by_login_name(data._students.first)
|
386
|
+
file = course.exam_files(student).first
|
387
|
+
reply(:update, name_file_direct: exam_file_to_href(course, student, file)) +
|
388
|
+
update_grade(data) +
|
389
|
+
reply(:focus, {table: 'grades', col: 1, row: 0})
|
390
|
+
end
|
391
|
+
|
392
|
+
def rpc_button_upload_direct(session, data)
|
393
|
+
rpc_button(session, 'upload_file_1', data)
|
394
|
+
end
|
395
|
+
|
396
|
+
|
397
|
+
def exam_file_to_href(course, student, file)
|
398
|
+
dst = "#{course.name}/#{student.login_name}"
|
399
|
+
file ? "<a href='/exas/#{dst}/#{file}' target='_blank'>#{file}</a>" : 'Upload file'
|
400
|
+
end
|
401
|
+
end
|