编程作业创建部分值获取

增加、删除编程作业测试结果
样式调整
This commit is contained in:
sw 2015-06-16 17:55:07 +08:00
parent dd8e8e38ac
commit ab88156d2f
7 changed files with 93 additions and 58 deletions

View File

@ -30,6 +30,7 @@ class HomeworkCommonController < ApplicationController
@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
@ -38,6 +39,13 @@ class HomeworkCommonController < ApplicationController
@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
@ -58,6 +66,21 @@ class HomeworkCommonController < ApplicationController
homework.save_attachments(params[:attachments])
render_attachment_warning_if_needed(homework)
if homework.homework_type == 2
homework_detail_programing = HomeworkDetailPrograming.new
homework_detail_programing.language = "C++"
homework_detail_programing.standard_code = params[:standard_code]
if params[:input] && params[:output]
params[:input].each do |k,v|
if params[:output][k]
end
end
end
homework.homework_detail_programing = homework_detail_programing
else
#匿评作业相关属性
homework_detail_manual = HomeworkDetailManual.new
homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
@ -67,6 +90,7 @@ class HomeworkCommonController < ApplicationController
homework_detail_manual.evaluation_num = params[:evaluation_num]
homework_detail_manual.absence_penalty = params[:absence_penalty]
homework.homework_detail_manual = homework_detail_manual
end
if homework.save
respond_to do |format|

View File

@ -1,6 +1,6 @@
<ul class="hwork_new_basic">
<li >
<label class="label02 mb10">
<label class="label02 mb20">
<span class="c_red">*</span>
&nbsp;<%= l(:field_name)%>&nbsp;
</label>
@ -12,10 +12,10 @@
<label class="label02 ">&nbsp;&nbsp;&nbsp;<%= l(:field_quote)%>&nbsp;</label>
<div style="width: 83%;float: left;">
<% if edit_mode %>
<%= f.kindeditor :description,:editor_id => 'homework_description_editor_1',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %>
<%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %>
<% else %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :description,:editor_id => 'homework_description_editor_1' %>
<%= f.kindeditor :description,:editor_id => 'homework_description_editor' %>
<% end %>
</div>
</li>
@ -62,28 +62,29 @@
</li>
<li >
<label class="label02">&nbsp;标准代码:&nbsp;</label>
<textarea name="" class=" w459 h150 mb10 fl" ></textarea>
<textarea name="standard_code" class=" w547 h150 mb10 fl"><%= homework.homework_detail_programing.standard_code%></textarea>
<div class="cl"></div>
</li>
<li >
<% if edit_mode %>
<% else %>
<div>
<li>
<label class="label02">&nbsp;测试输入:&nbsp;</label>
<input type="text" class="fl h26 w196 mb10" />
<input type="text" class="fl h26 w186 mb10" name="input[0]" />
</li>
<li >
<label class=" fl f14 ml10">&nbsp;输出:&nbsp;</label>
<input type="text" class="fl h26 w196 mb10" />
<input type="text" class="fl h26 w186 mb10" name="output[0]" />
</li>
<li>
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
<span class="green_btn fl ml5 mt1">测试</span>
</li>
<li><a class="icon_add ml10 " href="javascript:void(0);" title="添加测试"></a> <span class="green_btn fl ml5">OK&nbsp;!</span></li>
<div class="cl"></div>
<li >
<label class="label02">&nbsp;测试输入:&nbsp;</label>
<input type="text" class="fl h26 w196 mb10" />
</li>
<li >
<label class="fl f14 ml10">&nbsp;输出:&nbsp;</label>
<input type="text" class="fl h26 w196 mb10" />
</li>
<li><a class="icon_add ml10 " href="javascript:void(0);" title="添加测试"></a> <a href="javascript:void(0);" class="green_btn fl ml5 ">测试</a></li>
<div class="cl"></div>
</div>
<% end %>
</ul>
</div>

View File

@ -1,5 +1,3 @@
<%= 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)%>

View File

@ -9,7 +9,6 @@
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= hidden_field_tag "homework_common_tyle","homework_detail_manual"%>
<%= 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"%>
@ -20,7 +19,7 @@
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= hidden_field_tag "homework_common_tyle","homework_detail_programing"%>
<%= hidden_field_tag "homework_common[homework_type]","2"%>
<%= render :partial => 'homework_common/homework_detail_programing_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"%>

View File

@ -415,6 +415,7 @@ function regex_homework_name()
//验证匿评数量
function regex_evaluation_num()
{
if($("#evaluation_num").length == 0){ return true;}
var evaluation_num = $.trim($("#evaluation_num").val());
var regex = /^\d+$/;
if(evaluation_num=="")
@ -502,6 +503,25 @@ function submit_homework(id)
}
}
//增加测试结果
function add_programing_test(obj) {
var now = new Date().getTime();
obj.after("<div><li><label class='label02'>&nbsp;测试输入:&nbsp;</label><input type='text' class='fl h26 w186 mb10' name='input[" + now +"]'' />" +
"</li><li ><label class='fl f14 ml10'>&nbsp;输出:&nbsp;</label><input type='text' class='fl h26 w186 mb10' name='output[" + now +"]' />" +
"</li><li><a class='icon_add ml10' href='javascript:void(0);' title='添加测试' onclick='add_programing_test($(this).parent().parent())'></a>" +
"<a class='icon_remove' href='javascript:void(0);' title='删除测试' onclick='remove_programing_test($(this).parent().parent())'></a>" +
"<span class='green_btn fl ml5 mt1'>测试</span></li><div class='cl'></div></div>");
}
//删除测试结果
function remove_programing_test(obj) {
if(obj.siblings("div").length == 0){
alert("至少需要一组测试");
}
else{
obj.remove();
}
}
function show_window (id1,id2,top,left) {
$('#'+ id1).css('top',top);
$('#'+ id1).css('left',left);

View File

@ -551,19 +551,7 @@ a.wzan_visited{background:url(../images/new_project/public_icon.png) 0px -503px
a.files_tag_icon{ background:#e2f3f9; color:#54aeca; border:1px solid #bbe2ef; padding:1px 10px; float:left; margin-right:10px;margin-bottom:10px; }
a.files_tag_select{ background:#64bdd9; color:#fff; border:1px solid #64bdd9; padding:1px 10px; float:left; margin-right:10px;margin-bottom:10px;}
/* 20150423作业评分*/
.ml14{ margin-left:14px;}
.w548{ width:552px;}
.w547{ width:544px;}
.w196{ width:182px;}
.w459{ width:459px;}
.hwork_new_set{border:1px dashed #CCC; background:#f5f5f5; text-align:center; padding:10px 0; margin-bottom:10px;}
.hwork_new_grey{background:#dbdbdb; width:610px; padding:10px 20px; margin:0 auto; text-align:left; margin-bottom:5px;}
.hwork_new_left{ width:220px; float:left; }
.hwork_new_right{ width:350px; float:left; margin-left:40px;}
.w305{ width:305px;}
.icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;}
a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;}
/* 20150505讨论区*/
.w664{ width:664px;}
@ -599,10 +587,12 @@ a:hover.Reply_pic{border:1px solid #64bdd9;}
/*.talk_new{ border-bottom:1px dashed #d9d9d9; padding-bottom:10px;}*/
#about_newtalk{ display:none;}
/* 20150423作业评分*/
.ml14{ margin-left:14px;}
.w548{ width:552px;}
.w547{ width:544px;}
.w196{ width:196px;}
.w186{ width:186px;}
.w459{ width:459px;}
.hwork_new_set{border:1px dashed #CCC; background:#f5f5f5; text-align:center; padding:10px 0; margin-bottom:10px;}
.hwork_new_grey{background:#dbdbdb; width:610px; padding:10px 20px; margin:0 auto; text-align:left; margin-bottom:5px;}
@ -611,6 +601,8 @@ a:hover.Reply_pic{border:1px solid #64bdd9;}
.w305{ width:305px;}
.icon_add{background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;}
a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;}
.icon_remove{background:url(images/icons.png) 0px -338px no-repeat; width:16px; height:27px; display:block;float:left;}
a:hover.icon_remove{background:url(images/icons.png) -20px -338px no-repeat;}
/* 20150506上传头像*/
.uppicBox{ width:265px; height:265px; background:#f2f2f5; float:left; color:#666; text-align:center;}

View File

@ -77,6 +77,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.mr50{margin-right: 50px;}
.mr55{margin-right: 55px;}
.mr70{margin-right: 70px;}
.mt1{margin-top: 1px;}
.mt3{ margin-top:3px;}
.mt5{ margin-top:5px;}
.mt8{ margin-top:8px;}