Merge branch 'yuanke' into develop

This commit is contained in:
yuanke 2016-04-15 11:29:40 +08:00
commit e58f1ab94b
10 changed files with 54 additions and 32 deletions

View File

@ -559,7 +559,8 @@ class AdminController < ApplicationController
#代码测试列表 #代码测试列表
def code_work_tests def code_work_tests
@code_work_tests = StudentWorkTest.find_by_sql("select a.* ,b.id as homeworkid,d.language from student_work_tests as a , homework_commons as b ,student_works as c, homework_detail_programings as d where a.student_work_id = c.id and b.id = c.homework_common_id and c.homework_common_id = d.homework_common_id order by a.created_at desc") @code_work_tests = StudentWorkTest.find_by_sql("select status,results,created_at, student_work_id from student_work_tests order by id desc ")
#@code_work_tests = StudentWorkTest.find_by_sql("select a.status,a.results,a.created_at ,b.id as homeworkid,d.language from student_work_tests as a , homework_commons as b ,student_works as c, homework_detail_programings as d where a.student_work_id = c.id and b.id = c.homework_common_id and c.homework_common_id = d.homework_common_id order by a.id desc ")
#@code_work_tests = StudentWorkTest.order('created_at desc') #@code_work_tests = StudentWorkTest.order('created_at desc')
@code_work_tests = paginateHelper @code_work_tests,30 @code_work_tests = paginateHelper @code_work_tests,30
@page = (params['page'] || 1).to_i - 1 @page = (params['page'] || 1).to_i - 1

View File

@ -942,6 +942,12 @@ class CoursesController < ApplicationController
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
if !@is_teacher
render_403
return
end
@homework = HomeworkCommon.find params[:homework] @homework = HomeworkCommon.find params[:homework]
#order("#{@order} #{@b_sort}" #order("#{@order} #{@b_sort}"
@student_works = 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("simi_value desc"),@name @student_works = 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("simi_value desc"),@name
@ -962,10 +968,19 @@ class CoursesController < ApplicationController
src_id = params[:src_id] src_id = params[:src_id]
dst_id = params[:dst_id] dst_id = params[:dst_id]
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
if !@is_teacher
render_403
return
end
src_work = StudentWork.where("id =?", src_id).first src_work = StudentWork.where("id =?", src_id).first
@homework = HomeworkCommon.find params[:homework_id] @homework = HomeworkCommon.find params[:homework_id]
@simi_value = src_work.simi_value.to_i
@src_code = src_work.description @src_code = src_work.description
src_user = User.where("id =?", src_work.user_id).first src_user = User.where("id =?", src_work.user_id).first

View File

@ -254,14 +254,11 @@ class StudentWorkController < ApplicationController
logger.debug "time3 is #{Time.now.usec} " logger.debug "time3 is #{Time.now.usec} "
result['results'].each do |key,value| result['results'].each do |key,value|
if value['simiworkid'].to_i > 0
@student_work = StudentWork.where("id =?", key.to_i).first @student_work = StudentWork.where("id =?", key.to_i).first
@student_work.update_column('simi_id', value['simiworkid'].to_i) @student_work.update_column('simi_id', value['simiworkid'].to_i)
@student_work.update_column('simi_value', value['simivalue'].to_i) @student_work.update_column('simi_value', value['simivalue'].to_i)
end
# sqlstr = "update student_works set simi_id=#{value['simiworkid']},simi_value=#{value['simivalue']} where id=#{key.to_i} " # sqlstr = "update student_works set simi_id=#{value['simiworkid']},simi_value=#{value['simivalue']} where id=#{key.to_i} "
# dbh.execute(sqlstr) # dbh.execute(sqlstr)
end end
logger.debug "time4 is #{Time.now.usec} " logger.debug "time4 is #{Time.now.usec} "
end end
@ -281,7 +278,7 @@ class StudentWorkController < ApplicationController
if @homework.simi_time != nil if @homework.simi_time != nil
resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M") resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M")
else else
resultObj[:comparetime] = @homework.simi_time resultObj[:comparetime] = 0
end end
render :json => resultObj render :json => resultObj

View File

@ -37,9 +37,11 @@
</thead> </thead>
<tbody> <tbody>
<% @code_work_tests.each do |test| %> <% @code_work_tests.each do |test| %>
<% infos = StudentWorkTest.find_by_sql("select a.homework_common_id as homeworkid,b.language from student_works as a, homework_detail_programings as b where a.id = #{test.student_work_id} and a.homework_common_id = b.homework_common_id
").first %>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center; " title='<%=test.homeworkid%>'> <td style="text-align: center; " title='<%=infos.homeworkid%>'>
<%=link_to(test.homeworkid, student_work_index_path(:homework => test.homeworkid))%> <%=link_to(infos.homeworkid, student_work_index_path(:homework => infos.homeworkid))%>
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">
<% if test.status != -2 && test.results.first['user_wait'] %> <% if test.status != -2 && test.results.first['user_wait'] %>
@ -51,7 +53,7 @@
<% end %> <% end %>
</td> </td>
<td align="center"> <td align="center">
<%=%W(C C++ Python Java).at(test.language.to_i - 1)%> <%=%W(C C++ Python Java).at(infos.language.to_i - 1)%>
</td> </td>
<td align="center"> <td align="center">
<%=Time.parse(test.created_at.to_s).strftime("%Y-%m-%d %H:%M:%S")%> <%=Time.parse(test.created_at.to_s).strftime("%Y-%m-%d %H:%M:%S")%>

View File

@ -1,8 +1,6 @@
<div class="blue-border-box"> <div class="blue-border-box">
<div class="box-con"> <div class="box-con">
<%if @homework.simi_time != nil %> <h4 id = "compare-tips-1"></h4>
<h4 id = "compare-tips-1"><%="您上次查重的时间为"+Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M")%></h4>
<%end%>
<div class="box-con-a"> <div class="box-con-a">
<a href="javascript:void(0);" class="Blue-btn fl " onclick = "compare_code_btn(<%=homework.id%>,<%=courseid%>)">重新查重</a> <a href="javascript:void(0);" class="Blue-btn fl " onclick = "compare_code_btn(<%=homework.id%>,<%=courseid%>)">重新查重</a>
<a href="javascript:void(0);" class="Blue-btn fl " onclick = "see_last_compare_code(<%=courseid%>,<%=homework.id%>)">查看结果</a> <a href="javascript:void(0);" class="Blue-btn fl " onclick = "see_last_compare_code(<%=courseid%>,<%=homework.id%>)">查看结果</a>
@ -39,7 +37,7 @@
console.log(data); console.log(data);
if (data.status == 0) { if (data.status == 0) {
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成是否立即查看结果?",:status=>1, :homework=> homework,:courseid=> courseid})%>'); $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成,是否立即查看结果?",:status=>1, :homework=> homework,:courseid=> courseid})%>');
showModal('ajax-modal', '580px'); showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove(); $('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 560px;' class='resourceClose'></a>"); $('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 560px;' class='resourceClose'></a>");

View File

@ -8,8 +8,13 @@
<% end %> <% end %>
<article> <article>
<h3 style="float:left; width:50%; text-align:center;"><%=src_name%></h3> <h3 style="float:left; width:47%; text-align:center;"><%=src_name%></h3>
<h3 style="float:left; width:50%; text-align:center;"><%=dst_name%></h3><div class="cl"></div> <% if @simi_value.to_i >= 90 %>
<h6 style="color:red;float:left; width:6%; text-align:center;">相似度<%=@simi_value.to_i%>%</h3>
<% else %>
<h6 style="float:left; width:6%; text-align:center;">相似度<%=@simi_valu.to_i%>%</h3>
<% end %>
<h3 style="float:left; width:47%; text-align:center;"><%=dst_name%></h3><div class="cl"></div>
<pre id = "program-src_1" style = "display: none" ><%= src_code if src_code%></pre> <pre id = "program-src_1" style = "display: none" ><%= src_code if src_code%></pre>
<pre id = "program-src_2" style = "display: none" ><%= dst_code if dst_code%></pre> <pre id = "program-src_2" style = "display: none" ><%= dst_code if dst_code%></pre>
<div class = "program-compare-code" id=program-compare-code></div> <div class = "program-compare-code" id=program-compare-code></div>

View File

@ -2,16 +2,17 @@
<h2 class="conbox-h2">查重结果</h2> <h2 class="conbox-h2">查重结果</h2>
<div class="chabox"> <div class="chabox">
<ul class="chabox-header"> <ul class="chabox-header">
<li class="chabox-w-500" style = "width:413px" >全部作品</li> <li class="chabox-w-500" style = "width:438px" >被查作品</li>
<li class="chabox-w-500" style = "width:585px" >对比作品</li> <li class="chabox-w-500" style = "width:560px" >疑被抄袭作品</li>
<div class="cl"></div> <div class="cl"></div>
</ul> </ul>
<ul class="chabox-top"> <ul class="chabox-top">
<li class="chabox-w-151" >作品名称</li> <li class="chabox-w-40 " >序号</li>
<li class="chabox-w-401" >作品名称</li>
<li>姓名</li> <li>姓名</li>
<li>学号 </li> <li>学号 </li>
<li class="chabox-r-line">时间 </li> <li class="chabox-r-line">时间 </li>
<li class="chabox-w-151">作品名称</li> <li class="chabox-w-401">作品名称</li>
<li>姓名</li> <li>姓名</li>
<li>学号 </li> <li>学号 </li>
<li class="chabox-r-line">时间 </li> <li class="chabox-r-line">时间 </li>
@ -20,18 +21,18 @@
</ul> </ul>
<%if @homework.homework_type == 2 %> <%if @homework.homework_type == 2 %>
<% @student_works.each do |student_work|%> <% @student_works.each_with_index do |student_work,index|%>
<ul class="chabox-con" id = "chabox-con-<%=student_work.id%>" > <ul class="chabox-con" id = "chabox-con-<%=student_work.id%>" >
<li class="chabox-w-40 chabox-txt-left" ><%=index+1%></li>
<% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%> <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
<li class="chabox-w-401 chabox-txt-left" style =" text-align:left; text-indent:1em; " ><%=student_work_name%></li>
<li class="chabox-w-151" ><%=student_work_name%></li>
<li><%=student_work.user.show_name%></li> <li><%=student_work.user.show_name%></li>
<li><%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> </li> <li><%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> </li>
<li class="chabox-r-line"><%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%></li> <li class="chabox-r-line"><%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%></li>
<% if student_work.simi_id.to_i > 0 && @works_hash[student_work.simi_id.to_i] %> <% if student_work.simi_id.to_i > 0 && @works_hash[student_work.simi_id.to_i] %>
<% simi_student_work = @works_hash[student_work.simi_id.to_i] %> <% simi_student_work = @works_hash[student_work.simi_id.to_i] %>
<% simi_student_work_name = simi_student_work.name.nil? || simi_student_work.name.empty? ? simi_student_work.user.show_name + '的作品' : simi_student_work.name%> <% simi_student_work_name = simi_student_work.name.nil? || simi_student_work.name.empty? ? simi_student_work.user.show_name + '的作品' : simi_student_work.name%>
<li class="chabox-w-151"><%=simi_student_work_name%></li> <li class="chabox-w-401 chabox-txt-left" style =" text-align:left; text-indent:1em; " ><%=simi_student_work_name%></li>
<li><%=simi_student_work.user.show_name%></li> <li><%=simi_student_work.user.show_name%></li>
<li><%= simi_student_work.user.user_extensions.nil? ? "--" : simi_student_work.user.user_extensions.student_id%></li> <li><%= simi_student_work.user.user_extensions.nil? ? "--" : simi_student_work.user.user_extensions.student_id%></li>
<li class="chabox-r-line"><%= Time.parse(format_time(simi_student_work.created_at)).strftime("%m-%d %H:%M")%></li> <li class="chabox-r-line"><%= Time.parse(format_time(simi_student_work.created_at)).strftime("%m-%d %H:%M")%></li>
@ -47,11 +48,12 @@
<%= link_to("查看", show_comparecode_course_path(:homework_id => @homework.id,:src_id => student_work.id,:dst_id => student_work.simi_id.to_i),:class => "cha-btn",:remote => true ) %> <%= link_to("查看", show_comparecode_course_path(:homework_id => @homework.id,:src_id => student_work.id,:dst_id => student_work.simi_id.to_i),:class => "cha-btn",:remote => true ) %>
</li> </li>
<%else%> <%else%>
<li class="chabox-w-151">无</li> <li class="chabox-w-401">无</li>
<li>--</li> <li>--</li>
<li>--</li> <li>--</li>
<li class="chabox-r-line">--</li> <li class="chabox-r-line">--</li>
<li >--</li> <li >--</li>
<li > </li>
<% end %> <% end %>
</ul> </ul>
<%end%> <%end%>

View File

@ -1,10 +1,10 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/show_compare_code' ,:locals => {:src_code=> @src_code,:src_name=> @src_username,:dst_name=> @dst_username, :dst_code=> @dst_code,})%>'); $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/show_compare_code' ,:locals => {:src_code=> @src_code,:src_name=> @src_username,:dst_name=> @dst_username, :dst_code=> @dst_code, :simivalue=> @simi_value })%>');
showModal('ajax-modal', '1250px'); showModal('ajax-modal', '1250px');
$('#ajax-modal').siblings().remove(); $('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal();' style='margin-left: 1235px;' class='resourceClose'></a>"); $('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal();' style='margin-left: 1235px; margin-top:-18px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","20%").css("left","20%").css("position","absolute"); $('#ajax-modal').parent().css("top","30%").css("left","20%").css("padding-top","20px").css("position","fixed");
//$('#ajax-modal').parent().addClass("resourceUploadPopup"); //$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px").css("padding-top","10px"); $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
function closeModal(){ function closeModal(){
hideModal($(".program-compare-code")); hideModal($(".program-compare-code"));

View File

@ -123,7 +123,7 @@
if (data.status == 0) { if (data.status == 0) {
var homework_simi_time = data.comparetime; var homework_simi_time = data.comparetime;
if (!homework_simi_time){ if (homework_simi_time == 0){
//没进行过代码查重则直接查重 //没进行过代码查重则直接查重
test_repeat(); test_repeat();
} }

View File

@ -2850,19 +2850,21 @@ img.school_avatar {
a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;} a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;}
/*20160401袁可------------------ 查重结果样式*/ /*20160401袁可------------------ 查重结果样式*/
.conbox{ width:1000px; margin:0 auto; border:1px solid #f0f0f0; background:#fff;} .conbox{ width:1000px; margin:0 auto; border:3px solid #f0f0f0; background:#fff;}
.conbox-h2{ font-size:16px; padding:10px 0; padding-left:25px;} .conbox-h2{ font-size:16px; padding:10px 0; padding-left:25px;}
.chabox{ width:1000px;} .chabox{ width:1000px;}
.chabox ul li{ float:left; width:87px; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} .chabox ul li{ float:left; width:82px; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.chabox ul li.chabox-w-151{ width:151px; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} .chabox ul li.chabox-w-401{ width:151px; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.chabox ul li.chabox-r-line{ border-right:1px solid #D1D1D1;} .chabox ul li.chabox-r-line{ border-right:1px solid #D1D1D1;}
.chabox-top{ width:1000px; } .chabox-top{ width:1000px; }
.chabox-top li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000;} .chabox-top li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000;}
.chabox-con li{font-size:12px; line-height:35px; height:35px; color:#000; border-bottom:1px solid #DFDFDF;} .chabox-con li{font-size:12px; line-height:35px; height:35px; color:#888; border-bottom:1px solid #DFDFDF;}
a.cha-btn{ display:block; width:50px; height:20px; line-height:20px; margin:0 auto; border:1px solid #269ac9; color:#269ac9;-webkit-border-radius: 3px;border-radius:3px; margin-top:8px;} a.cha-btn{ display:block; width:50px; height:20px; line-height:20px; margin:0 auto; border:1px solid #269ac9; color:#269ac9;-webkit-border-radius: 3px;border-radius:3px; margin-top:8px;}
a:hover.cha-btn{ background:#269ac9; color:#fff;} a:hover.cha-btn{ background:#269ac9; color:#fff;}
.chabox-header li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; border-top:1px solid #E4E4E4; border-right:1px solid #E4E4E4; color:#000;} .chabox-header li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; border-top:1px solid #E4E4E4; border-right:1px solid #E4E4E4; color:#000;}
.chabox ul li.chabox-w-500{ width:499px;} .chabox ul li.chabox-w-500{ width:499px;}
.chabox ul li.chabox-w-40{ width:39px; border-right:1px solid #D1D1D1;}
.chabox ul li.chabox-txt-left{ text-align:left;text-indent:1em; }
.contrast-box{ width:1200px;box-shadow: 0 0 5px #6B6B6B; background:#fff; margin:0 auto; } .contrast-box{ width:1200px;box-shadow: 0 0 5px #6B6B6B; background:#fff; margin:0 auto; }
.contrast-con{ width:599px; border-right:1px solid #D1D1D1; float:left;} .contrast-con{ width:599px; border-right:1px solid #D1D1D1; float:left;}