新建课程和课程配置页面增加结束学期
This commit is contained in:
parent
16a6278b29
commit
ec631691e3
|
@ -196,6 +196,8 @@ class CoursesService
|
|||
@course.tea_id = current_user.id
|
||||
@course.term = params[:term]
|
||||
@course.time = params[:time]
|
||||
@course.end_term = params[:end_term]
|
||||
@course.end_time = params[:end_time]
|
||||
#@course.school_id = params[:occupation]
|
||||
@course.school_id = current_user.user_extensions.school_id
|
||||
@course.setup_time = params[:setup_time]
|
||||
|
|
|
@ -4,64 +4,82 @@
|
|||
<div class="hwork_new">
|
||||
<ul>
|
||||
<%= labelled_form_for @course do |f| %>
|
||||
<li class="ml45">
|
||||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<label><span class="c_red">*</span> <%= l(:label_tags_course_name)%> :</label>
|
||||
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();">
|
||||
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45">
|
||||
<label><span class="c_red">*</span> <%= l(:label_class_period)%> :</label>
|
||||
<input type="text" name="class_period" id="class_period" class="hwork_input02" onkeyup="regex_course_class_period();" maxlength="6">
|
||||
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_course_term)%> :</label>
|
||||
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %>
|
||||
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_new_course_password)%> :</label>
|
||||
<input type="text" style="display: none;">
|
||||
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" onkeyup="regex_course_password();">
|
||||
<a id="psw_btn" href="javascript:void(0)">显示明码</a>
|
||||
<span class="c_red" id="course_course_password_notice"></span>
|
||||
<li class="ml45">
|
||||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<label><span class="c_red">*</span> <%= l(:label_tags_course_name)%> :</label>
|
||||
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();">
|
||||
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<span class=" ml80 c_orange">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
|
||||
</li>
|
||||
<li class="ml45">
|
||||
<label class="fl" > <%= l(:label_new_course_description)%> :</label>
|
||||
<textarea name="course[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="courses_text fl" ></textarea>
|
||||
<li class="ml45">
|
||||
<label><span class="c_red">*</span> <%= l(:label_class_period)%> :</label>
|
||||
<input type="text" name="class_period" id="class_period" class="hwork_input02" onkeyup="regex_course_class_period();" maxlength="6">
|
||||
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class=" mb5 ml80">
|
||||
<label >公开 :</label>
|
||||
<input id="course_is_public" name="course[is_public]" type="checkbox" value="1">
|
||||
<span class="c_grey">(打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。)</span>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_course_term)%> :</label>
|
||||
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %>
|
||||
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>
|
||||
<span class="c_red" id="course_time_term_notice"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class=" mb5 ml30">
|
||||
<label >学生列表公开 :</label>
|
||||
<input id="course_open_student" name="course[open_student]" type="checkbox" value="1">
|
||||
<span class="c_grey">(打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表)</span>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> 结束学期 :</label>
|
||||
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {} %>
|
||||
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{} %>
|
||||
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则不用修改。</span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class=" mb5 ml30">
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_new_course_password)%> :</label>
|
||||
<input type="text" style="display: none;">
|
||||
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" onkeyup="regex_course_password();">
|
||||
<a id="psw_btn" href="javascript:void(0)">显示明码</a>
|
||||
<span class="c_red" id="course_course_password_notice"></span>
|
||||
<div class="cl"></div>
|
||||
<span class="ml80 c_red">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
|
||||
</li>
|
||||
<li class="ml45">
|
||||
<label class="fl" > <%= l(:label_new_course_description)%> :</label>
|
||||
<textarea name="course[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="courses_text fl" ></textarea>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class=" mb5 ml80">
|
||||
<label >公开 :</label>
|
||||
<input id="course_is_public" name="course[is_public]" type="checkbox" value="1">
|
||||
<span class="c_grey">(选中后课外用户可见该课程,否则仅对课内成员可见)</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class=" mb5 ml30">
|
||||
<label >学生列表公开 :</label>
|
||||
<input id="course_open_student" name="course[open_student]" type="checkbox" value="1">
|
||||
<span class="c_grey">(选中后课外用户可见学生列表,否则仅对课内成员可见)</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class=" mb5 ml30">
|
||||
<label >学生上传资源 :</label>
|
||||
<input <%= @course.publish_resource == 1 ? 'checked' : ''%> id="course_publish_resource" name="course[publish_resource]" type="checkbox" />
|
||||
<span class="c_grey">(打钩为"允许学生上传资源",不打钩为"不允许学生上传资源")</span>
|
||||
<span class="c_grey">(选中后允许学生上传课程资源,否则不允许)</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class=" ml90" >
|
||||
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="submit_new_course();" >提交</a>
|
||||
<%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
</li>
|
||||
<li class=" ml90" >
|
||||
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="submit_new_course();" >提交</a>
|
||||
<%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end%>
|
||||
</ul>
|
||||
</div><!--talknew end-->
|
||||
<div class="cl"></div>
|
||||
<div class="cl"></div>
|
||||
<script>
|
||||
$(function(){
|
||||
$("#time").change(function(){
|
||||
document.getElementById("end_time").options[document.getElementById("time").selectedIndex].selected = true;
|
||||
});
|
||||
$("#term").change(function(){
|
||||
document.getElementById("end_term").options[document.getElementById("term").selectedIndex].selected = true;
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -2,11 +2,11 @@
|
|||
<h2 class="project_h2"><%= l(:label_course_modify_settings)%></h2>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
<% if @select_tab == 'member'%>
|
||||
$("#tb_2").click();
|
||||
<% end %>
|
||||
})
|
||||
$(function(){
|
||||
<% if @select_tab == 'member'%>
|
||||
$("#tb_2").click();
|
||||
<% end %>
|
||||
})
|
||||
</script>
|
||||
<div class="hwork_new">
|
||||
<div id="tb_" class="hwork_tb_">
|
||||
|
@ -50,6 +50,12 @@
|
|||
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term_selected"} %>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> 结束学期 :</label>
|
||||
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"end_time_selected"} %>
|
||||
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"end_term_selected"} %>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_new_course_password)%> :</label>
|
||||
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" value="<%= @course.password%>" onkeyup="regex_course_password();">
|
||||
|
@ -123,15 +129,17 @@
|
|||
</div><!--talknew end-->
|
||||
<div class="cl"></div>
|
||||
<script type="text/javascript">
|
||||
function select() {
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/term_select') %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
}
|
||||
$("#time_selected").click(select);
|
||||
$("#term_selected").click(select);
|
||||
function select() {
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/term_select') %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
}
|
||||
$("#time_selected").click(select);
|
||||
$("#term_selected").click(select);
|
||||
$("#end_time_selected").click(select);
|
||||
$("#end_term_selected").click(select);
|
||||
</script>
|
||||
|
|
|
@ -15,7 +15,7 @@ en:
|
|||
label_homework: Task
|
||||
label_course_news: 课程通知
|
||||
label_main_teacher: 主讲教师
|
||||
label_course_term: 开课学期
|
||||
label_course_term: 开始学期
|
||||
|
||||
label_join_course: 加入
|
||||
label_exit_course: exit course
|
||||
|
|
|
@ -19,7 +19,7 @@ zh:
|
|||
label_course_news: 课程通知
|
||||
label_course_mail_news_reply: 课程通知回复
|
||||
label_main_teacher: 主讲教师
|
||||
label_course_term: 开课学期
|
||||
label_course_term: 开始学期
|
||||
label_isuue_mail_status: 更新了issue状态!
|
||||
|
||||
label_join_course: 加入
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
class AddLastTermToCourse < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :courses, :end_time, :integer
|
||||
add_column :courses, :end_term, :string
|
||||
|
||||
count = Course.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do
|
||||
Course.page(i).per(30).each do |course|
|
||||
course.end_time = course.time
|
||||
course.end_term = course.term
|
||||
course.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20151229022049) do
|
||||
ActiveRecord::Schema.define(:version => 20151231012634) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -198,6 +198,7 @@ ActiveRecord::Schema.define(:version => 20151229022049) do
|
|||
t.integer "last_message_id"
|
||||
t.integer "parent_id"
|
||||
t.integer "course_id"
|
||||
t.integer "org_subfield_id"
|
||||
end
|
||||
|
||||
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
|
||||
|
@ -474,6 +475,8 @@ ActiveRecord::Schema.define(:version => 20151229022049) do
|
|||
t.integer "outline", :default => 0
|
||||
t.integer "publish_resource", :default => 0
|
||||
t.integer "is_delete", :default => 0
|
||||
t.integer "end_time"
|
||||
t.string "end_term"
|
||||
end
|
||||
|
||||
create_table "custom_fields", :force => true do |t|
|
||||
|
@ -1643,10 +1646,6 @@ ActiveRecord::Schema.define(:version => 20151229022049) do
|
|||
t.string "extra"
|
||||
end
|
||||
|
||||
create_table "temp", :id => false, :force => true do |t|
|
||||
t.integer "id", :default => 0, :null => false
|
||||
end
|
||||
|
||||
create_table "time_entries", :force => true do |t|
|
||||
t.integer "project_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
|
|
|
@ -119,6 +119,46 @@ function regex_course_class_period()
|
|||
return false;
|
||||
}
|
||||
}
|
||||
//验证开始学期和结束学期
|
||||
function regex_time_term(){
|
||||
var obj_time = document.getElementById("time");
|
||||
var obj_end_time = document.getElementById("end_time");
|
||||
var obj_term = document.getElementById("term");
|
||||
var obj_end_term = document.getElementById("end_term");
|
||||
var time = obj_time.options[obj_time.selectedIndex];
|
||||
var end_time = obj_end_time.options[obj_end_time.selectedIndex];
|
||||
var term = obj_term.options[obj_term.selectedIndex];
|
||||
var end_term = obj_end_term.options[obj_end_term.selectedIndex];
|
||||
if(time.value == end_time.value) {
|
||||
if(set_term_val(term.value) > set_term_val(end_term.value)) {
|
||||
$("#course_time_term_notice").html("开始学期不能晚于结束学期");
|
||||
$("#course_time_term_notice").show();
|
||||
return false;
|
||||
} else {
|
||||
$("#course_time_term_notice").html("");
|
||||
$("#course_time_term_notice").hide();
|
||||
return true;
|
||||
}
|
||||
} else if(time.value < end_time.value) {
|
||||
$("#course_time_term_notice").html("");
|
||||
$("#course_time_term_notice").hide();
|
||||
return true;
|
||||
} else {
|
||||
$("#course_time_term_notice").html("开始学期不能晚于结束学期");
|
||||
$("#course_time_term_notice").show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//学期转换为数字
|
||||
function set_term_val(val) {
|
||||
if(val == "春季学期"){
|
||||
return 1;
|
||||
} else if(val == "夏季学期"){
|
||||
return 2;
|
||||
} else if(val == "秋季学期"){
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
//验证密码
|
||||
function regex_course_password()
|
||||
{
|
||||
|
@ -145,7 +185,7 @@ function regex_course_password()
|
|||
//提交新建课程
|
||||
function submit_new_course()
|
||||
{
|
||||
if(regex_course_name()&®ex_course_class_period()&®ex_course_password())
|
||||
if(regex_course_name()&®ex_course_class_period()&®ex_time_term()&®ex_course_password())
|
||||
{
|
||||
$("#new_course").submit();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue