diff --git a/Gemfile b/Gemfile index 318b8dcf0..84d578acd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,125 +1,249 @@ source 'https://rubygems.org' unless RUBY_PLATFORM =~ /w32/ +5 # unix-like only +6 gem 'iconv' +7 gem 'rubyzip' +8 gem 'zip-zip' +9 end - +10 +11 gem 'seems_rateable', path: 'lib/seems_rateable' +12 gem "rails", "3.2.13" +13 gem "jquery-rails", "~> 2.0.2" +14 gem "i18n", "~> 0.6.0" +15 gem "coderay", "~> 1.0.6" +16 gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] +17 gem "builder", "3.0.0" +18 gem 'acts-as-taggable-on', '2.4.1' - +19 +gem 'spreadsheet' +20 +gem 'ruby-ole' +21 +22 group :development do +23 gem 'better_errors', path: 'lib/better_errors' +24 gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' - if ENV['PRY'] - gem 'pry' - gem 'pry-nav' +25 +end +26 +27 +group :test do +28 + gem "shoulda", "~> 3.5.0" +29 + gem "mocha", "~> 1.1.0" +30 + gem 'capybara', '~> 2.4.1' +31 + gem 'nokogiri', '~> 1.6.3' +32 + gem 'factory_girl', '~> 4.4.0' +33 + gem 'selenium-webdriver', '~> 2.42.0' +34 +35 +36 + platforms :mri, :mingw do +37 + group :rmagick do +38 + # RMagick 2 supports ruby 1.9 +39 + # RMagick 1 would be fine for ruby 1.8 but Bundler does not support +40 + # different requirements for the same gem on different platforms +41 + gem "rmagick", ">= 2.0.0" +42 + end +43 end +44 end - -# group :test do -# # shoulda的版本做了改动 -# #gem "shoulda", "~> 3.3.2" -# gem "shoulda", "> 3.3.2" -# gem "mocha", "~> 0.13.3" -# gem 'capybara', '~> 2.0.0' -# gem 'nokogiri', '< 1.6.0' -# end - - +45 +46 +group :development, :test do +47 + gem "guard-rails", '~> 0.5.3' +48 + gem 'spork-testunit', '~> 0.0.8' +49 + gem 'guard-spork', '~> 1.5.1' +50 + gem 'guard-test', '~> 1.0.0' +51 + gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/ +52 + gem 'pry' +53 + gem 'pry-nav' +54 +55 +end +56 +57 +58 # Gems used only for assets and not required +59 # in production environments by default. +60 group :assets do +61 gem 'sass-rails', '~> 3.2.3' +62 gem 'coffee-rails', '~> 3.2.1' - +63 +64 # See https://github.com/sstephenson/execjs#readme for more supported runtimes +65 gem 'therubyracer', :platforms => :ruby - +66 +67 gem 'uglifier', '>= 1.0.3' +68 end - +69 +70 # Optional gem for LDAP authentication +71 group :ldap do +72 gem "net-ldap", "~> 0.3.1" +73 end - - -# platforms :mri, :mingw do -# group :rmagick do -# # RMagick 2 supports ruby 1.9 -# # RMagick 1 would be fine for ruby 1.8 but Bundler does not support -# # different requirements for the same gem on different platforms -# gem "rmagick", ">= 2.0.0" -# end -# end - +74 +75 +76 # Optional gem for OpenID authentication +77 group :openid do +78 gem "ruby-openid", "~> 2.1.4", :require => "openid" +79 gem "rack-openid" +80 end - +81 +82 # Optional gem for exporting the gantt to a PNG file, not supported with jruby +83 platforms :jruby do +84 # jruby-openssl is bundled with JRuby 1.7.0 +85 gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0' +86 gem "activerecord-jdbc-adapter", "1.2.5" +87 end - +88 +89 # Include database gems for the adapters found in the database +90 # configuration file +91 require 'erb' +92 require 'yaml' +93 database_file = File.join(File.dirname(__FILE__), "config/database.yml") +94 if File.exist?(database_file) +95 database_config = YAML::load(ERB.new(IO.read(database_file)).result) +96 adapters = database_config.values.map {|c| c['adapter']}.compact.uniq +97 if adapters.any? +98 adapters.each do |adapter| +99 case adapter +100 when 'mysql2' +101 gem "mysql2", "= 0.3.11", :platforms => [:mri, :mingw] +102 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby +103 when 'mysql' +104 gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw] +105 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby +106 when /postgresql/ +107 gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw] +108 gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby +109 when /sqlite3/ +110 gem "sqlite3", :platforms => [:mri, :mingw] +111 gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby +112 when /sqlserver/ +113 gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw] +114 gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw] +115 else +116 warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems") +117 end +118 end +119 else +120 warn("No adapter found in config/database.yml, please configure it first") +121 end +122 else +123 warn("Please configure your config/database.yml first") +124 end - +125 +126 local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local") +127 if File.exists?(local_gemfile) +128 puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v` +129 instance_eval File.read(local_gemfile) +130 end - +131 +132 # Load plugins' Gemfiles +133 Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file| +134 puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` +135 instance_eval File.read(file) -end +136 +end \ No newline at end of file diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2809f6e9a..2a0b6110a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -19,7 +19,7 @@ class CoursesController < ApplicationController before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course] before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create] before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar] - before_filter :toggleCourse, only: [:finishcourse, :restartcourse] + before_filter :toggleCourse, :only => [:finishcourse, :restartcourse] before_filter :require_login, :only => [:join, :unjoin] #before_filter :allow_join, :only => [:join] @@ -500,7 +500,8 @@ class CoursesController < ApplicationController end end - def course + def + course @school_id = params[:school_id] per_page_option = 10 if @school_id == "0" or @school_id.nil? diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index cd51d2e58..03d1454ef 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -13,6 +13,44 @@ class ForumsController < ApplicationController include SortHelper PageLimit = 20 + def create_feedback + if User.current.logged? + @memo = Memo.new(params[:memo]) + @memo.forum_id = "1" + @memo.author_id = User.current.id + #@forum = @memo.forum + respond_to do |format| + if @memo.save + format.html { redirect_to forum_path(@memo.forum) } + else + sort_init 'updated_at', 'desc' + sort_update 'created_at' => "#{Memo.table_name}.created_at", + 'replies' => "#{Memo.table_name}.replies_count", + 'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)" + + @topic_count = @forum.topics.count + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @memos = @forum.topics. + reorder("#{Memo.table_name}.sticky DESC"). + includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + order(sort_clause). + preload(:author, {:last_reply => :author}). + all + + flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" + # back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id) + format.html { render action: :show, layout: 'base_forums' }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } + format.json { render json: @memo.errors, status: :unprocessable_entity } + end + end + else + respond_to do |format| + format.html { redirect_to signin_path } + end + end + end def create_memo @memo = Memo.new(params[:memo]) @@ -49,16 +87,15 @@ class ForumsController < ApplicationController end end end - + def index @offset, @limit = api_offset_and_limit({:limit => 10}) @forums_all = Forum.reorder("sticky DESC") @forums_count = @forums_all.count @forums_pages = Paginator.new @forums_count, @limit, params['page'] - @offset ||= @forums_pages.offset - @forums = @forums_all.offset(@offset).limit(@limit).all + @forums = @forums_all.offset(@offset).limit(@limit).all #@forums = Forum.all respond_to do |format| format.html # index.html.erb @@ -86,14 +123,12 @@ class ForumsController < ApplicationController preload(:author, {:last_reply => :author}). all - - # @offset, @limit = api_offset_and_limit({:limit => 10}) # @forum = Forum.find(params[:id]) # @memos_all = @forum.topics # @topic_count = @memos_all.count # @topic_pages = Paginator.new @topic_count, @limit, params['page'] - + # @offset ||= @topic_pages.offset # @memos = @memos_all.offset(@offset).limit(@limit).all respond_to do |format| @@ -176,7 +211,6 @@ class ForumsController < ApplicationController @forums_count = @forums_all.count @forums_pages = Paginator.new @forums_count, @limit, params['page'] - @offset ||= @forums_pages.offset @forums = @forums_all.offset(@offset).limit(@limit).all respond_to do |format| @@ -197,7 +231,7 @@ class ForumsController < ApplicationController @memos_all = @forum.topics.where("subject LIKE ?", q) @topic_count = @memos_all.count @topic_pages = Paginator.new @topic_count, @limit, params['page'] - + @offset ||= @topic_pages.offset @memos = @memos_all.offset(@offset).limit(@limit).all respond_to do |format| @@ -205,20 +239,17 @@ class ForumsController < ApplicationController render 'show', :layout => 'base_forums' } format.json { render json: @forum } - end + end end - - private - def find_forum_if_available @forum = Forum.find(params[:id]) if params[:id] rescue ActiveRecord::RecordNotFound render_404 nil - end + end def authenticate_user_edit find_forum_if_available diff --git a/app/controllers/poll_answer_controller.rb b/app/controllers/poll_answer_controller.rb new file mode 100644 index 000000000..521f7ed3f --- /dev/null +++ b/app/controllers/poll_answer_controller.rb @@ -0,0 +1,2 @@ +class PollAnswerController < ApplicationController +end \ No newline at end of file diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb new file mode 100644 index 000000000..a21fdb549 --- /dev/null +++ b/app/controllers/poll_controller.rb @@ -0,0 +1,2 @@ +class PollController < ApplicationController +end \ No newline at end of file diff --git a/app/controllers/poll_question_controller.rb b/app/controllers/poll_question_controller.rb new file mode 100644 index 000000000..46a75c0ab --- /dev/null +++ b/app/controllers/poll_question_controller.rb @@ -0,0 +1,2 @@ +class PollQuestionController < ApplicationController +end \ No newline at end of file diff --git a/app/controllers/poll_user_controller.rb b/app/controllers/poll_user_controller.rb new file mode 100644 index 000000000..0373fe085 --- /dev/null +++ b/app/controllers/poll_user_controller.rb @@ -0,0 +1,2 @@ +class PollUserController < ApplicationController +end \ No newline at end of file diff --git a/app/controllers/poll_vote_controller.rb b/app/controllers/poll_vote_controller.rb new file mode 100644 index 000000000..e77bdc622 --- /dev/null +++ b/app/controllers/poll_vote_controller.rb @@ -0,0 +1,2 @@ +class PollVoteController < ApplicationController +end \ No newline at end of file diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fa0beb311..0fcf35aff 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -129,7 +129,7 @@ class UsersController < ApplicationController end def show_new_score - render :layout => false + render :layout => 'users_base' end # end @@ -188,9 +188,9 @@ class UsersController < ApplicationController for user in @watcher events << Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 30) end - - - + + + @events_by_day = events.group_by(&:event_date) unless User.current.admin? diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 3612bf7a4..12637e2fb 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -75,16 +75,21 @@ class ZipdownController < ApplicationController def zip_homework_by_user(homeattach) homeworks_attach_path = [] + not_exist_file = [] # 需要将所有homework.attachments遍历加入zip # 并且返回zip路径 homeattach.attachments.each do |attach| - homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) + if File.exist?(attach.diskfile) + homeworks_attach_path << attach.diskfile + else + not_exist_file << attach.filename + end end - zipping("#{homeattach.user.lastname}#{homeattach.user.firstname}_#{((homeattach.user.user_extensions.nil? || homeattach.user.user_extensions.student_id.nil?) ? "" : homeattach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) + zipping("#{homeattach.user.lastname}#{homeattach.user.firstname}_#{((homeattach.user.user_extensions.nil? || homeattach.user.user_extensions.student_id.nil?) ? "" : homeattach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) end - def zipping(zip_name_refer, files_paths, output_path, is_attachment=false) + def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) # 输入待打包的文件列表,已经打包文件定位到ouput_path ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') input_filename = files_paths @@ -101,9 +106,11 @@ class ZipdownController < ApplicationController zipfile.add(rename_file, filename) end - #zipfile.get_output_stream('ReadMe') do |os| - # os.write 'Homeworks' - #end + unless not_exist_file.empty? + zipfile.get_output_stream('FILE_LOST.txt') do |os| + os.write l(:label_file_lost) + not_exist_file.join(',').to_s + end + end end zipfile_name rescue Errno => e @@ -119,4 +126,4 @@ class ZipdownController < ApplicationController attach = Attachment.find_by_disk_filename(name) attach.filename end -end +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8c2542aa2..cb88742ad 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1593,6 +1593,12 @@ module ApplicationHelper end s end + + def get_memo + @new_memo = Memo.new + #@new_memo.subject = "有什么想说的,尽管来咆哮吧~~" + @public_forum = Forum.find(1) + end private diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 096ce7ad8..a862753ef 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -20,7 +20,7 @@ module CoursesHelper # 返回教师数量,即roles表中定义的Manager def teacherCount project - searchTeacherAndAssistant(project).count + project.members.count - studentCount(project).to_i # or # searchTeacherAndAssistant(project).count end @@ -114,7 +114,7 @@ module CoursesHelper # 学生人数计算 # add by nwb def studentCount course - searchStudent(course).count.to_s#course.student.count + course.student.count.to_s#course.student.count end #课程成员数计算 diff --git a/app/models/course.rb b/app/models/course.rb index 196e7168d..c11f66d49 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -38,7 +38,7 @@ class Course < ActiveRecord::Base validates_presence_of :password, :term,:name validates_format_of :class_period, :with =>/^[1-9]\d*$/ - validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ + validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/ validates_length_of :description, :maximum => 10000 before_save :self_validate after_create :create_board_sync diff --git a/app/models/poll.rb b/app/models/poll.rb new file mode 100644 index 000000000..803ee6ac6 --- /dev/null +++ b/app/models/poll.rb @@ -0,0 +1,9 @@ +class Poll < ActiveRecord::Base + #attr_accessible :closed_at, :polls_group_id, :polls_name, :polls_status, :polls_type, :published_at, :user_id + include Redmine::SafeAttributes + + belongs_to :user + has_many :poll_questions, :dependent => :destroy + has_many :poll_users, :dependent => :destroy + has_many :users, :through => :poll_users #该文件被哪些用户提交答案过 +end diff --git a/app/models/poll_answer.rb b/app/models/poll_answer.rb new file mode 100644 index 000000000..93c75da97 --- /dev/null +++ b/app/models/poll_answer.rb @@ -0,0 +1,7 @@ +class PollAnswer < ActiveRecord::Base + # attr_accessible :answer_position, :answer_text, :poll_questions_id + include Redmine::SafeAttributes + + belongs_to :poll_question + has_many :poll_votes, :dependent => :destroy +end diff --git a/app/models/poll_question.rb b/app/models/poll_question.rb new file mode 100644 index 000000000..66dcea67e --- /dev/null +++ b/app/models/poll_question.rb @@ -0,0 +1,8 @@ +class PollQuestion < ActiveRecord::Base + # attr_accessible :is_necessary, :polls_id, :question_title, :question_type + include Redmine::SafeAttributes + + belongs_to :poll + has_many :poll_answers, :dependent => :destroy + has_many :poll_votes, :dependent => :destroy +end diff --git a/app/models/poll_user.rb b/app/models/poll_user.rb new file mode 100644 index 000000000..e7a122da9 --- /dev/null +++ b/app/models/poll_user.rb @@ -0,0 +1,7 @@ +class PollUser < ActiveRecord::Base + # attr_accessible :poll_id, :user_id + include Redmine::SafeAttributes + + belongs_to :poll + belongs_to :user +end diff --git a/app/models/poll_vote.rb b/app/models/poll_vote.rb new file mode 100644 index 000000000..550563e38 --- /dev/null +++ b/app/models/poll_vote.rb @@ -0,0 +1,8 @@ +class PollVote < ActiveRecord::Base + # attr_accessible :poll_answers_id, :poll_questions_id, :user_id, :vote_text + include Redmine::SafeAttributes + + belongs_to :poll_answer + belongs_to :poll_question + belongs_to :user +end diff --git a/app/models/user.rb b/app/models/user.rb index e966742f1..735b80762 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -77,6 +77,13 @@ class User < Principal has_many :homework_attaches, :through => :homework_users has_many :homework_evaluations + #问卷相关关关系 + has_many :poll_users, :dependent => :destroy + has_many :poll_votes, :dependent => :destroy + has_many :poll, :dependent => :destroy #用户创建的问卷 + has_many :answers, :source => :poll, :through => :poll_users, :dependent => :destroy #用户已经完成问答的问卷 + # end + has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, :after_remove => Proc.new {|user, group| group.user_removed(user)} has_many :changesets, :dependent => :nullify diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb index 75b892461..170f11037 100644 --- a/app/views/contests/index.html.erb +++ b/app/views/contests/index.html.erb @@ -10,7 +10,7 @@ <%= l(:label_user_location) %> : - + <% if User.current.logged? %> <% unless User.current.user_extensions.identity == 1 %> <%= link_to(l(:label_newtype_contest), new_contest_contests_path, :class => 'icon icon-add', :target => "_blank") %> diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index 313e50748..2599760ad 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -1,21 +1,21 @@ @@ -66,7 +66,7 @@
<% if @subPage_title == l(:label_student_list) %>
- <%= render :partial => 'groups_name', locals: {:course_groups => @course_groups} %> + <%= render :partial => 'groups_name', :locals => {:course_groups => @course_groups} %>
<% end %> diff --git a/app/views/courses/search.html.erb b/app/views/courses/search.html.erb index e2c701932..661feb3c9 100644 --- a/app/views/courses/search.html.erb +++ b/app/views/courses/search.html.erb @@ -13,7 +13,7 @@ <%= l(:label_user_location) %> : - + <% if User.current.logged?%> <% if User.current.user_extensions.identity == 0 %> <%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %> diff --git a/app/views/forums/create_feedback.js.erb b/app/views/forums/create_feedback.js.erb new file mode 100644 index 000000000..b94ac73aa --- /dev/null +++ b/app/views/forums/create_feedback.js.erb @@ -0,0 +1,6 @@ +$(function(){ + $("#button1").click(function(){ + myTips("您的意见已经反馈到公共贴吧的新手讨论吧,我们会第一时间解决您的问题,谢谢支持!","success"); + }); + +}) \ No newline at end of file diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index 5321abac0..77077f102 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -82,6 +82,8 @@

+
+

+
+ + <% get_memo %> + <%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %> +
+

+ <%= f.text_area :subject, :class => "opnionText",:placeholder => "有什么想说的,尽管来咆哮吧~~"%> +

+

+ <%= f.hidden_field :content, :required => true ,:value=>'该贴来自用户反馈!'%> +

+ <%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %> + 提  交 + <% end %> +
+ + + +
+
+ +
+
技术支持:
+

<%= l(:label_course_adcolick) %>黄井泉
+ <%= l(:label_course_adcolick) %>白羽

+
+ +
+ + + + + diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 6f87d4171..445a5abf4 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -27,6 +27,7 @@ #@nav_dispaly_user_label = 1 end %> +<%= render :partial => "layouts/base_feedback" %>