Merge branch 'szzh' into develop
This commit is contained in:
commit
174be73bd1
|
@ -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 {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
<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">
|
||||
<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_orange">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
|
||||
</li>
|
||||
|
|
|
@ -39,8 +39,9 @@
|
|||
<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%>">
|
||||
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" value="<%= @course.password%>" 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_orange">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
|
||||
</li>
|
||||
|
|
|
@ -15,12 +15,8 @@
|
|||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="files_tag">
|
||||
<% unless @tag_list.nil?%>
|
||||
<% @tag_list.each do |k,v|%>
|
||||
<a href="javascript:void(0);" class="files_tag_icon" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','<%= k%>','<%= @q%>','<%= course.id%>');"><%= k%>(<span class="c_red"><%= v%></span>)</a>
|
||||
<% end%>
|
||||
<% end%>
|
||||
<div class="files_tag" id="files_tag">
|
||||
<%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => course,:tag_name => @tag_name}%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
|
@ -56,8 +52,8 @@
|
|||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="tag_h">
|
||||
<%= 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} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!---re_con_box end-->
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<% unless tag_list.nil?%>
|
||||
<% tag_list.each do |k,v|%>
|
||||
<% if tag_name && tag_name == k%>
|
||||
<a href="javascript:void(0);" class="files_tag_icon" style="background: #28be6c;"><%= k%>(<span class="c_red"><%= v%></span>)</a>
|
||||
<% else%>
|
||||
<a href="javascript:void(0);" class="files_tag_icon" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(course)%>','<%= k%>','<%= @q%>','<%= course.id%>');"><%= k%>(<span class="c_red"><%= v%></span>)</a>
|
||||
<% end%>
|
||||
<% end%>
|
||||
<% end%>
|
|
@ -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" %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
<% end %>
|
||||
<% when '6' %>
|
||||
<% if obj.author_id == User.current.id || User.current.admin?%>
|
||||
<% select_tag_name ||= ""%>
|
||||
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag_new", :remote => true, :tag_name => tag,
|
||||
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
||||
:taggable_id => obj.id, :taggable_type => object_flag, :select_tag_name => select_tag_name %> </span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
</div>
|
||||
<% elsif object_flag == '6' %>
|
||||
<div id="tags_show-<%=obj.class%>-<%=obj.id%>" style="display:inline; ">
|
||||
<%= 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} %>
|
||||
</div>
|
||||
<div id="put-tag-form-<%=obj.class%>-<%=obj.id%>" style="display: none;height: 100px;">
|
||||
<%= render :partial => "courses/course_resources_html", :locals => {:obj => obj ,:object_flag => object_flag } %>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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}) %>');
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue