修改普通作业
This commit is contained in:
parent
fce5405c41
commit
93b179c958
|
@ -3,6 +3,7 @@ class HomeworkCommonController < ApplicationController
|
||||||
require 'json'
|
require 'json'
|
||||||
require "base64"
|
require "base64"
|
||||||
layout "base_courses"
|
layout "base_courses"
|
||||||
|
include StudentWorkHelper
|
||||||
before_filter :find_course, :only => [:index,:new,:create,:next_step]
|
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 :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 :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment]
|
||||||
|
@ -18,151 +19,125 @@ class HomeworkCommonController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#新建作业,在个人作业列表创建作业
|
||||||
def new
|
def new
|
||||||
@homework_type = "1"
|
render_404
|
||||||
|
# @homework_type = "1"
|
||||||
@homework = HomeworkCommon.new
|
#
|
||||||
@homework.safe_attributes = params[:homework_common]
|
# @homework = HomeworkCommon.new
|
||||||
@homework.late_penalty = 2
|
# @homework.safe_attributes = params[:homework_common]
|
||||||
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
# @homework.late_penalty = 2
|
||||||
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
# @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||||
|
# @homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||||
if @homework_type == "1"
|
#
|
||||||
#匿评作业相关属性
|
# if @homework_type == "1"
|
||||||
@homework_detail_manual = HomeworkDetailManual.new
|
# #匿评作业相关属性
|
||||||
@homework_detail_manual.ta_proportion = 0.6
|
# @homework_detail_manual = HomeworkDetailManual.new
|
||||||
@homework_detail_manual.absence_penalty = 2
|
# @homework_detail_manual.ta_proportion = 0.6
|
||||||
@homework_detail_manual.evaluation_num = 3
|
# @homework_detail_manual.absence_penalty = 2
|
||||||
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
# @homework_detail_manual.evaluation_num = 3
|
||||||
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
# @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||||
@homework.homework_detail_manual = @homework_detail_manual
|
# @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||||
elsif @homework_type == "2"
|
# @homework.homework_detail_manual = @homework_detail_manual
|
||||||
#编程作业相关属性
|
# elsif @homework_type == "2"
|
||||||
@homework_detail_programing = HomeworkDetailPrograming.new
|
# #编程作业相关属性
|
||||||
@homework.homework_detail_programing = @homework_detail_programing
|
# @homework_detail_programing = HomeworkDetailPrograming.new
|
||||||
end
|
# @homework.homework_detail_programing = @homework_detail_programing
|
||||||
respond_to do |format|
|
# end
|
||||||
format.html
|
# respond_to do |format|
|
||||||
end
|
# format.html
|
||||||
end
|
# end
|
||||||
|
|
||||||
#新建作业下一步
|
|
||||||
def next_step
|
|
||||||
@homework_type = params[:homework_common_type]
|
|
||||||
|
|
||||||
@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
|
end
|
||||||
|
|
||||||
|
#新建作业,在个人作业列表创建作业
|
||||||
def create
|
def create
|
||||||
if params[:homework_common]
|
redirect_to user_homeworks_user_path(User.current.id)
|
||||||
homework = HomeworkCommon.new
|
# if params[:homework_common]
|
||||||
homework.name = params[:homework_common][:name]
|
# homework = HomeworkCommon.new
|
||||||
homework.description = params[:homework_common][:description]
|
# homework.name = params[:homework_common][:name]
|
||||||
homework.end_time = params[:homework_common][:end_time]
|
# homework.description = params[:homework_common][:description]
|
||||||
homework.publish_time = params[:homework_common][:publish_time]
|
# homework.end_time = params[:homework_common][:end_time]
|
||||||
homework.homework_type = params[:homework_common][:homework_type]
|
# homework.publish_time = params[:homework_common][:publish_time]
|
||||||
homework.late_penalty = params[:late_penalty]
|
# homework.homework_type = params[:homework_common][:homework_type]
|
||||||
homework.user_id = User.current.id
|
# homework.late_penalty = params[:late_penalty]
|
||||||
homework.course_id = @course.id
|
# homework.user_id = User.current.id
|
||||||
|
# homework.course_id = @course.id
|
||||||
homework.save_attachments(params[:attachments])
|
#
|
||||||
render_attachment_warning_if_needed(homework)
|
# homework.save_attachments(params[:attachments])
|
||||||
|
# render_attachment_warning_if_needed(homework)
|
||||||
if homework.homework_type == 2
|
#
|
||||||
homework_detail_programing = HomeworkDetailPrograming.new
|
# if homework.homework_type == 2
|
||||||
homework_detail_programing.language = params[:language]
|
# homework_detail_programing = HomeworkDetailPrograming.new
|
||||||
homework_detail_programing.standard_code = params[:standard_code]
|
# homework_detail_programing.language = params[:language]
|
||||||
homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
|
# homework_detail_programing.standard_code = params[:standard_code]
|
||||||
question = {title:homework.name,content:homework.description}
|
# homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
|
||||||
question[:input] = []
|
# question = {title:homework.name,content:homework.description}
|
||||||
question[:output] = []
|
# question[:input] = []
|
||||||
if params[:input] && params[:output] && params[:result]
|
# question[:output] = []
|
||||||
params[:input].each do |k,v|
|
# if params[:input] && params[:output] && params[:result]
|
||||||
if params[:output].include? k
|
# params[:input].each do |k,v|
|
||||||
homework_test = HomeworkTest.new
|
# if params[:output].include? k
|
||||||
homework_test.input = v
|
# homework_test = HomeworkTest.new
|
||||||
homework_test.output = params[:output][k]
|
# homework_test.input = v
|
||||||
homework_test.result = params[:result][k]
|
# homework_test.output = params[:output][k]
|
||||||
homework_test.error_msg = params[:error_msg]
|
# homework_test.result = params[:result][k]
|
||||||
homework.homework_tests << homework_test
|
# homework_test.error_msg = params[:error_msg]
|
||||||
question[:input] << homework_test.input
|
# homework.homework_tests << homework_test
|
||||||
question[:output] << homework_test.output
|
# question[:input] << homework_test.input
|
||||||
end
|
# question[:output] << homework_test.output
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
# uri = URI('http://192.168.80.21:8080/api/questions.json')
|
#
|
||||||
# body = question.to_json
|
# # uri = URI('http://192.168.80.21:8080/api/questions.json')
|
||||||
# res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
# # body = question.to_json
|
||||||
# request = Net::HTTP::Post.new(uri.path)
|
# # res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||||
# request.body = body
|
# # request = Net::HTTP::Post.new(uri.path)
|
||||||
# request["Content-Type"] = "application/json"
|
# # request.body = body
|
||||||
# client.request(request)
|
# # request["Content-Type"] = "application/json"
|
||||||
# end
|
# # client.request(request)
|
||||||
# result = JSON.parse(res.body)
|
# # end
|
||||||
# homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
|
# # 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.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 = HomeworkDetailManual.new
|
||||||
homework_detail_manual.comment_status = 1
|
# homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
|
||||||
homework_detail_manual.evaluation_start = params[:evaluation_start]
|
# homework_detail_manual.comment_status = 1
|
||||||
homework_detail_manual.evaluation_end = params[:evaluation_end]
|
# homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||||
homework_detail_manual.evaluation_num = params[:evaluation_num]
|
# homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||||
homework_detail_manual.absence_penalty = params[:absence_penalty]
|
# homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||||
homework.homework_detail_manual = homework_detail_manual
|
# homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||||
end
|
# homework.homework_detail_manual = homework_detail_manual
|
||||||
|
# end
|
||||||
if homework.save
|
#
|
||||||
homework_detail_programing.save if homework_detail_programing
|
# if homework.save
|
||||||
homework_detail_manual.save if homework_detail_manual
|
# homework_detail_programing.save if homework_detail_programing
|
||||||
respond_to do |format|
|
# homework_detail_manual.save if homework_detail_manual
|
||||||
format.html {
|
# respond_to do |format|
|
||||||
flash[:notice] = l(:notice_successful_create)
|
# format.html {
|
||||||
redirect_to homework_common_index_path(:course => @course.id)
|
# flash[:notice] = l(:notice_successful_create)
|
||||||
}
|
# redirect_to homework_common_index_path(:course => @course.id)
|
||||||
end
|
# }
|
||||||
return
|
# end
|
||||||
end
|
# return
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
respond_to do |format|
|
#
|
||||||
format.html {
|
# respond_to do |format|
|
||||||
flash[:notice] = l(:notice_failed_create)
|
# format.html {
|
||||||
redirect_to new_homework_common_path(:course => @course.id)
|
# flash[:notice] = l(:notice_failed_create)
|
||||||
}
|
# redirect_to new_homework_common_path(:course => @course.id)
|
||||||
end
|
# }
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@user = User.current
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html{render :layout => 'new_base_user'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -284,7 +259,7 @@ class HomeworkCommonController < ApplicationController
|
||||||
def destroy
|
def destroy
|
||||||
if @homework.destroy
|
if @homework.destroy
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {redirect_to homework_common_index_path(:course => @course.id)}
|
format.html {redirect_to user_homeworks_user_path(User.current.id)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -367,6 +367,19 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#修改编程作业
|
||||||
|
def edit_user_commit_homework
|
||||||
|
if User.current.logged?
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
format.html {render :layout => 'new_base_user'}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render_403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def user_commit_homework
|
def user_commit_homework
|
||||||
homework = HomeworkCommon.find(params[:homework])
|
homework = HomeworkCommon.find(params[:homework])
|
||||||
student_work = homework.student_works.where(user_id: User.current.id).first
|
student_work = homework.student_works.where(user_id: User.current.id).first
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
<script type="text/javascript">
|
||||||
<%= error_messages_for 'homework_common' %>
|
function reset_homework(){
|
||||||
|
$("#homework_name").val("");
|
||||||
<div class="project_r_h">
|
$("#homework_end_time").val("");
|
||||||
<h2 class="project_h2">
|
$("#course_id").val($("#option_select").val());
|
||||||
<%= l(:label_course_homework_edit)%>
|
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new })%>");
|
||||||
</h2>
|
homework_description_editor.html("");
|
||||||
|
$("#homework_editor").toggle();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<div class="homepageRightBanner mb10">
|
||||||
|
<div class="NewsBannerName">编辑作业</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hwork_new">
|
|
||||||
<%if @homework.homework_type == 2%>
|
|
||||||
<%= form_for @homework do |f| %>
|
|
||||||
<%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
|
|
||||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('edit_homework_common_<%= @homework.id%>');" >提交</a>
|
|
||||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
|
||||||
<% end%>
|
|
||||||
<% else %>
|
|
||||||
<%= form_for @homework do |f| %>
|
|
||||||
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
|
|
||||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('edit_homework_common_<%= @homework.id%>');" >提交</a>
|
|
||||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
|
||||||
<% end%>
|
|
||||||
<% end%>
|
|
||||||
</div><!--hwork_new end-->
|
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
||||||
|
<!-- 老师身份才可以发布作业 -->
|
||||||
|
<div class="HomeWork mb10">
|
||||||
|
<%= form_for @homework do |f| %>
|
||||||
|
<div id="HomeWorkCon">
|
||||||
|
<%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
|
||||||
|
</div>
|
||||||
|
<% end%>
|
||||||
|
</div><!----HomeWork end-->
|
||||||
|
|
|
@ -11,17 +11,16 @@
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
||||||
<div class=" mt10">
|
<div class=" mt10">
|
||||||
<%= link_to "导入作业", user_import_homeworks_user_path(User.current.id),:class => "BlueCirBtn fl mr10",:remote => true%>
|
<%= link_to("导入作业", user_import_homeworks_user_path(User.current.id),:class => "BlueCirBtn fl mr10",:remote => true) unless edit_mode%>
|
||||||
<div class="calendar_div fl">
|
<div class="calendar_div fl">
|
||||||
<input type="text" name="homework_common[end_time]" id="homework_end_time" placeholder="截止日期" class="InputBox fl W120 calendar_input" readonly="readonly" >
|
<input type="text" name="homework_common[end_time]" id="homework_end_time" placeholder="截止日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >
|
||||||
<%= calendar_for('homework_end_time')%>
|
<%= calendar_for('homework_end_time')%>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<p id="homework_end_time_span" class="c_red mt5"></p>
|
<p id="homework_end_time_span" class="c_red mt5"></p>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div id="homework_editor" style="display: none">
|
<div id="homework_editor" style="display: <%= edit_mode ? 'block':'none'%>">
|
||||||
<div class="mt10">
|
<div class="mt10">
|
||||||
<% if edit_mode %>
|
<% if edit_mode %>
|
||||||
<%= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON %>
|
<%= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON %>
|
||||||
|
@ -40,14 +39,19 @@
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
||||||
<div id="homework_attachments">
|
<div id="homework_attachments">
|
||||||
<%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>true} %>
|
<!-- 编辑作业 && 作业类型为匿评作业 时没有编程选项-->
|
||||||
|
<%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type == 1)} %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="mt5">
|
<div class="mt5">
|
||||||
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_homework('new_homework_common');">发送</a>
|
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_homework('new_homework_common');">发送</a>
|
||||||
<span class="fr mr10 mt3">或</span>
|
<span class="fr mr10 mt3">或</span>
|
||||||
<a href="javascript:void(0);" class=" fr mr10 mt3" onclick="reset_homework();">取消</a>
|
<% if edit_mode %>
|
||||||
|
<%= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
|
||||||
|
<% else %>
|
||||||
|
<a href="javascript:void(0);" class=" fr mr10 mt3" onclick="reset_homework();">取消</a>
|
||||||
|
<% end %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -576,6 +576,7 @@ a.postReplyCancel:hover {color:#ffffff;}
|
||||||
.homepagePostReplyInput2 {width:588px; height:45px; max-width:588px; max-height:45px; border:1px solid #d9d9d9; outline:none; margin:0px auto 10px auto;}
|
.homepagePostReplyInput2 {width:588px; height:45px; max-width:588px; max-height:45px; border:1px solid #d9d9d9; outline:none; margin:0px auto 10px auto;}
|
||||||
.homepagePostReplyContainer {border-bottom:1px solid #e3e3e3; width:680px; margin:0px auto; margin-top:15px; min-height:60px;}
|
.homepagePostReplyContainer {border-bottom:1px solid #e3e3e3; width:680px; margin:0px auto; margin-top:15px; min-height:60px;}
|
||||||
.homepagePostSetting {position:absolute; width:20px; height:20px; right:0px; top:0px;}
|
.homepagePostSetting {position:absolute; width:20px; height:20px; right:0px; top:0px;}
|
||||||
|
.homepagePostSetting ul li:hover ul {display:block;}
|
||||||
.homepagePostSettingIcon {background:url(../images/homepage_icon.png) -93px -5px no-repeat; width:20px; height:20px;}
|
.homepagePostSettingIcon {background:url(../images/homepage_icon.png) -93px -5px no-repeat; width:20px; height:20px;}
|
||||||
.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;}
|
.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;}
|
||||||
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;}
|
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;}
|
||||||
|
|
Loading…
Reference in New Issue