Description:
added default grading mode, changed log message in grader git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@393 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r187:a677937ad928 - - 2 files changed: 7 inserted, 5 deleted

@@ -12,35 +12,37
12 recipient_id = recipient
12 recipient_id = recipient
13 if recipient == :any
13 if recipient == :any
14 recipient_id = GraderMessage::RECIPIENT_ANY
14 recipient_id = GraderMessage::RECIPIENT_ANY
15 end
15 end
16
16
17 GraderMessage.create(:grader_process_id => recipient_id,
17 GraderMessage.create(:grader_process_id => recipient_id,
18 :command => command,
18 :command => command,
19 :options => options,
19 :options => options,
20 :target_id => target_id,
20 :target_id => target_id,
21 :taken => false)
21 :taken => false)
22 end
22 end
23
23
24 - def self.create_grade_submission(mode,submission)
24 + def self.create_grade_submission(submission,
25 + grading_environment="grading")
25 GraderMessage.create_message(:any,
26 GraderMessage.create_message(:any,
26 GraderMessage::GRADE_SUBMISSION,
27 GraderMessage::GRADE_SUBMISSION,
27 - mode,
28 + grading_environment,
28 submission.id)
29 submission.id)
29 end
30 end
30
31
31 - def self.create_grade_test_request(mode,test_request)
32 + def self.create_grade_test_request(test_request,
33 + grading_environment="grading")
32 GraderMessage.create_message(:any,
34 GraderMessage.create_message(:any,
33 GraderMessage::GRADE_TEST_REQUEST,
35 GraderMessage::GRADE_TEST_REQUEST,
34 - mode,
36 + grading_environment,
35 test_request.id)
37 test_request.id)
36 end
38 end
37
39
38 def self.create_stop(grader_process_id)
40 def self.create_stop(grader_process_id)
39 GraderMessage.create_message(grader_process_id,
41 GraderMessage.create_message(grader_process_id,
40 GraderMessage::STOP)
42 GraderMessage::STOP)
41 end
43 end
42
44
43 def self.get_message_for(recipient_id, accepting_commands=:all)
45 def self.get_message_for(recipient_id, accepting_commands=:all)
44 command_conditions =
46 command_conditions =
45 GraderMessage.build_command_conditions(accepting_commands)
47 GraderMessage.build_command_conditions(accepting_commands)
46 recp_conditions= "((`grader_process_id` = #{recipient_id.to_i})" +
48 recp_conditions= "((`grader_process_id` = #{recipient_id.to_i})" +
@@ -19,25 +19,25
19 end
19 end
20 end
20 end
21
21
22 def config
22 def config
23 Grader::Configuration.get_instance
23 Grader::Configuration.get_instance
24 end
24 end
25
25
26 def log_file_name
26 def log_file_name
27 if !File.exists?(config.log_dir)
27 if !File.exists?(config.log_dir)
28 raise "Log directory does not exist: #{config.log_dir}"
28 raise "Log directory does not exist: #{config.log_dir}"
29 end
29 end
30 config.log_dir +
30 config.log_dir +
31 - "/#{GRADER_ENV}_#{config.grader_mode}.#{Process.pid}"
31 + "/#{GRADER_ENV}.#{Process.pid}"
32 end
32 end
33
33
34 def log(str)
34 def log(str)
35 if config.talkative
35 if config.talkative
36 puts str
36 puts str
37 end
37 end
38 if config.logging
38 if config.logging
39 fp = File.open(log_file_name,"a")
39 fp = File.open(log_file_name,"a")
40 fp.puts("GRADER: #{Time.new.strftime("%H:%M")} #{str}")
40 fp.puts("GRADER: #{Time.new.strftime("%H:%M")} #{str}")
41 fp.close
41 fp.close
42 end
42 end
43 end
43 end
You need to be logged in to leave comments. Login now