Merge branch 'yuanke' into yuanke_1

This commit is contained in:
yuanke 2016-04-21 14:01:54 +08:00
commit eddea2eabd
2 changed files with 32 additions and 6 deletions

View File

@ -610,15 +610,33 @@ class AdminController < ApplicationController
tStart = @page*30 tStart = @page*30
@code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ") @code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ")
#取出各个作是否是模拟答题的 #取出各个作是否是模拟答题的
is_test = {} is_test = {}
#作品是否存在
link_swork = {}
#作业是否存在
link_hwork = {}
@code_work_tests.each do |test| @code_work_tests.each do |test|
#作品是否存在
if is_test[test['student_work_id']] != nil if is_test[test['student_work_id']] != nil
test['link_swork'] = link_swork[test['student_work_id']]
test['is_test'] = is_test[test['student_work_id']] test['is_test'] = is_test[test['student_work_id']]
else else
test['is_test'] = StudentWork.find(test['student_work_id']).is_test work = StudentWork.where("id=?",test['student_work_id']).first
test['link_swork'] = !work.nil?
test['is_test'] = work.nil? ? false : work.is_test
#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'] = 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'] is_test[test['student_work_id']] = test['is_test']
link_swork[test['student_work_id']] = test['link_swork']
end
#作业是否存在
if link_hwork[test['homework_id']] != nil
test['link_hwork'] = link_hwork[test['homework_id']]
else
hwork = HomeworkCommon.where("id=?",test['homework_id']).first
test['link_hwork'] = !hwork.nil?
link_hwork[test['homework_id']] = test['link_hwork']
end end
end end

View File

@ -37,14 +37,22 @@
<% if test['homework_id'] != nil %> <% if test['homework_id'] != nil %>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center; " title='<%=test['homework_id']%>'> <td style="text-align: center; " title='<%=test['homework_id']%>'>
<% if test['link_hwork'] %>
<%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%>
<% else %>
<%= test['homework_id'] %>
<% end %>
</td> </td>
<td style="text-align: center; " title='<%=test['student_work_id']%>'> <td style="text-align: center; " title='<%=test['student_work_id']%>'>
<% if test['link_swork'] && test['link_hwork'] %>
<% if !test['is_test'] %> <% 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']))%> <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%>
<% else %> <% else %>
<%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%>
<% end %> <% end %>
<% else %>
<%= test['student_work_id'] %>
<% end %>
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">
<% if test.wait_time != 0 %> <% if test.wait_time != 0 %>