实训作业的重命名功能

pre_develop
cxt 6 years ago
parent 8ad8395bfe
commit 58bf8a9947

@ -12,11 +12,12 @@ class HomeworkCommonController < ApplicationController
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,
:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,
:set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_notice,:publish_homework,:end_notice,:end_homework,
:setting,:set_public,:homework_setting,:update_explanation,:cancel_publish, :homework_code_repeat, :review_detail,:move_to_category]
:setting,:set_public,:homework_setting,:update_explanation,:cancel_publish, :homework_code_repeat, :review_detail,:move_to_category,
:rename_modal, :rename_homework]
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,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,
:open_student_works,:add_to_homework_bank,:publish_notice,:end_notice,:publish_homework,:end_homework,:update_explanation,
:cancel_publish, :move_to_category,:homework_setting]
:cancel_publish, :move_to_category,:homework_setting, :rename_homework, :rename_modal]
# before_filter :member_of_course, :only => [:index,:setting]
@ -275,6 +276,19 @@ class HomeworkCommonController < ApplicationController
@groups = paginateHelper @groups, 5
end
def rename_modal
end
def rename_homework
if params[:name].blank?
@notice = true
else
@homework.update_attributes(:name => params[:name].strip)
redirect_to homework_common_index_path(:course => @course.id, :homework_type => @homework.homework_type)
end
end
def setting
@is_new = params[:is_new].to_i if params[:is_new]
@is_empty = @homework.publish_time.nil?

@ -11,7 +11,8 @@
<div class="fl task-form-100 clearfix" style="box-sizing: border-box; padding-left: 15px;">
<span class="fl mr10 mt3 color-grey3"># <%= get_hw_index(homework_common, @is_teacher, @homework_type) + 1 %></span>
<% homework_curr_status = homework_curr_time(homework_common) %>
<%= link_to homework_common.name.to_s, student_work_index_path(:homework => homework_common.id,:host=> Setting.host_course), :class => "edu-class-inner-list fl color-grey-3"%>
<%= link_to homework_common.name.to_s, student_work_index_path(:homework => homework_common.id,:host=> Setting.host_course),
:id => "homework_name_#{homework_common.id}", :class => "edu-class-inner-list fl color-grey-3"%>
<% unless homework_common.is_public %>
<i id="homework_public_<%= homework_common.id %>" class="fa fa-lock color-grey-c fl mt8 ml15 font-18"></i>
<% end %>
@ -144,6 +145,9 @@
<li>
<%= link_to "设置", student_work_index_path(:homework => homework_common.id, :tab => 4) %>
</li>
<li>
<%= link_to "重命名", rename_modal_homework_common_path(homework_common), :remote => true %>
</li>
<% if homework_common.homework_detail_manual.try(:comment_status) == 0 %>
<li>
<%= link_to '立即发布', publish_notice_homework_common_path(homework_common), :remote => true %>

@ -0,0 +1,30 @@
<div class="task-popup" style="width:460px;">
<div class=" task-popup-title clearfix task-popup-bggrey">
重命名
</div>
<div class="task_popup_con">
<%= form_for "", :url => rename_homework_homework_common_path(@homework), :remote => true, :html => {:id => "rename_shixun_homework_form"} do |f| %>
<div class="df pl20 pr20 mb20 mt10">
<span class="fl pt3">作业名称:</span>
<div class="flex1">
<input type="text" class="input-100-35 greyInput" maxlength="20" value="<%= @homework.name %>" name="name" id="rename_homework_name" placeholder="请输入作业名称"/>
<p class="lineh-20" style="height: 20px;"><span class="color-orange-tip none" id="printNotice">请输入作业名称</span></p>
</div>
</div>
<% end %>
<li class="clearfix mt10 edu-txt-center">
<a href="javascript:void(0);" class="task-btn mr20" onclick="hideModal()">取消</a>
<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="surePutIn();">确定</a>
</li>
</div>
</div>
<script>
function surePutIn(){
if($("#rename_homework_name").val() == "") {
$("#printNotice").removeClass("none");
} else {
$("#rename_shixun_homework_form").submit();
hideModal();
}
}
</script>

@ -0,0 +1,5 @@
<% if @notice %>
notice_box("作业名称不能为空");
<% else %>
$("#homework_name_<%= @homework.id %>").html(<%= @homework.name %>);
<% end %>

@ -0,0 +1,2 @@
var html = '<%= escape_javascript(render :partial => "homework_common/rename_shixun_homework") %>';
pop_box_new(html, 460, 227);

@ -1103,6 +1103,8 @@ RedmineApp::Application.routes.draw do ## oauth相关
match 'move_to_category', :via => [:get,:post]
match 'homework_code_repeat', :via => [:get,:post]
get 'review_detail'
post 'rename_homework'
get 'rename_modal'
end
collection do

Loading…
Cancel
Save