Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
f16d269101
|
@ -23,7 +23,7 @@ class HomeworkCommonController < ApplicationController
|
|||
#
|
||||
# @homework = HomeworkCommon.new
|
||||
# @homework.safe_attributes = params[:homework_common]
|
||||
# @homework.late_penalty = 0
|
||||
# @homework.late_penalty = 2
|
||||
# @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
# @homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||
#
|
||||
|
@ -31,7 +31,7 @@ class HomeworkCommonController < ApplicationController
|
|||
# #匿评作业相关属性
|
||||
# @homework_detail_manual = HomeworkDetailManual.new
|
||||
# @homework_detail_manual.ta_proportion = 0.6
|
||||
# @homework_detail_manual.absence_penalty = 0
|
||||
# @homework_detail_manual.absence_penalty = 2
|
||||
# @homework_detail_manual.evaluation_num = 3
|
||||
# @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
# @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
|
@ -52,7 +52,7 @@ class HomeworkCommonController < ApplicationController
|
|||
|
||||
@homework = HomeworkCommon.new
|
||||
@homework.safe_attributes = params[:homework_common]
|
||||
@homework.late_penalty = 0
|
||||
@homework.late_penalty = 2
|
||||
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||
|
||||
|
@ -60,7 +60,7 @@ class HomeworkCommonController < ApplicationController
|
|||
#匿评作业相关属性
|
||||
@homework_detail_manual = HomeworkDetailManual.new
|
||||
@homework_detail_manual.ta_proportion = 0.6
|
||||
@homework_detail_manual.absence_penalty = 0
|
||||
@homework_detail_manual.absence_penalty = 2
|
||||
@homework_detail_manual.evaluation_num = 3
|
||||
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
|
@ -107,6 +107,7 @@ class HomeworkCommonController < ApplicationController
|
|||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
homework.homework_tests << homework_test
|
||||
question[:input] << homework_test.input
|
||||
question[:output] << homework_test.output
|
||||
|
@ -231,11 +232,13 @@ class HomeworkCommonController < ApplicationController
|
|||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
else #不存在的测试,增加
|
||||
homework_test = HomeworkTest.new
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
homework_test.homework_common = @homework
|
||||
end
|
||||
homework_test.save
|
||||
|
@ -367,6 +370,7 @@ class HomeworkCommonController < ApplicationController
|
|||
client.request(request)
|
||||
end
|
||||
result = JSON.parse(res.body)
|
||||
@err_msg = result["compile_error_msg"]
|
||||
result["results"].each do |re|
|
||||
@result = re["status"]
|
||||
end
|
||||
|
|
|
@ -2378,4 +2378,26 @@ module ApplicationHelper
|
|||
end
|
||||
notice.html_safe
|
||||
end
|
||||
|
||||
def stantard_code
|
||||
"// 这是一个C语言的样例程序
|
||||
// 功能:输入两个整数,输出两者之和
|
||||
// 测试:老师可以给出以下测试集:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// 那么下面这段代码将得到满分
|
||||
|
||||
// 注意:编程作业采用命令行传参方式
|
||||
// 程序的所有输入都通过argv传入
|
||||
// 否则您的程序将被判错
|
||||
|
||||
#include <stdio.h> //引用必须头文件
|
||||
int main(int argc, char** argv) {
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
|
||||
printf(\"%d\",a+b); //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
@ -66,4 +66,31 @@ module HomeworkCommonHelper
|
|||
link
|
||||
end
|
||||
|
||||
#将状态转换为错误信息
|
||||
def status_to_err_msg status
|
||||
case status.to_i
|
||||
when -1
|
||||
'编译出错'
|
||||
when -2
|
||||
'输入和输出不匹配'
|
||||
when -3
|
||||
'输入和输出不匹配'
|
||||
when 1
|
||||
'运行出错'
|
||||
when 2
|
||||
'超时'
|
||||
when 3
|
||||
'内存超出'
|
||||
when 4
|
||||
'输出超出'
|
||||
when 5
|
||||
'禁用函数'
|
||||
when 6
|
||||
'其他错误'
|
||||
when 0
|
||||
'成功'
|
||||
else
|
||||
'未知错误'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -78,7 +78,7 @@
|
|||
|
||||
<li >
|
||||
<label class="label02"> 标准代码: </label>
|
||||
<textarea name="standard_code" class=" w547 h150 mb10 fl" oninput="init_programing_test();" onpropertychange="init_programing_test()"><%= homework.homework_detail_programing.standard_code%></textarea>
|
||||
<textarea name="standard_code" class=" w547 h350 mb10 fl" oninput="init_programing_test();" onpropertychange="init_programing_test()"><%= homework.homework_detail_programing.standard_code || stantard_code%></textarea>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
|
@ -98,7 +98,7 @@
|
|||
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
|
||||
<% if homework_test.result && !homework_test.result.to_s.empty?%>
|
||||
<% if homework_test.result == 0%>
|
||||
<a class="green_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">成功</a>
|
||||
<a class="green_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">正确</a>
|
||||
<% else%>
|
||||
<a class="red_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">错误</a>
|
||||
<% end%>
|
||||
|
@ -114,11 +114,11 @@
|
|||
<div>
|
||||
<li>
|
||||
<label class="label02"> 测试输入: </label>
|
||||
<input type="text" class="fl h26 w190 mb10" name="input[0]" />
|
||||
<input type="text" class="fl h26 w190 mb10" name="input[0]" value="1 2"/>
|
||||
</li>
|
||||
<li >
|
||||
<label class=" fl f14 ml10"> 输出: </label>
|
||||
<input type="text" class="fl h26 w190 mb10" name="output[0]" />
|
||||
<input type="text" class="fl h26 w190 mb10" name="output[0]" value="3"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
|
||||
|
@ -129,6 +129,21 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<input type="hidden" name="error_msg" id="homework_test_error_msg" value="<%= homework.homework_tests.first.error_msg if homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg%>">
|
||||
<table class="border_ce" cellpadding="0" cellspacing="0" id="homework_work_test_show" style="display: <%= homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg && !homework.homework_tests.first.error_msg.empty? ? "block" : "none"%>">
|
||||
<tbody>
|
||||
<tr class="border_t" >
|
||||
<td class="td_end fb c_red w60 td_board_left">
|
||||
错误信息:
|
||||
</td>
|
||||
<td class="td_end wl" id="homework_work_test_desc">
|
||||
<% if homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg %>
|
||||
<%= homework.homework_tests.first.error_msg%>
|
||||
<% end%>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
$("#test_send_<%= @index%>").replaceWith("<a class='<%= @result == 0 ? 'green_btn' : 'red_btn'%> fl ml5 mt1 programing_test' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%></a>");
|
||||
$("#test_result_<%= @index%>").val("<%= @result%>");
|
||||
$("#test_result_<%= @index%>").val("<%= @result%>");
|
||||
<% if @err_msg || @result != 0%>
|
||||
$("#homework_work_test_show").show();
|
||||
$("#homework_work_test_desc").text("<%= escape_javascript(@err_msg || status_to_err_msg(@result))%>");
|
||||
<% if @err_msg%>
|
||||
$("#homework_test_error_msg").val("<%= escape_javascript(@err_msg)%>");
|
||||
<% end%>
|
||||
<% else%>
|
||||
$("#homework_work_test_show").hide();
|
||||
$("#homework_test_error_msg").val("");
|
||||
<% end%>
|
|
@ -44,7 +44,7 @@
|
|||
</p>
|
||||
<div class="cl"></div>
|
||||
<p id="about_project" class="about_project" >
|
||||
<label class="fl"> 关联项目 :</label>
|
||||
<label class="fl"> 选择项目 :</label>
|
||||
<%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "bo02 mb10"} %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
|
@ -54,7 +54,11 @@
|
|||
<%= @homework.homework_type == 2 ? "提交代码" : "作品描述"%>
|
||||
:
|
||||
</label>
|
||||
<%= f.text_area "description", :class => "w620 hwork_txt ", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%>
|
||||
<% if @homework.homework_type == 2%>
|
||||
<%= f.text_area "description", :class => "w620 hwork_txt h350", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => stantard_code%>
|
||||
<% else %>
|
||||
<%= f.text_area "description", :class => "w620 hwork_txt", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
|
||||
</p>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</span>
|
||||
<a href="<%= user_path(rec[:item].user.id) %>" class="c_orange course_name fl mr5" title="<%= rec[:item].user.show_name %>"><%= rec[:item].user.show_name %></a>
|
||||
<span class="fl mr5 c_grey"><%= get_activity_opt(rec[:item],rec[:e]) %></span>
|
||||
<% if( rec[:e].is_public == false || rec[:e].is_public == 0 ) %>
|
||||
<% if(( rec[:e].is_public == false || rec[:e].is_public == 0 )&& !rec[:e].visible?)%>
|
||||
<a href="<%= get_activity_url(rec[:item],rec[:e]) %>"
|
||||
class="c_grey fl users_courses_txt hidepic"
|
||||
title="<% if(rec[:item].activity_container_type=='Project')%><%='该项目是私有的,您无权查看。'%><% else %><%='该课程是私有的,您无权查看。' %><% end %>">
|
||||
|
|
|
@ -226,6 +226,7 @@ a:hover.ping_sub{ background:#14a8b9;}
|
|||
.w430{ width:470px;}
|
||||
.w557{ width:557px;}
|
||||
.w350{ width:350px;}
|
||||
.h350{height: 350px !important;}
|
||||
.w620{ width:480px; height:160px; border:1px solid #CCC;}
|
||||
.bo{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:470px; }
|
||||
.bo02{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:480px; margin-left:2px; color: #999; }
|
||||
|
@ -694,6 +695,9 @@ a.work_list_tit{width:580px; display:block; overflow:hidden; font-size:14px; f
|
|||
.border_l{border-left:1px solid #e4e4e4;}
|
||||
.border_t{ border-top:1px solid #e4e4e4;}
|
||||
.td_end{border-top:1px solid #e4e4e4; height:auto; padding:5px; }
|
||||
.wl{text-align: left;}
|
||||
.vt{vertical-align: top;}
|
||||
.td_board_left{border-right: 1px solid #e4e4e4;}
|
||||
.c_w{ color:#fff;}
|
||||
|
||||
.filename { background: url(../images/pic_file.png) 0 -25px no-repeat;color: #3ca5c6;max-width: 150px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px; white-space: nowrap; text-overflow:ellipsis;}
|
||||
|
@ -709,6 +713,7 @@ a:hover.about_me{ color:#0781b4;}
|
|||
.mb5 li{width:200px;word-wrap: break-word;
|
||||
word-break: normal;
|
||||
}
|
||||
#homework_work_test_show{margin-left: 35px;width: 94%;}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue