diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index a61a9f580..8ac5cb4bb 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -559,7 +559,8 @@ class AdminController < ApplicationController #代码测试列表 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 = paginateHelper @code_work_tests,30 @page = (params['page'] || 1).to_i - 1 diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 87ef77fdd..f4ca7f061 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -942,6 +942,12 @@ class CoursesController < ApplicationController @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? + + if !@is_teacher + render_403 + return + end + @homework = HomeworkCommon.find params[:homework] #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 @@ -962,10 +968,19 @@ class CoursesController < ApplicationController src_id = params[:src_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 @homework = HomeworkCommon.find params[:homework_id] + @simi_value = src_work.simi_value.to_i + @src_code = src_work.description src_user = User.where("id =?", src_work.user_id).first diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 25dfd4876..9597a35cf 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -254,14 +254,11 @@ class StudentWorkController < ApplicationController logger.debug "time3 is #{Time.now.usec} " result['results'].each do |key,value| - if value['simiworkid'].to_i > 0 @student_work = StudentWork.where("id =?", key.to_i).first @student_work.update_column('simi_id', value['simiworkid'].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} " # dbh.execute(sqlstr) - end logger.debug "time4 is #{Time.now.usec} " end @@ -281,7 +278,7 @@ class StudentWorkController < ApplicationController if @homework.simi_time != nil resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M") else - resultObj[:comparetime] = @homework.simi_time + resultObj[:comparetime] = 0 end render :json => resultObj diff --git a/app/views/admin/code_work_tests.html.erb b/app/views/admin/code_work_tests.html.erb index df7de6bf0..9fbd2fa46 100644 --- a/app/views/admin/code_work_tests.html.erb +++ b/app/views/admin/code_work_tests.html.erb @@ -37,9 +37,11 @@ <% @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 %> "> - - <%=link_to(test.homeworkid, student_work_index_path(:homework => test.homeworkid))%> + + <%=link_to(infos.homeworkid, student_work_index_path(:homework => infos.homeworkid))%> <% if test.status != -2 && test.results.first['user_wait'] %> @@ -51,7 +53,7 @@ <% end %> - <%=%W(C C++ Python Java).at(test.language.to_i - 1)%> + <%=%W(C C++ Python Java).at(infos.language.to_i - 1)%> <%=Time.parse(test.created_at.to_s).strftime("%Y-%m-%d %H:%M:%S")%> diff --git a/app/views/courses/_compare_code_tips_1.html.erb b/app/views/courses/_compare_code_tips_1.html.erb index 696c40a48..4dc073797 100644 --- a/app/views/courses/_compare_code_tips_1.html.erb +++ b/app/views/courses/_compare_code_tips_1.html.erb @@ -1,8 +1,6 @@
- <%if @homework.simi_time != nil %> -

<%="您上次查重的时间为"+Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M")%>

- <%end%> +

重新查重 查看结果 @@ -39,7 +37,7 @@ console.log(data); 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'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); diff --git a/app/views/courses/_show_compare_code.html.erb b/app/views/courses/_show_compare_code.html.erb index 39f8e0565..00bea362e 100644 --- a/app/views/courses/_show_compare_code.html.erb +++ b/app/views/courses/_show_compare_code.html.erb @@ -8,8 +8,13 @@ <% end %>
-

<%=src_name%>

-

<%=dst_name%>

+

<%=src_name%>

+ <% if @simi_value.to_i >= 90 %> +
相似度<%=@simi_value.to_i%>%
+ <% else %> +
相似度<%=@simi_valu.to_i%>%
+ <% end %> +

<%=dst_name%>

diff --git a/app/views/courses/code_repeat.html.erb b/app/views/courses/code_repeat.html.erb index 8a48cfda4..ccca72a20 100644 --- a/app/views/courses/code_repeat.html.erb +++ b/app/views/courses/code_repeat.html.erb @@ -2,16 +2,17 @@

查重结果

    -
  • 全部作品
  • -
  • 对比作品
  • +
  • 被查作品
  • +
  • 疑被抄袭作品
    -
  • 作品名称
  • +
  • 序号
  • +
  • 作品名称
  • 姓名
  • 学号
  • 时间
  • -
  • 作品名称
  • +
  • 作品名称
  • 姓名
  • 学号
  • 时间
  • @@ -20,18 +21,18 @@
<%if @homework.homework_type == 2 %> - <% @student_works.each do |student_work|%> + <% @student_works.each_with_index do |student_work,index|%>
    +
  • <%=index+1%>
  • <% 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%>
  • <%=student_work.user.show_name%>
  • <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
  • <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>
  • <% 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_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%>
  • <%=simi_student_work.user.show_name%>
  • <%= simi_student_work.user.user_extensions.nil? ? "--" : simi_student_work.user.user_extensions.student_id%>
  • <%= Time.parse(format_time(simi_student_work.created_at)).strftime("%m-%d %H:%M")%>
  • @@ -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 ) %> <%else%> -
  • +
  • --
  • --
  • --
  • --
  • +
  • <% end %>
<%end%> diff --git a/app/views/courses/show_comparecode.js.erb b/app/views/courses/show_comparecode.js.erb index 5cfae9428..be98db344 100644 --- a/app/views/courses/show_comparecode.js.erb +++ b/app/views/courses/show_comparecode.js.erb @@ -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'); $('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); -$('#ajax-modal').parent().css("top","20%").css("left","20%").css("position","absolute"); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","30%").css("left","20%").css("padding-top","20px").css("position","fixed"); //$('#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(){ hideModal($(".program-compare-code")); diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index db15e94fb..f6d310269 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -123,7 +123,7 @@ if (data.status == 0) { var homework_simi_time = data.comparetime; - if (!homework_simi_time){ + if (homework_simi_time == 0){ //没进行过代码查重则直接查重 test_repeat(); } diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 3a20dfa04..5162bcb16 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -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;} /*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;} .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.chabox-w-151{ width:151px; 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-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-top{ width:1000px; } .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: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 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-con{ width:599px; border-right:1px solid #D1D1D1; float:left;}