diff --git a/app/assets/javascripts/syllabuses.js.coffee b/app/assets/javascripts/syllabuses.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/syllabuses.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/syllabuses.css.scss b/app/assets/stylesheets/syllabuses.css.scss new file mode 100644 index 000000000..2576e25f0 --- /dev/null +++ b/app/assets/stylesheets/syllabuses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the syllabuses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index d3f681a06..4014a91bd 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -67,12 +67,15 @@ class AdminController < ApplicationController def excellent_all_courses name = params[:name] @order = "" - if params[:order] == 'asc' - courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) asc, c.id desc") + @sort = "" + if params[:sort] && (params[:order] == 'act') + courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) #{params[:sort]}, c.id desc") @order = params[:order] - elsif params[:order] == 'desc' - courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) DESC, c.id desc") + @sort = params[:sort] + elsif params[:sort] && (params[:order] == 'time') + courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY time #{params[:sort]},id desc") @order = params[:order] + @sort = params[:sort] else courses = Course.like(name).order('created_at desc') end @@ -99,6 +102,22 @@ class AdminController < ApplicationController end end + #取消精品 + def cancel_excellent_course + @course = Course.find params[:id] + unless @course.nil? + if @course.is_excellent == 1 || @course.excellent_option == 1 + @course.update_column('is_excellent', 0) + @course.update_column('excellent_option', 0) + end + end + respond_to do |format| + format.html{ + redirect_to excellent_courses_url + } + end + end + #管理员界面课程资源列表 def course_resource_list diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 10431f01a..d478b4d63 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1096,7 +1096,8 @@ class StudentWorkController < ApplicationController all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")" end all_students = User.where("id in #{all_student_ids}") - @commit_student_ids = @homework.student_work_projects.map{|student| student.user_id} + student_work_id = @homework.student_work_projects.where("user_id=?",User.current.id).empty? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id + @commit_student_ids = @homework.student_work_projects.where("student_work_id != #{student_work_id}").map{|student| student.user_id} @users = searchstudent_by_name all_students,name respond_to do |format| format.js @@ -1115,6 +1116,20 @@ class StudentWorkController < ApplicationController end end + def get_user_infor + req = Hash.new(false) + user = User.where("id = #{params[:user_id].to_i}").first + if user + req[:id] = user.id + req[:name] = user.show_name + req[:student_id] = user.user_extensions.student_id + req[:valid] = true + else + req[:valid] = false + end + render :json => req + end + private def searchstudent_by_name users, name mems = [] diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb new file mode 100644 index 000000000..69982b99a --- /dev/null +++ b/app/controllers/syllabuses_controller.rb @@ -0,0 +1,23 @@ +class SyllabusesController < ApplicationController + + before_filter :is_logged, :only => [:index, :show] + before_filter :find_syllabus, :only => [:show] + def index + user = User.current + @syllabuses = user.syllabuses + end + + def show + @courses = @syllabus.courses + + end + + private + def find_syllabus + @syllabus = Syllabus.find params[:id] + end + + def is_logged + redirect_to signin_path unless User.current.logged? + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cad57b49f..ca63f496c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -130,8 +130,11 @@ class UsersController < ApplicationController onclick_time = User.current.onclick_time.onclick_time messages.each do |message_all| # 未读的消息存放在数组 - if (message_all.message_type != "SystemMessage"&& !message_all.message.nil? && message_all.message.viewed == 0) || (message_all.message_type == "SystemMessage"&& !message_all.message.nil? && message_all.message.created_at > onclick_time) - @message_alls << message_all.message + mess = message_all.message + if (message_all.message_type != "SystemMessage"&& !mess.nil? && (mess.viewed == 0 || !mess.viewed)) || (message_all.message_type == "SystemMessage"&& !mess.nil? && mess.created_at > onclick_time) + unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + @message_alls << mess + end break if @message_alls.length == 5 end end @@ -154,33 +157,41 @@ class UsersController < ApplicationController update_message_viewed(@user) end # @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count + courses = @user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" case params[:type] when nil # 系统消息为管理员发送,我的消息中包含有系统消息 @message_alls = [] messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc") messages.each do |message_all| - @message_alls << message_all.message + mess = message_all.message + unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + @message_alls << mess + end end when 'unviewed' @message_alls = [] - messages = MessageAll.where("user_id =?", @user.id).includes(:message).order("created_at desc") + messages = MessageAll.where("message_alls.user_id =?", @user.id).includes(:message).order("created_at desc") messages.each do |message_all| # 在点击或者刷新消息列表后未读的消息存放在数组 - if message_all.message_type != "SystemMessage"&& !message_all.message.nil? && message_all.message.viewed == 0 - @message_alls << message_all.message + mess = message_all.message + if message_all.message_type != "SystemMessage"&& !mess.nil? && (mess.viewed == 0 || !mess.viewed) + unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + @message_alls << mess + end end end #课程相关消息 when 'homework' - @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?", @user.id).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =? and course_id NOT IN #{course_ids}", @user.id).order("created_at desc") when 'course_message' - @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user.id).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type =? and user_id =? and course_id NOT IN #{course_ids}", "Message", @user.id).order("created_at desc") when 'course_news' # 课程通知包含发布的通知和回复的通知 - @message_alls = CourseMessage.where("course_message_type in ('News', 'Comment') and user_id =?", @user.id).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('News', 'Comment') and user_id =? and course_id NOT IN #{course_ids}", @user.id).order("created_at desc") when 'poll' - @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user.id).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type =? and user_id =? and course_id NOT IN #{course_ids}", "Poll", @user.id).order("created_at desc") #项目相关消息 when 'issue' @message_alls = ForgeMessage.where("forge_message_type in ('Issue', 'Journal') and user_id =?" , @user.id).order("created_at desc") diff --git a/app/helpers/syllabuses_helper.rb b/app/helpers/syllabuses_helper.rb new file mode 100644 index 000000000..dac84937b --- /dev/null +++ b/app/helpers/syllabuses_helper.rb @@ -0,0 +1,2 @@ +module SyllabusesHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 44b919121..4a6dbc6b6 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -147,7 +147,9 @@ module UsersHelper # 统计未读消息数 def unviewed_message(user) - course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count + courses = user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" + course_count = CourseMessage.where("user_id =? and viewed =? and course_id not in #{course_ids}", user, 0).count forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count org_count = OrgMessage.where("user_id =? and viewed =?", user, 0).count user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count diff --git a/app/models/course.rb b/app/models/course.rb index 69dbec5d0..e3a845b11 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -24,6 +24,7 @@ class Course < ActiveRecord::Base #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 + belongs_to :syllabus # has_many :bid has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" has_many :memberships, :class_name => 'Member' diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb new file mode 100644 index 000000000..7d6319955 --- /dev/null +++ b/app/models/syllabus.rb @@ -0,0 +1,5 @@ +class Syllabus < ActiveRecord::Base + belongs_to :user + has_many :courses + attr_accessible :description, :title +end diff --git a/app/models/user.rb b/app/models/user.rb index 44ef54c95..258fe2ea5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -90,6 +90,7 @@ class User < Principal has_many :homework_users has_many :homework_attaches, :through => :homework_users has_many :homework_evaluations + has_many :syllabuses, :dependent => :destroy #问卷相关关关系 has_many :poll_users, :dependent => :destroy has_many :poll_votes, :dependent => :destroy diff --git a/app/views/admin/_course_detail_tr.html.erb b/app/views/admin/_course_detail_tr.html.erb index ca15a6696..bea14fd3d 100644 --- a/app/views/admin/_course_detail_tr.html.erb +++ b/app/views/admin/_course_detail_tr.html.erb @@ -27,6 +27,9 @@
- 当前作品未进行评分,是否确定提交? + <%#A if work.teacher_score.nil? || work. %> + 您当次评阅未对作品进行评分,分数将取上次的评分结果,若没有评分记录则不评分,是否确定提交?
\ No newline at end of file +作品信息完整性校验中,请稍等...
作品信息完整性校验中,请稍等...
作品信息完整性校验中,请稍等...
作品信息完整性校验中,请稍等...
作品信息完整性校验中,请稍等...
作品信息完整性校验中,请稍等...