You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/app/views/courses/settings.html.erb

313 lines
16 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%= javascript_include_tag 'jquery.datetimepicker.js' %>
<div class="stud-class-set">
<div class="course-ul-nav mt10 clearfix edu-back-white">
<a href="javascript:void(0)" id="basic_setting" class="active">基本信息</a>
<a href="javascript:void(0)" id="advanced_setting">高级配置</a>
</div>
<div class="news">
<div class="container" style="min-height: 570px;">
<!----------------基本信息模块----------------------->
<div class="for-content-0 for-content">
<%= labelled_form_for @course, :html => {:remote => true} do |f| %>
<div class="mb10 edu-back-white">
<div class="padding30-20">
<p class="color-grey-6 font-16 mb15">课程名称</p>
<div class="clearfix">
<span class="fl mr30 color-orange pt10">*</span>
<div class="pr fl with30">
<input type="text" name="course[course_list]" autocomplete="off" style="width: 100%;" id="edit_course_list" class="input-100-45 greyInput" maxlength="100" value="<%= @course.course_list_name %>" placeholder="例如:数据结构">
<ul class="course_list_ul">
</ul>
</div>
</div>
<div class="clearfix mt30">
<p class="color-grey-6 font-16 mb15">课堂名称</p>
<div class="clearfix">
<span class="fl mr30 color-orange pt10">*</span>
<div class="fl with30">
<input type="text" name="course[name]" autocomplete="off" value="<%= @course.name %>" id="edit_course_name" class="input-100-45 fl greyInput" maxlength="100" placeholder="例如数据结构2016秋季班级" onkeyup="regex_course_name('new');">
</div>
<span class="color-orange fl ml10 mt10 font-12 none" id="edit_course_name_notice"><i class="fa fa-exclamation-circle mr5 font-12"></i>课堂名称不能为空且至少有两个字符</span>
</div>
</div>
</div>
</div>
<div class="mb10 edu-back-white">
<div class="padding30-20">
<div class="clearfix mb30">
<p class="color-grey-6 font-16 mb15">总学时</p>
<input type="text" name="period" id="edit_class_period" value="<%= @course.class_period.to_i > 0 ? @course.class_period.to_i : '' %>" class="winput-90-40 greyInput fl ml40" onkeyup="regex_course_class_period('new');" placeholder="例如30" maxlength="6">
<span class="color-orange fl ml10 font-12 mt8 none" id="edit_course_class_period_notice"><i class="fa fa-exclamation-circle mr5 font-14"></i>请输入正整数</span>
</div>
<div class="clearfix mb30">
<p class="color-grey-6 font-16 mb15">学分</p>
<input type="text" id="edit_course_credit" name="credit" value="<%= @course.credit %>" maxlength="4" onkeyup="regex_course_credit('new');" class="winput-90-40 greyInput fl ml40" placeholder="例如4">
<span class="color-orange fl ml10 font-12 mt8 none" id="edit_course_class_period_notice"><i class="fa fa-exclamation-circle mr5 font-14"></i>请输入正整数</span>
</div>
<div class="clearfix">
<p class="color-grey-6 font-16 mb15">结束时间</p>
<input type="text" id="edit_course_end_date" autocomplete="off" value="<%= @course.end_date %>" class="winput-240-40 greyInput fl ml40" name="end_date" placeholder="请选择结束日期">
<span class="color-orange fl ml10 font-12 mt8 none" id="edit_course_end_date_notice"><i class="fa fa-exclamation-circle mr5 font-14"></i>结束日期必须晚于当前日期</span>
</div>
</div>
</div>
<div class="mb10 edu-back-white">
<div class="padding30-20 clearfix">
<p class="color-grey-6 font-16 mb15">单位显示设置</p>
<input id="course_show_unit" name="course[show_unit]" class="magic-checkbox" type="checkbox" value="1" <%= @course.show_unit ? 'checked' : '' %>>
<label for="course_show_unit" class="ml40">显示单位<span class="color-grey-8">(选中后本课堂的名称前面将增加单位名称)</span></label>
</div>
</div>
<div class="mb10 edu-back-white">
<div class="padding30-20 clearfix">
<p class="color-grey-6 font-16 mb15">公开设置</p>
<input id="course_is_public" name="course[is_public]" class="magic-checkbox" type="checkbox" value="1" <%= @course.is_public == 1 ? 'checked' : '' %>>
<label for="course_is_public" class="ml40">公开课堂<span class="color-grey-8">(选中后本课堂对所有用户可见,否则仅本课堂成员可见)</span></label>
</div>
</div>
<% end %>
</div>
<!--------------------高级配置-------------------->
<div style="display: none" class="edu-back-white padding40-30 for-content-1 for-content" id="upperSetting">
<%= form_for("", :url => update_course_module_course_path(@course), :remote => true, :html => {:multipart => true, :id => 'update_course_module'}) do |f| %>
<p>角色</p>
<div class="clearfix mb10">
<p class="ml50">
<span class="font-16 color-grey-6 width240" style="display: inline-block;">名称</span>
<span class="font-16 color-grey-6 ml40">类型</span>
</p>
<p class="ml50">
<input type="text" name="teacher_list" maxlength="10" placeholder="老师" value="<%= @course.teacher_list %>" class="winput-240-45 mt30 input_name"/>
<span class="font-16 color-grey-6 ml40">老师</span>
</p>
<p class="ml50">
<input type="text" name="student_list" maxlength="10" placeholder="学生" value="<%= @course.student_list %>" class="winput-240-45 mt30 input_name"/>
<span class="font-16 color-grey-6 ml40">学生</span>
</p>
</div>
<p class="color-orange-tip font-16 mb20">请选择此课堂可以使用的模块,支持重命名:</p>
<% activity_module = @course.course_modules.where(:module_type => "activity").first %>
<div class="clearfix mb20">
<p class="fl ml50">
<input type="checkbox" class="undis" value="<%= activity_module.module_type %>" name="message[]">
<span class="font-16 color-grey-6">名称</span><br/>
<input type="text" name="name[]" maxlength="10" placeholder="<%= activity_module.default_module_name %>" value="<%= activity_module.module_name %>" class="winput-240-45 mt30 input_name"/>
<input value="<%= activity_module.module_type %>" name="position[]" type="hidden"/>
</p>
<p class="fl ml40">
<span class="font-16 color-grey-6">类型</span><br/>
<span class="font-16 mt35 fl"><%= activity_module.default_module_name %></span>
</p>
</div>
<% @course.course_modules.where("module_type != 'activity'").reorder("position asc").each_with_index do |course_module, index| %>
<div id="upperTab<%= index %>" class="clearfix mb20">
<div class="upperLeft fl pr">
<div class="fl mr20">
<input type="checkbox" <%= course_module.hidden == 1 ? "" : "checked" %> value="<%= course_module.module_type %>" id="position_<%= course_module.position %>" name="message[]" class="magic-checkbox">
<label for="position_<%= course_module.position %>" style="top: 6px;">&nbsp;</label>
</div>
<input value="<%= course_module.module_type %>" name="position[]" type="hidden"/>
<input type="text" name="name[]" maxlength="10" placeholder="<%= course_module.default_module_name %>" value="<%= course_module.module_name %>" class="winput-240-45 input_name"/>
<span class="ml40 font-16"><%= course_module.default_module_name %></span>
<% if course_module.default_module_name == "讨论" %>
<a href="javascript:void(0)" class="color-blue addChildName" onclick="addChildName();">添加子栏目</a>
<% end %>
<div class="cl"></div>
<% if course_module.default_module_name == "讨论" %>
<div id="course_board_settings">
<%= render :partial => "course_board_settings" %>
</div>
<% end %>
</div>
<% if index > 0 %>
<a href="javascript:void(0)" class="ml20 color-blue mt5 fl" onclick="thisUpMove(<%= index %>)" data-tip-down="上移"><i class="iconfont icon-xiangshangyi"></i></a>
<% end %>
<% if index < 7 %>
<a href="javascript:void(0)" class="ml20 color-blue mt5 fl" onclick="thisDownMove(<%= index %>)" data-tip-down="下移"><i class="iconfont icon-xiangxiayi"></i></a>
<% end %>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
<div class="clearfix mb30 mt30 for-content-0 for-content">
<a href="javascript:void(0);" class="defalutSubmitbtn fl mr20" onclick="submit_edit_course(<%= @course.id%>);">保存</a>
<%= link_to '取消', course_path(@course), :class => 'defalutCancelbtn fl' %>
</div>
<div class="clearfix mb30 mt30 for-content-1 for-content" style="display: none">
<a href="javascript:void(0);" class="defalutSubmitbtn fl mr20" onclick="submit_update_course_module()">保存</a>
<%= link_to '取消', course_path(@course), :class => 'defalutCancelbtn fl' %>
</div>
</div>
<script>
var course_list_name = $("#edit_course_list").val();
$(function () {
<% if @tab == 2 %>
$(".course-ul-nav a").removeClass("active");
$("#advanced_setting").addClass("active");
$(".for-content").hide();
$(".for-content-1").show();
<% end %>
$(".course-ul-nav a").click(function () {
var index = $(this).index();
$(".course-ul-nav a").removeClass("active");
$(this).addClass("active");
$(".for-content").hide();
$(".for-content-" + index).show();
});
$("body").click(function (event) {
$(".course_list_ul").hide();
//event.stopPropagation();
});
$(".course_list_ul").on('click', 'p', function (event) {
$("#edit_course_list").val($(this).html());
if ($("#edit_course_name").val() == "") {
$("#edit_course_name").val($("#edit_course_list").val().trim());
} else {
if ($("#edit_course_name").val().indexOf(course_list_name) == 0) {
$("#edit_course_name").val($("#edit_course_name").val().replace(course_list_name, $("#edit_course_list").val()));
} else {
$("#edit_course_name").val($("#edit_course_list").val() + $("#edit_course_name").val());
}
}
regex_course_name('edit');
$(".course_list_ul").hide();
course_list_name = $(this).html();
event.stopPropagation();
});
//高级配置选择或者取消选择时要去掉checked属性
$(".upperLeft input[type='checkbox']").live("change",function () {
if ($(this).attr("checked") == "checked") {
$(this).attr("checked", true);
} else {
$(this).attr("checked", false);
}
})
});
window.onload = function(){
<% if @tab == 2 %>
$(".addChildName").click();
<% end %>
};
$('#edit_course_end_date').datetimepicker({
allowBlank: true,
lang: 'ch',
format: 'Y-m-d',
formatDate: 'Y-m-d',
timepicker: false,
validateOnBlur: false
});
function addtip() {
console.log("<%= @course.course_groups%>");
<% unless @course.course_groups.empty? %>
<% @course.course_groups.each do |group| %>
if ($(".setting_group_<%= group.id %> span").width() == 115) {
$(".setting_group_<%= group.id %>").attr("data-tip-left", "<%= group.name %>");
}
<% end %>
<% end %>
}
//向下移动
function thisDownMove(index) {
var indexvalue = $("#upperTab" + index).find(".upperLeft").find("input[name='position[]']").val();
$("#upperTab" + index).find(".upperLeft").find("input[name='position[]']").attr("value", indexvalue);
var indexHtml = $("#upperTab" + index).find(".upperLeft").html();
var after = index + 1;
var aftervalue = $("#upperTab" + after).find(".upperLeft").find("input[name='position[]']").val();
$("#upperTab" + after).find(".upperLeft").find("input[name='position[]']").attr("value", aftervalue);
var afterHtml = $("#upperTab" + after).find(".upperLeft").html();
$("#upperTab" + index).find(".upperLeft").html(afterHtml);
$("#upperTab" + after).find(".upperLeft").html(indexHtml);
}
//向上移动
function thisUpMove(index) {
var indexvalue = $("#upperTab" + index).find(".upperLeft").find("input[name='position[]']").val();
$("#upperTab" + index).find(".upperLeft").find("input[name='position[]']").attr("value", indexvalue);
var indexHtml = $("#upperTab" + index).find(".upperLeft").html();
var after = index - 1;
var aftervalue = $("#upperTab" + after).find(".upperLeft").find("input[name='position[]']").val();
$("#upperTab" + after).find(".upperLeft").find("input[name='position[]']").attr("value", aftervalue);
var afterHtml = $("#upperTab" + after).find(".upperLeft").html();
$("#upperTab" + index).find(".upperLeft").html(afterHtml);
$("#upperTab" + after).find(".upperLeft").html(indexHtml);
}
var new_board = true;
//添加子栏目
function addChildName() {
if ($("#add_board_form_subboard").length > 0) {
notice_box("请先保存子栏目");
} else{
var html = '<%= form_tag url_for(:controller => "boards", :action => "create", :course_id => @course.id, :board_id => @board.id), :id=> "add_board_form_subboard", :remote => true do |f| %><p class="clearfix mt15 pr">' +
'<span class="fr mr25 mt9 ml3">子栏目</span>' +
'<input type="text" class="upperleft-s-i winput-190-45 fr mr40" name="name" onblur="new_course_board(this);"/>' +
'<a href="javascript:void(0)" class="del-childName" onclick="deleteUpperleft(this)"><i class="iconfont icon-shanchudiao font-16 color-grey-6"></i></a>' +
'</p><% end %>';
$("#course_board_settings").append(html);
window.scrollTo(0, $('.addChildName').offset().top);
$("#add_board_form_subboard input").on("keydown", function(event){
var code;
if (!event) {
event = window.event; //针对ie浏览器
code = event.keyCode;
}
else {
code = event.keyCode;
}
if(code == 13) {
if(new_board){
new_board = false;
$("#add_board_form_subboard").submit();
}
return false;
}
});
}
}
//删除子栏目
function deleteUpperleft(item) {
$("#add_board_form_subboard").remove();
}
//新建子栏目,输入框失去焦点
function new_course_board(item) {
if ($(item).val().trim() != "") {
$(item).attr("value",$(item).val());
if(new_board){
new_board = false;
$("#add_board_form_subboard").submit();
}
}
}
//编辑子栏目时,输入框失去焦点
function ChildInputblur(board_id, course_id, item) {
if ($(item).val().trim() != "") {
$.ajax({
url: "/boards/" + board_id + "/update_name?course_id=" + course_id + "&name=" + $(item).val(),
type: 'put'
});
}
}
</script>