Skip to content

Commit

Permalink
Closes #637. Fix Grader View to show submissions.
Browse files Browse the repository at this point in the history
Description available at: http://review.markusproject.org/r/1171/
  • Loading branch information
Egor Philippov authored and jerboaa committed Mar 12, 2012
1 parent 873b368 commit 20db58b
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 44 deletions.
24 changes: 22 additions & 2 deletions app/controllers/assignments_controller.rb
Expand Up @@ -10,7 +10,8 @@ class AssignmentsController < ApplicationController
:decline_invitation,
:index,
:student_interface,
:update_collected_submissions]
:update_collected_submissions,
:render_test_result]

before_filter :authorize_for_student,
:only => [:student_interface,
Expand All @@ -23,12 +24,31 @@ class AssignmentsController < ApplicationController
:decline_invitation]

before_filter :authorize_for_user,
:only => [:index]
:only => [:index, :render_test_result]

auto_complete_for :assignment,
:name
# Publicly accessible actions ---------------------------------------

#=== Description
# Action called via Rails' remote_function from the test_result_window partial
# Prepares test result and updates content in window.
def render_test_result
@assignment = Assignment.find(params[:aid])
@test_result = TestResult.find(params[:test_result_id])

# Students can use this action only, when marks have been released
if current_user.student? &&
(@test_result.submission.grouping.membership_status(current_user).nil? ||
@test_result.submission.result.released_to_students == false)
render :partial => 'shared/handle_error',
:locals => {:error => I18n.t('test_result.error.no_access', :test_result_id => @test_result.id)}
return
end

render :template => 'assignments/render_test_result', :layout => "plain"
end

def student_interface
@assignment = Assignment.find(params[:id])
@student = current_user
Expand Down
23 changes: 2 additions & 21 deletions app/controllers/results_controller.rb
Expand Up @@ -7,13 +7,13 @@ class ResultsController < ApplicationController
:create,
:add_extra_mark, :next_grouping, :update_overall_comment, :expand_criteria,
:collapse_criteria, :remove_extra_mark, :expand_unmarked_criteria, :update_marking_state,
:download, :note_message, :render_test_result,
:download, :note_message,
:update_overall_remark_comment, :update_remark_request, :cancel_remark_request]
before_filter :authorize_for_ta_and_admin, :only => [:edit, :update_mark, :create, :add_extra_mark,
:next_grouping, :update_overall_comment, :expand_criteria,
:collapse_criteria, :remove_extra_mark, :expand_unmarked_criteria,
:update_marking_state, :note_message, :update_overall_remark_comment]
before_filter :authorize_for_user, :only => [:codeviewer, :render_test_result, :download]
before_filter :authorize_for_user, :only => [:codeviewer, :download]
before_filter :authorize_for_student, :only => [:view_marks, :update_remark_request, :cancel_remark_request]

def note_message
Expand Down Expand Up @@ -237,25 +237,6 @@ def codeviewer
render :template => 'results/common/codeviewer'
end

#=== Description
# Action called via Rails' remote_function from the test_result_window partial
# Prepares test result and updates content in window.
def render_test_result
@assignment = Assignment.find(params[:assignment_id])
@test_result = TestResult.find(params[:test_result_id])

# Students can use this action only, when marks have been released
if current_user.student? &&
(@test_result.submission.grouping.membership_status(current_user).nil? ||
@test_result.submission.result.released_to_students == false)
render :partial => 'shared/handle_error',
:locals => {:error => I18n.t('test_result.error.no_access', :test_result_id => @test_result.id)}
return
end

render :template => 'results/render_test_result', :layout => "plain"
end

def update_mark
result_mark = Mark.find(params[:mark_id])
result_mark.mark = params[:mark]
Expand Down
13 changes: 13 additions & 0 deletions app/views/assignments/_test_result_window.html.erb
@@ -0,0 +1,13 @@
<script type="text/javascript">
//<![CDATA[

function load_test_result(test_result_id) {
$('loading_test_result').show();
$('select_test_result_id').disable();
window.open('<%= url_for(:controller => "assignments", :action => "render_test_result", :aid => aid)%>?test_result_id='+test_result_id,
"Test Results", "width=400,height=250,resizable=yes,scrollbars=yes")
$('loading_test_result').hide();
$('select_test_result_id').enable();
}
//]]>
</script>
2 changes: 1 addition & 1 deletion app/views/assignments/student_interface.html.erb
Expand Up @@ -339,7 +339,7 @@
<%
# Javascript for test result window
%>
<%= render :partial => "results/common/test_result_window.html" %>
<%= render :partial => "assignments/test_result_window.html", :locals => {:aid => @assignment.id} %>
<div id="test_results_controls">
<%= render :partial => 'results/common/test_selector', :locals => {:test_result_files => @test_result_files, :result => @result} %>
<br />
Expand Down
17 changes: 0 additions & 17 deletions app/views/results/common/_test_result_window.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/results/edit.html.erb
Expand Up @@ -95,7 +95,7 @@ function check_working() {
<%
# Javascript for test result window
%>
<%= render :partial => "results/common/test_result_window.html" %>
<%= render :partial => "assignments/test_result_window.html", :locals => {:aid => @assignment.id} %>
<%= render :partial => "results/common/annotations.js" %>
<%= render :partial => "results/marker/setup_annotation_categories.js" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/results/view_marks.html.erb
Expand Up @@ -56,7 +56,7 @@
<%
# Javascript for test result window
%>
<%= render :partial => "results/common/test_result_window.html" %>
<%= render :partial => "assignments/test_result_window.html", :locals => {:aid => @assignment.id} %>
<%= render :partial => "results/common/annotations.js" %>
<%= render :partial => "results/student/boot.js", :locals => {:first_file => @first_file} %>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -39,6 +39,7 @@
get 'deletegroup'
get 'decline_invitation'
post 'disinvite_member'
get 'render_test_result'
end

resources :rubrics do
Expand Down Expand Up @@ -157,7 +158,6 @@
post 'update_overall_remark_comment'
post 'update_marking_state'
get 'update_remark_request'
get 'render_test_result'
get 'update_positions'
get 'update_mark'
get 'expand_criteria'
Expand Down

0 comments on commit 20db58b

Please sign in to comment.