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

This commit is contained in:
alan 2016-03-25 17:07:42 +08:00
commit 4587e728d8
35 changed files with 1634 additions and 1518 deletions

View File

@ -37,16 +37,6 @@ class MessagesController < ApplicationController
# Show a topic and its replies
def show
=begin
if @course
topic_id = params[:r]?params[:r]:params[:id]
parent_id = params[:id]
url = course_boards_path(@course,:topic_id => topic_id,:parent_id=>parent_id);
redirect_to url
return;
end
=end
@isReply = true
page = params[:page]
# Find the page of the requested reply
@ -54,16 +44,7 @@ class MessagesController < ApplicationController
offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i])
page = 1 + offset / REPLIES_PER_PAGE
end
@reply_count = @topic.children.count
# @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
# @replies = @topic.children.
# includes(:author, :attachments, {:board => :project}).
# reorder("#{Message.table_name}.created_on DESC").
# limit(@reply_pages.per_page).
# offset(@reply_pages.offset).
# all
@reply = Message.new(:subject => "RE: #{@message.subject}")
if @course
messages_replies = @topic.children.

View File

@ -5,14 +5,14 @@ class StudentWorkController < ApplicationController
include ApplicationHelper
require 'bigdecimal'
require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students]
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment]
before_filter :is_logged, :only => [:index]
###
###
def program_test
is_test = params[:is_test] == 'true'
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')}
@ -49,13 +49,102 @@ class StudentWorkController < ApplicationController
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
end
end
end
render :json => resultObj
end
$test_result = {}
$test_status = {}
#根据传入的tIndex确定是第几次测试
def program_test_ex
is_test = params[:is_test] == 'true'
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T'),tseq:1,tcount:1} #保存每测试一次返回的结果
student_work = find_or_save_student_work(is_test)
resultObj[:tcount] = @homework.homework_tests.size
unless student_work
resultObj[:status] = 100
else
if @homework.homework_type == 2 && @homework.homework_detail_programing
#找到第index个测试的输入输出
index = params[:tIndex].to_i
resultObj[:tseq] = index
test = @homework.homework_tests[index - 1]
#请求测试
result = test_realtime_ex(test, params[:src])
logger.debug result
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误
resultObj[:status] = -1
resultObj[:results] = result["results"][0] #本次测试结果
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
if result["status"].to_i == -2 #编译错误
resultObj[:status] = -2
elsif result["results"][0]["status"].to_i == 2
resultObj[:status] = 2
end
unless student_work.save
resultObj[:status] = 200
else
#索引
work_id = student_work.id
#测试第一个时初始化下全局变量
if index == 1
$test_result[work_id] = [] #保存本次测试的结果 输入输出
$test_status[work_id] = 0 #保存本次测试的结果 正确还是错误
end
if result["status"].to_i == -2
$test_result[work_id] = [result["error_msg"]]
$test_status[work_id] = -2
else
#存下每次的结果 只有每次都为0才全部正确
$test_status[work_id] = result["status"] != 0 ? result["status"]:$test_status[work_id]
$test_result[work_id][index - 1] = resultObj[:results]
end
student_work.name = params[:title]
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = @homework.late_penalty
else
student_work.late_penalty = 0
end
#超时或编译错误则直接返回了并存入数据库
if resultObj[:status] == 2 || resultObj[:status] == -2 || index == @homework.homework_tests.size
if $test_status[work_id] == 0
resultObj[:status] = 0
end
student_work_test = student_work.student_work_tests.build(status: $test_status[work_id],
results: $test_result[work_id],src: params[:src])
student_work.save
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
$test_result[work_id] = nil
$test_status[work_id] = nil
end
#渲染返回结果
render :json => resultObj
end
end
end
end
def index
# 作业消息状态更新
@homework.course_messages.each do |homework_message|
@ -996,7 +1085,6 @@ class StudentWorkController < ApplicationController
student_work
end
def test_realtime(student_work, src)
url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
@ -1020,6 +1108,28 @@ class StudentWorkController < ApplicationController
JSON.parse(res.body)
end
def test_realtime_ex(test, src)
url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
factor = []
factor << {input: test.input, output: test.output}
solutions = {
src:src,
language:@homework.homework_detail_programing.language,
factor: factor
}
uri = URI(url)
body = solutions.to_json
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
JSON.parse(res.body)
end
#成绩计算
def set_final_score homework,student_work
if homework && homework.homework_detail_manual

View File

@ -24,40 +24,20 @@ module CoursesHelper
def find_excelletn_course keywords, current_course
# 获取tag匹配结果ID
a_tags = []
# kc = keywords.to_a
Course.visible.where("is_excellent =? and is_public =?", 1, 1).each do |ec|
Course.where("is_excellent =? and is_public =?", 1, 1).each do |ec|
if ec.tags.any?{|value| current_course.name.include?(value.to_s)}
a_tags << ec.id
end
end
# sql = "SELECT distinct c.* FROM `courses` c, tags t, taggings ts where t.id = ts.tag_id and ts.taggable_id = c.id and c.is_excellent = 1 and is_delete = 0 and
# ts.taggable_type = 'Course' and t.name like '%#{keywords}%'"
# a_tags = Course.find_by_sql(sql).select{|course| course.is_public ==1 unless User.current.member_of_course?(course)}
# 通过elastic结果获取精品课程
a_courses = []
#courses = Course.search(keywords)
#courses.each do |c|
# a_courses << c.id
#end
a_courses << a_tags unless a_tags.length == 0
# 课程本身不能搜索显示自己
excellent_ids = a_courses.flatten.uniq.delete_if{|i| i == current_course.id}
limit = 5 - excellent_ids.length.to_i
excellent_ids = a_tags.uniq.delete_if{|i| i == current_course.id}
sql = "SELECT distinct c.id FROM course_activities cs, courses c where cs.course_id = c.id
and c.is_excellent =1 and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;"
default_ecourse_ids = Course.find_by_sql(sql).flatten
# REDO:时间紧,待优化
default_ids =[]
default_ecourse_ids.each do |de|
default_ids << de.id
end
default_ids = default_ids - excellent_ids
#default_ecourse = Course.where("id is not in (?)", ids).find_by_sql(sql).flatten.delete_if{|i| i == current_course.id}.flatten
arr_result = excellent_ids << default_ids
arr_result = arr_result.flatten.first(5)
return arr_result
# 过滤条件:精品课程、本身不在搜索范围
#e_courses = Course.where("is_excellent =? and id in (?)",1, arr_result).where("id !=?", current_course.id)
and (c.is_excellent =1 or c.excellent_option =1) and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;"
default_ids = Course.find_by_sql(sql).flatten.map { |c| c.id }
excellent_ids << default_ids.flatten
arr_result = excellent_ids.flatten.uniq.first(5)
excellent_courses = Course.find(arr_result)
return excellent_courses
end
# 判断精品课程是否可见,非课程成员无法查看私有课程
@ -258,7 +238,7 @@ module CoursesHelper
# 学生人数计算
# add by nwb
def studentCount course
course ? course.student.count.to_s : 0#course.student.count
course ? course.student.count.to_i : 0#course.student.count
end
#课程成员数计算
@ -293,12 +273,17 @@ module CoursesHelper
def searchTeacherAndAssistant project
#searchPeopleByRoles(project, TeacherRoles)
members = []
project.members.each do |m|
project.members.includes(:user).each do |m|
members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
end
members
end
def TeacherAndAssistantCount course
students_count = course.student.count
number = course.members.count - students_count
end
def search_student_in_group(project, course_group_id)
#searchPeopleByRoles(project, StudentRoles)
members = []
@ -766,7 +751,7 @@ module CoursesHelper
#加入课程、退出课程按钮
def join_in_course_header(course, user, options=[])
if user.logged?
joined = course.members.map{|member| member.user_id}.include? user.id
joined = course.members.includes(:user).map{|member| member.user_id}.include? user.id
text = joined ? l(:label_course_exit_student) : l(:label_course_join_student)
url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post'

View File

@ -2,20 +2,7 @@
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag "create_kindeditor" %>
<% end %>
<style type="text/css">
/*回复框*/
/*.homepagePostReplyInputContainer .ke-toolbar {display: none; width: 400px; border: none; background: none; padding: 0px 0px;}*/
/*.homepagePostReplyInputContainer .ke-toolbar-icon {line-height: 26px; font-size: 14px; padding-left: 26px;}*/
/*.homepagePostReplyInputContainer .ke-toolbar-icon-url {background-image: url(/images/public_icon.png)}*/
/*.homepagePostReplyInputContainer .ke-outline {padding: 0px 0px; line-height: 26px; font-size: 14px;}*/
/*.homepagePostReplyInputContainer .ke-icon-emoticons {background-position: 0px -671px; width: 50px; height: 26px;}*/
/*.homepagePostReplyInputContainer .ke-icon-emoticons:hover {background-position: -79px -671px; width: 50px; height: 26px;}*/
/*.homepagePostReplyInputContainer .ke-outline {border: none;}*/
/*.homepagePostReplyInputContainer .ke-inline-block {display: none;}*/
/*.homepagePostReplyInputContainer .ke-container {float: left;}*/
</style>
<% if topics%>
<% if topics %>
<% topics.each do |topic| %>
<script>
function expand_reply(container, btnid) {
@ -44,19 +31,12 @@
});
</script>
<% if topic %>
<%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id,:is_course=>1,:is_board=>1} %>
<%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id, :is_course => 1, :is_board=>1} %>
<% end %>
<% end %>
<% if topics.count == 10 %>
<!--<div id="show_more_course_topic" class="loadMore mt10 f_grey">展开更多<%#= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %></div>-->
<%= link_to "点击展开更多",boards_topic_path(@board, :course_id => @board.course.id ,:page => page),:id => "show_more_course_topic",:remote => "true",:class => "loadMore mt10 f_grey"%>
<% end %>
<% end%>
<!--
<script type="text/javascript">
$("#show_more_course_topic").mouseover(function () {
$("#more_topic_link").click();
});
</script>-->

View File

@ -192,6 +192,4 @@ function nh_init_board(params){
});
}
}
</script>

View File

@ -50,7 +50,7 @@
</script>
<style type="text/css">
</style>
<% course_activities.each do |activity| if course_activities %>
<% course_activities.includes(:course_act).each do |activity| if course_activities %>
<script>
function expand_reply(container, btnid) {
var target = $(container);
@ -73,7 +73,7 @@
sd_create_editor_from_data(<%= activity.id%>, null, "100%", "<%= activity.class.to_s %>");
});
</script>
<% if activity && activity.course_act%>
<% if activity && activity.course_act %>
<% act = activity.course_act %>
<% case activity.course_act_type.to_s %>
<% when 'HomeworkCommon' %>

View File

@ -1,22 +1,21 @@
<% unless excellent_course_recommend(course).length == 0 %>
<% exc_course = excellent_course_recommend(course) %>
<% unless exc_course.length == 0 %>
<ul class="courseR mb10">
<h4 class="mb5" ><%= l(:label_homework_recommendation) %></h4>
<% excellent_course_recommend(course).each do |e_course| %>
<% e_course = Course.find(e_course) %>
<% exc_course.each do |e_course| %>
<li class="mt15"> <%= image_tag(url_to_avatar(e_course), :width => "40", :height => "40", :class => "fl mr10 rankPortrait", :alt => "logo") %>
<div class="fl">
<p class="f12 mb5"><%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %><div class="cl"></div> </p>
<p class="f12">
<% if visable_attachemnts_incourse(e_course).count > 0 %>
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to visable_attachemnts_incourse(e_course).count, course_files_path(e_course), :class => "linkBlue2" %>)</span>
<% if course_file_num > 0 %>
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to course_file_num, course_files_path(e_course), :class => "linkBlue2" %>)</span>
<% end %>
<% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %>
<span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.where("publish_time <= '#{Date.today}'").count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span>
<% end %>
<div class="cl"></div>
</p>
</div>
</p>
</div>
<div class="cl"></div>
</li>
<% end %>

View File

@ -24,19 +24,6 @@
</ul>
</div>
<script>
<%# type = type%>
// $(function (){
// if('<%#= type %>' != null && '<%#= type %>' == 'courses' ){
// $('input:radio[value="courses"]').attr('checked','checked');
// }
// if('<%#= type %>' != null && '<%#= type %>' == 'projects' ){
// $('input:radio[value="projects"]').attr('checked','checked');
// }
// if('<%#= type %>' != null && '<%#= type %>' == 'users' ){
// $('input:radio[value="users"]').attr('checked','checked');
// }
// });
$(function(){
$("#navHomepageSearchInput").keypress(function(e){
var name = $.trim($('#navHomepageSearchInput').val());
@ -65,23 +52,6 @@
<input type="text" style="display: none;"/>
<a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header($(this));"></a>
<% end %>
<!--<div class="navSearchTypeBox" id="navHomepageSearchType">-->
<!--<div class="fl mr15 mt8">-->
<!--<input type="radio" value="courses" name="search_type" checked/>-->
<!--课程-->
<!--</div>-->
<!--<div class="fl mr15 mt8">-->
<!--<input type="radio" value="projects" name="search_type" />-->
<!--项目-->
<!--</div>-->
<!--<div class="fl mr15 mt8">-->
<!--<input type="radio" value="users" name="search_type" />-->
<!--用户-->
<!--</div>-->
<!--<div id="navSearchAlert" class="fr mr10">-->
<!--<span class="c_red">请选择搜索类型</span>-->
<!--</div>-->
<!--</div>-->
</div>
<div class="navHomepageProfile" id="navHomepageProfile">

View File

@ -1,80 +1,39 @@
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
<% teacher_num = searchTeacherAndAssistant(@course).count %>
<% student_num = studentCount(@course) %>
<% course_file_num = visable_attachemnts_incourse(@course).count%>
<% teacher_num = 0 %>
<% student_num = 0 %>
<div class="pr_info_logo fl mr10 mb5">
<% if is_excellent_course(@course) %>
<img src="/images/course/boutique.png" width="50" height="auto" alt="精品" class="boutiqueP" />
<% end %>
<!--<a href="#"><img src="images/courses/pic_courses.jpg" width="60" height="60" alt="logo" /></a>-->
<%= image_tag(url_to_avatar(@course), :width => "60", :height => "60") %>
</div>
<div class="pr_info_id fl mb5 f14">ID:<%= @course.id%><%= @course.is_public == 0 ? "(私有)" : "(公开)" %>
<div class="pr_info_id fl mb5 f14">ID:<%= @course.id %><%= @course.is_public == 0 ? "(私有)" : "(公开)" %>
<% if is_excellent_course(@course) %>
<img src="/images/course/medal.png" alt="精品课程" style="vertical-align:bottom;" class="ml5" />
<% end %>
</div>
<div class="pr_info_id fl f14">
<% unless is_teacher %>
<!--<a href="" class="pr_join_a f12">加入课程</a>-->
<div id="join_in_course_header"><%= join_in_course_header(@course, User.current) %></div>
<div id="join_in_course_header"><%= join_in_course_header(@course, User.current) %></div>
<% end %>
</div>
<!--<div class="pr_info_id fl mb5 f14">
ID:<%#= @course.id%>
</div>
<div class="pr_info_join fl">
<%# if is_teacher%>
<%#= link_to "<span class='pr_setting'></span>#{l(:button_configure)}".html_safe, {:controller => 'courses', :action => 'settings', :id => @course}, :class => "pr_join_a" %>
<%#= set_course_time @course%>
<%#= link_to "<span class='pr_copy'></span>#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %>
<%# else%>
<div id="join_in_course_header"><%#= join_in_course_header(@course, User.current) %></div>
<%# end%>
</div>-->
<div class="cl"></div>
<!--<div >-->
<!--<a class="pr_info_name fl c_dark fb break_word" href="http://<%#= Setting.host_course%>/courses/<%#= @course.id%>" target="_blank">-->
<!--<%#= @course.name %>-->
<!--</a>-->
<!--<%# if @course.is_public == 0%>-->
<!--<span class="img_private ">-->
<!--<%#= l(:field_is_private)%>-->
<!--</span>-->
<!--<%# end %>-->
<!--<%#if @course.tea_id == User.current.id && @course.outline == 0 %>-->
<!--<span>-->
<!--<a href="javascript:void(0)" onclick="course_outline('<%#= @course.id%>');">设置大纲</a>-->
<!--</span>-->
<!--<%# else%>-->
<!--<span>-->
<!--<a href="javascript:void(0)" onclick="course_outline('<%#= @course.id%>');">设置大纲</a>-->
<!--</span>-->
<!--<%# end %>-->
<!--</div>-->
<div >
<a class="pr_info_name fl c_dark fb break_word" href="http://<%= Setting.host_course%>/courses/<%= @course.id%>" target="_blank"></a>
<div>
<a class="pr_info_name c_dark fb break_word fl" href="http://<%= Setting.host_course%>/courses/<%= @course.id%>" target="_blank">
<%= @course.name %>
</a>
<%# if @course.is_public == 0%>
<!--<span class="img_private "></span>-->
<!--<span class="img_private mr5 fl">
<%#= l(:field_is_private)%>
</span>-->
<%# end %>
<span id="course_outline_bar">
<%if User.current && @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %>
<% if User.current && @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %>
<a href="javascript:void(0);" title="设置课程大纲" onclick="course_outline('<%= @course.id%>')" class="mr5 syllabusSetting fl"> </a>
<% elsif User.current && @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%>
<% elsif User.current && @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0 %>
<a href="<%=syllabus_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course) && @course.outline != 0%>
<% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course) && @course.outline != 0 %>
<a href="<%=syllabus_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<% elsif User.current && @course.tea_id != User.current.id && @course.is_public? && @course.outline != 0%>
<% elsif User.current && @course.tea_id != User.current.id && @course.is_public? && @course.outline != 0 %>
<a href="<%=syllabus_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<%else%>
<%else %>
<%end %>
</span>
</div>

View File

@ -55,7 +55,8 @@
<div id="content">
<div id="LSide" class="fl">
<div class="project_info" style="position: relative" id="project_info_<%=@course.id %>">
<%=render :partial=>'layouts/project_info' %>
<% course_file_num = visable_attachemnts_incourse(@course).count %>
<%=render :partial=>'layouts/project_info', :locals => {:course_file_num => course_file_num} %>
</div><!--课程信息 end-->
<div class="info_box">
<ul>
@ -168,7 +169,7 @@
<div class="cl"></div>
</div><!--项目标签 end-->
<!--课程推荐-->
<%= render :partial => 'courses/recommendation', :locals => {:course => @course} %>
<%= render :partial => 'courses/recommendation', :locals => {:course => @course, :course_file_num => course_file_num} %>
<div class="fontGrey5 mt10 ml10 mb10">访问计数 <%= @course.visits.to_i %></div>
</div><!--LSide end-->

View File

@ -29,7 +29,7 @@
showMathMenuMSIE: false,
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
</script>
</head>
<!--add by huang-->

View File

@ -48,7 +48,7 @@
</script>
<% unless forge_acts.empty? %>
<% forge_acts.each do |activity| -%>
<% forge_acts.includes(:forge_act).each do |activity| -%>
<script>
function expand_reply(container, btnid) {
var target = $(container);
@ -80,7 +80,7 @@
<%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %>
<!--message -->
<% when "Message" %>
<%= render :partial => 'users/project_message', :locals => {:activity => activity.forge_act,:user_activity_id =>activity.id,:is_course=>1,:is_board=>0} %>
<%= render :partial => 'users/project_message', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :is_course => 1, :is_board => 0} %>
<!--new 新闻-->
<% when "News" %>
<% if !activity.forge_act.nil? and activity.forge_act.project %>

View File

@ -53,18 +53,32 @@
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<% test.results.reverse.each_with_index do |x, i| %>
<li >
<span class="w60 T_C">测试<%=i+1%></span>
<span class="w60 T_C">测试<%=test.results.size-i%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<% if x["status"].to_i == 2 %>
<span class="w60 c_red">超时!</span>
<% else %>
<span class="w60 c_red">测试错误!</span>
<% end %>
<span class="w60">您的输出:</span>
<span class="width150"><pre><%=x["result"].force_encoding("UTF-8")%></pre></span>
<span class="width120"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["result"]%> </pre></span>
<span class="w60">正确输出:</span>
<span class="width150"><pre><%=x["output"]%></pre></span>
<span class="width120"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["output"]%></pre></span>
<% if x["status"].to_i == 2 %>
<span class="w50">耗时:</span>
<span class="w80"><pre><%=x["time_used"]%>毫秒</pre></span>
<% end %>
<div class="cl"></div>
<% else %>
<span class="w150 c_green">测试正确!</span>
<span class="w60 c_green">测试正确!</span>
<!-- <span class="w50"> 耗时:</span> -->
<!-- <span class="w80"><pre><%=x["time_used"]%>微秒</pre></span> -->
<div class="cl"></div>
<% end %>
</li>

View File

@ -151,7 +151,7 @@
<% else %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
<% end %>
<% student_works.each_with_index do |sw, i| %>
<% student_works.includes(:user).each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;">
<a href="javascript:void(0);" class="linkBlue">
<% if User.current.member_of_course?(activity.course) || User.current.admin? || activity.is_open == 1 %>

View File

@ -2,14 +2,14 @@
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
<%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
<%#= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word mt-4">
<% if activity.try(:author).try(:realname) == ' ' %>
<%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
<%= link_to activity.try(:author), user_path(activity.author_id, :host=>Setting.host_user), :class => "newsBlue mr15" %>
<% else %>
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id, :host=>Setting.host_user), :class => "newsBlue mr15" %>
<% end %>
TO
<%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%>
@ -18,15 +18,15 @@
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<% end %>
</div>
<% if activity.sticky == 1%>
<% if activity.sticky == 1 %>
<span class="sticky_btn_cir ml10">置顶</span>
<% end%>
<% if activity.locked%>
<% if activity.locked %>
<span class="locked_btn_cir ml10 fl" title="已锁定">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<% end%>
<% end %>
<div class="cl"></div>
<div class="homepagePostDate fl">
发帖时间:<%= format_time(activity.created_on) %>
@ -36,9 +36,9 @@
</div>
<div class="cl"></div>
<% if activity.parent_id.nil? %>
<% content = activity.content%>
<% content = activity.content %>
<% else %>
<% content = activity.parent.content%>
<% content = activity.parent.content %>
<% end %>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
<div class="cl"></div>
@ -113,7 +113,7 @@
<% if count > 0 %>
<div class="" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.children.reorder("created_on desc").each do |reply|%>
<% activity.children.includes(:author).reorder("created_on desc").each do |reply|%>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');

View File

@ -73,10 +73,9 @@
</div>
<div class="cl"></div>
</div>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => user_activity_id, :content => activity.description} %>
<div id="intro_content_show_<%= user_activity_id %>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id %>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<div class="cl"></div>
<%# 局部刷新修改xissue属性 %>
<% if User.current.member_of?(activity.project) %>

View File

@ -25,7 +25,7 @@
<% if count > 0 %>
<div class="" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.journals.reorder("created_on desc").each do |reply| %>
<% activity.journals.includes(:user, :details).reorder("created_on desc").each do |reply| %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
@ -44,7 +44,7 @@
<%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
<% end %>
<%= format_time(reply.created_on) %>
<span id="reply_praise_count_<%=reply.id %>">
<span id="reply_praise_count_<%= reply.id %>">
<% if reply.user == User.current %>
<span class="fr likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(reply) > 0 ? "#{get_praise_num(reply)}" : "" %></span></span>
<% else %>

View File

@ -108,7 +108,7 @@
<% if count > 0 %>
<div class="" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.children.reorder("created_on desc").each do |reply| %>
<% activity.children.includes(:author).reorder("created_on desc").each do |reply| %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');

View File

@ -155,7 +155,7 @@
<% else %>
<% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
<% end %>
<% student_works.each_with_index do |sw, i| %>
<% student_works.includes(:user).each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;">
<a href="javascript:void(0);" class="linkBlue">
<% if User.current.member_of_course?(homework_common.course) || User.current.admin? || homework_common.is_open == 1 %>

View File

@ -11,42 +11,52 @@
});
</script>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:result-list" type="text/html">
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<! if((tseq == tcount) ||(status == 2)||(status == -2)){ !>
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<!}!>
<! if(status == -2){!>
<div class="ProResultCon "><!= error_msg !></div>
<div class="ProResultCon "><pre style="white-space: pre-wrap;"><!= error_msg !></pre></div>
<!}else{!>
<div class="ProResultTable " >
<div class="ProResultTable ">
<ul class="ProResultUl " >
<! for(var i =0; i <results.length; ++i){ !>
<li ><span class="w60 T_C">测试<!=i+1!></span>
<! if(results[i]["status"]!=0){ !>
<span class="w150 c_red">测试错误!</span>
<span class="w60">您的输出:</span>
<span class="W200"><pre><!=results[i]["result"]!></pre></span>
<span class="w60">正确输出:</span>
<span class="W200"><pre><!=results[i]["output"]!></pre></span>
<div class="cl"></div>
<li ><span class="w60 T_C">测试<!=tseq!></span>
<! if(results["status"]!=0){ !>
<! if(results["status"]==2){!>
<span class="w60 c_red">超时!</span>
<!}else{!>
<span class="w60 c_red">测试错误!</span>
<!}!>
<span class="w60">您的输出:</span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["result"]!> </pre></span>
<span class="w60">正确输出:</span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["output"]!></pre></span>
<! if(results["status"]==2){!>
<span class="w50"> 耗时:</span>
<span class="w80"><pre><!=results["time_used"]!>毫秒</pre></span>
<!}!>
<div class="cl"></div>
</li>
<!}else{!>
<span class="w150 c_green">测试正确!</span>
<div class="cl"></div>
<span class="w60 c_green">测试正确!</span>
<!-- <span class="w50"> 耗时:</span> -->
<!-- <span class="w80"><pre><!=results["time_used"]!>微秒</pre></span> -->
<div class="cl"></div>
</li>
<!}!>
<!}!>
</ul>
</ul>
</div>
<! } !>
</script>
<!-- 模板1结束 -->
<div class="ProgramHomework ml10">
<div class="homepageRightBanner mb10">
<div class="NewsBannerName"><%= @is_test ? '模拟答题' : '提交作品' %></div>
@ -123,18 +133,28 @@
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=i+1%></span>
<% test.results.reverse.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=test.results.size-i%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<% if x["status"].to_i == 2 %>
<span class="w60 c_red">超时!</span>
<% else %>
<span class="w60 c_red">测试错误!</span>
<% end %>
<span class="w60">您的输出:</span>
<span class="W200"><pre><%=x["result"]%></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["result"]%> </pre></span>
<span class="w60">正确输出:</span>
<span class="W200"><pre><%= x["output"] %></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><%= x["output"] %></pre></span>
<% if x["status"].to_i == 2 %>
<span class="w50"> 耗时:</span>
<span class="w80"><pre><%=x["time_used"]%>毫秒</pre></span>
<% end %>
<div class="cl"></div>
</li>
<% else %>
<span class="w150 c_green">测试正确!</span>
<span class="w60 c_green">测试正确!</span>
<!-- <span class="w50"> 耗时:</span> -->
<!-- <span class="w80"><pre><%=x["time_used"]%>微秒</pre></span> -->
<div class="cl"></div>
</li>
<% end %>

View File

@ -2,36 +2,46 @@
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:result-list" type="text/html">
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<! if((tseq == tcount) ||(status == 2)||(status == -2)){ !>
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<!}!>
<! if(status == -2){!>
<div class="ProResultCon "><!= error_msg !></div>
<div class="ProResultCon "><pre style="white-space: pre-wrap;"><!= error_msg !></pre></div>
<!}else{!>
<div class="ProResultTable " >
<div class="ProResultTable ">
<ul class="ProResultUl " >
<! for(var i =0; i <results.length; ++i){ !>
<li ><span class="w60 T_C">测试<!=i+1!></span>
<! if(results[i]["status"]!=0){ !>
<span class="w150 c_red">测试错误!</span>
<span class="w60">您的输出:</span>
<span class="W200"><pre><!=results[i]["result"]!></pre></span>
<span class="w60">正确输出:</span>
<span class="W200"><pre><!=results[i]["output"]!></pre></span>
<div class="cl"></div>
</li>
<!}else{!>
<span class="w150 c_green">测试正确!</span>
<div class="cl"></div>
</li>
<!}!>
<!}!>
</ul>
</div>
<! } !>
<li ><span class="w60 T_C">测试<!=tseq!></span>
<! if(results["status"]!=0){ !>
<! if(results["status"]==2){!>
<span class="w60 c_red">超时!</span>
<!}else{!>
<span class="w60 c_red">测试错误!</span>
<!}!>
<span class="w60">您的输出:</span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["result"]!> </pre></span>
<span class="w60">正确输出:</span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["output"]!></pre></span>
<! if(results["status"]==2){!>
<span class="w50"> 耗时:</span>
<span class="w80"><pre><!=results["time_used"]!>毫秒</pre></span>
<!}!>
<div class="cl"></div>
</li>
<!}else{!>
<span class="w60 c_green">测试正确!</span>
<!-- <span class="w50"> 耗时:</span> -->
<!-- <span class="w80"><pre><!=results["time_used"]!>微秒</pre></span> -->
<div class="cl"></div>
</li>
<!}!>
</ul>
</div>
<! } !>
</script>
<!-- 模板1结束 -->
@ -90,18 +100,28 @@
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=i+1%></span>
<% test.results.reverse.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=test.results.size-i%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<% if x["status"].to_i == 2 %>
<span class="w60 c_red">超时!</span>
<% else %>
<span class="w60 c_red">测试错误!</span>
<% end %>
<span class="w60">您的输出:</span>
<span class="W200"><pre><%=x["result"]%></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["result"]%> </pre></span>
<span class="w60">正确输出:</span>
<span class="W200"><pre><%=x["output"]%></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["output"]%></pre></span>
<% if x["status"].to_i == 2 %>
<span class="w50"> 耗时:</span>
<span class="w80"><pre><%=x["time_used"]%>毫秒</pre></span>
<% end %>
<div class="cl"></div>
</li>
<% else %>
<span class="w150 c_green">测试正确!</span>
<span class="w60 c_green">测试正确!</span>
<!--<span class="w50"> 耗时:</span> -->
<!--<span class="w80"><pre><%=x["time_used"]%>微秒</pre></span> -->
<div class="cl"></div>
</li>
<% end %>

View File

@ -273,7 +273,7 @@ RedmineApp::Application.routes.draw do
get 'absence_penalty_list'
get 'evaluation_list'
# post 'set_program_score'
post 'program_test'
post 'program_test_ex'
post 'set_score_rule'
end
end

View File

@ -1,5 +1,5 @@
class AddIndexToForgeActivities < ActiveRecord::Migration
def change
add_index :forge_activities, [:project_id, :forge_act_id, :created_at], :name => 'forge_cat_project_id'
add_index :forge_activities, [:project_id, :forge_act_id, :created_at, :forge_act_type], :name => "forge_act_index"
end
end

View File

@ -0,0 +1,5 @@
class AddIndexToCourseActiivities < ActiveRecord::Migration
def change
add_index :course_activities, [:course_id, :course_act_id, :course_act_type, :created_at], :name => "course_act_index"
end
end

View File

@ -0,0 +1,5 @@
class AddIndexToUserActivities < ActiveRecord::Migration
def change
add_index :user_activities, [:act_id, :act_type, :container_id, :created_at], :name => "user_act_index"
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160324052634) do
ActiveRecord::Schema.define(:version => 20160325030423) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -405,6 +405,8 @@ ActiveRecord::Schema.define(:version => 20160324052634) do
t.datetime "updated_at", :null => false
end
add_index "course_activities", ["course_id", "course_act_id", "course_act_type", "created_at"], :name => "course_act_index"
create_table "course_attachments", :force => true do |t|
t.string "filename"
t.string "disk_filename"
@ -731,6 +733,7 @@ ActiveRecord::Schema.define(:version => 20160324052634) do
end
add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id"
add_index "forge_activities", ["project_id", "forge_act_id", "created_at", "forge_act_type"], :name => "forge_act_index"
create_table "forge_messages", :force => true do |t|
t.integer "user_id"
@ -1812,6 +1815,8 @@ ActiveRecord::Schema.define(:version => 20160324052634) do
t.integer "user_id"
end
add_index "user_activities", ["act_id", "act_type", "container_id", "created_at"], :name => "user_act_index"
create_table "user_extensions", :force => true do |t|
t.integer "user_id", :null => false
t.date "birthday"

View File

@ -14,7 +14,7 @@ module RailsKindeditor
output = ActiveSupport::SafeBuffer.new
output << text_area_tag(name, content, input_html)
output << javascript_tag(js_replace(id, options.merge(window_onload: 'true',
:autoHeightMode=>false,
:autoHeightMode=>true,#yuanke 所有调用该方法创建的KE都自动增高
afterCreate: eval_str(at_id, at_type),
emotionsBasePath: 'http://' + Setting.host_name
)))
@ -29,7 +29,7 @@ module RailsKindeditor
output_buffer = ActiveSupport::SafeBuffer.new
output_buffer << build_text_area_tag(name, method, self, options, input_html)
output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true',
:autoHeightMode=>false,
:autoHeightMode=>true,#yuanke 所有调用该方法创建的KE都自动增高
afterCreate: eval_str(at_id, at_type),
emotionsBasePath: 'http://' + Setting.host_name
)))

View File

@ -174,7 +174,7 @@ function(a,c){var d=J(c,["prop","delete"])<0?b.plugin.getSelectedCell:b.plugin.g
function(a,d){c[d]&&b.afterCreate(function(){Ka(this.edit.doc,c[d],function(){b.cmd.selection();b.clickToolbar(d)})});b.clickToolbar(d,function(){b.focus().exec(d,null)})});b.afterCreate(function(){function c(){f.range.moveToBookmark(j);f.select();X&&(a("div."+l,i).each(function(){a(this).after("<br />").remove(!0)}),a("span.Apple-style-span",i).remove(!0),a("span.Apple-tab-span",i).remove(!0),a("span[style]",i).each(function(){a(this).css("white-space")=="nowrap"&&a(this).remove(!0)}),a("meta",i).remove());
var d=i[0].innerHTML;i.remove();d!==""&&(X&&(d=d.replace(/(<br>)\1/ig,"$1")),b.pasteType===2&&(d=d.replace(/(<(?:p|p\s[^>]*)>) *(<\/p>)/ig,""),/schemas-microsoft-com|worddocument|mso-\w+/i.test(d)?d=nb(d,b.filterMode?b.htmlTags:a.options.htmlTags):(d=U(d,b.filterMode?b.htmlTags:null),d=b.beforeSetHtml(d))),b.pasteType===1&&(d=d.replace(/&nbsp;/ig," "),d=d.replace(/\n\s*\n/g,"\n"),d=d.replace(/<br[^>]*>/ig,"\n"),d=d.replace(/<\/p><p[^>]*>/ig,"\n"),d=d.replace(/<[^>]+>/g,""),d=d.replace(/ {2}/g," &nbsp;"),
b.newlineTag=="p"?/\n/.test(d)&&(d=d.replace(/^/,"<p>").replace(/$/,"<br /></p>").replace(/\n/g,"<br /></p><p>")):d=d.replace(/\n/g,"<br />$&")),b.insertHtml(d,!0))}var d=b.edit.doc,f,j,i,l="__kindeditor_paste__",m=!1;a(d.body).bind("paste",function(p){if(b.pasteType===0)p.stop();else if(!m){m=!0;a("div."+l,d).remove();f=b.cmd.selection();j=f.range.createBookmark();i=a('<div class="'+l+'"></div>',d).css({position:"absolute",width:"1px",height:"1px",overflow:"hidden",left:"-1981px",top:a(j.start).pos().y+
"px","white-space":"nowrap"});a(d.body).append(i);if(o){var s=f.range.get(!0);s.moveToElementText(i[0]);s.select();s.execCommand("paste");p.preventDefault()}else f.range.selectNodeContents(i[0]),f.select();setTimeout(function(){c();m=!1},0)}})});b.beforeGetHtml(function(a){o&&A<=8&&(a=a.replace(/<div\s+[^>]*data-ke-input-tag="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b){return unescape(b)}),a=a.replace(/(<input)((?:\s+[^>]*)?>)/ig,function(a,b,c){if(!/\s+type="[^"]+"/i.test(a))return b+' type="text"'+
"px","white-space":"nowrap"});a(d.body).append(i);if(o||Yb){var s=f.range.get(!0);s.moveToElementText(i[0]);s.select();s.execCommand("paste");p.preventDefault()}else f.range.selectNodeContents(i[0]),f.select();setTimeout(function(){c();m=!1},0)}})});b.beforeGetHtml(function(a){o&&A<=8&&(a=a.replace(/<div\s+[^>]*data-ke-input-tag="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b){return unescape(b)}),a=a.replace(/(<input)((?:\s+[^>]*)?>)/ig,function(a,b,c){if(!/\s+type="[^"]+"/i.test(a))return b+' type="text"'+
c;return a}));return a.replace(/(<(?:noscript|noscript\s[^>]*)>)([\s\S]*?)(<\/noscript>)/ig,function(a,b,c,d){return b+fa(c).replace(/\s+/g," ")+d}).replace(/<img[^>]*class="?ke-(flash|rm|media)"?[^>]*>/ig,function(a){var a=I(a),b=ba(a.style||""),c=pb(a["data-ke-tag"]),d=l(b.width,""),b=l(b.height,"");/px/i.test(d)&&(d=t(d));/px/i.test(b)&&(b=t(b));c.width=l(a.width,d);c.height=l(a.height,b);return Ma(c)}).replace(/<img[^>]*class="?ke-anchor"?[^>]*>/ig,function(a){a=I(a);return'<a name="'+unescape(a["data-ke-name"])+
'"></a>'}).replace(/<div\s+[^>]*data-ke-script-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b,c){return"<script"+unescape(b)+">"+unescape(c)+"<\/script>"}).replace(/<div\s+[^>]*data-ke-noscript-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b,c){return"<noscript"+unescape(b)+">"+unescape(c)+"</noscript>"}).replace(/(<[^>]*)data-ke-src="([^"]*)"([^>]*>)/ig,function(a,b,c){a=a.replace(/(\s+(?:href|src)=")[^"]*(")/i,function(a,b,d){return b+fa(c)+d});return a=a.replace(/\s+data-ke-src="[^"]*"/i,
"")}).replace(/(<[^>]+\s)data-ke-(on\w+="[^"]*"[^>]*>)/ig,function(a,b,c){return b+c})});b.beforeSetHtml(function(a){o&&A<=8&&(a=a.replace(/<input[^>]*>|<(select|button)[^>]*>[\s\S]*?<\/\1>/ig,function(a){var b=I(a);if(ba(b.style||"").display=="none")return'<div class="ke-display-none" data-ke-input-tag="'+escape(a)+'"></div>';return a}));return a.replace(/<embed[^>]*type="([^"]+)"[^>]*>(?:<\/embed>)?/ig,function(a){a=I(a);a.src=l(a.src,"");a.width=l(a.width,0);a.height=l(a.height,0);return qb(b.themesPath+

View File

@ -251,7 +251,7 @@ K.options = {
langType : 'zh_CN',
urlType : '',
newlineTag : 'p',
resizeType : 2,
resizeType : 1,
syncType : 'form',
pasteType : 2,
dialogAlignType : 'page',
@ -4938,7 +4938,7 @@ KEditor.prototype = {
afterSetHtml : function(fn) {
return this.handler('afterSetHtml', fn);
},
create : function() {
create : function() {K
var self = this, fullscreenMode = self.fullscreenMode;
if (self.isCreated) {
return self;
@ -5076,8 +5076,11 @@ KEditor.prototype = {
self.afterSetHtml();
},
afterCreate : function() {
self.edit = edit = this;
self.loadPlugin('autoheight');
self.edit = edit = this;
self.cmd = edit.cmd;
//edit.iframe[0].scroll = 'no';
//edit.doc.body.style.overflowY = 'hidden';
self._docMousedownFn = function(e) {
if (self.menu) {
self.hideMenu();
@ -6015,6 +6018,7 @@ _plugin('core', function(K) {
'white-space' : 'nowrap'
});
K(doc.body).append(div);
if (_IE) {
var rng = cmd.range.get(true);
rng.moveToElementText(div[0]);

View File

@ -9,7 +9,7 @@
KindEditor.plugin('autoheight', function(K) {
var self = this;
//self.autoHeightMode = true;
if (!self.autoHeightMode) {
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -31,35 +31,78 @@ $(function(){
if(!valid_form()){
return;
}
/*
$.post(
'/student_work/program_test_ex',
{homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test},
function(data,status){
tested = true;
console.log(data);
if(data.index <=0){
data.index = $('.ProResultTop').length+1;
}
$.ajax({
url: '/student_work/program_test',
type: 'POST',
timeout: 60*1000,
data: {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}
}).done(function(data){
tested = true;
console.log(data);
if(data.index <=0){
data.index = $('.ProResultTop').length+1;
}
if (typeof cb == 'function') {cb(data); return;}
var html=bt('t:result-list',data);
$('.ProResult').prepend(html);
if (typeof cb == 'function') {cb(data); return;}
if (data.status==0 && is_test != 'true') {
var r=confirm("答题正确,是否立刻提交?");
if (r) {
$(".HomeWorkCon form").submit();
var html=bt('t:result-list',data);
$('.ProResult').prepend(html);
if (data.status==0 && is_test != 'true') {
var r=confirm("答题正确,是否立刻提交?");
if (r) {
$(".HomeWorkCon form").submit();
}
}
}
}).fail(function(xhr, status){
if(status == 'timeout'){
alert("您的答案超时了, 请检查代码是否存在死循环的错误.");
} else {
alert("测试失败,服务器出错.")
}
});
);
*/
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
var test_post = function(i){
$.post(
'/student_work/program_test_ex',
{homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test,tIndex:i},
function(data,status){
var tSeq = data.tseq;
var tCount = data.tcount;
console.log("tSeq="+tSeq);
console.log("tCount="+tCount);
tested = true;
console.log(data);
if(data.index <=0){
data.index = $('.ProResultTop').length+1;
}
var html=bt('t:result-list',data);
$('.ProResult').prepend(html);
if (data.status==0 && is_test != 'true') {
if (typeof cb == 'function') {cb(data); return;}
var r=confirm("答题正确,是否立刻提交?");
if (r) {
$(".HomeWorkCon form").submit();
}
return;
}
//2 超时 -2 编译错误 测试结束
if (data.status == 2 || data.status == -2 || tSeq >= tCount ){
if (typeof cb == 'function') {cb(data); return;}
return;
}
test_post(i+1);
}
).fail(function(xhr, status){
if(status == 'timeout'){
alert("您的答案超时了, 请检查代码是否存在死循环的错误.");
} else {
alert("测试失败,服务器出错.");
return;
}
});
};
test_post(1);
};
$('#test-program-btn').on('click', test_program);
@ -377,6 +420,10 @@ $(function(){
var src = '';
if(language==4){
src = '\
//注意\n\
//1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
//2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
import java.io.*;\n\
import java.util.*;\n\
\n\
@ -396,8 +443,12 @@ class Main\n\
';
}
else if(language==1){
src = '#include <stdio.h>\n\
\n\
src = '\
//注意\n\
//1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
//2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
#include <stdio.h>\n\
int main()\n\
{\n\
//获取参数方式 scanf\n\
@ -413,6 +464,10 @@ int main()\n\
';
} else if(language==2){
src = '\
//注意\n\
//1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
//2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
#include <iostream>\n\
using namespace std;\n\
\n\
@ -430,6 +485,10 @@ int main()\n\
';
} else if(language==3){
src = '\
#注意\n\
#1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
#2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
#3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
import sys \n\
\n\
#获取参数方式使用raw_input\n\

View File

@ -443,6 +443,7 @@ a:hover.tijiao{ background:#0f99a9;}
.members_left ul li span{ float:left; text-align:center; color:#484747;}
.w150{ text-align:center; width:150px;min-height: 10px;}
.width150{width:150px;min-height: 10px;}
.width120{width:120px;min-height: 10px;}
.f_b{ font-weight: bold;}
.members_right label{ margin-left:15px;}
.N_search{ height:20px; border:1px solid #999;}

View File

@ -1482,9 +1482,8 @@ a.choose-active {background-color:#269ac9; color:#ffffff;}
.subject-list-count {width:60px; text-align:center;}
.subject-list-from {width:145px; text-align:center;}
/*视频播放默认图标*/
.mediaIco{margin: 30px 0 30px 20px;}
/*视频播放默认图标*/
.mediaIco{margin: 30px 0 30px 20px;width: 200px;}
a.st_up{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;}
a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;}
a.st_img { display:block;width:32px; height:32px; border:1px solid #CCC; padding:1px;}
a:hover.st_img { border:1px solid #1c9ec7; }

View File

@ -147,6 +147,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.w90{ width:90px;}
.w100{width: 100px;}
.w125{width:125px;}
.w180{width:180px;}
.w210{ width:210px;}
.w150{ width:150px;}
.w170{width:170px;}