diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 8710b624e..c12f59f21 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -423,7 +423,7 @@ class CoursesController < ApplicationController
@course = cs.create_course(params,User.current)[:course]
if @course.new_record?
respond_to do |format|
- format.html { render :action => 'new', :layout => 'base' } #Added by young
+ format.html { render :action => 'new', :layout => 'new_base' } #Added by young
format.api { render_validation_errors(@course) }
end
else
@@ -493,7 +493,7 @@ class CoursesController < ApplicationController
respond_to do |format|
format.html {
- render :layout => 'base'
+ render :layout => 'new_base'
}
format.api {
}
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 29350f0f7..8b1c8ba32 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -79,7 +79,8 @@ class FilesController < ApplicationController
@result = find_course_attache q,@course,sort
@result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
- @tag_list = attachment_tag_list @result
+
+ @tag_list = get_course_tag_list @course
end
#rescue Exception => e
# #render 'stores'
@@ -387,6 +388,7 @@ class FilesController < ApplicationController
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
show_attachments @containers
+ @tag_list = attachment_tag_list @all_attachments
@attachtype = 0
@contenttype = 0
@@ -522,7 +524,7 @@ class FilesController < ApplicationController
end
end
- #查找指定TAG的按条件过滤的资源列表
+ #查找指定TAG的按条件过滤的资源列表,只有课程内搜索有此功能
def search_tag_attachment
@q,@tag_name,@order = params[:q],params[:tag_name]
@is_remote = true
@@ -540,7 +542,7 @@ class FilesController < ApplicationController
@result = visable_attachemnts @result
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)}
@searched_attach = paginateHelper @result,10
- @tag_list = attachment_tag_list @result
+ @tag_list = get_course_tag_list @course
respond_to do |format|
format.js
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index e26901320..253faa2b1 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -220,11 +220,18 @@ class TagsController < ApplicationController
@tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
@tag.delete unless @tag.nil?
end
+
+ if @obj && @object_flag == '6' && @obj.container.kind_of?(Course)
+ @course = @obj.container
+ @tag_list = get_course_tag_list @course
+ @select_tag_name = params[:select_tag_name]
+ end
# end
end
end
def tag_save
+ @select_tag_name = params[:tag_for_save][:tag_name]
@tags = params[:tag_for_save][:name]
@obj_id = params[:tag_for_save][:object_id]
@obj_flag = params[:tag_for_save][:object_flag]
@@ -263,6 +270,10 @@ class TagsController < ApplicationController
else
logger.error "#{__FILE__}:#{__LINE__} ===> #{@obj.errors.try(:full_messages)}"
end
+ if @obj && @obj_flag == '6' && @obj.container.kind_of?(Course)
+ @course = @obj.container
+ @tag_list = @tag_list = get_course_tag_list @course
+ end
respond_to do |format|
format.js
format.html
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 095d0ada5..9c9c96ce5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -2097,4 +2097,23 @@ module ApplicationHelper
request.env["HTTP_USER_AGENT"] =~ /MSIE 8.0/
end
+
+ #获取指定资源列表的TAG的集合以及每个TAG的数量,降序排序
+ def attachment_tag_list attachments
+ tag_list = Hash.new
+ attachments.each do |attachment|
+ attachment.tag_list.map{|tag| tag_list.has_key?(tag) ? tag_list[tag] = tag_list[tag] + 1 : tag_list[tag] = 1}
+ end
+ tag_list.sort {|a,b| b[1]<=>a[1]}
+ end
+
+ #获取课程资源的TAG云
+ def get_course_tag_list course
+ all_attachments = course.attachments.select{|attachment| attachment.is_public? ||
+ (attachment.container_type == "Course" && User.current.member_of_course?(course))||
+ attachment.author_id == User.current.id
+ }
+ tag_list = attachment_tag_list all_attachments
+ tag_list
+ end
end
diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb
index 0be59c0da..d69f13a29 100644
--- a/app/helpers/files_helper.rb
+++ b/app/helpers/files_helper.rb
@@ -120,14 +120,6 @@ module FilesHelper
result
end
- def attachment_tag_list attachments
- tag_list = Hash.new
- attachments.each do |attachment|
- attachment.tag_list.map{|tag| tag_list.has_key?(tag) ? tag_list[tag] = tag_list[tag] + 1 : tag_list[tag] = 1}
- end
- tag_list.sort {|a,b| b[1]<=>a[1]}
- end
-
def get_attachments_by_tag attachments,tag
attachments.each do |attachment|
attachment.tag_list.include?(tag)
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index aa216d755..6f207d76d 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -198,7 +198,7 @@ class CoursesService
@course.school_id = current_user.user_extensions.school_id
@course.setup_time = params[:setup_time]
@course.endup_time = params[:endup_time]
- @course.class_period = params[:class_period]
+ @course.class_period = params[:class_period].to_i
params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0
params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0
end
@@ -245,7 +245,7 @@ class CoursesService
#course.safe_attributes = params[:course]
course.time = params[:time]
course.term = params[:term]
- course.class_period = params[:class_period]
+ course.class_period = params[:class_period].to_i
params[:course][:is_public] ? course.is_public = 1 : course.is_public = 0
params[:course][:open_student] ? course.open_student = 1 : course.open_student = 0
if course.save
diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb
index 0ea51d5f4..75979d9f3 100644
--- a/app/views/courses/new.html.erb
+++ b/app/views/courses/new.html.erb
@@ -25,8 +25,9 @@
-
+
显示明码
+
学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。
diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb
index acc6c12a5..2907ee0ac 100644
--- a/app/views/courses/settings.html.erb
+++ b/app/views/courses/settings.html.erb
@@ -39,8 +39,9 @@
-
+
显示明码
+
学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。
diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb
index 5bbb8757d..42f51e07a 100644
--- a/app/views/files/_course_list.html.erb
+++ b/app/views/files/_course_list.html.erb
@@ -15,12 +15,8 @@
-
- <% unless @tag_list.nil?%>
- <% @tag_list.each do |k,v|%>
-
<%= k%>(<%= v%>)
- <% end%>
- <% end%>
+
+ <%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => course,:tag_name => @tag_name}%>
@@ -56,8 +52,8 @@
- <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %>
- <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %>
+ <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
+ <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
diff --git a/app/views/files/_tag_yun.html.erb b/app/views/files/_tag_yun.html.erb
new file mode 100644
index 000000000..c9ac1999f
--- /dev/null
+++ b/app/views/files/_tag_yun.html.erb
@@ -0,0 +1,9 @@
+<% unless tag_list.nil?%>
+ <% tag_list.each do |k,v|%>
+ <% if tag_name && tag_name == k%>
+ <%= k%>(<%= v%>)
+ <% else%>
+ <%= k%>(<%= v%>)
+ <% end%>
+ <% end%>
+<% end%>
\ No newline at end of file
diff --git a/app/views/tags/_tag_add.html.erb b/app/views/tags/_tag_add.html.erb
index f8cac7c0d..ad97cd693 100644
--- a/app/views/tags/_tag_add.html.erb
+++ b/app/views/tags/_tag_add.html.erb
@@ -9,6 +9,8 @@
<%= f.text_field :name ,:id => "tags_name_#{obj.id}",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length,:class => "isTxt w90 f_l" %>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
+ <% tag_name ||= ""%>
+ <%= f.text_field :tag_name,:value=> tag_name,:style=>"display:none"%>
<%= f.submit "",:class => "submit f_l" %>
<% end %>
diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb
index e18dafd7d..b512f1ef3 100644
--- a/app/views/tags/_tag_list.html.erb
+++ b/app/views/tags/_tag_list.html.erb
@@ -12,8 +12,9 @@
<% end %>
<% when '6' %>
<% if obj.author_id == User.current.id || User.current.admin?%>
+ <% select_tag_name ||= ""%>
<%= link_to 'x', :controller => "tags", :action => "remove_tag_new", :remote => true, :tag_name => tag,
- :taggable_id => obj.id, :taggable_type => object_flag %>
+ :taggable_id => obj.id, :taggable_type => object_flag, :select_tag_name => select_tag_name %>
<% end %>
<% end %>
diff --git a/app/views/tags/_tag_new.html.erb b/app/views/tags/_tag_new.html.erb
index 0d5d371e3..bbedaff78 100644
--- a/app/views/tags/_tag_new.html.erb
+++ b/app/views/tags/_tag_new.html.erb
@@ -21,7 +21,8 @@
<% elsif object_flag == '6' %>
- <%= render :partial => "tags/tag_list",:locals => {:obj => obj,:object_flag => object_flag} %>
+ <% tag_name ||= ""%>
+ <%= render :partial => "tags/tag_list",:locals => {:obj => obj,:object_flag => object_flag,:select_tag_name => tag_name} %>
<%= render :partial => "courses/course_resources_html", :locals => {:obj => obj ,:object_flag => object_flag } %>
diff --git a/app/views/tags/remove_tag_new.js.erb b/app/views/tags/remove_tag_new.js.erb
index 01edf3e1c..9a43dd9b4 100644
--- a/app/views/tags/remove_tag_new.js.erb
+++ b/app/views/tags/remove_tag_new.js.erb
@@ -2,7 +2,9 @@
<% if @object_flag == "6"%>
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_list',
- :locals => {:obj => @obj,:non_list_all => false,:object_flag => @object_flag}) %>');
+ :locals => {:obj => @obj,:non_list_all => false,:object_flag => @object_flag,:select_tag_name => @select_tag_name}) %>');
+
+$("#files_tag").html("<%= escape_javascript(render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => @course,:tag_name => @select_tag_name}) %>");
<% end %>
<% if @object_flag == "10"%>
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
diff --git a/app/views/tags/tag_save.js.erb b/app/views/tags/tag_save.js.erb
index c7dbec65d..74a38c99d 100644
--- a/app/views/tags/tag_save.js.erb
+++ b/app/views/tags/tag_save.js.erb
@@ -5,11 +5,19 @@ $('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_n
//$('#put-tag-form-issue').hide();
$('#name-issue').val("");
<% elsif @obj_flag == '6'%>
-$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
-$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/course_attachment_tag_name',
+ <%if @course%>
+ $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
+ $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_list',
+ :locals => {:obj => @obj,:object_flag => @obj_flag,:select_tag_name => @select_tag_name}) %>');
+ $("#files_tag").html("<%= escape_javascript(render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => @course,:tag_name => @select_tag_name}) %>");
+ <%else%>
+ $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
+ $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/course_attachment_tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
-$("#tags_name_<%=@obj.id%>").val("");
-$("#add_tag_<%=@obj.id%>").hide();
+ <%end%>
+
+ $("#tags_name_<%=@obj.id%>").val("");
+ $("#add_tag_<%=@obj.id%>").hide();
<% elsif @obj_flag == '9'%>
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/new_tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index c2a5da03d..8a16def1d 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -80,9 +80,18 @@ function regex_course_class_period()
return false;
}
else if (regex.test(class_period)) {
- $("#course_class_period_notice").html("");
- $("#course_class_period_notice").hide();
- return true;
+ if(parseInt(class_period) > 0)
+ {
+ $("#course_class_period_notice").html("");
+ $("#course_class_period_notice").hide();
+ return true;
+ }
+ else
+ {
+ $("#course_class_period_notice").html("学时总数必须大于0");
+ $("#course_class_period_notice").show();
+ return false;
+ }
}
else
{
@@ -91,10 +100,33 @@ function regex_course_class_period()
return false;
}
}
+//验证密码
+function regex_course_password()
+{
+ var class_period = $.trim($("#course_course_password").val());
+ var regex = /^\w+$/;
+ if(class_period.length == 0)
+ {
+ $("#course_course_password_notice").html("课程密码不能为空");
+ $("#course_course_password_notice").show();
+ return false;
+ }
+ else if (regex.test(class_period)) {
+ $("#course_course_password_notice").html("");
+ $("#course_course_password_notice").hide();
+ return true;
+ }
+ else
+ {
+ $("#course_course_password_notice").html("课程密码有非法字符");
+ $("#course_course_password_notice").show();
+ return false;
+ }
+}
//提交新建课程
function submit_new_course()
{
- if(regex_course_name()&®ex_course_class_period())
+ if(regex_course_name()&®ex_course_class_period()&®ex_course_password())
{
$("#new_course").submit();
}
@@ -102,7 +134,7 @@ function submit_new_course()
function submit_edit_course(id)
{
- if(regex_course_name()&®ex_course_class_period())
+ if(regex_course_name()&®ex_course_class_period()&®ex_course_password())
{
$("#edit_course_"+id).submit();
}
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 1e67e5f8d..b24c9d366 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -508,8 +508,13 @@ a.wzan_visited{background:url(../images/new_project/public_icon.png) 0px -503px
.vi_zan{color:#28be6c;}
.newwork_btn a{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; display:block; text-align:center; float:right;}
.newwork_btn a:hover{ background:#329cbd;}
-a.files_tag_icon{ background:#dcdcdc; color:#fff; border:1px solid #c8c8c8; padding:1px 10px; float:left; margin-right:10px; margin-bottom:10px;}
-a:hover.files_tag_icon{ background:#64bdd9; color:#fff; border:1px solid #54aeca; }
+.files_tag{ width:670px; height:22px; overflow:hidden; margin-bottom:10px;}
+a.files_tag_icon{ background:#64bdd9; color:#fff; border:1px solid #54aeca; padding:1px 10px; float:left; margin-right:10px;margin-bottom:10px; }
+a:hover.files_tag_icon{ background:#54aeca;}
+
+
+
+