diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -39,7 +39,7 @@ redirect_to :action => 'list' end - def get_source + def source submission = Submission.find(params[:id]) if submission.user_id == session[:user_id] fname = submission.problem.name + '.' + submission.language.ext @@ -52,6 +52,16 @@ end end + def compiler_msg + @submission = Submission.find(params[:id]) + if @submission.user_id == session[:user_id] + render :action => 'compiler_msg', :layout => 'empty' + else + flash[:notice] = 'Error viewing source' + redirect_to :action => 'list' + end + end + def submission @user = User.find(session[:user_id]) @problems = Problem.find_available_problems diff --git a/app/views/main/_problem.html.erb b/app/views/main/_problem.html.erb --- a/app/views/main/_problem.html.erb +++ b/app/views/main/_problem.html.erb @@ -11,6 +11,8 @@ <%= render :partial => 'submission_short', - :locals => { :submission => @prob_submissions[problem_counter][:submission]} %> + :locals => { + :submission => @prob_submissions[problem_counter][:submission], + :problem_name => problem.name }%> diff --git a/app/views/main/_submission_short.html.haml b/app/views/main/_submission_short.html.haml --- a/app/views/main/_submission_short.html.haml +++ b/app/views/main/_submission_short.html.haml @@ -9,5 +9,9 @@ = "Graded at #{format_short_time(submission.graded_at)}, " = "score: #{submission.points} " = " [" + submission.grader_comment + "]" + = " | " + = link_to('[msg]', {:action => 'compiler_msg', :id => submission.id}, {:popup => true}) = " | " - = link_to('[source]',{:action => 'get_source', :id => submission.id}) + = link_to('[source]',{:action => 'source', :id => submission.id}) + = " | " + = link_to '[submissions]', :action => 'submission', :id => problem_name diff --git a/app/views/main/compiler_msg.html.haml b/app/views/main/compiler_msg.html.haml new file mode 100644 --- /dev/null +++ b/app/views/main/compiler_msg.html.haml @@ -0,0 +1,6 @@ +%h2= "Compiler message for submission \##{@submission.number}, task: #{@submission.problem.name}" +%p + - if @submission.compiler_message.chomp == '' + no message + - else + = simple_format(@submission.compiler_message)