点击作品消息,作品展开

This commit is contained in:
huang 2016-03-24 15:04:50 +08:00
parent 77419dc2d4
commit 88185b1f34
3 changed files with 41 additions and 39 deletions

View File

@ -230,12 +230,12 @@ class StudentWorkController < ApplicationController
render_403
return
end
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name).count
end
@score = @b_sort == "desc" ? "asc" : "desc"
# 消息传过来的ID
@message_student_work_id = params[:student_work_id]
respond_to do |format|
format.js
format.html

View File

@ -47,42 +47,44 @@
<script type="text/javascript">
$(function(){
<% if !@is_evaluation && !@is_teacher %>
<% work=@homework.student_works.where("user_id = ?",User.current.id).first %>
<% unless work.nil? %>
<% 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")}) %>");
<% work = @homework.student_works.where("user_id = ?",User.current.id).first %>
<% elsif !@message_student_work_id.nil? %>
<% work = @homework.student_works.where("id =?", @message_student_work_id).first %>
<% end %>
<% unless work.nil? %>
<% 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 language = <%= @homework.language %>;
if (language == 1) {
program_name = 'text/x-csrc';
} else if(language==2){
program_name = 'text/x-c++src';
}else if(language==3){
program_name = 'text/x-cython';
} else if(language==4){
program_name = 'text/x-java';
}
var editor = CodeMirror(document.getElementById("work-code_<%= work.id%>"), {
mode: {name: program_name,
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 2,
matchBrackets: true,
readOnly: true,
value: $("#work-src_<%= work.id%>").text()
});
<% 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")}) %>");
<% end %>
<% end %>
$('#score_<%= work.id%>').peSlider({range: 'min'});
<% end %>
var program_name = "text/x-csrc";
var language = <%= @homework.language %>;
if (language == 1) {
program_name = 'text/x-csrc';
} else if(language==2){
program_name = 'text/x-c++src';
}else if(language==3){
program_name = 'text/x-cython';
} else if(language==4){
program_name = 'text/x-java';
}
var editor = CodeMirror(document.getElementById("work-code_<%= work.id%>"), {
mode: {name: program_name,
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 2,
matchBrackets: true,
readOnly: true,
value: $("#work-src_<%= work.id%>").text()
});
<% 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")}) %>");
<% end %>
<% end %>
$('#score_<%= work.id%>').peSlider({range: 'min'});
<% end %>
});
</script>

View File

@ -167,7 +167,7 @@
</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<% unless ma.content.nil? %>
<%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),
<%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id, :student_work_id => ma.course_message.student_work),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<!--:onmouseover =>"message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
@ -208,7 +208,7 @@
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">回复了作品评论:</span>
</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id, :student_work_id => ma.course_message.jour.student_work), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<!--:onmouseover => "message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
</a>