This commit is contained in:
parent
b67afc2b95
commit
ac82910aa5
|
@ -713,7 +713,28 @@ class CoursesController < ApplicationController
|
||||||
|
|
||||||
#从课程创建的老师那里选择课程大纲
|
#从课程创建的老师那里选择课程大纲
|
||||||
def course_outline
|
def course_outline
|
||||||
|
@teacher = User.find(@course.tea_id)
|
||||||
|
@blog_articles = @teacher.blog.articles
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#根据关键字搜索,查找方法一样的,但返回内容不一样
|
||||||
|
def search_course_outline
|
||||||
|
@article_title = params[:title]
|
||||||
|
@teacher = User.find(@course.tea_id)
|
||||||
|
@blog_articles = @teacher.blog.articles.like(@article_title)
|
||||||
|
render :json=>@blog_articles.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
#设置或者更改课程的大纲
|
||||||
|
def set_course_outline
|
||||||
|
@course.outline = params[:outline_id]
|
||||||
|
@course.save
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#删除课程
|
#删除课程
|
||||||
|
|
|
@ -19,6 +19,15 @@ class BlogComment < ActiveRecord::Base
|
||||||
after_save :add_user_activity
|
after_save :add_user_activity
|
||||||
before_destroy :destroy_user_activity
|
before_destroy :destroy_user_activity
|
||||||
|
|
||||||
|
scope :like, lambda {|arg|
|
||||||
|
if arg.blank?
|
||||||
|
where(nil)
|
||||||
|
else
|
||||||
|
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||||
|
where(" LOWER(title) LIKE :p ", :p => pattern)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
#在个人动态里面增加当前动态
|
#在个人动态里面增加当前动态
|
||||||
def add_user_activity
|
def add_user_activity
|
||||||
if self.parent_id.nil? #只有发博文才插入动态
|
if self.parent_id.nil? #只有发博文才插入动态
|
||||||
|
|
|
@ -8,19 +8,24 @@
|
||||||
<!--<input class="searchIconPopup" name="commit" onfocus="this.blur();" style="border-style:none" type="submit" value="">-->
|
<!--<input class="searchIconPopup" name="commit" onfocus="this.blur();" style="border-style:none" type="submit" value="">-->
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<span class="f12 c_red fl mb8" name="course_outline_hint" style="display: none">未搜索到对应大纲,请重新输入</span>
|
<span class="f12 c_red fl mb8" id="course_outline_hint" style="display: none">未搜索到对应大纲,请重新输入</span>
|
||||||
|
<%= form_tag(url_for(:controller=>'courses',:action=>'set_course_outline',:id=>course.id),:method=>'post',:remote=>'true') do %>
|
||||||
<div class="blogBlock fl" id="course_outline_list" >
|
<div class="blogBlock fl" id="course_outline_list" >
|
||||||
|
<% unless articles.blank? %>
|
||||||
|
<% articles.each do |article|%>
|
||||||
<ul class="blogRow">
|
<ul class="blogRow">
|
||||||
<li class="fl">
|
<li class="fl">
|
||||||
<input name="checkMenu" type="radio" class="courseSendCheckbox"/>
|
<input name="outline_id" type="radio" value="<%= article.id%>" class="courseSendCheckbox"/>
|
||||||
</li>
|
</li>
|
||||||
<li class="blogTitle fl">博客一</li>
|
<li class="blogTitle fl"><%= article.title%></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="homeworkPublishTime">发布时间:2015-05-11</div>
|
<div class="homeworkPublishTime">发布时间:<%= format_date(article.created_at)%></div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="courseSendSubmit"><a href="javascript:void(0);" class="sendSourceText">确定</a></div>
|
<div class="courseSendSubmit"><a href="javascript:void(0);" class="sendSourceText" onclick="$(this).parent().parent().submit();">确定</a></div>
|
||||||
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText">取消</a></div>
|
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="hideModal();">取消</a></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'course_outlines_list') %>');
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'course_outlines_list',:locals => {:articles=>@blog_articles,:course=>@course}) %>');
|
||||||
showModal('ajax-modal', '300px');
|
showModal('ajax-modal', '300px');
|
||||||
//$('#ajax-modal').css('height','250px');
|
//$('#ajax-modal').css('height','250px');
|
||||||
$('#ajax-modal').css('padding-top','0px');
|
$('#ajax-modal').css('padding-top','0px');
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
hideModal();
|
|
@ -63,7 +63,7 @@
|
||||||
<%= l(:field_is_private)%>
|
<%= l(:field_is_private)%>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%if @course.tea_id == User.current.id && @course.outline == 0%>
|
<%if @course.tea_id == User.current.id %>
|
||||||
<span>
|
<span>
|
||||||
<a href="javascript:void(0)" onclick="course_outline('<%= @course.id%>');">设置大纲</a>
|
<a href="javascript:void(0)" onclick="course_outline('<%= @course.id%>');">设置大纲</a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -172,6 +172,7 @@
|
||||||
<%= call_hook :view_layouts_base_body_bottom %>
|
<%= call_hook :view_layouts_base_body_bottom %>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
|
var blog_artile_list_html = '';
|
||||||
$(function(){
|
$(function(){
|
||||||
$(document).on('input','input[name="course_outline_search"]',function(e){
|
$(document).on('input','input[name="course_outline_search"]',function(e){
|
||||||
throttle(course_outline_search,window,e);
|
throttle(course_outline_search,window,e);
|
||||||
|
@ -180,14 +181,34 @@
|
||||||
clearTimeout(method.tId);
|
clearTimeout(method.tId);
|
||||||
method.tId=setTimeout(function(){
|
method.tId=setTimeout(function(){
|
||||||
method.call(context,e);
|
method.call(context,e);
|
||||||
},300);
|
},500);
|
||||||
}
|
}
|
||||||
function course_outline_search(e){
|
function course_outline_search(e){
|
||||||
|
// if($(e.target).val().trim() == ''){
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
$("#course_outline_hint").hide();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:'',
|
url:'<%=search_course_outline_course_path(@course) %>'+"?&title="+ e.target.value,
|
||||||
type:'post',
|
type:'post',
|
||||||
success:function(data){
|
success:function(data){
|
||||||
|
|
||||||
|
if(data.length != 0 ){
|
||||||
|
$("#course_outline_list").html('');
|
||||||
|
for(var i =0;i<data.length;i++){
|
||||||
|
var html = ' <ul class="blogRow"> '+
|
||||||
|
' <li class="fl"> '+
|
||||||
|
'<input name="outline_id" type="radio" value="'+data[i].blog_comment.id+'" class="courseSendCheckbox"/>'+
|
||||||
|
'</li>'+
|
||||||
|
'<li class="blogTitle fl">'+data[i].blog_comment.title+'</li>'+
|
||||||
|
'</ul>'+
|
||||||
|
'<div class="homeworkPublishTime">发布时间:'+data[i].blog_comment.created_at.match(/(\S*)T/)[1]+'</div>';
|
||||||
|
$("#course_outline_list").append(html)
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$("#course_outline_hint").show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -791,6 +791,7 @@ RedmineApp::Application.routes.draw do
|
||||||
match 'course_activity', :to => 'courses#course_activity', :via => :get, :as => "course_activity"
|
match 'course_activity', :to => 'courses#course_activity', :via => :get, :as => "course_activity"
|
||||||
get 'course_outline'
|
get 'course_outline'
|
||||||
post 'search_course_outline'
|
post 'search_course_outline'
|
||||||
|
post 'set_course_outline'
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
match 'join_private_courses', :via => [:get, :post]
|
match 'join_private_courses', :via => [:get, :post]
|
||||||
|
|
Loading…
Reference in New Issue