From c6174406fb0294c2371dc095cc34490a131210cb Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Apr 2016 10:39:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AF=AD=E5=8F=A5?= =?UTF-8?q?=E4=BD=BF=E7=94=A8rails=E5=B7=B2=E6=9C=89=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 5 +++-- app/views/admin/code_work_tests.html.erb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7d1ff6426..e581216fe 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -596,7 +596,7 @@ class AdminController < ApplicationController #代码测试列表 def code_work_tests #求出所有条数 - tCount = StudentWorkTest.find_by_sql("select count(*) from code_tests").first['count(*)'] + tCount = CodeTests.count() #设置个空的数组 以便paginateHelper来分页 @code_work_tests = [] @@ -615,7 +615,8 @@ class AdminController < ApplicationController if is_test[test['student_work_id']] != nil test['is_test'] = is_test[test['student_work_id']] else - test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] + test['is_test'] = StudentWork.find(test['student_work_id']).is_test + #test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] is_test[test['student_work_id']] = test['is_test'] end end diff --git a/app/views/admin/code_work_tests.html.erb b/app/views/admin/code_work_tests.html.erb index 385f97169..cb113f1e6 100644 --- a/app/views/admin/code_work_tests.html.erb +++ b/app/views/admin/code_work_tests.html.erb @@ -40,7 +40,7 @@ <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> '> - <% if test['is_test'] == 0 %> + <% if !test['is_test'] %> <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> <% else %> <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%>