发布和编辑作业时可设置是否启用匿评

This commit is contained in:
cxt 2015-12-25 15:57:30 +08:00
parent b8d8cece02
commit 7f133c860a
4 changed files with 23 additions and 2 deletions

View File

@ -63,6 +63,7 @@ class HomeworkCommonController < ApplicationController
end end
@homework.end_time = params[:homework_common][:end_time] || Time.now @homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id] @homework.course_id = params[:course_id]
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 1
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0

View File

@ -522,6 +522,7 @@ class UsersController < ApplicationController
else else
homework.publish_time = params[:homework_common][:publish_time] homework.publish_time = params[:homework_common][:publish_time]
end end
homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 1
homework.homework_type = params[:homework_type].to_i || 1 homework.homework_type = params[:homework_type].to_i || 1
homework.late_penalty = 10 homework.late_penalty = 10
homework.teacher_priority = 1 homework.teacher_priority = 1

View File

@ -3,6 +3,7 @@
$("#homework_name").val(""); $("#homework_name").val("");
$("#homework_publish_time").val(""); $("#homework_publish_time").val("");
$("#homework_end_time").val(""); $("#homework_end_time").val("");
document.getElementById("anonymous_comment").checked = true;
$("#course_id").val($("#option_select").val()); $("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true})%>"); $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true})%>");
homework_description_editor.html(""); homework_description_editor.html("");

View File

@ -4,11 +4,23 @@
<%= javascript_include_tag 'homework','baiduTemplate' %> <%= javascript_include_tag 'homework','baiduTemplate' %>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
if($.trim($("#anonymous_comment").val()) == 1) {
$("#anonymous_comment").attr('checked',false);
} else {
$("#anonymous_comment").attr('checked',true);
}
$("#BluePopupBox a.BlueCirBtn").click(); $("#BluePopupBox a.BlueCirBtn").click();
<% if edit_mode && homework.is_group_homework? %> <% if edit_mode && homework.is_group_homework? %>
$("#GroupPopupBox a.group_btn").click(); $("#GroupPopupBox a.group_btn").click();
<% end %> <% end %>
}); });
function checked_val() {
if ($("#anonymous_comment").is(":checked")) {
$("#anonymous_comment").val(0);
} else {
$("#anonymous_comment").val(1);
}
}
</script> </script>
<% end %> <% end %>
@ -39,6 +51,12 @@
<%= calendar_for('homework_publish_time')%> <%= calendar_for('homework_publish_time')%>
<% end %> <% end %>
</div> </div>
<% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
<div class="fl f14 ml10" style="margin-top: 4px;">
<input type="checkbox" name="homework_common[anonymous_comment]" checked="checked" value="<%=edit_mode ? homework.anonymous_comment : 0 %>" id="anonymous_comment"/>
<span class="f14 c_grey mr10">启用匿评</span>
</div>
<% end %>
</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>
@ -68,12 +86,12 @@
<div class="mt5"> <div class="mt5">
<% if edit_mode %> <% if edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_homework('edit_homework_common_<%= homework.id%>');">确定</a> <a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="checked_val();submit_homework('edit_homework_common_<%= homework.id%>');">确定</a>
<span class="fr mr10 mt3">或</span> <span class="fr mr10 mt3">或</span>
<%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%> <%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="cancel_edit();">取消</a> <a href="javascript:void(0);" class="fr mr10 mt3" onclick="cancel_edit();">取消</a>
<% else %> <% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_homework('new_homework_common');">发送</a> <a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="checked_val();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> <a href="javascript:void(0);" class=" fr mr10 mt3" onclick="reset_homework();">取消</a>
<% end %> <% end %>