Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-04-21 11:22:14 +08:00
commit 6fe86fb24e
2 changed files with 32 additions and 6 deletions

View File

@ -610,15 +610,33 @@ class AdminController < ApplicationController
tStart = @page*30
@code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ")
#取出各个作是否是模拟答题的
#取出各个作是否是模拟答题的
is_test = {}
#作品是否存在
link_swork = {}
#作业是否存在
link_hwork = {}
@code_work_tests.each do |test|
#作品是否存在
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']]
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']
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

View File

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