Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
cc9c84b333
|
@ -12,8 +12,11 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
###
|
||||
def program_test
|
||||
resultObj = {status: 0, results: [], error_msg: '', time: Time.now}
|
||||
is_test = params[:is_test] == 'true'
|
||||
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')}
|
||||
unless is_test
|
||||
student_work = find_or_save_student_work
|
||||
|
||||
unless student_work
|
||||
resultObj[:status] = 100
|
||||
else
|
||||
|
@ -39,6 +42,27 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing
|
||||
result = test_realtime(student_work, params[:src])
|
||||
logger.debug result
|
||||
resultObj[:status] = result["status"]
|
||||
resultObj[:results] = result["results"]
|
||||
resultObj[:error_msg] = result["error_msg"]
|
||||
results = result["results"]
|
||||
if result["status"].to_i == -2 #编译错误
|
||||
results = [result["error_msg"]]
|
||||
end
|
||||
|
||||
resultObj[:status] = result["status"].to_i
|
||||
resultObj[:time] = Time.now.strftime('%Y-%m-%d %T')
|
||||
resultObj[:index] = 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
render :json => resultObj
|
||||
end
|
||||
|
||||
|
@ -142,6 +166,10 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
if @homework.homework_type==2
|
||||
redirect_to new_user_commit_homework_users_path(homework_id: @homework.id)
|
||||
return
|
||||
end
|
||||
@user = User.current
|
||||
@student_work = @homework.student_works.where("user_id = ?",User.current.id).first
|
||||
if @student_work.nil?
|
||||
|
|
|
@ -106,18 +106,18 @@ class UsersController < ApplicationController
|
|||
return
|
||||
end
|
||||
# 当前用户查看消息,则设置消息为已读
|
||||
if params[:viewed] == "all"
|
||||
course_querys = @user.course_messages
|
||||
forge_querys = @user.forge_messages
|
||||
user_querys = @user.user_feedback_messages
|
||||
forum_querys = @user.memo_messages
|
||||
if User.current.id == @user.id
|
||||
course_querys.update_all(:viewed => true)
|
||||
forge_querys.update_all(:viewed => true)
|
||||
user_querys.update_all(:viewed => true)
|
||||
forum_querys.update_all(:viewed => true)
|
||||
end
|
||||
end
|
||||
#if params[:viewed] == "all"
|
||||
# course_querys = @user.course_messages
|
||||
# forge_querys = @user.forge_messages
|
||||
# user_querys = @user.user_feedback_messages
|
||||
# forum_querys = @user.memo_messages
|
||||
# if User.current.id == @user.id
|
||||
# course_querys.update_all(:viewed => true)
|
||||
# forge_querys.update_all(:viewed => true)
|
||||
# user_querys.update_all(:viewed => true)
|
||||
# forum_querys.update_all(:viewed => true)
|
||||
# end
|
||||
#end
|
||||
# @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count
|
||||
case params[:type]
|
||||
when nil
|
||||
|
@ -347,6 +347,7 @@ class UsersController < ApplicationController
|
|||
def new_user_commit_homework
|
||||
@user = User.current
|
||||
@homework = HomeworkCommon.find(params[:homework_id])
|
||||
@is_test = params[:is_test] == 'true'
|
||||
@student_work = @homework.student_works.where(user_id: User.current.id).first
|
||||
if @student_work.nil?
|
||||
@student_work = StudentWork.new
|
||||
|
@ -359,7 +360,7 @@ class UsersController < ApplicationController
|
|||
|
||||
def user_commit_homework
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to user_homeworks_user_path(User.current)
|
||||
redirect_to student_work_index_url(:homework => params[:homework])
|
||||
end
|
||||
|
||||
def user_new_homework
|
||||
|
|
|
@ -2347,7 +2347,7 @@ module ApplicationHelper
|
|||
if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前
|
||||
link_to "修改作品", "", :class => 'c_blue', :title => "开启匿评后不可修改作品"
|
||||
elsif homework.homework_type == 2 #编程作业不能修改作品
|
||||
link_to "作品已交", "",:class => 'c_blue',:title => "编程作业不可修改作品"
|
||||
link_to "作品已交", student_work_index_path(:homework => homework.id),:class => 'c_blue',:title => "编程作业不可修改作品"
|
||||
else
|
||||
link_to "修改作品", edit_student_work_path(work.id),:class => 'c_blue'
|
||||
end
|
||||
|
|
|
@ -492,6 +492,7 @@ class Query < ActiveRecord::Base
|
|||
|
||||
def project_statement
|
||||
project_clauses = []
|
||||
unless project.descendants.blank?
|
||||
if project && !project.descendants.active.empty?
|
||||
ids = [project.id]
|
||||
if has_filter?("subproject_id")
|
||||
|
@ -512,6 +513,7 @@ class Query < ActiveRecord::Base
|
|||
elsif project
|
||||
project_clauses << "#{Project.table_name}.id = %d" % project.id
|
||||
end
|
||||
end
|
||||
project_clauses.any? ? project_clauses.join(' AND ') : nil
|
||||
end
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
<% activity= activity.parent ? activity.parent : activity%>
|
||||
<% replies_all_i = 0 %>
|
||||
<% if count > 0 %>
|
||||
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
|
||||
<div class="" id="reply_div_<%= user_activity_id %>">
|
||||
<ul>
|
||||
<% activity.children.reorder("created_on desc").each do |reply|%>
|
||||
<% replies_all_i=replies_all_i+1 %>
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
<% replies_all_i = 0 %>
|
||||
<% if count > 0 %>
|
||||
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
|
||||
<div class="" id="reply_div_<%= user_activity_id %>">
|
||||
<ul>
|
||||
<% activity.comments.reorder("created_on desc").each do |comment| %>
|
||||
<% replies_all_i = replies_all_i + 1 %>
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
|
||||
<% replies_all_i = 0 %>
|
||||
<% if count > 0 %>
|
||||
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
|
||||
<div class="" id="reply_div_<%= user_activity_id %>">
|
||||
<ul>
|
||||
<% activity.journals.reorder("created_on desc").each do |reply| %>
|
||||
<% replies_all_i=replies_all_i + 1 %>
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<% activity= activity.parent_id.nil? ? activity : activity.parent %>
|
||||
<% replies_all_i = 0 %>
|
||||
<% if count > 0 %>
|
||||
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
|
||||
<div class="" id="reply_div_<%= user_activity_id %>">
|
||||
<ul>
|
||||
<% activity.children.reorder("created_on desc").each do |reply| %>
|
||||
<% replies_all_i=replies_all_i+1 %>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
|
||||
div.ke-toolbar .ke-outline{border:none;}
|
||||
.ke-inline-block{display: none;}
|
||||
.ke-container{height: 40px !important;}
|
||||
.ke-container{height: 30px !important;}
|
||||
</style>
|
||||
<% user_activities.each do |user_activity|
|
||||
if user_activities %>
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
<div class="homepagePostSubmit">
|
||||
<%= user_for_homework_common homework_common,is_teacher %>
|
||||
</div>
|
||||
<% if homework_common.homework_type == 2 && is_teacher%>
|
||||
<div class="homepagePostSubmit">
|
||||
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="homepagePostDeadline">
|
||||
<%= l(:label_end_time)%>:<%= homework_common.end_time%>
|
||||
</div>
|
||||
|
|
|
@ -41,19 +41,17 @@
|
|||
<div class="homepageRight">
|
||||
<div class="HomeWork">
|
||||
<div class="RightBanner">
|
||||
<div class="NewsBannerName">提交作品</div>
|
||||
<div class="NewsBannerName"><%= @is_test ? '模拟答题' : '提交作品' %></div>
|
||||
</div>
|
||||
<div class="HomeWorkBox">
|
||||
<div class="">
|
||||
<div class="homepagePostTitle fl"><%= @homework.name %></div><span class="fr c_grey">截止时间:<%= @homework.end_time %></span>
|
||||
<div class="cl"></div>
|
||||
<a href="javascript:void(0);" class="c_blue"><%= @homework.user.show_name %></a>
|
||||
<p class="HomeWorkP"><%= @homework.description %> <br />
|
||||
输入 2 1 1 4 4 2 3 6 5 <br />
|
||||
输出 15<br />
|
||||
<p class="HomeWorkP"><%= @homework.description.html_safe %> <br />
|
||||
</p>
|
||||
</div>
|
||||
<p class="c_grey mt15">注:迟交扣<span class="c_red">2</span>分,缺评一个作品扣<span class="c_red">2</span>分</p>
|
||||
<!--p class="c_grey mt15">注:迟交扣<span class="c_red">2</span>分,缺评一个作品扣<span class="c_red">2</span>分</p-->
|
||||
</div><!---HomeWorkBox end -->
|
||||
<div class="HomeWorkCon">
|
||||
<%= form_for(@student_work,
|
||||
|
@ -64,7 +62,7 @@
|
|||
:homework => @homework.id
|
||||
},
|
||||
:method => :post) do |f|%>
|
||||
|
||||
<input type="hidden" name="is_test" value="<%=@is_test%>">
|
||||
<div class="mt15">
|
||||
<span>请使用 <%= @homework.language_name %> 语言编写</span>
|
||||
</div>
|
||||
|
@ -76,13 +74,18 @@
|
|||
</div>
|
||||
<div class="mt10">
|
||||
<a href="javascript:void(0);" class="BlueCirBtn fl" data-homework-id="<%=@homework.id%>" data-student-work-id="<%=@student_work.id%>" id="test-program-btn">测试代码</a>
|
||||
<% unless @is_test %>
|
||||
<a href="javascript:void(0);" class="BlueCirBtn fr" id="commit-program-work-btn">提交代码</a>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div><!----HomeWorkCon end-->
|
||||
</div><!----HomeWork end-->
|
||||
|
||||
<div class="cl"></div>
|
||||
<div class="ProResult mt10">
|
||||
|
||||
<% @student_work.student_work_tests.each_with_index do |test, index| %>
|
||||
<div class="ProResultTop">
|
||||
<p class="c_blue fl">第<%= @student_work.student_work_tests.count - index%>次测试</p><span class="fr c_grey"><%= test.created_at.to_s(:db) %></span>
|
||||
|
|
|
@ -29,14 +29,7 @@
|
|||
</div>
|
||||
<div class="resources mt10" id="users_setting">
|
||||
<div>
|
||||
<% if params[:type].nil? %>
|
||||
<div class="newsReadSetting">
|
||||
有 <span class="c_red"><%= User.current.count_new_message %></span> 条未读
|
||||
<% unless User.current.count_new_message == 0 %>
|
||||
<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @message_alls.count >0 %>
|
||||
<%# 课程消息 %>
|
||||
<% unless @message_alls.nil? %>
|
||||
|
|
|
@ -26,6 +26,7 @@ $(function(){
|
|||
var student_work_id = $('#test-program-btn').attr('data-student-work-id');
|
||||
var src = $('#program-src').val();
|
||||
var title = $('#program-title').val();
|
||||
var is_test = $('input[name=is_test]').val();
|
||||
|
||||
if(!valid_form()){
|
||||
return;
|
||||
|
@ -33,10 +34,13 @@ $(function(){
|
|||
|
||||
$.post(
|
||||
'/student_work/program_test',
|
||||
{homework: homework_id, student_work_id: student_work_id, src: src, title: title},
|
||||
{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;
|
||||
}
|
||||
|
||||
if (typeof cb == 'function') {cb(); return;}
|
||||
|
||||
|
@ -44,7 +48,7 @@ $(function(){
|
|||
var html=bt('t:result-list',data);
|
||||
$('.ProResult').prepend(html);
|
||||
|
||||
if (data.status==0) {
|
||||
if (data.status==0 && is_test != 'true') {
|
||||
var r=confirm("答题正确,是否立刻提交?");
|
||||
if (r) {
|
||||
$(".HomeWorkCon form").submit();
|
||||
|
|
Loading…
Reference in New Issue