学生作品列表打开报500

cxt_course
cxt 10 years ago
parent 1263e4cac0
commit 5b234580a8

@ -45,38 +45,40 @@
<% end%> <% end%>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
<% work=@homework.student_works.where("user_id = ?",User.current.id).first %> <% if !@is_evaluation && !@is_teacher %>
<% unless @is_evaluation %> <% work=@homework.student_works.where("user_id = ?",User.current.id).first %>
<% if @homework.homework_type == 2 %> <% unless work.nil? %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>"); <% if @homework.homework_type == 2 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");
var program_name = "text/x-csrc"; var program_name = "text/x-csrc";
var language = <%= @homework.language %>; var language = <%= @homework.language %>;
if (language == 1) { if (language == 1) {
program_name = 'text/x-csrc'; program_name = 'text/x-csrc';
} else if(language==2){ } else if(language==2){
program_name = 'text/x-c++src'; program_name = 'text/x-c++src';
}else if(language==3){ }else if(language==3){
program_name = 'text/x-cython'; program_name = 'text/x-cython';
} else if(language==4){ } else if(language==4){
program_name = 'text/x-java'; program_name = 'text/x-java';
} }
var editor = CodeMirror(document.getElementById("work-code"), { var editor = CodeMirror(document.getElementById("work-code"), {
mode: {name: program_name, mode: {name: program_name,
version: 2, version: 2,
singleLineStringErrors: false}, singleLineStringErrors: false},
lineNumbers: true, lineNumbers: true,
indentUnit: 2, indentUnit: 2,
matchBrackets: true, matchBrackets: true,
readOnly: true, readOnly: true,
value: $("#work-src").text() value: $("#work-src").text()
}); });
<% elsif @homework.homework_type == 1 %> <% elsif @homework.homework_type == 1 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");
<% elsif @homework.homework_type == 3 %>
<% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %>
<% if pro && pro.student_work_id == work.id %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>"); $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");
<% elsif @homework.homework_type == 3 %>
<% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %>
<% if pro && pro.student_work_id == work.id %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");
<% end %>
<% end %> <% end %>
<% end %> <% end %>
$('#score_<%= work.id%>').peSlider({range: 'min'}); $('#score_<%= work.id%>').peSlider({range: 'min'});

Loading…
Cancel
Save