Merge branch 'szzh' into dev_hjq
Conflicts: app/models/poll.rb
This commit is contained in:
commit
9a695b2d09
|
@ -106,74 +106,17 @@ class CoursesController < ApplicationController
|
||||||
# 课程搜索
|
# 课程搜索
|
||||||
# add by nwb
|
# add by nwb
|
||||||
def search
|
def search
|
||||||
courses_all = Course.all_course
|
if params[:name].empty?
|
||||||
name = params[:name]
|
courses = Course.visible
|
||||||
if name.blank?
|
@courses = paginateHelper courses,10
|
||||||
@courses = []
|
|
||||||
@courses_all = []
|
|
||||||
@course_count = 0
|
|
||||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
|
||||||
else
|
else
|
||||||
@courses = courses_all.visible
|
courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'")
|
||||||
if params[:name].present?
|
@courses = paginateHelper courses,10
|
||||||
@courses_all = @courses.like(params[:name])
|
|
||||||
else
|
|
||||||
@courses_all = @courses;
|
|
||||||
end
|
|
||||||
@course_count = @courses_all.count
|
|
||||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
|
||||||
|
|
||||||
# 课程的动态数
|
|
||||||
# @course_activity_count=Hash.new
|
|
||||||
# @courses_all.each do |course|
|
|
||||||
# @course_activity_count[course.id]=0
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# case params[:course_sort_type]
|
|
||||||
# when '0'
|
|
||||||
# @courses = @courses_all.order("created_at desc")
|
|
||||||
# @s_type = 0
|
|
||||||
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
|
||||||
#
|
|
||||||
# @course_activity_count=get_course_activity @courses,@course_activity_count
|
|
||||||
#
|
|
||||||
# when '1'
|
|
||||||
# @courses = @courses_all.order("course_ac_para desc")
|
|
||||||
# @s_type = 1
|
|
||||||
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
|
||||||
#
|
|
||||||
# @course_activity_count=get_course_activity @courses,@course_activity_count
|
|
||||||
#
|
|
||||||
# when '2'
|
|
||||||
# @courses = @courses_all.order("watchers_count desc")
|
|
||||||
# @s_type = 2
|
|
||||||
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
|
||||||
#
|
|
||||||
# @course_activity_count=get_course_activity @courses,@course_activity_count
|
|
||||||
#
|
|
||||||
# when '3'
|
|
||||||
# @course_activity_count=get_course_activity @courses_all,@course_activity_count_array
|
|
||||||
# @courses=handle_course @courses_all,@course_activity_count
|
|
||||||
# @s_type = 3
|
|
||||||
# @courses = @courses[@course_pages.offset, @course_pages.per_page]
|
|
||||||
#
|
|
||||||
# else
|
|
||||||
# @s_type = 0
|
|
||||||
# @courses = @courses_all.order("created_at desc")
|
|
||||||
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
|
||||||
#
|
|
||||||
# @course_activity_count=get_course_activity @courses,@course_activity_count
|
|
||||||
#
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
render :layout => 'course_base'
|
render :layout => 'course_base'
|
||||||
scope = Course
|
|
||||||
unless params[:closed]
|
|
||||||
scope = scope.active
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||||
|
|
|
@ -704,7 +704,7 @@ module CoursesHelper
|
||||||
url = course_feedback_path(activity.course)
|
url = course_feedback_path(activity.course)
|
||||||
when "Poll"
|
when "Poll"
|
||||||
title = "问卷 " + activity.course_act.polls_name
|
title = "问卷 " + activity.course_act.polls_name
|
||||||
url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id)
|
url = poll_path(activity.course_act_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb"
|
link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb"
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Poll < ActiveRecord::Base
|
||||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||||
# 课程动态
|
# 课程动态
|
||||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||||
|
after_create :act_as_activity, :act_as_course_activity
|
||||||
# 课程消息
|
# 课程消息
|
||||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||||
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message
|
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message
|
||||||
|
@ -34,7 +35,10 @@ class Poll < ActiveRecord::Base
|
||||||
#课程动态公共表记录
|
#课程动态公共表记录
|
||||||
def act_as_course_activity
|
def act_as_course_activity
|
||||||
if self.polls_type == "Course"
|
if self.polls_type == "Course"
|
||||||
|
if self.polls_status == 2 #问卷是发布状态
|
||||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
|
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
|
||||||
|
elsif self.polls_status == 1 #问卷是新建状态
|
||||||
|
self.course_acts.destroy_all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,17 +39,17 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if @courses.size == 0 %>
|
<% if @courses && !@courses.empty? %>
|
||||||
<%= render :partial => 'layouts/no_content'%>
|
<div id="courses-index">
|
||||||
|
<%= render_course_hierarchy(@courses)%>
|
||||||
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div id="courses-index">
|
<%= render :partial => 'layouts/no_content'%>
|
||||||
<%= render_course_hierarchy(@courses)%>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<ul>
|
<ul>
|
||||||
<%= pagination_links_full @course_pages %>
|
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<%= course_activity_desc activity%>
|
<%= course_activity_desc activity%>
|
||||||
<br />
|
<br />
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<%= l :label_activity_time %> : <%= format_time(activity.created_at) %>
|
<%= activity.course_act_type == "Course" ? l(:label_create_time) : l(:label_activity_time) %> : <%= format_time(activity.created_at) %>
|
||||||
</p>
|
</p>
|
||||||
<%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %>
|
<%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
<ul class="ml10">
|
<ul class="ml10">
|
||||||
<li>
|
<li>
|
||||||
<label class="label02">迟交扣分: </label>
|
<label class="label02">迟交扣分: </label>
|
||||||
<%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
<%#= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||||
|
<input type="number" value="<%= homework.late_penalty%>" min="0" max="50" class="fl mb10 h26 w70" name="late_penalty" onkeyup="check_late_penalty()">
|
||||||
<span class="fl mt5"> 分</span>
|
<span class="fl mt5"> 分</span>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label class="label02">迟交扣分: </label>
|
<label class="label02">迟交扣分: </label>
|
||||||
<%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
<%#= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||||
|
<input type="number" value="<%= homework.late_penalty%>" min="0" max="50" class="fl mb10 h26 w70" name="late_penalty" onkeyup="check_late_penalty()">
|
||||||
<span class="fl mt5"> 分</span>
|
<span class="fl mt5"> 分</span>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
class UpdateCourseActivityTime < ActiveRecord::Migration
|
|
||||||
def up
|
|
||||||
count = CourseActivity.all.count / 10 + 1
|
|
||||||
transaction do
|
|
||||||
for i in 1 ... count do i
|
|
||||||
CourseActivity.page(i).per(10).each do |activity|
|
|
||||||
if activity.course_act
|
|
||||||
if activity.course_act.respond_to?("created_at")
|
|
||||||
activity.created_at = activity.course_act.created_at
|
|
||||||
elsif activity.course_act.respond_to?("created_on")
|
|
||||||
activity.created_at = activity.course_act.created_on
|
|
||||||
end
|
|
||||||
activity.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
class ChangeAttachmentTime < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
Attachment.where("container_type = 'Course'").each do |attachment|
|
||||||
|
if attachment.container && attachment.container.created_at.to_i > attachment.created_on.to_i
|
||||||
|
attachment.created_on = attachment.container.created_at + 3600 * 24
|
||||||
|
attachment.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,22 @@
|
||||||
|
class UpdateCourseActivityTime < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
count = CourseActivity.all.count / 10 + 1
|
||||||
|
transaction do
|
||||||
|
for i in 1 ... count do i
|
||||||
|
CourseActivity.page(i).per(10).each do |activity|
|
||||||
|
if activity.course_act
|
||||||
|
if activity.course_act.respond_to?("created_at")
|
||||||
|
activity.created_at = activity.course_act.created_at
|
||||||
|
elsif activity.course_act.respond_to?("created_on")
|
||||||
|
activity.created_at = activity.course_act.created_on
|
||||||
|
end
|
||||||
|
activity.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20150811083234) do
|
ActiveRecord::Schema.define(:version => 20150814031258) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
|
|
@ -412,6 +412,24 @@ function regex_homework_name()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//处理迟交扣分
|
||||||
|
function check_late_penalty()
|
||||||
|
{
|
||||||
|
var obj = $("input[name='late_penalty']");
|
||||||
|
var regex = /^\d+$/;
|
||||||
|
if(regex.test(obj.val()))
|
||||||
|
{
|
||||||
|
if(obj.val() > 50)
|
||||||
|
{
|
||||||
|
obj.val("50");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
obj.val("0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//验证匿评数量
|
//验证匿评数量
|
||||||
function regex_evaluation_num()
|
function regex_evaluation_num()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue