匿评参数设置功能完成
This commit is contained in:
parent
9d474d6528
commit
fa13ccfaa8
|
@ -5,9 +5,9 @@ class HomeworkCommonController < ApplicationController
|
|||
layout "base_courses"
|
||||
|
||||
include StudentWorkHelper
|
||||
before_filter :find_course, :only => [:index,:new,:create,:next_step]
|
||||
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy]
|
||||
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment]
|
||||
before_filter :find_course, :only => [:index,:new,:create]
|
||||
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr]
|
||||
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr]
|
||||
before_filter :member_of_course, :only => [:index]
|
||||
|
||||
def index
|
||||
|
@ -23,116 +23,11 @@ class HomeworkCommonController < ApplicationController
|
|||
#新建作业,在个人作业列表创建作业
|
||||
def new
|
||||
render_404
|
||||
# @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
|
||||
end
|
||||
|
||||
#新建作业,在个人作业列表创建作业
|
||||
def create
|
||||
redirect_to user_homeworks_user_path(User.current.id)
|
||||
# if params[:homework_common]
|
||||
# homework = HomeworkCommon.new
|
||||
# homework.name = params[:homework_common][:name]
|
||||
# homework.description = params[:homework_common][:description]
|
||||
# homework.end_time = params[:homework_common][:end_time]
|
||||
# homework.publish_time = params[:homework_common][:publish_time]
|
||||
# homework.homework_type = params[:homework_common][:homework_type]
|
||||
# homework.late_penalty = params[:late_penalty]
|
||||
# homework.user_id = User.current.id
|
||||
# homework.course_id = @course.id
|
||||
#
|
||||
# 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 = params[:language]
|
||||
# homework_detail_programing.standard_code = params[:standard_code]
|
||||
# homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
|
||||
# question = {title:homework.name,content:homework.description}
|
||||
# question[:input] = []
|
||||
# question[:output] = []
|
||||
# if params[:input] && params[:output] && params[:result]
|
||||
# params[:input].each do |k,v|
|
||||
# if params[:output].include? k
|
||||
# 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.homework_tests << homework_test
|
||||
# question[:input] << homework_test.input
|
||||
# question[:output] << homework_test.output
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # uri = URI('http://192.168.80.21:8080/api/questions.json')
|
||||
# # body = question.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
|
||||
# # result = JSON.parse(res.body)
|
||||
# # homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
|
||||
#
|
||||
# homework.homework_detail_programing = homework_detail_programing
|
||||
# else
|
||||
# #匿评作业相关属性
|
||||
# homework_detail_manual = HomeworkDetailManual.new
|
||||
# homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
|
||||
# homework_detail_manual.comment_status = 1
|
||||
# homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||
# homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||
# 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
|
||||
# homework_detail_programing.save if homework_detail_programing
|
||||
# homework_detail_manual.save if homework_detail_manual
|
||||
# respond_to do |format|
|
||||
# format.html {
|
||||
# flash[:notice] = l(:notice_successful_create)
|
||||
# redirect_to homework_common_index_path(:course => @course.id)
|
||||
# }
|
||||
# end
|
||||
# return
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html {
|
||||
# flash[:notice] = l(:notice_failed_create)
|
||||
# redirect_to new_homework_common_path(:course => @course.id)
|
||||
# }
|
||||
# end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -294,6 +189,27 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#启动匿评参数设置
|
||||
def start_evaluation_set
|
||||
|
||||
end
|
||||
|
||||
#设置匿评参数
|
||||
def set_evaluation_attr
|
||||
if @homework_detail_manual
|
||||
unless params[:evaluation_start].to_s == @homework_detail_manual.evaluation_start.to_s
|
||||
@homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||
end
|
||||
|
||||
unless @homework_detail_manual.evaluation_end.to_s == params[:evaluation_end].to_s
|
||||
@homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||
end
|
||||
|
||||
@homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
@homework_detail_manual.save
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
#获取课程
|
||||
def find_course
|
||||
|
|
|
@ -1,44 +1,53 @@
|
|||
<div class="markPopup" id="popbox02">
|
||||
<span class="uploadText">匿评设置</span>
|
||||
<div class="cl"></div>
|
||||
<%= form_for('new_form',:url => {:controller => 'homework_common',:action => 'set_evaluation_attr',:homework => @homework.id},:method => "post",:remote => true) do |f|%>
|
||||
<span class="uploadText">匿评设置</span>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt15">
|
||||
<span class="f14 fontGrey3 fl mt5">开启匿评</span>
|
||||
<div class="calendar_div fl ml10">
|
||||
<input type="text" name="evaluation_start" id="evaluation_start_time" placeholder="开启匿评日期" class="InputBox fl W120 calendar_input" readonly="readonly"/>
|
||||
<%= calendar_for('evaluation_start_time')%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt15">
|
||||
<span class="f14 fontGrey3 fl mt5">开启匿评</span>
|
||||
<div class="calendar_div fl ml10">
|
||||
<input type="text" name="evaluation_start" id="evaluation_start_time" placeholder="开启匿评日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= @homework_detail_manual.evaluation_start%>"/>
|
||||
<%= calendar_for('evaluation_start_time')%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p id="homework_evaluation_start_time" class="c_red"></p>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="cl"></div>
|
||||
<div class="mt15">
|
||||
<span class="f14 fontGrey3 fl mt5">关闭匿评</span>
|
||||
<div class="calendar_div fl ml10">
|
||||
<input type="text" name="evaluation_end" id="evaluation_end_time" placeholder="关闭匿评日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= @homework_detail_manual.evaluation_end%>"/>
|
||||
<%= calendar_for('evaluation_end_time')%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p id="homework_evaluation_end_time" class="c_red"></p>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt15">
|
||||
<span class="f14 fontGrey3 fl mt5">关闭匿评</span>
|
||||
<div class="calendar_div fl ml10">
|
||||
<input type="text" name="evaluation_end" id="evaluation_end_time" placeholder="关闭匿评日期" class="InputBox fl W120 calendar_input" readonly="readonly" />
|
||||
<%= calendar_for('evaluation_end_time')%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="mt15 mb10">
|
||||
<span class="f14 fontGrey3 mr10 fl mt5">匿评人数</span>
|
||||
<input type="text" name="evaluation_num" id="evaluation_num" placeholder="默认匿评人数为3" maxlength="2" class="markInput fl" value="<%= @homework_detail_manual.evaluation_num%>"/>
|
||||
<div class="cl"></div>
|
||||
<p id="evaluation_num_notice" class="c_red"></p>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt15">
|
||||
<span class="f14 fontGrey3 mr10 fl mt5">匿评人数</span>
|
||||
<input type="text" name="" placeholder="默认匿评人数为3" class="markInput fl" />
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="mb20 none">
|
||||
<span class="f14 fontGrey3 mr10">禁用匿评</span>
|
||||
<input type="checkbox" />
|
||||
<span class="f12 c_red ml10">禁用后将无法进行学生互评</span>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mb20">
|
||||
<span class="f14 fontGrey3 mr10">禁用匿评</span>
|
||||
<input type="checkbox" />
|
||||
<span class="f12 c_red ml10">禁用后将无法进行学生互评</span>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div>
|
||||
<div class="courseSendSubmit"><a href="javascript:void(0);" class="sendSourceText">确定</a></div>
|
||||
<div class="courseSendCancel">
|
||||
<a href="javascript:void(0);" class="sendSourceText linkGrey6" onclick="clickCanel();">取消</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<div class="courseSendSubmit">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="submit_set_evaluation_attr('<%= @homework.end_time%>');">确定</a>
|
||||
</div>
|
||||
<div class="courseSendCancel">
|
||||
<a href="javascript:void(0);" class="sendSourceText linkGrey6" onclick="clickCanel();">取消</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
</div>
|
|
@ -0,0 +1 @@
|
|||
clickCanel();
|
|
@ -0,0 +1,6 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_common/set_evalutation_att') %>');
|
||||
showModal('ajax-modal', '350px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed");
|
|
@ -61,7 +61,7 @@
|
|||
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => 0),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0)" class="postOptionLink" onclick="set_evaluation_att();">匿评设置</a>
|
||||
<%= link_to "匿评设置", start_evaluation_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true%>
|
||||
</li>
|
||||
<li>
|
||||
<%= homework_anonymous_comment homework_common %>
|
||||
|
|
|
@ -7,15 +7,6 @@
|
|||
homework_description_editor.html("");
|
||||
$("#homework_editor").toggle();
|
||||
}
|
||||
|
||||
function set_evaluation_att(){
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_common/set_evalutation_att') %>');
|
||||
showModal('ajax-modal', '350px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed");
|
||||
}
|
||||
</script>
|
||||
<div class="homepageRightBanner mb10">
|
||||
<div class="NewsBannerName">作业</div>
|
||||
|
|
|
@ -101,6 +101,8 @@ RedmineApp::Application.routes.draw do
|
|||
get 'start_anonymous_comment'
|
||||
get 'stop_anonymous_comment'
|
||||
get 'alert_anonymous_comment'
|
||||
get 'start_evaluation_set'
|
||||
post 'set_evaluation_attr'
|
||||
end
|
||||
collection do
|
||||
post 'next_step'
|
||||
|
|
|
@ -136,18 +136,36 @@ function search_homework_by_name(url){
|
|||
);
|
||||
}
|
||||
|
||||
//提交匿评参数设置
|
||||
function submit_set_evaluation_attr(end_time){
|
||||
if(!regex_evaluation_start(end_time)){
|
||||
$("#evaluation_start_time").focus();
|
||||
}
|
||||
else if(!regex_evaluation_end()){
|
||||
$("#evaluation_end_time").focus();
|
||||
}
|
||||
else if(!regex_evaluation_num()){
|
||||
$("#evaluation_num").focus();
|
||||
}
|
||||
else{
|
||||
$('#popbox02 form').submit();
|
||||
}
|
||||
}
|
||||
|
||||
//验证匿评开启时间:大于截止时间,或者为空
|
||||
function regex_evaluation_start(){
|
||||
function regex_evaluation_start(end_time){
|
||||
var evaluation_start = $.trim($("#evaluation_start_time").val());
|
||||
if(evaluation_start == ""){
|
||||
return true;
|
||||
$("#homework_evaluation_start_time").text("开启匿评日期不能为空");
|
||||
return false;
|
||||
}
|
||||
var end_time = new Date($.trim($("#homework_end_time").val()));
|
||||
var end_time = new Date(end_time);
|
||||
var evaluation_start_time = new Date(evaluation_start);
|
||||
if(evaluation_start_time > end_time){
|
||||
$("#homework_evaluation_start_time").text("");
|
||||
return true;
|
||||
}else{
|
||||
$("#homework_end_time_span").text("开启匿评日期必须大于截止日期");
|
||||
$("#homework_evaluation_start_time").text("开启匿评日期必须大于截止日期");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -157,17 +175,40 @@ function regex_evaluation_end(){
|
|||
var evaluation_start = $.trim($("#evaluation_start_time").val());
|
||||
var evaluation_end = $.trim($("#evaluation_end_time").val());
|
||||
if(evaluation_end == ""){
|
||||
$("#homework_evaluation_end_time").text("关闭匿评日期不能为空");
|
||||
return true;
|
||||
}else if(evaluation_start == ""){
|
||||
$("#homework_end_time_span").text("开启匿评日期为空时,关闭匿评日期必须为空");
|
||||
return false;
|
||||
}
|
||||
var evaluation_start_time = new Date(evaluation_start);
|
||||
var evaluation_end_time = new Date(evaluation_end);
|
||||
if(evaluation_end_time > evaluation_start_time){
|
||||
$("#homework_evaluation_end_time").text("");
|
||||
return true;
|
||||
}else{
|
||||
$("#homework_end_time_span").text("关闭匿评日期必须大于开启匿评日期");
|
||||
$("#homework_evaluation_end_time").text("关闭匿评日期必须大于开启匿评日期");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//验证匿评数量
|
||||
function regex_evaluation_num(){
|
||||
var evaluation_num = $.trim($("#evaluation_num").val());
|
||||
var regex = /^\d+$/;
|
||||
if(evaluation_num==""){
|
||||
$("#evaluation_num_notice").text("匿评人数不能为空");
|
||||
return false;
|
||||
}
|
||||
else if(regex.test(evaluation_num)){
|
||||
if(evaluation_num > 0){
|
||||
$("#evaluation_num_notice").html("");
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
$("#evaluation_num_notice").text("匿评人数必须为大于0");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$("#evaluation_num_notice").text("匿评人数只能为数字");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ h4{ font-size:14px; color:#3b3b3b;}
|
|||
a.linkGrey6 {color:#484848 !important;}
|
||||
a.linkGrey6:hover {color:#ffffff !important;}
|
||||
.markPopup {width:290px; height:auto; padding:5px 0px 15px 15px; background-color:#ffffff; z-index:1000;}
|
||||
.markInput {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:140px; color:#3d3c3c;}
|
||||
.markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:140px; color:#3d3c3c;}
|
||||
.markPercentage {margin:10px 0; border:1px solid #e6e6e6; width:70px; height:30px; outline:none; font-size:12px; color:#3d3c3c;}
|
||||
|
||||
/* Spacing */
|
||||
|
@ -109,6 +109,7 @@ a.linkGrey6:hover {color:#ffffff !important;}
|
|||
.mb8 {margin-bottom:8px !important;}
|
||||
.mb10{ margin-bottom:10px !important;}
|
||||
.mb12 {margin-bottom:12px !important;}
|
||||
.mb15{margin-bottom: 15px;}
|
||||
.mb20{ margin-bottom:20px;}
|
||||
.pl15{ padding-left:15px;}
|
||||
.w20{ width:20px;}
|
||||
|
|
Loading…
Reference in New Issue