Merge branch 'szzh' into develop

This commit is contained in:
sw 2015-08-04 16:43:08 +08:00
commit f3e9d6248d
17 changed files with 228 additions and 43 deletions

View File

@ -19,28 +19,28 @@ class HomeworkCommonController < ApplicationController
end
def new
@homework_type = "1"
@homework = HomeworkCommon.new
@homework.safe_attributes = params[:homework_common]
@homework.late_penalty = 0
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
if @homework_type == "1"
#匿评作业相关属性
@homework_detail_manual = HomeworkDetailManual.new
@homework_detail_manual.ta_proportion = 0.6
@homework_detail_manual.absence_penalty = 0
@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')
@homework.homework_detail_manual = @homework_detail_manual
elsif @homework_type == "2"
#编程作业相关属性
@homework_detail_programing = HomeworkDetailPrograming.new
@homework.homework_detail_programing = @homework_detail_programing
end
# @homework_type = "1"
#
# @homework = HomeworkCommon.new
# @homework.safe_attributes = params[:homework_common]
# @homework.late_penalty = 2
# @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
# @homework.publish_time = Time.now.strftime('%Y-%m-%d')
#
# if @homework_type == "1"
# #匿评作业相关属性
# @homework_detail_manual = HomeworkDetailManual.new
# @homework_detail_manual.ta_proportion = 0.6
# @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')
# @homework.homework_detail_manual = @homework_detail_manual
# elsif @homework_type == "2"
# #编程作业相关属性
# @homework_detail_programing = HomeworkDetailPrograming.new
# @homework.homework_detail_programing = @homework_detail_programing
# end
respond_to do |format|
format.html
end
@ -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

View File

@ -2378,4 +2378,26 @@ module ApplicationHelper
end
notice.html_safe
end
def stantard_code
"// 这是一个C语言的样例程序
//
//
// 123
// 347
//
//
// 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

View File

@ -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

View File

@ -78,7 +78,7 @@
<li >
<label class="label02">&nbsp;标准代码:&nbsp;</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>
@ -114,11 +114,11 @@
<div>
<li>
<label class="label02">&nbsp;测试输入:&nbsp;</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">&nbsp;输出:&nbsp;</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>

View File

@ -1,17 +1,27 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= error_messages_for 'homework_common' %>
<div class="project_r_h">
<h2 class="project_h2">
<%= l(:label_course_homework_new)%>
</h2>
</div>
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
<%#= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%>
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
<div class="hwork_new" id="hwork_new">
<%= form_for("new_homework_common",:url => next_step_homework_common_index_path) do |f|%>
<input type="hidden" name="course" value="<%= @course.id%>">
<h3 class="c_blue f16 mb10">
请选择将要发布的作业类型
</h3>
<input type="radio" class="mb10 fl" name="homework_common_type" value="1" id="homework_detail_manual_radio" checked/>
<span class="ml5 fl">
人工评分的作业(支持匿名互评、灵活设置评分比例)
</span>
<div class="cl"></div>
<input type="radio" class="mb20 fl" name="homework_common_type" value="2" id="homework_detail_programing_radio"/>
<span class="ml5 fl">
自动评测的编程作业支持C/C++程序的自动评分)
</span>
<div class="cl"></div>
<a href="javascript:void(0);" class=" orange_btn" onclick="$(this).parent().submit();">
下一步
</a>
<% end%>
</div><!--hwork_new end-->
<div class="cl"></div>

View File

@ -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%>

View File

@ -0,0 +1,44 @@
<div id="Footer">
<div class="footerAboutContainer">
<ul class="footerAbout">
<li class="fl"><a href="javascript:void:(0);" class="f_grey mw20" target="_blank"><%= l(:label_about_us)%></a>|</li>
<li class="fl"><a href="http://forge.trustie.net/projects/2/feedback" class="f_grey mw20" target="_blank"><%= l(:label_contact_us)%></a>|</li>
<li class="fl"><a href="javascript:void:(0);" class="f_grey mw20" target="_blank"><%= l(:label_recruitment_information)%></a>|</li>
<li class="fl"><a href="http://forge.trustie.net/forums/1/memos/1168" class="f_grey mw20" target="_blank"><%= l(:label_surpport_group)%></a>|</li>
<li class="fl"><a href="javascript:void:(0);" class="f_grey mw20" target="_blank"><%= l(:label_forums)%></a>|</li>
<li class="fl"><a href="javascript:void:(0);" class="f_grey ml20" target="_blank"><%= l(:label_language)%></a><select class="languageBox">
<option value="Chinese" selected="selected">中文</option>
<option value="English">英文</option>
</select></li>
</ul>
</div>
<div class="cl"></div>
<ul class="departments">
<li class="fl mr10">
<strong><%= l(:label_hosted_organization)%></strong><a href="http://www.nudt.edu.cn/ArticleShow.asp?ID=47" class=" ml10 f_grey" target="_blank"><%= l(:label_hosted_by)%></a>
</li>
<li class="fl">
<a href="http://www.nudt.edu.cn/ArticleShow.asp?ID=41" class="mr45 f_grey" target="_blank"><%= l(:label_sponsor)%></a>
</li>
<li class="fl mr10">
<strong><%= l(:label_partners)%></strong><a href="http://eecs.pku.edu.cn" class="ml10 f_grey" target="_blank"><%= l(:label_co_organizer_EECS)%></a>
</li>
<li class="fl">
<a href="http://scse.buaa.edu.cn/" class="mr10 f_grey" target="_blank"><%= l(:label_co_organizer_BHU)%></a>
</li>
<li class="fl">
<a href="http://www.iscas.ac.cn/" class="mr10 f_grey" target="_blank"><%= l(:label_co_organizer_CAS)%></a>
</li>
<li class="fl">
<a href="http://www.inforbus.com/" class="f_grey" target="_blank"><%= l(:label_co_organizer_InforS)%></a>
</li>
</ul>
<div class="cl"></div>
<ul class="copyright">
<li class="fl"><%= l(:label_rights_reserved)%></li>
<span class="fl mw15">|</span>
<li class="fl"><a href="http://www.miibeian.gov.cn/" class="fl f_grey" target="_blank"><%= l(:label_license)%></a></li>
</ul>
</div><!--Footer end-->
<div class="cl"></div>

View File

@ -180,7 +180,7 @@
</div><!--Content end-->
<div class="cl"></div>
<%= render :partial => 'layouts/new_footer' %>
<%= render :partial => 'layouts/base_footer_public' %>
<div class="cl"></div>
</div><!--Container end-->
<%= render :partial => 'layouts/new_feedback' %>

View File

@ -173,7 +173,7 @@
</div>
<div style="clear:both;"></div>
<div class="cl"></div>
<%= render :partial => 'layouts/new_footer'%>
<%= render :partial => 'layouts/base_footer_public'%>
<div class="cl"></div>
</div><!--Container end-->
<div id="light" class="white_content02">

View File

@ -271,7 +271,7 @@
</div><!--Content end-->
<div class="cl"></div>
<%= render :partial => 'layouts/new_footer'%>
<%= render :partial => 'layouts/base_footer_public'%>
<div class="cl"></div>
</div><!--Container end-->

View File

@ -81,7 +81,7 @@
:style => "color:#2E8DD7; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
<span class="wmail_txt" style="float:left; margin-right:5px;color:#ACAEB1;"><%= l(:label_course_homework) %></span>
<%= link_to truncate(bid.name.html_safe,length: 30,omission: '...'), student_work_index_path(:homework => bid.id,:token => @token.value),
<%= link_to truncate(bid.name.html_safe,length: 30,omission: '...'), student_work_index_url(:homework => bid.id,:token => @token.value),
:class => 'wmail_info',
:style => "color:#2E8DD7;float:left; font-weight:normal;margin-right:5px; display:block;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
%>

View File

@ -54,7 +54,11 @@
<%= @homework.homework_type == 2 ? "提交代码" : "作品描述"%>
&nbsp;&nbsp;&nbsp;
</label>
<%= f.text_area "description", :class => "w620 hwork_txt ", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => "#include<stdio.h>\nint main(int argc, char** argv)\n{\n\t//在此填写逻辑代码\n\treturn 0;\n"%>
<% 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>

View File

@ -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 %>">

View File

@ -2058,5 +2058,22 @@ zh:
lable_unset: 未设置
label_chose_group: 请选择分班
label_hosted_organization: 主办单位
label_hosted_by: 国防科学技术大学并行与分布处理国家重点实验室
label_sponsor: 计算机科学与技术系
label_partners: 合作单位
label_co_organizer_NUDT: 国防科学技术大学计算机学院
label_co_organizer_EECS: 北京大学
label_co_organizer_BHU: 北京航空航天大学
label_co_organizer_CAS: 中国科学院软件研究所
label_co_organizer_InforS: 中创软件
label_rights_reserved: Copyright 2007~2015, All Rights Riserved
label_about_us: 关于我们
label_contact_us: 联系我们
label_recruitment_information: 招聘信息
label_surpport_group: 帮助中心
label_forums: 论坛反馈
label_language: 语言
label_license: 湘ICP备09019772

View File

@ -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%;}

View File

@ -77,9 +77,12 @@ h4{ font-size:14px; color:#3b3b3b;}
.mr20{ margin-right:20px;}
.mr30{ margin-right:30px;}
.mr40{ margin-right:40px;}
.mr45{margin-right: 45px;}
.mr50{margin-right: 50px;}
.mr55{margin-right: 55px;}
.mr70{margin-right: 70px;}
.mw15{margin:0 15px;}
.mw20{margin:0 20px;}
.mt1{margin-top: 1px;}
.mt3{ margin-top:3px;}
.mt5{ margin-top:5px;}
@ -454,3 +457,13 @@ img,embed{max-width: 100%;}
.is_public_checkbox{margin-left: 15px;margin-right: 10px;}
.author_name{color: #3ca5c6 !important;}
.ke-container-default{max-width: 100%;}
/*底部*/
#Footer{background-color:#ffffff; margin-bottom:10px; padding-bottom:15px; color:#666666;}
.footerAboutContainer {width:auto; border-bottom:1px solid #efefef;}
.footerAbout{ width:585px; margin:0 auto;height:35px; line-height:35px; border-bottom:1px solid #efefef; }
.languageBox {width:55px; height:20px; margin-left:5px; outline:none; color:#666666; border:1px solid #d9d9d9;}
.departments{ width:890px; margin:5px auto 0 auto;height:30px;line-height:30px;}
.copyright{ width:390px; margin:0 auto;height:20px;line-height:20px;}
a.f_grey {color:#666666;}
a.f_grey:hover {color:#000000;}

View File

@ -72,6 +72,9 @@ h4{ font-size:14px; color:#3b3b3b;}
.mr20{ margin-right:20px;}
.mr30{ margin-right:30px;}
.mr40{ margin-right:40px;}
.mr45{margin-right: 45px;}
.mw15{margin:0 15px;}
.mw20{margin:0 20px;}
.mt3{ margin-top:3px;}
.mt5{ margin-top:5px;}
.mt8{ margin-top:8px;}
@ -431,3 +434,14 @@ a.box_close{ display:block; float:right; width:16px; height:16px; background:url
a:hover.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;}
div.ke-statusbar{height:1px; border-top:none;}
/*底部*/
#Footer{background-color:#ffffff; margin-bottom:10px; padding-bottom:15px; color:#666666;}
.footerAboutContainer {width:auto; border-bottom:1px solid #efefef;}
.footerAbout{ width:585px; margin:0 auto;height:35px; line-height:35px; border-bottom:1px solid #efefef; }
.languageBox {width:55px; height:20px; margin-left:5px; outline:none; color:#666666; border:1px solid #d9d9d9;}
.departments{ width:890px; margin:5px auto 0 auto;height:30px;line-height:30px;}
.copyright{ width:390px; margin:0 auto;height:20px;line-height:20px;}
a.f_grey {color:#666666;}
a.f_grey:hover {color:#000000;}