Description:
fix bug: test_request: read empty output file
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@102 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r49:5bcf18c63ae4 - - 1 file changed: 3 inserted, 0 deleted
@@ -22,24 +22,27 | |||||
|
22 | end |
|
22 | end |
|
23 |
|
23 | ||
|
24 | def read |
|
24 | def read |
|
25 | user = User.find(session[:user_id]) |
|
25 | user = User.find(session[:user_id]) |
|
26 | test_request = TestRequest.find(params[:id]) |
|
26 | test_request = TestRequest.find(params[:id]) |
|
27 | if test_request.user_id != user.id |
|
27 | if test_request.user_id != user.id |
|
28 | flash[:notice] = 'Invalid output' |
|
28 | flash[:notice] = 'Invalid output' |
|
29 | redirect_to :action => 'index' |
|
29 | redirect_to :action => 'index' |
|
30 | return |
|
30 | return |
|
31 | end |
|
31 | end |
|
32 | if test_request.output_file_name!=nil |
|
32 | if test_request.output_file_name!=nil |
|
33 | data = File.open(test_request.output_file_name).read(2048) |
|
33 | data = File.open(test_request.output_file_name).read(2048) |
|
|
34 | + if data==nil | ||
|
|
35 | + data="" | ||
|
|
36 | + end | ||
|
34 | send_data(data, |
|
37 | send_data(data, |
|
35 | {:filename => 'output.txt', |
|
38 | {:filename => 'output.txt', |
|
36 | :type => 'text/plain'}) |
|
39 | :type => 'text/plain'}) |
|
37 | return |
|
40 | return |
|
38 | end |
|
41 | end |
|
39 | redirect_to :action => 'index' |
|
42 | redirect_to :action => 'index' |
|
40 | end |
|
43 | end |
|
41 |
|
44 | ||
|
42 | protected |
|
45 | protected |
|
43 |
|
46 | ||
|
44 | def prepare_index_information |
|
47 | def prepare_index_information |
|
45 | @submissions = Submission.find_last_for_all_available_problems(@user.id) |
|
48 | @submissions = Submission.find_last_for_all_available_problems(@user.id) |
You need to be logged in to leave comments.
Login now