基础数据加上“专业”、“课程”,实训的适用专业和课程
This commit is contained in:
parent
fc9b20cc61
commit
7b9c59d6e8
|
@ -4,7 +4,7 @@ class ShixunsController < ApplicationController
|
|||
layout 'base_shixun'
|
||||
before_filter :require_login
|
||||
before_filter :check_authentication
|
||||
before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search ]
|
||||
before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search, :shixun_courses]
|
||||
before_filter :shixun_view_allow, :only => [:show]
|
||||
before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators]
|
||||
#skip_before_filter :verify_authenticity_token, :only => :update_propaedeutics
|
||||
|
@ -288,6 +288,28 @@ class ShixunsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def shixun_courses
|
||||
data = {result:0,options:[]}
|
||||
if params[:major_id] != 0
|
||||
major = Major.find params[:major_id]
|
||||
if major
|
||||
data[:result] = 1
|
||||
major_courses = major.major_courses
|
||||
CourseList.where(:id => major_courses.map(&:course_list_id)).each do |course|
|
||||
option = []
|
||||
option << course.name.to_s
|
||||
option << course.id
|
||||
data[:options] << option
|
||||
end
|
||||
else
|
||||
data[:result] = 0
|
||||
end
|
||||
else
|
||||
data[:result] = 0
|
||||
end
|
||||
render :json =>data
|
||||
end
|
||||
|
||||
def new
|
||||
@shixun = Shixun.new
|
||||
|
||||
|
@ -303,7 +325,14 @@ class ShixunsController < ApplicationController
|
|||
@shixun = Shixun.new(params[:shixun])
|
||||
@shixun.user_id = User.current.id
|
||||
@shixun.language = params[:language]
|
||||
@shixun.major_id = params[:major_id]
|
||||
@shixun.trainee = params[:trainee]
|
||||
@shixun.identifier = identifier
|
||||
if params[:course_id]
|
||||
params[:course_id].each do |course_id|
|
||||
@shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id)
|
||||
end
|
||||
end
|
||||
(params[:shixun][:is_public] == "1" ? @shixun.is_public = true : @shixun.is_public = false)
|
||||
respond_to do |format|
|
||||
if @shixun.save
|
||||
|
@ -359,6 +388,13 @@ class ShixunsController < ApplicationController
|
|||
language = @shixun.language
|
||||
@shixun.attributes = params[:shixun]
|
||||
@shixun.language = params[:language]
|
||||
@shixun.trainee = params[:trainee]
|
||||
if params[:course_id]
|
||||
params[:course_id].each do |course_id|
|
||||
@shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id)
|
||||
end
|
||||
end
|
||||
@shixun.major_id = params[:major_id]
|
||||
params[:shixun][:is_public] == "on" ? @shixun.is_public = 1 : @shixun.is_public = 0
|
||||
if @shixun.save
|
||||
# 实训语言更改了会影响后续的评测,所以需要更新is_updated
|
||||
|
|
|
@ -157,6 +157,28 @@ module ApplicationHelper
|
|||
["Java", "C", "C++", "Python", "MySQL/Java"]
|
||||
end
|
||||
|
||||
# 实训试用专业
|
||||
def shixun_major_option
|
||||
content = []
|
||||
content << ["选择实训适用的专业", 0]
|
||||
content << ["计算机科学与技术", 635]
|
||||
content << ["软件工程", 636]
|
||||
content << ["网络工程", 637]
|
||||
content << ["信息安全", 638]
|
||||
content << ["物联网工程", 639]
|
||||
content << ["信息工程", 622]
|
||||
content << ["通信工程", 619]
|
||||
end
|
||||
|
||||
# 实训面向学员
|
||||
def shixun_trainee
|
||||
content = []
|
||||
content << ["初级学员", 1]
|
||||
content << ["中级学员", 2]
|
||||
content << ["高级学员", 3]
|
||||
content << ["顶级学员", 4]
|
||||
end
|
||||
|
||||
# 班级设置排序中文
|
||||
def switch_to_chinese word
|
||||
case word
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class CourseList < ActiveRecord::Base
|
||||
has_many :major_courses
|
||||
has_many :shixun_major_courses
|
||||
attr_accessible :name
|
||||
end
|
|
@ -2,4 +2,5 @@ class DisciplineCategory < ActiveRecord::Base
|
|||
attr_accessible :major_level, :name
|
||||
|
||||
has_many :first_level_disciplines
|
||||
has_many :majors
|
||||
end
|
||||
|
|
|
@ -2,4 +2,5 @@ class FirstLevelDiscipline < ActiveRecord::Base
|
|||
belongs_to :discipline_category
|
||||
attr_accessible :name
|
||||
has_many :syllabuses
|
||||
has_many :majors
|
||||
end
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class Major < ActiveRecord::Base
|
||||
belongs_to :first_level_discipline
|
||||
belongs_to :discipline_category
|
||||
has_many :major_courses
|
||||
has_many :shixun_major_courses
|
||||
attr_accessible :major_code, :major_level, :name, :first_level_discipline_id, :discipline_category_id
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class MajorCourse < ActiveRecord::Base
|
||||
belongs_to :course_list
|
||||
belongs_to :major
|
||||
attr_accessible :course_list_id, :major_id
|
||||
end
|
|
@ -1,3 +1,4 @@
|
|||
# encoding: utf-8
|
||||
# status 控制实训的状态,0:编辑;1: 申请发布; 2:正式发布; 3:关闭
|
||||
# is_updated 字段为1表示实训的更改可能会影响到后续的评测,0表示更改不会影响后续的评测
|
||||
# 繁忙等级参数:80发布实训失败,返回code为-1;81:实训开启的时候fork失败;83:开启实训的时候,openGameInstance返回非0值;84:jenkins系统异常,post数据不成功
|
||||
|
@ -15,6 +16,9 @@ class Shixun < ActiveRecord::Base
|
|||
has_many :homework_commons_shixunses
|
||||
has_many :challenges, :dependent => :destroy, :order => "challenges.id ASC"
|
||||
has_many :myshixuns
|
||||
belongs_to :major
|
||||
belongs_to :major_course
|
||||
has_many :shixun_major_courses
|
||||
has_and_belongs_to_many :homework_commons
|
||||
|
||||
# 获取特定格式的实训测试用例
|
||||
|
@ -48,6 +52,21 @@ class Shixun < ActiveRecord::Base
|
|||
identifier
|
||||
end
|
||||
|
||||
def shixun_trainee
|
||||
trainee = ""
|
||||
case self.trainee
|
||||
when 1
|
||||
trainee = "初级学员"
|
||||
when 2
|
||||
trainee = "中级学员"
|
||||
when 3
|
||||
trainee = "高级学员"
|
||||
when 4
|
||||
trainee = "顶级学员"
|
||||
end
|
||||
trainee
|
||||
end
|
||||
|
||||
def owner
|
||||
User.find(self.user_id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class ShixunMajorCourse < ActiveRecord::Base
|
||||
belongs_to :shixun
|
||||
belongs_to :major
|
||||
belongs_to :course_list
|
||||
#attr_accessible :course_list
|
||||
end
|
|
@ -13,6 +13,22 @@
|
|||
<%= javascript_include_tag "edu/application",'edu/base_edu','baiduTemplate','jquery.datetimepicker.js','edu/course','attachments' %>
|
||||
<%= call_hook :view_layouts_base_html_head %>
|
||||
<%= yield :header_tags -%>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||
</script>
|
||||
<!--<script type="text/javascript"-->
|
||||
<!--src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">-->
|
||||
<!--</script>-->
|
||||
<!-- 配置 : 在生成的公式图片上去掉Math定义的右键菜单,$$ $$ \( \) \[ \] 中的公式给予显示-->
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
|
||||
showMathMenu: false,
|
||||
showMathMenuMSIE: false,
|
||||
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body onload="prettyPrint();">
|
||||
<div class="newContainer"> <!-- 页面全部内容 -->
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %>
|
||||
<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %>
|
||||
<%= javascript_include_tag '/editormd/editormd.min.js' %>
|
||||
<div class="edu-con-bg01 " style="padding:30px 0;">
|
||||
<div class="ml30 mr30">
|
||||
<div>
|
||||
|
@ -34,34 +34,32 @@
|
|||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class="clearfix mb15">
|
||||
<label class="panel-form-label fl">适用专业 </label>
|
||||
<%= select_tag :major, options_for_select(shixun_language, "Java"), :id => 'shixun[major]', :class => "fl task-form-30 task-height-40"%>
|
||||
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>适用专业 </label>
|
||||
<%= select_tag :major_id, options_for_select(shixun_major_option, 0), :id => 'shixun_major', :class => "fl task-form-30 task-height-40"%>
|
||||
<div class="cl"></div>
|
||||
<p class="-text-danger ml115" id="shixun_major_notice" style="display: none;">请选择适用专业</p>
|
||||
</li>
|
||||
<li class="clearfix mb15 pr">
|
||||
<label class="panel-form-label fl">适用课程 </label>
|
||||
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>适用课程 </label>
|
||||
<div id="shixun[lesson]" class="fl task-form-28 task-height-40 lesson pr" onclick="checkLesson(this);">
|
||||
<input type="text" class="lesson_content" placeholder="选择实训适用的课程">
|
||||
<img src="../images/textarea.png" class="lesson_img"/>
|
||||
<i class="fa fa-sort-desc lesson_img"></i>
|
||||
<ul class="lesson_checkbox" showul="0">
|
||||
<li><input type="checkbox" name="role[]" value="离散数学" id="join_course_role_0" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_0">离散数学</label></li>
|
||||
<li><input type="checkbox" name="role[]" value="数据结构" id="join_course_role_1" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_1">数据结构</label></li>
|
||||
<li><input type="checkbox" name="role[]" value="计算机思维导论" id="join_course_role_2" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_2">计算机思维导论</label></li>
|
||||
<li><input type="checkbox" name="role[]" value="算法分析" id="join_course_role_3" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_3">算法分析</label></li>
|
||||
<li><input type="checkbox" name="role[]" value="数字逻辑" id="join_course_role_4" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_4">数字逻辑</label></li>
|
||||
<li><input type="checkbox" name="role[]" value="自然语言处理" id="join_course_role_5" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_5">自然语言处理</label></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p class="-text-danger ml115" id="shixun_major_course_notice" style="display: none;">请选择适用课程</p>
|
||||
</li>
|
||||
<li class="clearfix mb15">
|
||||
<label class="panel-form-label fl">面向学员 </label>
|
||||
<%= select_tag :student, options_for_select(shixun_language, "Java"), :id => 'shixun[student]', :class => "fl task-form-10 task-height-40" %>
|
||||
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>面向学员 </label>
|
||||
<%= select_tag :trainee, options_for_select(shixun_trainee, 0), :id => 'shixun_trainee', :class => "fl task-form-10 task-height-40" %>
|
||||
</li>
|
||||
<li class="clearfix mb15">
|
||||
<label class="panel-form-label fl">语言 </label>
|
||||
<%= select_tag :language, options_for_select(shixun_language, "Java"), :id => 'shixun[language]', :class => "fl task-form-10 task-height-40" %>
|
||||
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>技术平台 </label>
|
||||
<%= select_tag :language, options_for_select(shixun_language, "Java"), :id => 'shixun_language', :class => "fl task-form-10 task-height-40" %>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-blue fr" onclick="submit_new_project();" >提交</a>
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-blue fr" onclick="submit_new_project();">提交</a>
|
||||
<%= link_to "取消",user_activities_path(User.current.id),:class => "task-btn fr mr10" %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
@ -69,15 +67,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.task-form-28{width: 28%;padding:0px 10px}
|
||||
.lesson{border:1px solid #EEEEEE;line-height:40px;}
|
||||
.lesson_img{position: absolute;right: 5px;top:15px;}
|
||||
.lesson_checkbox{display: none;position: absolute;top:40px;left: -1px;width: 100%;border:1px solid #eeeeee;background: #FFFFFF;padding-bottom: 5px;height: 150px;}
|
||||
.lesson_checkbox li{height:20px;padding:5px 10px;clear:both;line-height:28px;}
|
||||
.lesson_checkbox li input{float: left;margin: 3px 5px 0px 0px;}
|
||||
.lesson_content{height: 100%;border:none;width:96%;outline: none;}
|
||||
</style>
|
||||
<script>
|
||||
/* ------------------------------- 简介md ------------------------------*/
|
||||
var shixun_editormd = editormd("shixun_introduction", {
|
||||
|
@ -136,113 +125,106 @@
|
|||
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url
|
||||
});
|
||||
//////////////////////////////////////////////////////////////
|
||||
//新建项目
|
||||
//验证项目名称
|
||||
function regex_project_name()
|
||||
{
|
||||
var name = $.trim($("#shixun_name").val());
|
||||
if(name.length == 0)
|
||||
{
|
||||
$("#project_name_notice").show();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#project_name_notice").hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//提交新建项目
|
||||
function submit_new_project()
|
||||
{
|
||||
if(regex_project_name())
|
||||
if(regex_shixun_name() && regex_major() && regex_major_course())
|
||||
{
|
||||
$("#new_shixun").submit();
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function(){
|
||||
$("#shixun_introduction [type=\"latex\"]").bind("click", function(){
|
||||
shixun_editormd.cm.replaceSelection("```latex");
|
||||
shixun_editormd.cm.replaceSelection("\n");
|
||||
shixun_editormd.cm.replaceSelection("\n");
|
||||
shixun_editormd.cm.replaceSelection("```");
|
||||
var __Cursor = shixun_editormd.cm.getDoc().getCursor();
|
||||
shixun_editormd.cm.setCursor(__Cursor.line-1, 0);
|
||||
});
|
||||
|
||||
function checkLesson(item){
|
||||
var showul=$(item).find("ul").attr("showul");
|
||||
if(showul=="0"){
|
||||
$(item).find("ul").show();
|
||||
$(item).find("ul").attr("showul","1");
|
||||
if($(item).find("ul input").length>5){
|
||||
$(item).find("ul").css("overflow-y","scroll");
|
||||
}
|
||||
event.stopPropagation();
|
||||
}else{
|
||||
$(item).find("ul").hide();
|
||||
$(item).find("ul").attr("showul","0");
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
$("#shixun_propaedeutics [type=\"latex\"]").bind("click", function(){
|
||||
shixun_propaedeutics.cm.replaceSelection("```latex");
|
||||
shixun_propaedeutics.cm.replaceSelection("\n");
|
||||
shixun_propaedeutics.cm.replaceSelection("\n");
|
||||
shixun_propaedeutics.cm.replaceSelection("```");
|
||||
var __Cursor = shixun_propaedeutics.cm.getDoc().getCursor();
|
||||
shixun_propaedeutics.cm.setCursor(__Cursor.line-1, 0);
|
||||
});
|
||||
|
||||
$("#shixun_introduction [type=\"inline\"]").bind("click", function(){
|
||||
shixun_editormd.cm.replaceSelection("$$$$");
|
||||
var __Cursor = shixun_editormd.cm.getDoc().getCursor();
|
||||
shixun_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
|
||||
shixun_editormd.cm.focus();
|
||||
});
|
||||
|
||||
$("#shixun_propaedeutics [type=\"inline\"]").bind("click", function(){
|
||||
shixun_propaedeutics.cm.replaceSelection("$$$$");
|
||||
var __Cursor = shixun_propaedeutics.cm.getDoc().getCursor();
|
||||
shixun_propaedeutics.cm.setCursor(__Cursor.line, __Cursor.ch-2);
|
||||
shixun_propaedeutics.cm.focus();
|
||||
});
|
||||
$("[type=\"inline\"]").attr("title", "行内公式");
|
||||
$("[type=\"latex\"]").attr("title", "多行公式");
|
||||
|
||||
};
|
||||
$(function(){
|
||||
//多选适用课程
|
||||
$("body").click(function(event){
|
||||
$(".lesson_checkbox").hide();
|
||||
$(".lesson_checkbox").attr("showul","0");
|
||||
event.stopPropagation();
|
||||
})
|
||||
$(".lesson_checkbox label").click(function(event){
|
||||
});
|
||||
$(".lesson_checkbox").on('click', 'label', function(event) {
|
||||
event.stopPropagation();
|
||||
})
|
||||
$(".lesson_checkbox input").click(function(event){
|
||||
if($(this).is(':checked')){
|
||||
if($(".lesson_content").val()==""){
|
||||
$(".lesson_content").val($(this).attr("value"));
|
||||
}else{
|
||||
$(".lesson_content").val($(".lesson_content").val()+","+$(this).attr("value"));
|
||||
});
|
||||
$(".lesson_checkbox").on('click', 'input',function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
if ($(".lesson_content").val() == "") {
|
||||
$(".lesson_content").val($(this).attr("data-val"));
|
||||
} else {
|
||||
$(".lesson_content").val($(".lesson_content").val() + "," + $(this).attr("data-val"));
|
||||
}
|
||||
event.stopPropagation();
|
||||
}else{
|
||||
var valueCon=$(".lesson_content").val().split(",");
|
||||
var list=[];
|
||||
for(var i=0;i<valueCon.length;i++){
|
||||
if(valueCon[i]!=$(this).attr("value")){
|
||||
} else {
|
||||
var valueCon = $(".lesson_content").val().split(",");
|
||||
var list = [];
|
||||
for (var i = 0; i < valueCon.length; i++) {
|
||||
if (valueCon[i] != $(this).attr("data-val")) {
|
||||
list.push(valueCon[i]);
|
||||
}
|
||||
}
|
||||
$(".lesson_content").val(list);
|
||||
event.stopPropagation();
|
||||
}
|
||||
})
|
||||
})
|
||||
window.onload = function(){
|
||||
$("#shixun_introduction [type=\"latex\"]").bind("click", function(){
|
||||
shixun_editormd.cm.replaceSelection("```latex");
|
||||
shixun_editormd.cm.replaceSelection("\n");
|
||||
shixun_editormd.cm.replaceSelection("\n");
|
||||
shixun_editormd.cm.replaceSelection("```");
|
||||
var __Cursor = shixun_editormd.cm.getDoc().getCursor();
|
||||
shixun_editormd.cm.setCursor(__Cursor.line-1, 0);
|
||||
});
|
||||
|
||||
$("#shixun_propaedeutics [type=\"latex\"]").bind("click", function(){
|
||||
shixun_propaedeutics.cm.replaceSelection("```latex");
|
||||
shixun_propaedeutics.cm.replaceSelection("\n");
|
||||
shixun_propaedeutics.cm.replaceSelection("\n");
|
||||
shixun_propaedeutics.cm.replaceSelection("```");
|
||||
var __Cursor = shixun_propaedeutics.cm.getDoc().getCursor();
|
||||
shixun_propaedeutics.cm.setCursor(__Cursor.line-1, 0);
|
||||
});
|
||||
|
||||
$("#shixun_introduction [type=\"inline\"]").bind("click", function(){
|
||||
shixun_editormd.cm.replaceSelection("$$$$");
|
||||
var __Cursor = shixun_editormd.cm.getDoc().getCursor();
|
||||
shixun_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
|
||||
shixun_editormd.cm.focus();
|
||||
});
|
||||
|
||||
$("#shixun_propaedeutics [type=\"inline\"]").bind("click", function(){
|
||||
shixun_propaedeutics.cm.replaceSelection("$$$$");
|
||||
var __Cursor = shixun_propaedeutics.cm.getDoc().getCursor();
|
||||
shixun_propaedeutics.cm.setCursor(__Cursor.line, __Cursor.ch-2);
|
||||
shixun_propaedeutics.cm.focus();
|
||||
});
|
||||
$("[type=\"inline\"]").attr("title", "行内公式");
|
||||
$("[type=\"latex\"]").attr("title", "多行公式");
|
||||
|
||||
}
|
||||
});
|
||||
$("#shixun_major").on("change", function(){
|
||||
if($("#shixun_major").val() != "0"){
|
||||
$.ajax({
|
||||
url: '/shixuns/shixun_courses',
|
||||
type: 'get',
|
||||
data: {major_id:$("#shixun_major").val()},
|
||||
success: function(data){
|
||||
if (data.result == 1){
|
||||
$(".lesson_content").val("");
|
||||
$(".lesson_checkbox").html("");
|
||||
for(var i=0; i<data.options.length; i++){
|
||||
$(".lesson_checkbox").append('<li><input type="checkbox" name="course_id[]" data-val="'+ data.options[i][0] +'" value="'+ data.options[i][1] +'" id="join_course_role_'+ i +'" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_'+ i +'">'+ data.options[i][0] +'</label></li>');
|
||||
}
|
||||
$("#shixun_major_notice").hide();
|
||||
}
|
||||
else{
|
||||
$(".lesson_content").val("");
|
||||
$(".lesson_checkbox").html("");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else{
|
||||
$(".lesson_content").val("");
|
||||
$(".lesson_checkbox").html("");
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -18,8 +18,29 @@
|
|||
<textarea name="shixun[propaedeutics]"><%#= @shixun.propaedeutics %></textarea>
|
||||
</div>
|
||||
</li>-->
|
||||
<li class="clearfix mb15">
|
||||
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>适用专业 </label>
|
||||
<%= select_tag :major_id, options_for_select(shixun_major_option, @shixun.major_id ? @shixun.major_id : 0), :id => 'shixun_major', :class => "fl task-form-30 task-height-40"%>
|
||||
<div class="cl"></div>
|
||||
<p class="-text-danger ml95" id="shixun_major_notice" style="display: none;">请选择适用专业</p>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>适用课程 </label>
|
||||
<div id="shixun[lesson]" class="fl task-form-28 task-height-40 lesson pr" onclick="checkLesson(this);">
|
||||
<input type="text" class="lesson_content" placeholder="选择实训适用的课程">
|
||||
<i class="fa fa-sort-desc lesson_img"></i>
|
||||
<ul class="lesson_checkbox" showul="0">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p class="-text-danger ml95" id="shixun_major_course_notice" style="display: none;">请选择适用课程</p>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">语言:</label>
|
||||
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>面向学员 </label>
|
||||
<%= select_tag :trainee, options_for_select(shixun_trainee, @shixun.trainee), :id => 'shixun_trainee', :class => "fl task-form-10 task-height-40" %>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>技术平台:</label>
|
||||
<%= select_tag :language, options_for_select(shixun_language, @shixun.language), :id => 'shixun[language]', :class => "fl task-form-10 task-height-40" %>
|
||||
</li>
|
||||
<!-- <li class="clearfix">
|
||||
|
@ -28,32 +49,89 @@
|
|||
<span class="fl" style="line-height: 40px;">(选中为公开实训,不选中为私有实训;私有实训仅自己可见。)</span>
|
||||
</li>-->
|
||||
<li class="clearfix">
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-green fr " onclick="submit_edit_shixun(<%= @shixun.id %>);" >保存</a>
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-green fr " onclick="submit_edit_shixun(<%= @shixun.id %>);">保存</a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function regex_shixun_name() {
|
||||
var name = $.trim($("#shixun_name").val());
|
||||
if (name.length == 0) {
|
||||
$("#project_name_notice").show();
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$("#project_name_notice").hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//配置-信息提交
|
||||
function submit_edit_shixun(id) {
|
||||
if (regex_shixun_name()) {
|
||||
if (regex_shixun_name() && regex_major() && regex_major_course()) {
|
||||
$("#edit_shixun_" + id).submit();
|
||||
}
|
||||
}
|
||||
|
||||
$(function(){
|
||||
<% if @shixun.major_id %>
|
||||
<% major_courses = @shixun.major.major_courses %>
|
||||
<% CourseList.where(:id => major_courses.map(&:course_list_id)).each_with_index do |course, index| %>
|
||||
$(".lesson_checkbox").append('<li><input type="checkbox" name="course_id[]" data-val="<%= course.name %>" value="<%= course.id %>" id="join_course_role_<%= index %>" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_<%= index %>"><%= course.name %></label></li>');
|
||||
<% end %>
|
||||
<% @shixun.shixun_major_courses.each_with_index do |shixun_course, index| %>
|
||||
$(".lesson_content").val($(".lesson_content").val() + "<%= index == 0 ? '' : ',' %>" + "<%= shixun_course.course_list.name %>");
|
||||
$("input[value='<%= shixun_course.course_list_id %>']").attr("checked", true);
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
//多选适用课程
|
||||
$("body").click(function(event){
|
||||
$(".lesson_checkbox").hide();
|
||||
$(".lesson_checkbox").attr("showul","0");
|
||||
event.stopPropagation();
|
||||
});
|
||||
$(".lesson_checkbox").on('click', 'label', function(event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
$(".lesson_checkbox").on('click', 'input',function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
if ($(".lesson_content").val() == "") {
|
||||
$(".lesson_content").val($(this).attr("data-val"));
|
||||
} else {
|
||||
$(".lesson_content").val($(".lesson_content").val() + "," + $(this).attr("data-val"));
|
||||
}
|
||||
event.stopPropagation();
|
||||
} else {
|
||||
var valueCon = $(".lesson_content").val().split(",");
|
||||
var list = [];
|
||||
for (var i = 0; i < valueCon.length; i++) {
|
||||
if (valueCon[i] != $(this).attr("data-val")) {
|
||||
list.push(valueCon[i]);
|
||||
}
|
||||
}
|
||||
$(".lesson_content").val(list);
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
});
|
||||
$("#shixun_major").on("change", function(){
|
||||
if($("#shixun_major").val() != "0"){
|
||||
$.ajax({
|
||||
url: '/shixuns/shixun_courses',
|
||||
type: 'get',
|
||||
data: {major_id:$("#shixun_major").val()},
|
||||
success: function(data){
|
||||
if (data.result == 1){
|
||||
$(".lesson_content").val("");
|
||||
$(".lesson_checkbox").html("");
|
||||
for(var i=0; i<data.options.length; i++){
|
||||
$(".lesson_checkbox").append('<li><input type="checkbox" name="course_id[]" data-val="'+ data.options[i][0] +'" value="'+ data.options[i][1] +'" id="join_course_role_'+ i +'" class="ml-3 mr5 magic-checkbox"><label for="join_course_role_'+ i +'">'+ data.options[i][0] +'</label></li>');
|
||||
}
|
||||
$("#shixun_major_notice").hide();
|
||||
}
|
||||
else{
|
||||
$(".lesson_content").val("");
|
||||
$(".lesson_checkbox").html("");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else{
|
||||
$(".lesson_content").val("");
|
||||
$(".lesson_checkbox").html("");
|
||||
}
|
||||
});
|
||||
|
||||
/* ----------------------------------- 预备知识Md ----------------------------------------- */
|
||||
/* var p_editormd = editormd("setting_propaedeutics", {
|
||||
width : "89.7%",
|
||||
|
|
|
@ -22,7 +22,25 @@
|
|||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">语言:</label>
|
||||
<label class="panel-form-label fl">适用专业:</label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690">
|
||||
<%= @shixun.major ? @shixun.major.try(:name) : "" %>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">适用课程:</label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690">
|
||||
<%= @shixun.shixun_major_courses.blank? ? "" : CourseList.where(:id => @shixun.shixun_major_courses.map(&:course_list_id)).map(&:name).join(",") %>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">面向学员:</label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690">
|
||||
<%= @shixun.shixun_trainee %>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">技术平台:</label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690">
|
||||
<%= @shixun.language %>
|
||||
</div>
|
||||
|
|
|
@ -58,6 +58,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'operation'
|
||||
end
|
||||
collection do
|
||||
get 'shixun_courses'
|
||||
match 'search', :via => [:get, :post]
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class CreateMajors < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :majors do |t|
|
||||
t.string :major_code
|
||||
t.string :name
|
||||
t.references :first_level_discipline
|
||||
t.references :discipline_category
|
||||
t.integer :major_level
|
||||
end
|
||||
add_index :majors, :first_level_discipline_id
|
||||
add_index :majors, :discipline_category_id
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
class MigrateMajor < ActiveRecord::Migration
|
||||
def up
|
||||
count = Major.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 .. count do
|
||||
Major.page(i).per(30).each do |major|
|
||||
dis = major.first_level_discipline.discipline_category
|
||||
major.update_attributes(:discipline_category_id => dis.id, :major_level => dis.major_level) if dis
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
class CreateCourseLists < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :course_lists do |t|
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class CreateMajorCourses < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :major_courses do |t|
|
||||
t.references :course_list
|
||||
t.references :major
|
||||
|
||||
end
|
||||
add_index :major_courses, :course_list_id
|
||||
add_index :major_courses, :major_id
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class AddColumnsToShixuns < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :shixuns, :trainee, :integer
|
||||
add_column :shixuns, :major_id, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
class CreateShixunMajorCourses < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :shixun_major_courses do |t|
|
||||
t.references :shixun
|
||||
t.references :course_list
|
||||
t.references :major
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :shixun_major_courses, :shixun_id
|
||||
add_index :shixun_major_courses, :major_id
|
||||
end
|
||||
end
|
|
@ -945,3 +945,63 @@ function submit_send_res_to_course(){
|
|||
$("#search_course_notice_h").html("请先选择一个班级").show();
|
||||
}
|
||||
}
|
||||
|
||||
//验证实训名称
|
||||
function regex_shixun_name()
|
||||
{
|
||||
var name = $.trim($("#shixun_name").val());
|
||||
if(name.length == 0)
|
||||
{
|
||||
$("#project_name_notice").show();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#project_name_notice").hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function regex_major()
|
||||
{
|
||||
if($("#shixun_major").val() == "0")
|
||||
{
|
||||
$("#shixun_major_notice").show();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#shixun_major_notice").hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function regex_major_course()
|
||||
{
|
||||
if($("input[name='course_id[]']:checked").length == 0){
|
||||
$("#shixun_major_course_notice").html("请先选择适用的课程").show();
|
||||
return false;
|
||||
} else{
|
||||
$("#shixun_major_course_notice").hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function checkLesson(item){
|
||||
if($("#shixun_major").val() == "0") {
|
||||
$("#shixun_major_course_notice").html("请先选择适用专业").show();
|
||||
} else{
|
||||
var showul=$(item).find("ul").attr("showul");
|
||||
if(showul=="0"){
|
||||
$(item).find("ul").show();
|
||||
$(item).find("ul").attr("showul","1");
|
||||
if($(item).find("ul input").length>5){
|
||||
$(item).find("ul").css("overflow-y","scroll");
|
||||
}
|
||||
event.stopPropagation();
|
||||
}else{
|
||||
$(item).find("ul").hide();
|
||||
$(item).find("ul").attr("showul","0");
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -71,7 +71,7 @@ a:hover.link-color-grey03{color:#3498db!important;}
|
|||
/*通用内外边距*/
|
||||
.mt-10{ margin-top:-10px;}.mt3{ margin-top:3px;}.mt5{ margin-top:5px;}.mt6{ margin-top:6px;}.mt7{ margin-top:7px;}.mt8{ margin-top:8px;}.mt10{ margin-top:10px;}.mt12{ margin-top:12px;}.mt15{ margin-top:15px;}.mt20{ margin-top:20px;}.mt25{ margin-top:25px;}.mt30{ margin-top:30px;}.mt50{ margin-top:50px;}
|
||||
.mb5{ margin-bottom: 5px;}.mb10{ margin-bottom: 10px;}.mb15{ margin-bottom: 15px;}.mb20{ margin-bottom: 20px;}.mb25{ margin-bottom: 25px;}.mb30{ margin-bottom: 30px;}.mb50{ margin-bottom: 50px;}
|
||||
.ml-3{ margin-left: -3px;}.ml5{ margin-left: 5px;}.ml6{ margin-left: 6px;}.ml10{ margin-left: 10px;}.ml15{ margin-left: 15px;}.ml20{ margin-left: 20px;}.ml25{ margin-left: 25px;}.ml30{ margin-left: 30px;}.ml35{ margin-left:35px;}.ml40{margin-left:40px;}.ml50{ margin-left: 50px;}.ml75{ margin-left: 75px;}.ml115{margin-left: 115px}.ml230{ margin-left: 230px;}
|
||||
.ml-3{ margin-left: -3px;}.ml5{ margin-left: 5px;}.ml6{ margin-left: 6px;}.ml10{ margin-left: 10px;}.ml15{ margin-left: 15px;}.ml20{ margin-left: 20px;}.ml25{ margin-left: 25px;}.ml30{ margin-left: 30px;}.ml35{ margin-left:35px;}.ml40{margin-left:40px;}.ml50{ margin-left: 50px;}.ml75{ margin-left: 75px;}.ml95{ margin-left: 95px;}.ml115{margin-left: 115px}.ml230{ margin-left: 230px;}
|
||||
.mr5{ margin-right: 5px;}.mr10{ margin-right: 10px;}.mr15{ margin-right: 15px;}.mr18{ margin-right: 18px;}.mr20{ margin-right: 20px;}.mr25{ margin-right: 25px;}.mr30{ margin-right:30px;}.mr50{ margin-right: 50px;}.mr60{ margin-right:60px;}
|
||||
.pt5{ padding-top:5px;}.pt10{ padding-top:10px;}.pt15{ padding-top:15px;}.pt20{ padding-top:20px;}
|
||||
.pb5{ padding-bottom:5px;}.pb10{ padding-bottom:10px;}.pb15{ padding-bottom:15px;}.pb20{ padding-bottom:20px;}
|
||||
|
|
|
@ -279,3 +279,11 @@ a.shixun-task-ban-btn{background-color: #c2c4c6;display: inline-block;font-weigh
|
|||
.task-width33{ width:33.3%;}
|
||||
|
||||
.read_only{ -moz-user-select: none; -webkit-user-select: none; }
|
||||
|
||||
.task-form-28{width: 28%;padding:0px 10px}
|
||||
.lesson{border:1px solid #EEEEEE;line-height:40px;}
|
||||
.lesson_img{position: absolute;right: 5px;top:10px;}
|
||||
.lesson_checkbox{display: none;position: absolute;top:40px;left: -1px;width: 100%;border:1px solid #eeeeee;background: #FFFFFF;padding-bottom: 5px;height: 150px;}
|
||||
.lesson_checkbox li{height:20px;padding:5px 10px;clear:both;line-height:28px;margin-bottom: 0;}
|
||||
.lesson_checkbox li input{float: left;margin: 3px 5px 0px 0px;}
|
||||
.lesson_content{height: 100%;border:none !important;width:96%;outline: none;padding-left: 0;}
|
|
@ -0,0 +1,6 @@
|
|||
FactoryGirl.define do
|
||||
factory :course_list do
|
||||
name "MyString"
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :major_course do
|
||||
course_list nil
|
||||
major nil
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
FactoryGirl.define do
|
||||
factory :major do
|
||||
major_code "MyString"
|
||||
name "MyString"
|
||||
first_level_discipline nil
|
||||
discipline_category nil
|
||||
major_level 1
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
FactoryGirl.define do
|
||||
factory :shixun_major_course do
|
||||
shixun nil
|
||||
course_list ""
|
||||
major nil
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CourseList, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe MajorCourse, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Major, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ShixunMajorCourse, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue