diff --git a/.gitignore b/.gitignore index f1eed7367..ca12f81a9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /.bundle *.swp /config/database.yml +/config/configuration.yml /files/* /log/* /tmp/* @@ -14,7 +15,6 @@ /db/schema.rb /Gemfile.lock /lib/plugins/acts_as_versioned/test/debug.log -/config/configuration.yml .rbenv-gemsets .DS_Store public/api_doc/ diff --git a/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch b/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch index f21eed9f2..678ced8a0 100644 --- a/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch +++ b/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch @@ -2,6 +2,7 @@ + diff --git a/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch b/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch index 2134fa92c..f7b0844d8 100644 --- a/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch +++ b/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch @@ -2,6 +2,7 @@ + diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..8c18f1abd --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/Gemfile b/Gemfile index 893c75789..42bfc83db 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source 'http://ruby.taobao.org' +source 'http://rubygems.org' #source 'http://ruby.sdutlinux.org/' unless RUBY_PLATFORM =~ /w32/ @@ -20,6 +20,7 @@ gem "builder", "3.0.0" gem 'acts-as-taggable-on', '2.4.1' gem 'spreadsheet' gem 'ruby-ole' +#gem 'email_verifier' group :development do gem 'grape-swagger' @@ -38,17 +39,18 @@ group :test do gem 'selenium-webdriver', '~> 2.42.0' - 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 + # 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 end - + gem 'rspec-rails' , '2.13.1' + gem 'guard-rspec','2.5.0' # Gems used only for assets and not required # in production environments by default. group :assets do diff --git a/Gemfile.lock b/Gemfile.lock index e89b80221..6677141c9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,7 +26,7 @@ PATH rails GEM - remote: http://ruby.taobao.org/ + remote: http://rubygems.org/ remote: https://rubygems.org/ specs: actionmailer (3.2.13) @@ -70,6 +70,8 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + celluloid (0.16.0) + timers (~> 4.0.0) childprocess (0.5.3) ffi (~> 1.0, >= 1.0.11) climate_control (0.0.3) @@ -88,6 +90,7 @@ GEM coffee-script-source (1.7.1) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) + diff-lcs (1.2.5) equalizer (0.0.9) erubis (2.7.0) execjs (2.2.1) @@ -96,6 +99,7 @@ GEM fastercsv (1.5.5) ffi (1.9.3) ffi (1.9.3-x86-mingw32) + formatador (0.2.5) grape (0.9.0) activesupport builder @@ -112,8 +116,21 @@ GEM grape-swagger (0.8.0) grape grape-entity + guard (2.11.1) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-rspec (2.5.0) + guard (>= 1.1) + rspec (~> 2.11) hashie (3.3.1) hike (1.2.3) + hitimes (1.2.2-x86-mingw32) htmlentities (4.3.2) i18n (0.6.1) ice_nine (0.11.0) @@ -126,10 +143,16 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) libv8 (3.16.14.3) + listen (2.8.5) + celluloid (>= 0.15.2) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + lumberjack (1.0.9) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.4) + method_source (0.8.2) mime-types (1.25.1) mini_portile (0.6.0) mocha (1.1.0) @@ -138,17 +161,26 @@ GEM multi_xml (0.5.5) mysql2 (0.3.11) mysql2 (0.3.11-x86-mingw32) + nenv (0.2.0) net-ldap (0.3.1) nokogiri (1.6.3) mini_portile (= 0.6.0) nokogiri (1.6.3-x86-mingw32) mini_portile (= 0.6.0) + notiffany (0.0.3) + nenv (~> 0.1) + shellany (~> 0.0) paperclip (3.5.4) activemodel (>= 3.0.0) activesupport (>= 3.0.0) cocaine (~> 0.5.3) mime-types polyglot (0.3.5) + pry (0.9.12.6-x86-mingw32) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + win32console (~> 1.3) rack (1.4.5) rack-accept (0.4.5) rack (>= 0.4) @@ -181,6 +213,9 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (10.3.2) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) + ffi (>= 0.5.0) rdoc (3.12.2) json (~> 1.4) ref (1.0.5) @@ -192,7 +227,21 @@ GEM rack-raw-upload rails (>= 3.2.0) sass-rails - rmagick (2.13.2) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.1) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.1) + rspec-rails (2.13.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) ruby-ole (1.2.11.7) ruby-openid (2.1.8) rubyzip (1.1.6) @@ -206,12 +255,14 @@ GEM multi_json (~> 1.0) rubyzip (~> 1.0) websocket (~> 1.0.4) + shellany (0.0.1) shoulda (3.5.0) shoulda-context (~> 1.0, >= 1.0.1) shoulda-matchers (>= 1.4.1, < 3.0) shoulda-context (1.2.1) shoulda-matchers (2.6.1) activesupport (>= 3.0.0) + slop (3.6.0) spreadsheet (1.0.0) ruby-ole (>= 1.0) sprockets (2.2.2) @@ -225,6 +276,8 @@ GEM thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) + timers (4.0.1) + hitimes treetop (1.4.15) polyglot polyglot (>= 0.3.1) @@ -238,6 +291,7 @@ GEM descendants_tracker (~> 0.0, >= 0.0.3) equalizer (~> 0.0, >= 0.0.9) websocket (1.0.7) + win32console (1.3.2-x86-mingw32) xpath (2.0.0) nokogiri (~> 1.3) @@ -260,6 +314,7 @@ DEPENDENCIES grape-entity grape-swagger grape-swagger-ui! + guard-rspec (= 2.5.0) htmlentities i18n (~> 0.6.0) jquery-rails (~> 2.0.2) @@ -273,7 +328,7 @@ DEPENDENCIES rack-openid rails (= 3.2.13) rich (= 1.4.6) - rmagick (>= 2.0.0) + rspec-rails (= 2.13.1) ruby-ole ruby-openid (~> 2.1.4) sass-rails (~> 3.2.3) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 49ee726e2..ff66b8d46 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -367,7 +367,10 @@ class AccountController < ApplicationController if user.save and token.save UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) Mailer.register(token).deliver + + flash[:notice] = l(:notice_account_register_done) + render action: 'email_valid', locals: {:mail => user.mail} else yield if block_given? diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2721c57c7..06e5dac30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -156,7 +156,16 @@ class ApplicationController < ActionController::Base user end end + def try_to_autologin1 + # auto-login feature starts a new session + user = User.try_to_autologin(params[:token]) + if user + start_user_session(user) + end + user + + end # Sets the logged in user def logged_user=(user) reset_session @@ -248,7 +257,30 @@ class ApplicationController < ActionController::Base end end end + def authorize1(ctrl = params[:controller], action = params[:action],token = params[:token], global = false) + if(!User.current.logged? && !token.nil?) + + User.current =try_to_autologin1 + end + allowed = authorize_allowed(params[:controller], params[:action],global) + + if allowed + true + else + if @project && @project.archived? + render_403 :message => :notice_not_authorized_archived_project + else + deny_access + end + end + end + def auth_login1(token = params[:token]) + if(!User.current.logged? && !token.nil?) + + User.current =try_to_autologin1 + end + end def authorize_allowed(ctrl = params[:controller], action = params[:action], global = false) #modify by NWB if @project @@ -261,6 +293,7 @@ class ApplicationController < ActionController::Base allowed end def authorize_attachment_download(ctrl = params[:controller], action = params[:action], global = false) + case @attachment.container_type when "Memo" allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) @@ -289,6 +322,37 @@ class ApplicationController < ActionController::Base end end + def authorize_attachment_download1(ctrl = params[:controller], action = params[:action],token = params[:token], global = false) + if(!User.current.logged? && !token.nil?) + User.current = try_to_autologin1 + end + case @attachment.container_type + when "Memo" + allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) + when "Message" + if @project + allowed = User.current.allowed_to?(:projects_attachments_download,@project,:global => false) + elsif @course + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) + end + when "contest" + return true + when "Course" + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) + else + return true + end + + if allowed + true + else + if @project && @project.archived? + render_403 :message => :notice_not_authorized_archived_project + else + deny_access + end + end + end def authorize_course(ctrl = params[:controller], action = params[:action], global = false) allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @course, :global => global) if allowed @@ -789,4 +853,29 @@ class ApplicationController < ActionController::Base @organizer = WebFooterOranizer.first @companies = WebFooterCompany.all end + + + + + def password_authentication + user, last_login_on = User.try_to_login(params[:user_name], params[:password]) + + + successful_authentication(user, last_login_on) + + end + + + def successful_authentication(user, last_login_on) + logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}" + # Valid user + self.logged_user = user + # generate a key and set cookie if autologin + if params[:autologin] && Setting.autologin? + set_autologin_cookie(user) + end + call_hook(:controller_account_success_authentication_after, {:user => user }) + + + end end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 952dcdf44..2c6a002b4 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -17,11 +17,12 @@ class AttachmentsController < ApplicationController layout "users_base" + before_filter :find_project, :only => [:show, :download, :thumbnail, :destroy, :delete_homework]#, :except => [:upload, :autocomplete] before_filter :file_readable, :read_authorize, :only => [:show, :thumbnail]#Modified by young before_filter :delete_authorize, :only => :destroy before_filter :authorize_global, :only => :upload - before_filter :authorize_attachment_download, :only => :download + before_filter :authorize_attachment_download1, :only => :download #before_filter :login_without_softapplication, only: [:download] accept_api_auth :show, :download, :upload require 'iconv' diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index ec2fb7d77..7e5894b83 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -9,6 +9,8 @@ class BidsController < ApplicationController menu_item :homework_statistics, :only => :homework_statistics menu_item :edit, :only => :edit + + before_filter :can_show_course,only: [] before_filter :can_show_contest,only: [] #Ended by young diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 16fe60bd2..ecb5ba8c3 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -323,6 +323,7 @@ class CoursesController < ApplicationController if valid_attr.eql?('name') faker.name = valid_value + faker.course_id = params[:course_id] faker.valid? req[:valid] = faker.errors[:name].blank? req[:message] = faker.errors[:name] @@ -572,8 +573,7 @@ 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? @@ -882,9 +882,9 @@ class CoursesController < ApplicationController # modify by nwb # 添加私密性判断 if User.current.member_of_course?(@course)|| User.current.admin? - events = @activity.events(@date_from, @date_to) + events = @activity.events(@days, @course.created_at) else - events = @activity.events(@date_from, @date_to, :is_public => 1) + events = @activity.events(@days, @course.created_at, :is_public => 1) end # 无新动态时,显示老动态 diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 03d1454ef..54b8c6305 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -160,12 +160,15 @@ class ForumsController < ApplicationController def create @forum = Forum.new(params[:forum]) @forum.creator_id = User.current.id + if @forum.save + respond_to do |format| - respond_to do |format| - if @forum.save - format.html { redirect_to @forum, notice: l(:label_forum_create_succ) } - format.json { render json: @forum, status: :created, location: @forum } - else + format.html { redirect_to @forum, notice: l(:label_forum_create_succ) } + format.json { render json: @forum, status: :created, location: @forum } + end + + else + respond_to do |format| flash.now[:error] = "#{l :label_forum_create_fail}: #{@forum.errors.full_messages[0]}" format.html { render action: "new" } format.json { render json: @forum.errors, status: :unprocessable_entity } diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 8b9bf9099..8e69d1d72 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -26,6 +26,7 @@ class HomeworkAttachController < ApplicationController get_not_batch_homework_list sort,direction, @bid.id @cur_page = params[:page] || 1 @cur_type = 1 + @cur_sort,@cur_direction = params[:sort] || "s_socre", params[:direction] || "desc" @direction = direction == 'asc'? 'desc' : 'asc' respond_to do |format| format.js @@ -433,7 +434,7 @@ class HomeworkAttachController < ApplicationController #添加留言 def addjours @is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value] - @cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5 + @cur_page,@cur_type = params[:page] || 1,params[:cur_type] || 5 @homework = HomeworkAttach.find(params[:homework_id]) @stars_reates = @homework.rates(:quality) homework = @homework @@ -479,7 +480,7 @@ class HomeworkAttachController < ApplicationController if @cur_type == "1" #如果当前是老师未批列表,需要刷新整个作业列表界面 @bid = @homework.bid - get_not_batch_homework_list "s_socre","desc",@homework.bid_id + get_not_batch_homework_list params[:cur_sort] || "s_socre",params[:cur_direction] || "desc",@homework.bid_id elsif @cur_type == "2" #老师已批列表 @result_homework = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f3c2b199c..c0d83fdcd 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -19,10 +19,13 @@ class IssuesController < ApplicationController layout 'base_projects'#Added by young default_search_scope :issues + before_filter :authorize1, :only => [:show] before_filter :find_issue, :only => [:show, :edit, :update] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] + #before_filter :authorize, :except => [:index, :show] before_filter :authorize, :except => [:index] + before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form] @@ -107,7 +110,7 @@ class IssuesController < ApplicationController end def show - + @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 17daea2ac..7ff015fbc 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -17,6 +17,9 @@ class MyController < ApplicationController layout "users_base" + # edit + before_filter :auth_login1, :only => [:account] + # before_filter :require_login helper :issues diff --git a/app/controllers/poll_answer_controller.rb b/app/controllers/poll_answer_controller.rb deleted file mode 100644 index 521f7ed3f..000000000 --- a/app/controllers/poll_answer_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class PollAnswerController < ApplicationController -end \ No newline at end of file diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index a21fdb549..8926c0be6 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,2 +1,420 @@ class PollController < ApplicationController + before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result] + before_filter :find_container, :only => [:new,:create, :index] + before_filter :is_member_of_course, :only => [:index,:show,:poll_result] + before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll] + include PollHelper + def index + if @course + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + if @is_teacher + polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}") + else + polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2") + end + @polls = paginateHelper polls,20 #分页 + respond_to do |format| + format.html{render :layout => 'base_courses'} + end + elsif @project + #项目的问卷调查相关代码 + end + end + + def show + @poll = Poll.find params[:id] + #已提交问卷的用户不能再访问该界面 + if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?) + render_403 + else + @can_edit_poll = (!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin? + @percent = get_percent(@poll,User.current) + poll_questions = @poll.poll_questions + @poll_questions = paginateHelper poll_questions,5 #分页 + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + end + end + + def new + if @course + option = { + :polls_name => "", + :polls_type => @course.class.to_s, + :polls_group_id => @course.id, + :polls_status => 1, + :user_id => User.current.id, + :published_at => Time.now, + :closed_at => Time.now, + :show_result => 1, + :polls_description => "" + } + @poll = Poll.create option + if @poll + redirect_to edit_poll_url @poll.id + end + elsif @project + #项目的问卷调查相关代码 + end + end + + def create + + end + + def edit + respond_to do |format| + format.html{render :layout => 'base_courses'} + end + end + + def update + @poll.polls_name = params[:polls_name] + @poll.polls_description = params[:polls_description] + if @poll.save + respond_to do |format| + format.js + end + else + render_404 + end + end + + def destroy + if @poll && @poll.destroy + respond_to do |format| + format.js + end + end + end + + def statistics_result + @poll = Poll.find(params[:id]) + poll_questions = @poll.poll_questions + @poll_questions = paginateHelper poll_questions, 5 + respond_to do |format| + format.html{render :layout => 'base_courses'} + end + end + + def get_poll_totalcount poll_question + @total_questions_count = poll_question.poll_votes.count + end + + def get_poll_everycount poll_answer + @every_answer_count = poll_answer.poll_votes.count + end + + + #添加题目 + def create_poll_question + question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title] + option = { + :is_necessary => (params[:is_necessary]=="true" ? 1 : 0), + :question_title => question_title, + :question_type => params[:question_type] || 1, + :question_number => @poll.poll_questions.count + 1 + } + @poll_questions = @poll.poll_questions.new option + if params[:question_answer] + for i in 1..params[:question_answer].count + answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + question_option = { + :answer_position => i, + :answer_text => answer + } + @poll_questions.poll_answers.new question_option + end + end + if @poll_questions.save + respond_to do |format| + format.js + end + end + end + + #修改题目 + def update_poll_question + @poll_question = PollQuestion.find params[:poll_question] + #@poll = @poll_question.poll + @poll_question.is_necessary = params[:is_necessary]=="true" ? 1 : 0 + @poll_question.question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title] + ################处理选项 + if params[:question_answer] + @poll_question.poll_answers.each do |answer| + answer.destroy unless params[:question_answer].keys.include? answer.id.to_s + end + for i in 1..params[:question_answer].count + question = @poll_question.poll_answers.find_by_id params[:question_answer].keys[i-1] + answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + if question + question.answer_position = i + question.answer_text = answer + question.save + else + question_option = { + :answer_position => i, + :answer_text => answer + } + @poll_question.poll_answers.new question_option + end + end + end + @poll_question.save + respond_to do |format| + format.js + end + end + + #删除题目 + def delete_poll_question + @poll_question = PollQuestion.find params[:poll_question] + @poll = @poll_question.poll + poll_questions = @poll.poll_questions.where("question_number > #{@poll_question.question_number}") + poll_questions.each do |question| + question.question_number -= 1 + question.save + end + if @poll_question && @poll_question.destroy + respond_to do |format| + format.js + end + end + end + + #发布问卷 + def publish_poll + @poll.polls_status = 2 + @poll.published_at = Time.now + if @poll.save + if params[:is_remote] + redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id) + else + respond_to do |format| + format.js + end + end + end + end + + #提交答案 + def commit_answer + pq = PollQuestion.find(params[:poll_question_id]) + if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?) + render :json => {:text => "failure"} + return + end + if pq.question_type == 1 + #单选题 + pv = PollVote.find_by_poll_question_id_and_user_id(params[:poll_question_id],User.current.id) + if pv.nil? + #尚未答该题,添加答案 + pv = PollVote.new + pv.user_id = User.current.id + pv.poll_question_id = params[:poll_question_id] + end + #修改该题对应答案 + pv.poll_answer_id = params[:poll_answer_id] + if pv.save + #保存成功返回成功信息及当前以答题百分比 + @percent = get_percent(@poll,User.current) + render :json => {:text => "ok" ,:percent => format("%.2f" ,@percent)} + else + #返回失败信息 + render :json => {:text => "failure"} + end + elsif pq.question_type == 2 + #多选题 + pv = PollVote.find_by_poll_answer_id_and_user_id(params[:poll_answer_id],User.current.id) + if pv.nil? + #尚未答该题,添加答案 + pv = PollVote.new + pv.user_id = User.current.id + pv.poll_question_id = params[:poll_question_id] + pv.poll_answer_id = params[:poll_answer_id] + if pv.save + @percent = get_percent(@poll,User.current) + render :json => {:text => "true",:percent => format("%.2f" ,@percent)} + else + render :json => {:text => "failure"} + end + else + #pv不为空,则当前选项之前已被选择,再次点击则是不再选择该项,故删除该答案 + if pv.delete + @percent = get_percent(@poll,User.current) + render :json => {:text => "false" ,:percent => format("%.2f" ,@percent)} + else + render :json => {:text => "failure"} + end + end + elsif pq.question_type == 3 || pq.question_type == 4 + #单行文本,多行文本题 + pv = PollVote.find_by_poll_question_id_and_user_id(params[:poll_question_id],User.current.id) + if pv.nil? + #pv为空之前尚未答题,添加答案 + if params[:vote_text].nil? || params[:vote_text].blank? + #用户提交空答案,视作不作答 + @percent = get_percent(@poll,User.current) + render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)} + else + #添加答案 + pv = PollVote.new + pv.user_id = User.current.id + pv.poll_question_id = params[:poll_question_id] + pv.vote_text = params[:vote_text] + if pv.save + @percent = get_percent(@poll,User.current) + render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)} + else + render :json => {:text => "failure"} + end + end + else + #pv不为空说明用户之前已作答 + if params[:vote_text].nil? || params[:vote_text].blank? + #用户提交空答案,视为删除答案 + if pv.delete + @percent = get_percent(@poll,User.current) + render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)} + else + render :json => {:text => "failure"} + end + else + #用户修改答案 + pv.vote_text = params[:vote_text] + if pv.save + @percent = get_percent(@poll,User.current) + render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)} + else + render :json => {:text => "failure"} + end + end + end + + else + render :json => {:text => "failure"} + end + end + + #提交问卷 + def commit_poll + @uncomplete_question = get_uncomplete_question(@poll,User.current) + if @uncomplete_question.count < 1 + pu = get_poll_user(@poll.id,User.current.id) + pu.user_id = User.current.id + pu.poll_id = @poll.id + if pu.save + #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course') + @status = 0 #提交成功 + else + @status = 2 #未知错误 + end + else + @status = 1 #有未做得必答题 + end + respond_to do |format| + format.js + end + end + + #重新发布问卷 + def republish_poll + @poll.poll_questions.each do |poll_question| + poll_question.poll_votes.destroy_all + end + @poll.poll_users.destroy_all + @poll.polls_status = 1 + @poll.save + respond_to do |format| + format.js + end + end + + #显示某个学生某份问卷的填写结果 + def poll_result + @poll_questions = paginateHelper @poll.poll_questions,5 + respond_to do |format| + format.html{render :layout => 'base_courses'} + end + end + + private + def find_poll_and_course + @poll = Poll.find params[:id] + @course = Course.find @poll.polls_group_id + rescue Exception => e + render_404 + end + + def find_container + if params[:polls_type] && params[:polls_group_id] + case params[:polls_type] + when "Course" + @course = Course.find_by_id params[:polls_group_id] + when "Project" + @project = Project.find_by_id params[:polls_group_id] + end + else + render_404 + end + end + + def is_member_of_course + render_403 unless(@course && User.current.member_of_course?(@course)) + end + + def is_course_teacher + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + render_403 unless(@course && @is_teacher) + end + + #获取未完成的题目 + def get_uncomplete_question poll,user + necessary_questions = poll.poll_questions.where("#{PollQuestion.table_name}.is_necessary = 1") + uncomplete_question = [] + necessary_questions.each do |question| + answers = get_user_answer(question,user) + if answers.nil? || answers.count < 1 + uncomplete_question << question + end + end + uncomplete_question + end + + #获取用户对某个问题的答案 + def get_user_answer(question,user) + user_answer = question.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id}") + user_answer + end + + def get_complete_question(poll,user) + questions = poll.poll_questions + complete_question = [] + questions.each do |question| + answers = get_user_answer(question,user) + if !(answers.nil? || answers.count < 1) + complete_question << question + end + end + complete_question + end + + def get_percent poll,user + complete_count = get_complete_question(poll,user).count + if poll.poll_questions.count == 0 + return 0 + else + return (complete_count.to_f / poll.poll_questions.count.to_f)*100 + end + end + + #PollUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个 + def get_poll_user poll_id,user_id + pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id) + if pu.nil? + pu = PollUser.new + end + pu + end end \ No newline at end of file diff --git a/app/controllers/poll_question_controller.rb b/app/controllers/poll_question_controller.rb deleted file mode 100644 index 46a75c0ab..000000000 --- a/app/controllers/poll_question_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 0373fe085..000000000 --- a/app/controllers/poll_user_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index e77bdc622..000000000 --- a/app/controllers/poll_vote_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class PollVoteController < ApplicationController -end \ No newline at end of file diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0b7cbbb5f..a2e793a10 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -31,14 +31,16 @@ class ProjectsController < ApplicationController menu_item :feedback, :only => :feedback menu_item l(:label_course_file), :only => :index menu_item l(:label_course_news), :only => :index - - before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] +# edit + before_filter :authorize1, :only => [:show] +# + before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project] # before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, # :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share, # :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index] #此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member - before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] + before_filter :authorize, :only => [:settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] before_filter :file, :statistics, :watcherlist @@ -116,8 +118,8 @@ class ProjectsController < ApplicationController joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").joins("LEFT JOIN #{ProjectScore.table_name} ON #{Project.table_name}.id = #{ProjectScore.table_name}.project_id"). where("#{Project.table_name}.project_type = ? ", Project::ProjectType_project) - @project_count = @projects_all.count - @project_pages = Paginator.new @project_count, per_page_option, params['page'] + @poll_questions_count = @projects_all.count + @poll_questions_pages = Paginator.new @project_count, per_page_option, params['page'] #gcm activity count @@ -556,6 +558,11 @@ class ProjectsController < ApplicationController # Show @project def show + if(@project && !@project.is_public && !User.current.member_of?(@project)) + render_403 + return + end + @project_type = params[:project_type] # try to redirect to the requested menu item @@ -597,8 +604,8 @@ class ProjectsController < ApplicationController "show_wiki_edits"=>true, "show_journals_for_messages" => true } - @date_to ||= Date.today + 1 - @date_from = @date_to - @days-1.years + + @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) # 决定显示所用用户或单个用户活动 @@ -612,9 +619,9 @@ class ProjectsController < ApplicationController # modify by nwb # 添加私密性判断 if User.current.member_of?(@project)|| User.current.admin? - events = @activity.events(@date_from, @date_to) + events = @activity.events(@days) else - events = @activity.events(@date_from, @date_to, :is_public => 1) + events = @activity.events(@days,nil, :is_public => 1) end @offset, @limit = api_offset_and_limit({:limit => 10}) @@ -910,6 +917,14 @@ class ProjectsController < ApplicationController end end end + + #加入私有项目 + def join_project + respond_to do |format| + format.js + end + end + private def memberAccess diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9752459b9..859b5468b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -15,8 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class UsersController < ApplicationController + layout :setting_layout #Added by young + before_filter :auth_login1, :only => [:show, :user_activities] menu_item :activity menu_item :user_information, :only => :info menu_item :user_course, :only => :user_courses @@ -29,6 +31,9 @@ class UsersController < ApplicationController #Ended by young + # edit + + # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 12637e2fb..b329e4c27 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -7,17 +7,6 @@ class ZipdownController < ApplicationController SAVE_FOLDER = "#{Rails.root}/files" OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip" - #通过作业Id找到项目(课程) - def find_project_by_bid_id - obj_class = params[:obj_class] - obj_id = params[:obj_id] - obj = obj_class.constantize.find(obj_id) - case obj.class.to_s.to_sym - when :Bid - @project = obj.courses[0] - end - end - def assort if params[:obj_class] == "Bid" bid = Bid.find params[:obj_id] @@ -33,8 +22,8 @@ class ZipdownController < ApplicationController end send_file zipfile, :filename => bid.name + ".zip", :type => detect_content_type(zipfile) if zipfile - rescue Exception => e - render file: 'public/no_file_found.html' + #rescue Exception => e + # render file: 'public/no_file_found.html' end #下载某一学生的作业的所有文件 @@ -56,12 +45,23 @@ class ZipdownController < ApplicationController else render_403 end - rescue => e - render file: 'public/file_not_found.html' + #rescue => e + # render file: 'public/file_not_found.html' end private + #通过作业Id找到项目(课程) + def find_project_by_bid_id + obj_class = params[:obj_class] + obj_id = params[:obj_id] + obj = obj_class.constantize.find(obj_id) + case obj.class.to_s.to_sym + when :Bid + @project = obj.courses[0] + end + end + def zip_bid(bid) # Todo: User Access Controll bid_homework_path = [] @@ -101,10 +101,20 @@ class ZipdownController < ApplicationController Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| input_filename.each do |filename| + flag = true + index = 1 rename_file = ic.iconv( (File.basename(filename)) ).to_s rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment - zipfile.add(rename_file, filename) + begin + zipfile.add(rename_file, filename) + flag = false + rescue Exception => e + zipfile.get_output_stream('FILE_NOTICE.txt') do |os| + os.write l(:label_file_exist) + end + next + end end unless not_exist_file.empty? zipfile.get_output_stream('FILE_LOST.txt') do |os| @@ -113,9 +123,9 @@ class ZipdownController < ApplicationController end end zipfile_name - rescue Errno => e - logger.error "[zipdown#zipping] ===> #{e}" - @error = e + #rescue Errno => e + # logger.error "[zipdown#zipping] ===> #{e}" + # @error = e end def detect_content_type(name) content_type = Redmine::MimeType.of(name) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cb88742ad..caf29ba90 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -140,10 +140,12 @@ module ApplicationHelper # * :text - Link text (default to attachment filename) # * :download - Force download (default: false) def link_to_attachment(attachment, options={}) + token = options[:token] if options[:token] text = options.delete(:text) || attachment.filename route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path html_options = options.slice!(:only_path) url = send(route_method, attachment, attachment.filename, options) + url << "?token=#{token}" unless token.nil? link_to text, url, html_options end @@ -492,7 +494,7 @@ module ApplicationHelper def principals_check_box_tags_ex(name, principals) s = '' principals.each do |principal| - s << "\n" + s << "\n" end s.html_safe end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index a862753ef..22eb9bfae 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -111,6 +111,10 @@ module CoursesHelper #garble count # end + #获取课程所有成员 + def course_all_member course + course.members + end # 学生人数计算 # add by nwb def studentCount course @@ -561,12 +565,13 @@ module CoursesHelper def course_in_current_or_next_term course is_current_term = false is_next_term = false - if course.time == Time.now.year && course.term == cur_course_term + year_now = Time.now.month < 3 ? Time.now.year - 1:Time.now.year + if course.time == year_now && course.term == cur_course_term is_current_term = true end - if cur_course_term == "秋季学期" && course.time == (Time.now.year + 1) && course.term == "春季学期" + if cur_course_term == "秋季学期" && course.time == (year_now + 1) && course.term == "春季学期" is_next_term = true - elsif cur_course_term == "春季学期" && course.time == Time.now.year && course.term == "秋季学期" + elsif cur_course_term == "春季学期" && course.time == year_now && course.term == "秋季学期" is_next_term = true end is_current_term || is_next_term diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 8390fc61c..6a708051a 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -224,6 +224,7 @@ module IssuesHelper # as an array of strings def details_to_strings(details, no_html=false, options={}) options[:only_path] = (options[:only_path] == false ? false : true) + options[:token] = options[:token] if options[:token] strings = [] values_by_field = {} details.each do |detail| @@ -312,7 +313,11 @@ module IssuesHelper old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank? if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key) # Link to the attachment if it has not been removed - value = link_to_attachment(atta, :download => true, :only_path => options[:only_path]) + if options[:token].nil? + value = link_to_attachment(atta, :download => true, :only_path => options[:only_path]) + else + value = link_to_attachment(atta, :download => true, :only_path => options[:only_path], :token => options[:token]) + end if options[:only_path] != false && atta.is_text? value += link_to( image_tag('magnifier.png'), diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb new file mode 100644 index 000000000..60d82c096 --- /dev/null +++ b/app/helpers/poll_helper.rb @@ -0,0 +1,77 @@ +# encoding: utf-8 +# +# Redmine - project management software +# Copyright (C) 2006-2013 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +module PollHelper + #判断选项是否被选中 + def answer_be_selected?(answer,user) + pv = answer.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id} ") + if !pv.nil? && pv.count > 0 + true + else + false + end + end + + #获取文本题答案 + def get_anwser_vote_text(question_id,user_id) + pv = PollVote.find_by_poll_question_id_and_user_id(question_id,user_id) + if pv.nil? + '' + else + pv.vote_text + end + end + + #判断用户是否已经提交了问卷 + def has_commit_poll?(poll_id,user_id) + pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id) + if pu.nil? + false + else + true + end + end + + #统计答题百分比,统计结果保留两位小数 + def statistics_result_percentage(e, t) + e = e.to_f + t = t.to_f + t == 0 ? 0 : format("%.2f", e*100/t) + end + + #多选的时候查询去重 + def total_answer id + total = PollVote.find_by_sql("SELECT distinct(user_id) FROM `poll_votes` where poll_question_id = #{id}").count + end + + #页面体型显示 + def options_show pq + case pq + when 1 + "单选题" + when 2 + "多选题" + when 3 + "单行主观题" + else + "多行主观题" + end + end + +end \ No newline at end of file diff --git a/app/models/contest.rb b/app/models/contest.rb index ad54e8fb4..650e363a8 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -15,7 +15,8 @@ class Contest < ActiveRecord::Base has_many :praise_tread, as: :praise_tread_object, dependent: :destroy has_many :contestnotifications, :dependent => :destroy, :include => :author - + + acts_as_attachable diff --git a/app/models/course_group.rb b/app/models/course_group.rb index 144c43c6e..c7fc81df4 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -12,11 +12,20 @@ class CourseGroup < ActiveRecord::Base before_destroy :set_member_nil attr_accessible :name - validates :name, :presence => true, :length => {:maximum => 20}, - :uniqueness => {case_sensitive: false} + validates :name, :presence => true, :length => {:maximum => 20} + validate :unique_name_and_course + + + def set_member_nil if self.members && self.members.count > 0 self.members.update_all("course_group_id = 0") end end + private + def unique_name_and_course + if CourseGroup.where("name=? and course_id=?", name, course_id).first + errors.add(:name, :groupname_repeat) + end + end end diff --git a/app/models/forum.rb b/app/models/forum.rb index 61ba528a0..eb8bb19d2 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -18,7 +18,7 @@ class Forum < ActiveRecord::Base acts_as_taggable scope :by_join_date, order("created_at DESC") - + after_create :send_email def reset_counters! self.class.reset_counters!(id) end @@ -33,6 +33,11 @@ class Forum < ActiveRecord::Base self.creator == user || user.admin? end + def send_email + Thread.start do + Mailer.forum_add(self).deliver if Setting.notified_events.include?('forum_add') + end + end # Updates topic_count, memo_count and last_memo_id attributes for +board_id+ def self.reset_counters!(forum_id) forum_id = forum_id.to_i diff --git a/app/models/forum_observer.rb b/app/models/forum_observer.rb new file mode 100644 index 000000000..1c514d6ab --- /dev/null +++ b/app/models/forum_observer.rb @@ -0,0 +1,8 @@ +class ForumObserver < ActiveRecord::Observer + def after_create(forum) + Thread.start do + Mailer.forum_add(forum).deliver if Setting.notified_events.include?('forum_add') + end + + end +end diff --git a/app/models/issue_observer.rb b/app/models/issue_observer.rb index 3369387ee..e404a4a1c 100644 --- a/app/models/issue_observer.rb +++ b/app/models/issue_observer.rb @@ -18,8 +18,13 @@ class IssueObserver < ActiveRecord::Observer def after_create(issue) - thread1=Thread.new do - Mailer.issue_add(issue).deliver if Setting.notified_events.include?('issue_added') - end + Thread.start do + # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, + recipients = issue.recipients - issue.watcher_recipients + issue.watcher_recipients + recipients.each do |rec| + Mailer.issue_add(issue,rec).deliver if Setting.notified_events.include?('issue_added') + end + end + end end diff --git a/app/models/issue_overdue.rb b/app/models/issue_overdue.rb index 5caec94c9..3002b74ef 100644 --- a/app/models/issue_overdue.rb +++ b/app/models/issue_overdue.rb @@ -20,7 +20,11 @@ class IssueOverdue < ActiveRecord::Base #发邮件 #puts "11" + issue.id.to_s #Mailer.issue_expire(issue).deliver - Mailer.issue_add(issue).deliver + recipients = issue.recipients + recipients.each do |rec| + + Mailer.issue_edit(issue,rec).deliver + end break end end diff --git a/app/models/journal_observer.rb b/app/models/journal_observer.rb index 0357fb74d..b58464a9b 100644 --- a/app/models/journal_observer.rb +++ b/app/models/journal_observer.rb @@ -23,8 +23,13 @@ class JournalObserver < ActiveRecord::Observer (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) || (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?) ) - Thread.new do - Mailer.issue_edit(journal).deliver + Thread.start do + # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, + recipients = journal.recipients - journal.watcher_recipients + journal.watcher_recipients + recipients.each do |rec| + + Mailer.issue_edit(journal,rec).deliver + end end end end diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb index 093002a2c..0e5f29d03 100644 --- a/app/models/journals_for_message_observer.rb +++ b/app/models/journals_for_message_observer.rb @@ -1,7 +1,9 @@ # Added by young class JournalsForMessageObserver < ActiveRecord::Observer def after_create(journals_for_message) + thread1 = Thread.start do Mailer.journals_for_message_add(User.current, journals_for_message).deliver + end end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a7f850766..f42c20acc 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -26,7 +26,39 @@ class Mailer < ActionMailer::Base def self.default_url_options { :host => Setting.host_name, :protocol => Setting.protocol } end - + + # 贴吧新建贴吧发送邮件 + # example Mailer.forum(forum).deliver + def forum_add(forum) + + redmine_headers 'Forum' => forum.id + @forum = forum + @author = forum.creator + recipients = forum.creator.mail + # cc = wiki_content.page.wiki.watcher_recipients - recipients + @issue_author_url = url_for(user_activities_url(@author)) + @forum_url = url_for(:controller => 'forums', :action => 'show', :id => forum.id) + mail :to => recipients,:subject => "[ #{l(:label_forum)} : #{forum.name} #{l(:notice_successful_create)}]" + + end + + def forum_message_added(memo) + @memo = memo + redmine_headers 'Memo' => memo.id + @forum = memo.forum + @author = memo.author + @forum_url = url_for(:controller => 'forums', :action => 'show', :id => @forum.id) + @issue_author_url = url_for(user_activities_url(@author)) + recipients ||= [] + mems = memo.self_and_siblings + mems.each do |mem| + recipients << mem.author.mail unless recipients.include? mem.author.mail + end + # cc = wiki_content.page.wiki.watcher_recipients - recipients + + @memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))) + mail :to => recipients,:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]" + end # Builds a Mail::Message object used to email recipients of the added journals for message. # 留言分为直接留言,和对留言人留言的回复 @@ -39,7 +71,7 @@ class Mailer < ActionMailer::Base @mail = journals_for_message.at_user if journals_for_message.at_user @message = journals_for_message.notes @title = "#@user #{t(:label_leave_your_message, :locale => 'zh')}" - + @issue_author_url = url_for(user_activities_url(@user)) @url = case journals_for_message.jour.class.to_s.to_sym # 判断留言的对象所属类型 when :Bid course_for_bid_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") @@ -62,13 +94,13 @@ class Mailer < ActionMailer::Base course = journals_for_message.jour @author = journals_for_message.user #课程的教师 - @teachers = searchTeacherAndAssistant journals_for_message.jour + @members = course_all_member journals_for_message.jour #收件人邮箱 @recipients ||= [] - @teachers.each do |teacher| - if teacher.user.notify_about? journals_for_message + @members.each do |teacher| + @recipients << teacher.user.mail - end + end mail :to => @recipients, @@ -95,29 +127,50 @@ class Mailer < ActionMailer::Base # Example: # issue_add(issue) => Mail::Message object # Mailer.issue_add(issue).deliver => sends an email to issue recipients - def issue_add(issue) + def issue_add(issue, recipients) issue_id = issue.project_index redmine_headers 'Project' => issue.project.identifier, 'Issue-Id' => issue_id, 'Issue-Author' => issue.author.login redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to message_id issue + @author = issue.author @issue = issue - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) - recipients = issue.recipients - cc = issue.watcher_recipients - recipients - mail :to => recipients, - :cc => cc, - :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" + user = User.find_by_mail(recipients) + + token = Token.new(:user =>user , :action => 'autologin') + token.save + @token = token + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value) + + # edit + @issue_author_url = url_for(user_activities_url(@author,:token => @token.value)) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) + + @user_url = url_for(my_account_url(user,:token => @token.value)) + + + subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" + mail(:to => recipients, + + :subject => subject) end + # issue.attachments.each do |attach| + # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}") + # end + # cc = issue.watcher_recipients - recipients + #mail.attachments['test'] = File.read("#{RAILS.root}/files/2015/01/150114094010_libegl.dll") + + + # Builds a Mail::Message object used to email recipients of the edited issue. # # Example: # issue_edit(journal) => Mail::Message object # Mailer.issue_edit(journal).deliver => sends an email to issue recipients - def issue_edit(journal) + def issue_edit(journal,recipients) issue = journal.journalized.reload issue_id = issue.project_index redmine_headers 'Project' => issue.project.identifier, @@ -127,18 +180,41 @@ class Mailer < ActionMailer::Base message_id journal references issue @author = journal.user - recipients = journal.recipients - # Watchers in cc - cc = journal.watcher_recipients - recipients + + user = User.find_by_mail(recipients) + + token = Token.new(:user =>user , :action => 'autologin') + token.save + @token = token + + + # edit + @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) + @user_url = url_for(my_account_url(user,:token => @token.value)) + + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value) + + + + + + s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] " s << "(#{issue.status.name}) " if journal.new_value_for('status_id') s << issue.subject @issue = issue @journal = journal - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") - mail :to => recipients, - :cc => cc, - :subject => s + # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") + mail(:to => recipients, + + :subject => s) + end + + def self.deliver_mailer(to,cc, subject) + mail :to => to, + :cc => cc, + :subject => subject end # 用户申请加入项目邮件通知 @@ -215,6 +291,7 @@ class Mailer < ActionMailer::Base redmine_headers 'Project' => document.project.identifier @author = User.current @document = document + @issue_author_url = url_for(user_activities_url(@author)) @document_url = url_for(:controller => 'documents', :action => 'show', :id => document) mail :to => document.recipients, :subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" @@ -230,6 +307,7 @@ class Mailer < ActionMailer::Base added_to = '' added_to_url = '' @author = attachments.first.author + @issue_author_url = url_for(user_activities_url(@author)) case container.class.name when 'Project' added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container) @@ -237,7 +315,7 @@ class Mailer < ActionMailer::Base recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail } when 'Course' added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container) - added_to = "#{l(:label_course)}: #{container}" + added_to = "#{l(:label_course)}: #{container.name}" recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail } when 'Version' added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project) @@ -278,13 +356,27 @@ class Mailer < ActionMailer::Base # news_added(news) => Mail::Message object # Mailer.news_added(news).deliver => sends an email to the news' project recipients def news_added(news) - redmine_headers 'Project' => news.project.identifier - @author = news.author - message_id news - @news = news - @news_url = url_for(:controller => 'news', :action => 'show', :id => news) - mail :to => news.recipients, - :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}" + + if news.project + redmine_headers 'Project' => news.project.identifier + @author = news.author + @issue_author_url = url_for(user_activities_url(@author)) + message_id news + @news = news + @news_url = url_for(:controller => 'news', :action => 'show', :id => news) + mail :to => news.recipients, + :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}" + elsif news.course + redmine_headers 'Course' => news.course.id + @author = news.author + @issue_author_url = url_for(user_activities_url(@author)) + message_id news + @news = news + recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail } + @news_url = url_for(:controller => 'news', :action => 'show', :id => news) + mail :to => recipients, + :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}" + end end # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added. @@ -294,15 +386,30 @@ class Mailer < ActionMailer::Base # Mailer.news_comment_added(comment) => sends an email to the news' project recipients def news_comment_added(comment) news = comment.commented - redmine_headers 'Project' => news.project.identifier - @author = comment.author - message_id comment - @news = news - @comment = comment - @news_url = url_for(:controller => 'news', :action => 'show', :id => news) - mail :to => news.recipients, - :cc => news.watcher_recipients, - :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}" + if news.project + redmine_headers 'Project' => news.project.identifier + @author = comment.author + @issue_author_url = url_for(user_activities_url(@author)) + message_id comment + @news = news + @comment = comment + @news_url = url_for(:controller => 'news', :action => 'show', :id => news) + mail :to => news.recipients, + :cc => news.watcher_recipients, + :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}" + elsif news.course + redmine_headers 'Course' => news.course.id + @author = comment.author + @issue_author_url = url_for(user_activities_url(@author)) + message_id comment + @news = news + @comment = comment + @news_url = url_for(:controller => 'news', :action => 'show', :id => news) + recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail } + + mail :to => recipients, + :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}" + end end # Builds a Mail::Message object used to email the recipients of the specified message that was posted. @@ -311,18 +418,35 @@ class Mailer < ActionMailer::Base # message_posted(message) => Mail::Message object # Mailer.message_posted(message).deliver => sends an email to the recipients def message_posted(message) - redmine_headers 'Project' => message.project.identifier, - 'Topic-Id' => (message.parent_id || message.id) - @author = message.author - message_id message - references message.parent unless message.parent.nil? - recipients = message.recipients - cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients) - @message = message - @message_url = url_for(message.event_url) - mail :to => recipients, - :cc => cc, - :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}" + if message.project + redmine_headers 'Project' => message.project.identifier, + 'Topic-Id' => (message.parent_id || message.id) + @author = message.author + @issue_author_url = url_for(user_activities_url(@author)) + message_id message + references message.parent unless message.parent.nil? + recipients = message.recipients + cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients) + @message = message + @message_url = url_for(message.event_url) + mail :to => recipients, + :cc => cc, + :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}" + elsif message.course + redmine_headers 'Course' => message.course.id, + 'Topic-Id' => (message.parent_id || message.id) + @author = message.author + @issue_author_url = url_for(user_activities_url(@author)) + message_id message + references message.parent unless message.parent.nil? + recipients = message.course.notified_users.select { |user| user.allowed_to?(:view_files, message.course) }.collect { |u| u.mail } + cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients) + @message = message + @message_url = url_for(message.event_url) + mail :to => recipients, + :cc => cc, + :subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}" + end end # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was added. @@ -615,5 +739,15 @@ class Mailer < ActionMailer::Base Rails.logger end - + def add_attachments(obj) + if email.attachments && email.attachments.any? + email.attachments.each do |attachment| + obj.attachments << Attachment.create(:container => obj, + :file => attachment.decoded, + :filename => attachment.filename, + :author => user, + :content_type => attachment.mime_type) + end + end + end end diff --git a/app/models/memo.rb b/app/models/memo.rb index cfc509923..f9482911a 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -43,7 +43,7 @@ class Memo < ActiveRecord::Base "parent_id", "replies_count" - after_create :add_author_as_watcher, :reset_counters!#,:be_user_score -- 公共区发帖暂不计入得分 + after_create :add_author_as_watcher, :reset_counters!, :sendmail#,:be_user_score -- 公共区发帖暂不计入得分 # after_update :update_memos_forum after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分 # after_create :send_notification @@ -54,6 +54,12 @@ class Memo < ActiveRecord::Base # includes(:forum => ).where() # } + def sendmail + thread1=Thread.new do + Mailer.forum_message_added(self).deliver if Setting.notified_events.include?('forum_message_added') + end + end + def cannot_reply_to_locked_topic errors.add :base, l(:label_memo_locked) if root.locked? && self != root end diff --git a/app/models/memo_observer.rb b/app/models/memo_observer.rb new file mode 100644 index 000000000..66cabe923 --- /dev/null +++ b/app/models/memo_observer.rb @@ -0,0 +1,8 @@ +class MemoObserver < ActiveRecord::Observer + def after_create(memo) + + thread1=Thread.new do + Mailer.forum_message_added(memo).deliver if Setting.notified_events.include?('forum_message_added') + end + end +end diff --git a/app/models/poll.rb b/app/models/poll.rb index 803ee6ac6..06f1369c1 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -3,7 +3,7 @@ class Poll < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :user - has_many :poll_questions, :dependent => :destroy + has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number" has_many :poll_users, :dependent => :destroy has_many :users, :through => :poll_users #该文件被哪些用户提交答案过 end diff --git a/app/models/poll_question.rb b/app/models/poll_question.rb index 66dcea67e..2d9912fc2 100644 --- a/app/models/poll_question.rb +++ b/app/models/poll_question.rb @@ -3,6 +3,6 @@ class PollQuestion < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :poll - has_many :poll_answers, :dependent => :destroy + has_many :poll_answers, :order => "#{PollAnswer.table_name}.answer_position",:dependent => :destroy has_many :poll_votes, :dependent => :destroy end diff --git a/app/models/user.rb b/app/models/user.rb index 735b80762..06f59c764 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -188,7 +188,7 @@ class User < Principal validates_confirmation_of :password, :allow_nil => true validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true validate :validate_password_length - + #validates_email_realness_of :mail before_create :set_mail_notification before_save :update_hashed_password before_destroy :remove_references_before_destroy @@ -380,7 +380,7 @@ class User < Principal raise text end - # Returns the user who matches the given autologin +key+ or nil + def self.try_to_autologin(key) user = Token.find_active_user('autologin', key, Setting.autologin.to_i) if user @@ -466,7 +466,11 @@ class User < Principal User.hash_password("#{salt}#{User.hash_password clear_password}") == hashed_password end end + def check_password1?(clear_password) + clear_password == hashed_password + + end # Generates a random salt and computes hashed_password for +clear_password+ # The hashed password is stored in the following form: SHA1(salt + SHA1(password)) def salt_password(clear_password) diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 2d6c35555..1009f405f 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -56,18 +56,30 @@ <%= link_to(bid.name, course_for_bid_path(bid), :class => 'bid_path') %> - + <% if User.current.logged? && is_cur_course_student(@course) %> <% cur_user_homework = cur_user_homework_for_bid(bid) %> + + <% if bid.open_anonymous_evaluation == 1 %> + <% case bid.comment_status %> + <% when 0 %> + 未开启匿评 + <% when 1 %> +   匿评中..   + <% when 2 %> +   匿评结束   + <% end %> + <% end%> + <% if cur_user_homework && cur_user_homework.empty? %> <%= link_to l(:label_commit_homework),new_exercise_book_path(bid) %> <% else %> - - <%= l(:lable_has_commit_homework)%> - + + 已 提 交 + <% end %> <% end %> <% if (User.current.admin?||User.current.allowed_to?(:as_teacher,@course)) %> diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index db1f555d3..e107e50b3 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -36,6 +36,7 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_attach/praise_alert') %>'); showModal('ajax-modal', '480px'); $('#ajax-modal').css('height','240px'); + $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); $('#ajax-modal').parent().css("top","").css("left","").css("width","511"); diff --git a/app/views/courses/_course_form.html.erb b/app/views/courses/_course_form.html.erb index c48d24935..d54741295 100644 --- a/app/views/courses/_course_form.html.erb +++ b/app/views/courses/_course_form.html.erb @@ -29,7 +29,7 @@ <%= l(:label_tags_course_name) %> *   - +

<%= f.fields_for @course do |m| %> @@ -38,7 +38,7 @@ diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 3937c1822..67e4da0f4 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -71,7 +71,7 @@ <%= l(:label_search)%>
- + <% end %> diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index dd2de21b7..abb896b61 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -1,33 +1,52 @@ +Trustie项目邮件 + + + + - -<%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.emails_header).html_safe %> -<%= yield %> -
-<%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.emails_footer).html_safe %> + + +
+
+
+

<%= l(:mail_issue_greetings)%>

+
+ <%= yield %> +
+ <%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.emails_footer).html_safe %> +
+
diff --git a/app/views/mailer/_issue.html.erb b/app/views/mailer/_issue.html.erb index f0dc88d8b..0ec585868 100644 --- a/app/views/mailer/_issue.html.erb +++ b/app/views/mailer/_issue.html.erb @@ -1,15 +1,50 @@ -

<%= link_to(h("#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}"), issue_url) %>

+ +

+ + <%= link_to(h("#{@author.login}(#{@author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> + <%= l(:mail_issue_title_userin)%> + <%= link_to(h("#{@issue.project.name}"), @project_url, :style=>'color:#1b55a7; font-weight:bold;') %><%= l(:mail_issue_title_active)%>

+
+
    +
  • <%= l(:mail_issue_subject)%><%= link_to(issue.subject, issue_url, :style=>'color:#1b55a7; font-weight:bold;') %>
  • +
  • <%= l(:mail_issue_sent_from)%><%= issue.project.name %><%= l(:mail_issue_from_project)%>
  • +
  • <%= l(:mail_issue_content)%> + + <% if @journal.nil? %> + <%= issue.description %> + <% else %> + <%= @journal.notes %> + <% end%> + +
  • +
  • -
      -
    • <%=l(:field_author)%>: <%=h issue.author %>
    • -
    • <%=l(:field_status)%>: <%=h issue.status %>
    • -
    • <%=l(:field_priority)%>: <%=h issue.priority %>
    • -
    • <%=l(:field_assigned_to)%>: <%=h issue.assigned_to %>
    • -
    • <%=l(:field_category)%>: <%=h issue.category %>
    • -
    • <%=l(:field_fixed_version)%>: <%=h issue.fixed_version %>
    • -<% issue.custom_field_values.each do |c| %> -
    • <%=h c.custom_field.name %>: <%=h show_value(c) %>
    • -<% end %> + <% unless @issue.attachments.nil? %> + <%= l(:mail_issue_attachments)%> + + <% @issue.attachments.each do |attach| %> +

      <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false, :style=>'color:#1b55a7; font-weight:bold;')%>

      + <% end %>
      + <% end %> + + +
    +
    + +
    +
+ +<%# issue.custom_field_values.each do |c| %> + diff --git a/app/views/mailer/_issue.text.erb b/app/views/mailer/_issue.text.erb index 7ab8acfeb..e0579824f 100644 --- a/app/views/mailer/_issue.text.erb +++ b/app/views/mailer/_issue.text.erb @@ -1,13 +1,23 @@ -<%= "#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}" %> -<%= issue_url %> -* <%=l(:field_author)%>: <%= issue.author %> -* <%=l(:field_status)%>: <%= issue.status %> -* <%=l(:field_priority)%>: <%= issue.priority %> -* <%=l(:field_assigned_to)%>: <%= issue.assigned_to %> -* <%=l(:field_category)%>: <%= issue.category %> -* <%=l(:field_fixed_version)%>: <%= issue.fixed_version %> -<% issue.custom_field_values.each do |c| %>* <%= c.custom_field.name %>: <%= show_value(c) %> -<% end -%> ----------------------------------------- -<%= issue.description %> + <%= link_to(h("#{@author.login}(#{@author.show_name})"), @issue_author_url) %> + <%= l(:mail_issue_title_userin)%> + <%= link_to(h("#{@issue.project.name}"),@project_url) %><%= l(:mail_issue_title_active)%> +<%= l(:mail_issue_subject)%><%= link_to(issue.subject, issue_url) %> +<%= l(:mail_issue_sent_from)%>| <%= l(:mail_issue_from_project)%> +<%= l(:mail_issue_content)%> + <% if @journal.nil? %> + <%= issue.description %> + <% else %> + <%= @journal.notes %> + <% end%> + <% unless @issue.attachments.nil? %> +<%= l(:mail_issue_attachments)%> + + + <% @issue.attachments.each do |attach| %> + <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %><%= l(:label_added) %> + <% end %> + <% end %> + + + <%= link_to( l(:mail_issue_reply), issue_url) %> diff --git a/app/views/mailer/forum_add.html.erb b/app/views/mailer/forum_add.html.erb new file mode 100644 index 000000000..7e26fd0df --- /dev/null +++ b/app/views/mailer/forum_add.html.erb @@ -0,0 +1,29 @@ + +

+ + <%= link_to(h("#{@forum.creator.login}(#{@forum.creator.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> + + <%= l(:label_forum_new)%> + <%= link_to(h(@forum.name), @forum_url,:style=>'color:#1b55a7; font-weight:bold;') %> +

+
+
    +
  • <%= l(:mail_issue_subject)%> + <%= link_to(h(@forum.name), @forum_url,:style=>'color:#1b55a7; font-weight:bold;') %>
  • + +
  • <%= l(:mail_issue_content)%> + + <%= @forum.description.html_safe %> + +
  • + +
+
+ +
+
+ + + diff --git a/app/views/mailer/forum_add.text.erb b/app/views/mailer/forum_add.text.erb new file mode 100644 index 000000000..ba7246a49 --- /dev/null +++ b/app/views/mailer/forum_add.text.erb @@ -0,0 +1,4 @@ +<%= @forum_url %> +<%= @author.name %> + +<%= @forum.description %> diff --git a/app/views/mailer/forum_message_added.html.erb b/app/views/mailer/forum_message_added.html.erb new file mode 100644 index 000000000..58657d46b --- /dev/null +++ b/app/views/mailer/forum_message_added.html.erb @@ -0,0 +1,32 @@ + +

+ + <%= link_to(h("#{@author.login}(#{@author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> + <%= l(:mail_issue_title_userin)%> + + <%= link_to(h(@forum.name), @forum_url,:style=>'color:#1b55a7; font-weight:bold;') %> + + <%= l(:mail_issue_title_active)%>

+
+
    +
  • <%= l(:mail_issue_subject)%> + <%= link_to(h(@memo.subject), @memo_url,:style=>'color:#1b55a7; font-weight:bold;') %>
  • +
  • <%= l(:mail_issue_sent_from)%> + <%= link_to(h(@forum.name), @forum_url,:style=>'color:#1b55a7; font-weight:bold;') %> +
  • +
  • <%= l(:mail_issue_content)%> + + <%= @memo.content.html_safe %> + +
  • + +
+
+ +
+
+ + + diff --git a/app/views/mailer/forum_message_added.text.erb b/app/views/mailer/forum_message_added.text.erb new file mode 100644 index 000000000..bd084cd40 --- /dev/null +++ b/app/views/mailer/forum_message_added.text.erb @@ -0,0 +1,5 @@ +<%= @memo_url %> +<%= @author.name %> + +<%= @memo.subject %> +<%= @memo.content %> diff --git a/app/views/mailer/issue_add.html.erb b/app/views/mailer/issue_add.html.erb index 8c9da02da..0b60097a7 100644 --- a/app/views/mailer/issue_add.html.erb +++ b/app/views/mailer/issue_add.html.erb @@ -1,3 +1,9 @@ -<%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => h(@issue.author)) %> -
-<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %> +
+ + + <%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %> + + +
+
<%= link_to( l(:mail_issue_footer), @user_url , :style=>'font-size:12px; font-weight:normal; color:#1b55a7;') %>
+ diff --git a/app/views/mailer/issue_add.text.erb b/app/views/mailer/issue_add.text.erb index dbba47d49..c5b391685 100644 --- a/app/views/mailer/issue_add.text.erb +++ b/app/views/mailer/issue_add.text.erb @@ -1,4 +1,3 @@ -<%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => @issue.author) %> ----------------------------------------- <%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> +<%= link_to( l(:mail_issue_footer), @user_url) %> \ No newline at end of file diff --git a/app/views/mailer/issue_edit.html.erb b/app/views/mailer/issue_edit.html.erb index be7076cb6..f7412402c 100644 --- a/app/views/mailer/issue_edit.html.erb +++ b/app/views/mailer/issue_edit.html.erb @@ -1,11 +1,11 @@ -<%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => h(@journal.user)) %> +
+ <%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => h(@journal.user)) %> -
    -<% details_to_strings(@journal.details, false, :only_path => false).each do |string| %> -
  • <%= string %>
  • -<% end %> -
+ +
+
+
-<%= textilizable(@journal, :notes, :only_path => false) %> -
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %> +
<%= link_to( l(:mail_issue_footer), @user_url, :style=>'font-size:12px; font-weight:normal; color:#1b55a7;') %>
+ diff --git a/app/views/mailer/issue_edit.text.erb b/app/views/mailer/issue_edit.text.erb index 45b8d3ecf..1434a7a33 100644 --- a/app/views/mailer/issue_edit.text.erb +++ b/app/views/mailer/issue_edit.text.erb @@ -1,12 +1,8 @@ <%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => @journal.user) %> -<% details_to_strings(@journal.details, true).each do |string| -%> -<%= string %> -<% end -%> -<% if @journal.notes? -%> -<%= @journal.notes %> -<% end -%> ----------------------------------------- +-------------------------------------------------------------------------------- <%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> + +<%= link_to( l(:mail_issue_footer), @user_url) %> \ No newline at end of file diff --git a/app/views/mailer/journals_for_message_add.html.erb b/app/views/mailer/journals_for_message_add.html.erb index 1aa8e45f8..cfb288d9d 100644 --- a/app/views/mailer/journals_for_message_add.html.erb +++ b/app/views/mailer/journals_for_message_add.html.erb @@ -1,5 +1,25 @@ -尊敬的用户,<%= @user %>给你留言了: -
<%= @message %>
-

点击链接查看最新回复<%= link_to(@url, @url) %>

-         

<%= link_to(l(:lable_not_receive_mail),"http://" + Setting.host_name + "/my/account")%>

+ +

+ + + <%= link_to(h("#{@user.login}(#{@user.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> + 给你留言了 +

+
+
    + +
  • <%= l(:mail_issue_content)%> + + <%= @message %> + +
  • + +
+
+ +
+
+ diff --git a/app/views/mailer/message_posted.html.erb b/app/views/mailer/message_posted.html.erb index f43a8cf0f..dbe41976a 100644 --- a/app/views/mailer/message_posted.html.erb +++ b/app/views/mailer/message_posted.html.erb @@ -1,4 +1,38 @@ -

<%=h @message.board.project.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url) %>

-<%=h @message.author %> -<%= textilizable(@message, :content, :only_path => false) %> +

+ + <%= link_to(h("#{@message.author.login}(#{@message.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> + + <%= l(:mail_issue_title_userin)%> + + <% if @message.project %> + <%=h @message.board.project.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url,:style=>'color:#1b55a7; font-weight:bold;') %> + <% elsif @message.course %> + <%=h @message.board.course.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url,:style=>'color:#1b55a7; font-weight:bold;') %> + <% end %> + <%= l(:mail_issue_title_active)%>

+
+
    +
  • <%= l(:mail_issue_subject)%> <%= link_to(h(@message.subject), @message_url, :style=>'color:#1b55a7; font-weight:bold;') %>
  • +
  • <%= l(:mail_issue_sent_from)%> + <% if @message.project %> + <%=h @message.board.project.name %> - <%=h @message.board.name %> + <% elsif @message.course %> + <%=h @message.board.course.name %> - <%=h @message.board.name %> + <% end %> +
  • +
  • <%= l(:mail_issue_content)%> + + <%= @message.content %> + +
  • + +
+
+ +
+
+ + diff --git a/app/views/mailer/news_added.html.erb b/app/views/mailer/news_added.html.erb index 758ebccb8..ca8f3c1b0 100644 --- a/app/views/mailer/news_added.html.erb +++ b/app/views/mailer/news_added.html.erb @@ -1,4 +1,41 @@ -

<%= link_to(h(@news.title), @news_url) %>

-<%=h @news.author.name %> -<%= textilizable(@news, :description, :only_path => false) %> +

+ + + <%= link_to(h("#{@news.author.login}(#{@news.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> + + <%= l(:mail_issue_title_userin)%> + + <% if @news.project %> + <%=h @news.project.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %> + <% elsif @news.course %> + <%=h @news.course.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %> + <% end %> + <%= l(:mail_issue_title_active)%>

+
+
    +
  • <%= l(:mail_issue_subject)%> + <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
  • +
  • <%= l(:mail_issue_sent_from)%> + <% if @news.project %> + <%=h @news.project.name %> + <% elsif @news.course %> + <%=h @news.course.name %> + <% end %> +
  • +
  • <%= l(:mail_issue_content)%> + + <%= @news.description %> + +
  • + +
+
+ +
+
+ + + diff --git a/app/views/mailer/news_comment_added.html.erb b/app/views/mailer/news_comment_added.html.erb index ef2be0f65..5ac95a571 100644 --- a/app/views/mailer/news_comment_added.html.erb +++ b/app/views/mailer/news_comment_added.html.erb @@ -1,5 +1,40 @@ -

<%= link_to(h(@news.title), @news_url) %>

-

<%= l(:text_user_wrote, :value => h(@comment.author)) %>

+

+ + <%= link_to(h("#{@comment.author.login}(#{@comment.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> + + <%= l(:mail_issue_title_userin)%> + + <% if @news.project %> + <%=h @news.project.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %> + <% elsif @news.course %> + <%=h @news.course.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %> + <% end %> + <%= l(:mail_issue_title_active)%>

+
+
    +
  • <%= l(:mail_issue_subject)%> + <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
  • +
  • <%= l(:mail_issue_sent_from)%> + <% if @news.project %> + <%=h @news.project.name %> + <% elsif @news.course %> + <%=h @news.course.name %> + <% end %> +
  • +
  • <%= l(:mail_issue_content)%> + + <%= @news.description %> + +
  • + +
+
+ +
+
+ + -<%= textilizable @comment, :comments, :only_path => false %> diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index ebdab208d..47cfb4221 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -123,10 +123,10 @@

-

- - @@ -187,19 +187,19 @@

- <%= l(:label_gender) %>   +

+ <%= select_tag 'gender', "".html_safe, :class => 'gender' %>

<% else %> <% if @user.user_extensions.gender == 0 %> -

- <%= l(:label_gender) %>   +

+ <%= select_tag 'gender', "".html_safe, :class => 'gender' %>

<% else %>

- <%= l(:label_gender) %>   + <%= select_tag 'gender', "".html_safe, :class => 'gender' %>

<% end %> @@ -212,9 +212,9 @@ -
-

<%= l(:lable_school_list)%>

+

<%= l(:lable_school_list)%>

  
    @@ -318,7 +318,7 @@ }); -

    +

- + <%= l(:label_class_period) %> *   @@ -118,7 +118,7 @@

- + <%= l(:text_command) %> <% end %> @@ -127,9 +127,7 @@ <%= l(:label_new_course_description) %>      - +

diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb index 41b4f41e7..dd543ec2c 100644 --- a/app/views/courses/_member_list.html.erb +++ b/app/views/courses/_member_list.html.erb @@ -56,24 +56,36 @@

    <% if @canShowCode %> -
  • - <%= l(:label_bidding_user_studentname) %> : - <%= link_to member.user.show_name, user_path(member.user) %> -
  • -
    + <% if member.user.show_name == '' && member.user.user_extensions.student_id == '' %> +
  • + <%= l(:label_username)%> + <%= link_to(member.user.name, user_path(member.user)) %> +
  • + <% else %> + <% unless member.user.show_name == ''%> +
  • + <%= l(:label_bidding_user_studentname) %> : + <%= link_to member.user.show_name, user_path(member.user) %> +
  • +
    + <% end %> + <% unless member.user.user_extensions.student_id == '' %> +
  • + <%= l(:label_bidding_user_studentcode) %> : + <%= link_to member.user.user_extensions.student_id, user_path(member.user) %> +
  • + <% end %> + <% end %> <%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %> <% else %> - <%= content_tag "li", link_to(member.user.name, user_path(member.user)) %> - <% end %> +
  • + <%= l(:label_username)%> + <%= link_to(member.user.name, user_path(member.user)) %> +
  • + <% end %> - <% if @canShowCode %> -
  • - <%= l(:label_bidding_user_studentcode) %> : - <%= link_to member.user.user_extensions.student_id, user_path(member.user) %> -
  • - <%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %> - <% end %> +
<% if @subPage_title == l(:label_student_list) %> <%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), { diff --git a/app/views/courses/_member_list_detail.html.erb b/app/views/courses/_member_list_detail.html.erb index f37067cb5..bc6cbd242 100644 --- a/app/views/courses/_member_list_detail.html.erb +++ b/app/views/courses/_member_list_detail.html.erb @@ -7,24 +7,36 @@ <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %>
    <% if @canShowCode %> -
  • - <%= l(:label_bidding_user_studentname) %> : - <%= link_to member.user.show_name, user_path(member.user) %> - -

  • + <% if member.user.show_name == '' && member.user.user_extensions.student_id == '' %> +
  • + <%= l(:label_username)%> + <%= link_to(member.user.name, user_path(member.user)) %> +
  • + <% else %> + <% unless member.user.show_name == ''%> +
  • + <%= l(:label_bidding_user_studentname) %> : + <%= link_to member.user.show_name, user_path(member.user) %> +
  • +
    + <% end %> + <% unless member.user.user_extensions.student_id == '' %> +
  • + <%= l(:label_bidding_user_studentcode) %> : + <%= link_to member.user.user_extensions.student_id, user_path(member.user) %> +
  • + <% end %> + <% end %> <%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %> <% else %> - <%= content_tag "li", link_to(member.user.name, user_path(member.user)) %> +
  • + <%= l(:label_username)%> + <%= link_to(member.user.name, user_path(member.user)) %> +
  • <% end %> - <% if @canShowCode %> -
  • - <%= l(:label_bidding_user_studentcode) %> : - <%= link_to member.user.user_extensions.student_id, user_path(member.user) %> -
  • - <%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %> - <% end %> +
<% if @subPage_title == l(:label_student_list) %> <%= link_to format("%0.2f",member.score.to_s), { diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index 2599760ad..e2c1fb418 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -6,7 +6,8 @@ $.get( '<%=valid_ajax_course_path%>', { valid: "name", - value: document.getElementById('group_name').value }, + value: document.getElementById('group_name').value, + course_id: <%= @course.id %> }, function (data) { if (!data.valid) { alert(data.message); @@ -56,7 +57,7 @@ <%= stylesheet_link_tag 'course_group', :media => 'all' %> -
+
@@ -275,6 +299,24 @@
+ + +
+ + <%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id)%> +
+

NEW

+
+
+
diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 8cae51063..0d234a69c 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -70,7 +70,7 @@ <%= l(:label_search)%>
- + <% end %>
+ + + + + + + <% poll_question.poll_answers.each do |poll_answer| %> + + + + + + <% end %> + + + + + + +
<%= l(:label_poll_options) %> <%= l(:label_poll_subtotal) %> <%= l(:label_poll_proportion) %>
<%= poll_answer.answer_text %> <%= poll_answer.poll_votes.count %> +
+ +
+ <%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>%
<%= l(:label_poll_valid_commit) %> <%= total_answer(poll_question.id) %> 
+ + diff --git a/app/views/poll/_commit_alert.html.erb b/app/views/poll/_commit_alert.html.erb new file mode 100644 index 000000000..3910bc8b5 --- /dev/null +++ b/app/views/poll/_commit_alert.html.erb @@ -0,0 +1,12 @@ +
+ <% if status == 0 %> +

提交成功!

+ <%= link_to "确定", poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course'),:class => 'commit'%> + <% elsif status == 1 %> +

您还有尚未作答的必答题目请完成后再提交!

+ <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> + <% else %> +

发生未知错误,请检查您的网络。

+ <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> + <% end %> +
diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb new file mode 100644 index 000000000..066eafe0d --- /dev/null +++ b/app/views/poll/_edit_MC.html.erb @@ -0,0 +1,48 @@ +<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%> + + + +
+
+ + + + /> + +
+
+
    + <% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %> +
  • + + + + +
  • +
    + <% end%> +
+
+ +
+
+ +<% end%> \ No newline at end of file diff --git a/app/views/poll/_edit_MCQ.html.erb b/app/views/poll/_edit_MCQ.html.erb new file mode 100644 index 000000000..129f50e94 --- /dev/null +++ b/app/views/poll/_edit_MCQ.html.erb @@ -0,0 +1,44 @@ +<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%> + +
+
+ + + /> + +
+
+
    + <% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %> +
  • + + + + +
  • +
    + <% end%> +
+
+ +
+
+<% end%> \ No newline at end of file diff --git a/app/views/poll/_edit_head.html.erb b/app/views/poll/_edit_head.html.erb new file mode 100644 index 000000000..ed90a5ef8 --- /dev/null +++ b/app/views/poll/_edit_head.html.erb @@ -0,0 +1,15 @@ +<%= form_for @poll,:remote => true do |f|%> +
+
+ +
+
+ +
+ +
+
+<% end%> diff --git a/app/views/poll/_edit_mulit.html.erb b/app/views/poll/_edit_mulit.html.erb new file mode 100644 index 000000000..d498169f4 --- /dev/null +++ b/app/views/poll/_edit_mulit.html.erb @@ -0,0 +1,28 @@ +<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%> + +
+
+ + + + /> + +
+
+ + + +
+ +
+
+<% end%> \ No newline at end of file diff --git a/app/views/poll/_edit_single.html.erb b/app/views/poll/_edit_single.html.erb new file mode 100644 index 000000000..2c2d41e0f --- /dev/null +++ b/app/views/poll/_edit_single.html.erb @@ -0,0 +1,24 @@ +<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%> + +
+
+ + + + /> + +
+ +
+
+<% end%> \ No newline at end of file diff --git a/app/views/poll/_new_MC.html.erb b/app/views/poll/_new_MC.html.erb new file mode 100644 index 000000000..a7f9e441b --- /dev/null +++ b/app/views/poll/_new_MC.html.erb @@ -0,0 +1,43 @@ +<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> + +
+
+ + + + + +
+
+
    +
  • + + + + +
  • +
    +
  • + + + + +
  • +
    +
  • + + + + +
  • +
    +
+
+ +
+
+ +<% end%> \ No newline at end of file diff --git a/app/views/poll/_new_MCQ.html.erb b/app/views/poll/_new_MCQ.html.erb new file mode 100644 index 000000000..027a1c1f6 --- /dev/null +++ b/app/views/poll/_new_MCQ.html.erb @@ -0,0 +1,41 @@ +<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> +
+
+ + + + + +
+
+
    +
  • + + + + +
  • +
    +
  • + + + + +
  • +
    +
  • + + + + +
  • +
    +
+
+ +
+
+<% end%> \ No newline at end of file diff --git a/app/views/poll/_new_mulit.html.erb b/app/views/poll/_new_mulit.html.erb new file mode 100644 index 000000000..02f7a71a7 --- /dev/null +++ b/app/views/poll/_new_mulit.html.erb @@ -0,0 +1,21 @@ +<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> +
+
+ + + + + +
+
+ + + +
+ +
+
+<% end%> \ No newline at end of file diff --git a/app/views/poll/_new_single.html.erb b/app/views/poll/_new_single.html.erb new file mode 100644 index 000000000..ffc525546 --- /dev/null +++ b/app/views/poll/_new_single.html.erb @@ -0,0 +1,16 @@ +<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> +
+
+ + + + + +
+ +
+
+<% end%> \ No newline at end of file diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb new file mode 100644 index 000000000..1bf6b3716 --- /dev/null +++ b/app/views/poll/_poll.html.erb @@ -0,0 +1,68 @@ +<% has_commit = has_commit_poll?(poll.id ,User.current)%> +<% poll_name = poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name%> +
  • + <% if @is_teacher %> + <% if has_commit %> + + <%= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl", :style => "max-width: 550px;width: 550px;" %> + + <% else %> + <%= link_to poll_name, poll_path(poll.id), :class => "polls_title polls_title_w fl" %> + <% end %> + <% else %> + <% if has_commit && poll.polls_status == 2 %> + <%= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl", :style => "max-width: 500px;width: auto;" %> + <% elsif !has_commit && poll.polls_status == 2 %> + <%= link_to poll_name, poll_path(poll.id), :class => "polls_title polls_title_w fl", :style => "max-width: 550px;width: 550px;" %> + <% end %> + <% end %> +
  • +<% if !@is_teacher && has_commit && poll.polls_status == 2%> +
  • 已答
  • +<% end %> + +<%if @is_teacher%> + <% if poll.polls_status == 1 %> +
  • 统计结果
  • + <% elsif poll.polls_status == 2%> +
  • + <%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%> +
  • + <% end%> +<% end%> + +
  • + <%if @is_teacher %> + <% if poll.polls_status == 1 %> + 发布问卷 + <% elsif poll.polls_status == 2%> + 取消发布 + <% end%> + <% end%> +
  • +
  • + <% if @is_teacher %> + + <%= link_to(l(:button_delete), poll, + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml20 mr10") %> + <% end%> +
  • +
  • + <% if @is_teacher%> + <% if poll.polls_status == 1 %> + <%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%> + <% elsif poll.polls_status == 2%> +
  • 编辑
  • + <% end%> + <% end%> + + + + + + + + +
  • + <%= format_time poll.created_at%> +
  • \ No newline at end of file diff --git a/app/views/poll/_poll_content.html.erb b/app/views/poll/_poll_content.html.erb new file mode 100644 index 000000000..40c9a6181 --- /dev/null +++ b/app/views/poll/_poll_content.html.erb @@ -0,0 +1,26 @@ +<% poll.poll_questions.each do |poll_question|%> +
    +
    + <% if poll_question.question_type == 1%> + <%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %> + <% elsif poll_question.question_type == 2%> + <%= render :partial => 'show_MCQ', :locals => {:poll_question => poll_question} %> + <% elsif poll_question.question_type == 3%> + <%= render :partial => 'show_single', :locals => {:poll_question => poll_question} %> + <% elsif poll_question.question_type == 4%> + <%= render :partial => 'show_mulit', :locals => {:poll_question => poll_question} %> + <% end%> +
    + +
    +<% end %> \ No newline at end of file diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb new file mode 100644 index 000000000..1d0dee837 --- /dev/null +++ b/app/views/poll/_poll_form.html.erb @@ -0,0 +1,139 @@ + + + + + 问卷调查_问卷编辑 + <%= stylesheet_link_tag 'polls', :media => 'all' %> + <%#= javascript_include_tag "polls" %> + + + + + +
    + + + +
    + <%= render :partial => 'edit_head', :locals => {:poll => @poll}%> +
    + + +
    + <%= render :partial => 'poll_content', :locals => {:poll => @poll}%> +
    + + + + +
    +
    + + +
    + +
    + + diff --git a/app/views/poll/_poll_question.html.erb b/app/views/poll/_poll_question.html.erb new file mode 100644 index 000000000..7731c9821 --- /dev/null +++ b/app/views/poll/_poll_question.html.erb @@ -0,0 +1,12 @@ + +<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %> + + + + + +<% end %> + \ No newline at end of file diff --git a/app/views/poll/_poll_republish.html.erb b/app/views/poll/_poll_republish.html.erb new file mode 100644 index 000000000..3f93b6b3d --- /dev/null +++ b/app/views/poll/_poll_republish.html.erb @@ -0,0 +1,32 @@ + + + + + + + +
    +
    +
    +

    + 问卷取消发布后学生提交的问卷答案将会被清空, +
    + 是否确定取消发布该问卷? +

    +
    + <%= link_to "确 定",republish_poll_poll_path(poll.id), :class => "upload_btn", :onclick => "clickCanel();" %> + + 取  消 + +
    +
    +
    + +
    + +
    + + + diff --git a/app/views/poll/_poll_submit.html.erb b/app/views/poll/_poll_submit.html.erb new file mode 100644 index 000000000..af3ca2d42 --- /dev/null +++ b/app/views/poll/_poll_submit.html.erb @@ -0,0 +1,29 @@ + + + + + + + +
    +
    +
    +

    问卷发布后将不能对问卷进行修改, +
    + 是否确定发布该问卷? +

    +
    + <%= link_to "确 定",publish_poll_poll_path(poll.id,:is_remote => is_remote), :class => "upload_btn", :onclick => "clickCanel();" %> + + 取  消 + +
    +
    +
    +
    +
    + + + diff --git a/app/views/poll/_quiz_answers.html.erb b/app/views/poll/_quiz_answers.html.erb new file mode 100644 index 000000000..34086d25e --- /dev/null +++ b/app/views/poll/_quiz_answers.html.erb @@ -0,0 +1,18 @@ +
    + + + + + + <% poll_question.poll_votes.each do |poll_vote| %> + + + + <% end %> + + + + +
    <%= l(:label_answer) %>
    <%= poll_vote.vote_text.html_safe %>
    <%= l(:label_poll_answer_valid_result) %> <%= l(:label_answer_total) %><%= poll_question.poll_votes.count %>
    +
    + diff --git a/app/views/poll/_show_MC.html.erb b/app/views/poll/_show_MC.html.erb new file mode 100644 index 000000000..ff8e52f25 --- /dev/null +++ b/app/views/poll/_show_MC.html.erb @@ -0,0 +1,32 @@ +
    +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [单选题] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    + <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + +
    +
    + + + <% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %> + + + + <% end %> + +
    + +
    +
    +
    \ No newline at end of file diff --git a/app/views/poll/_show_MCQ.html.erb b/app/views/poll/_show_MCQ.html.erb new file mode 100644 index 000000000..63b9d1c1f --- /dev/null +++ b/app/views/poll/_show_MCQ.html.erb @@ -0,0 +1,32 @@ +
    +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [多选题] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    + <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + +
    +
    + + + <% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %> + + + + <% end %> + +
    + +
    +
    +
    \ No newline at end of file diff --git a/app/views/poll/_show_MCQ_result.html.erb b/app/views/poll/_show_MCQ_result.html.erb new file mode 100644 index 000000000..f46882881 --- /dev/null +++ b/app/views/poll/_show_MCQ_result.html.erb @@ -0,0 +1,26 @@ +
  • +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [多选题] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    +
    +
    + + + <% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%> + + + + <% end%> + +
    + <%= answer.poll_answer.answer_text %> +
    +
    +
  • \ No newline at end of file diff --git a/app/views/poll/_show_MC_result.html.erb b/app/views/poll/_show_MC_result.html.erb new file mode 100644 index 000000000..7f2cbbd83 --- /dev/null +++ b/app/views/poll/_show_MC_result.html.erb @@ -0,0 +1,27 @@ +
  • +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [单选题] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    +
    +
    + + + <% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%> + + + + <% end%> + + +
    + <%= answer.poll_answer.answer_text %> +
    +
    +
  • \ No newline at end of file diff --git a/app/views/poll/_show_head.html.erb b/app/views/poll/_show_head.html.erb new file mode 100644 index 000000000..ce74dc10a --- /dev/null +++ b/app/views/poll/_show_head.html.erb @@ -0,0 +1,10 @@ +
    + +

    + <%= poll.polls_name%> +

    +

    + <%= @poll.polls_description%> +

    +
    +
    \ No newline at end of file diff --git a/app/views/poll/_show_mulit.html.erb b/app/views/poll/_show_mulit.html.erb new file mode 100644 index 000000000..2d52fffb5 --- /dev/null +++ b/app/views/poll/_show_mulit.html.erb @@ -0,0 +1,21 @@ +
    +
    +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [多行主观] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    + <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/app/views/poll/_show_mulit_result.html.erb b/app/views/poll/_show_mulit_result.html.erb new file mode 100644 index 000000000..786ed9460 --- /dev/null +++ b/app/views/poll/_show_mulit_result.html.erb @@ -0,0 +1,20 @@ +
  • +
    +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [多行主观] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    +
    +
    +

    + <%= get_anwser_vote_text(poll_question.id,User.current.id).html_safe%> +

    +
    +
    +
  • \ No newline at end of file diff --git a/app/views/poll/_show_single.html.erb b/app/views/poll/_show_single.html.erb new file mode 100644 index 000000000..8caa7b1a5 --- /dev/null +++ b/app/views/poll/_show_single.html.erb @@ -0,0 +1,19 @@ +
    +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [单行主观] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    + <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + +
    +
    + +
    +
    \ No newline at end of file diff --git a/app/views/poll/_show_single_result.html.erb b/app/views/poll/_show_single_result.html.erb new file mode 100644 index 000000000..07559773d --- /dev/null +++ b/app/views/poll/_show_single_result.html.erb @@ -0,0 +1,18 @@ +
  • +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [单行主观] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    +
    +
    +

    + <%= get_anwser_vote_text poll_question.id,User.current.id%> +

    +
    +
  • \ No newline at end of file diff --git a/app/views/poll/add_answer.html.erb b/app/views/poll/add_answer.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/poll/commit_answer.js.erb b/app/views/poll/commit_answer.js.erb new file mode 100644 index 000000000..b698d8658 --- /dev/null +++ b/app/views/poll/commit_answer.js.erb @@ -0,0 +1,3 @@ +<% if @pv_saved %> +$('#poll_vote_poll_answer_id_<%= @pv.poll_answer_id %>').checked = true; +<% end %> \ No newline at end of file diff --git a/app/views/poll/commit_poll.js.erb b/app/views/poll/commit_poll.js.erb new file mode 100644 index 000000000..f7a1b56fe --- /dev/null +++ b/app/views/poll/commit_poll.js.erb @@ -0,0 +1,9 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status}) %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').css('height','100px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("alert_box"); \ No newline at end of file diff --git a/app/views/poll/create_poll_question.js.erb b/app/views/poll/create_poll_question.js.erb new file mode 100644 index 000000000..ac44ebb4c --- /dev/null +++ b/app/views/poll/create_poll_question.js.erb @@ -0,0 +1,26 @@ +$("#new_poll_question").html(""); +$("#poll_content").append("
    " + + "
    " + + "<% if @poll_questions.question_type == 1%>" + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:poll_question => @poll_questions}) %>" + + "<% elsif @poll_questions.question_type == 2%>" + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:poll_question => @poll_questions}) %>" + + "<% elsif @poll_questions.question_type == 3%>" + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:poll_question => @poll_questions}) %>" + + "<% elsif @poll_questions.question_type == 4%>" + + "<%= escape_javascript(render :partial => 'show_mulit', :locals => {:poll_question => @poll_questions}) %>" + + "<% end%>" + + "
    " + + "" + + "
    "); + diff --git a/app/views/poll/delete_poll_question.js.erb b/app/views/poll/delete_poll_question.js.erb new file mode 100644 index 000000000..85057e550 --- /dev/null +++ b/app/views/poll/delete_poll_question.js.erb @@ -0,0 +1 @@ +$("#poll_content").html("<%= escape_javascript(render :partial => 'poll_content', :locals => {:poll => @poll}) %>"); \ No newline at end of file diff --git a/app/views/poll/destroy.js.erb b/app/views/poll/destroy.js.erb new file mode 100644 index 000000000..cf94b5661 --- /dev/null +++ b/app/views/poll/destroy.js.erb @@ -0,0 +1,4 @@ +<% if @poll%> + $("#polls_<%= @poll.id%>").remove(); +<%else%> +<% end %> \ No newline at end of file diff --git a/app/views/poll/edit.html.erb b/app/views/poll/edit.html.erb new file mode 100644 index 000000000..d346d0699 --- /dev/null +++ b/app/views/poll/edit.html.erb @@ -0,0 +1,2 @@ +<%= render :partial => 'poll_form'%> + diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb new file mode 100644 index 000000000..3962768da --- /dev/null +++ b/app/views/poll/index.html.erb @@ -0,0 +1,84 @@ +<%= stylesheet_link_tag 'polls', :media => 'all' %> + +
    +
    +

    所有问卷 + (<%= @obj_count%>) +

    + <% if @is_teacher%> + <%= link_to l(:label_new_poll), new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => "newbtn" %> + <% end%> +
    +
    +
    + <% @polls.each do |poll|%> +
      + <%= render :partial => 'poll', :locals => {:poll => poll} %> +
    +
    + <% end%> + +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    +
    +
    + +
    \ No newline at end of file diff --git a/app/views/poll/new.html.erb b/app/views/poll/new.html.erb new file mode 100644 index 000000000..eddb3a590 --- /dev/null +++ b/app/views/poll/new.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'poll_form'%> \ No newline at end of file diff --git a/app/views/poll/poll_result.html.erb b/app/views/poll/poll_result.html.erb new file mode 100644 index 000000000..a7cb415b3 --- /dev/null +++ b/app/views/poll/poll_result.html.erb @@ -0,0 +1,36 @@ +<%= stylesheet_link_tag 'polls', :media => 'all' %> +
    +
    +

    + <%= @poll.polls_name.empty? ? l(:label_poll_new) : @poll.polls_name %> +

    +

    + <%= @poll.polls_description%> +

    +
    +
    +
      + <% @poll_questions.each do |poll_question|%> + <% if poll_question.question_type == 1%> + <%= render :partial => 'show_MC_result', :locals => {:poll_question => poll_question} %> + <% elsif poll_question.question_type == 2%> + <%= render :partial => 'show_MCQ_result', :locals => {:poll_question => poll_question} %> + <% elsif poll_question.question_type == 3%> + <%= render :partial => 'show_single_result', :locals => {:poll_question => poll_question} %> + <% elsif poll_question.question_type == 4%> + <%= render :partial => 'show_mulit_result', :locals => {:poll_question => poll_question} %> + <% end%> + <% end%> +
    +
    +
    + + +
    +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    +
    +
    +
    + diff --git a/app/views/poll/publish_poll.js.erb b/app/views/poll/publish_poll.js.erb new file mode 100644 index 000000000..ad052f8f2 --- /dev/null +++ b/app/views/poll/publish_poll.js.erb @@ -0,0 +1,2 @@ +$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>"); +alert("发布成功"); \ No newline at end of file diff --git a/app/views/poll/republish_poll.js.erb b/app/views/poll/republish_poll.js.erb new file mode 100644 index 000000000..a2d8e28fa --- /dev/null +++ b/app/views/poll/republish_poll.js.erb @@ -0,0 +1,2 @@ +$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>"); +alert("取消成功"); \ No newline at end of file diff --git a/app/views/poll/show.html.erb b/app/views/poll/show.html.erb new file mode 100644 index 000000000..08c2608d0 --- /dev/null +++ b/app/views/poll/show.html.erb @@ -0,0 +1,256 @@ + + + + + <%= l(:label_poll_title) %> + <%= stylesheet_link_tag 'polls', :media => 'all' %> + + + + + +
    +
    +

    + <%= @poll.polls_name%> +

    +

    + <%= @poll.polls_description %> +

    +
    + + +
    +
      + <% @poll_questions.each do |pq| %> + <% if pq.question_type == 1 %> + +
    1. +
      + <%= l(:label_question_number,:question_number => pq.question_number) %> + <%= pq.question_title %> + [单选题] + <% if pq.is_necessary == 1 %> + * + <% end %> +
      +
      +
      +
      + + + <% pq.poll_answers.each do |pa| %> + + + + <% end %> + +
      + +
      +
      +
      +
    2. + <% elsif pq.question_type == 2 %> + +
    3. +
      + <%= l(:label_question_number,:question_number => pq.question_number) %> + <%= pq.question_title %> + [多选题] + <% if pq.is_necessary == 1 %> + * + <% end %> +
      +
      +
      +
      + + + <% pq.poll_answers.each do |pa| %> + + + + <% end %> + +
      + +
      +
      +
      +
    4. + <% elsif pq.question_type == 3 %> + +
    5. +
      + <%= l(:label_question_number,:question_number => pq.question_number) %> + <%= pq.question_title %> + [单行主观] + <% if pq.is_necessary == 1 %> + * + <% end %> +
      +
      +
      + + > +
      +
    6. + <% elsif pq.question_type == 4 %> + +
    7. +
      +
      + <%= l(:label_question_number,:question_number => pq.question_number) %> + <%= pq.question_title %> + [多行主观] + <% if pq.is_necessary == 1 %> + * + <% end %> +
      +
      +
      + +
      " onblur="onblur_<%= pq.id %>(this);"><%= get_anwser_vote_text(pq.id,User.current.id).html_safe %>
      +
      +
      +
    8. + <% else %> + + <% end %> + <% end %> +
    +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    +
    +
    + <% if @poll.polls_status == 2 %> + <%= link_to l(:button_submit),commit_poll_poll_path(@poll), :method => :post,:class => "ur_button",:format => 'js',:remote=>true %> + <% end %> +
    +
    +
    <%= l(:label_complete_question) %> <%= format "%.2f" ,@percent %>%
    + +
    + + + +
    + + diff --git a/app/views/poll/statistics_result.html.erb b/app/views/poll/statistics_result.html.erb new file mode 100644 index 000000000..fd78d9230 --- /dev/null +++ b/app/views/poll/statistics_result.html.erb @@ -0,0 +1,46 @@ + + + + + + <%= l(:label_poll_result) %> + + <%= stylesheet_link_tag 'polls', :media => 'all' %> + + +
    +
    +

    + <%= @poll.polls_name %> + <%= l(:label_poll) %> +

    +
    +
    + <% @poll_questions.each do |poll_question| %> +
      +
    1. +
      + + 第<%= poll_question.question_number %>题: + + <%= poll_question.question_title %> + + [<%= options_show(poll_question.question_type) %>] + +
      + <% if poll_question.question_type == 1 || poll_question.question_type == 2 %> + <%= render :partial =>'choice_show', :locals =>{ :poll_question => poll_question } %> + <% else %> + <%= render :partial =>'quiz_answers', :locals =>{ :poll_question => poll_question } %> + <% end %> +
    2. +
    + <% end %> +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    +
    +
    +
    + + diff --git a/app/views/poll/update.js.erb b/app/views/poll/update.js.erb new file mode 100644 index 000000000..15d0fabd5 --- /dev/null +++ b/app/views/poll/update.js.erb @@ -0,0 +1,6 @@ +$("#polls_title").val("<%= @poll.polls_name%>"); +$("#polls_description").val("<%= @poll.polls_description %>"); +$("#polls_name_h").html("<%= @poll.polls_name %>"); +$("#polls_description_p").html("<%= @poll.polls_description %>"); +$("#polls_head_edit").hide(); +$("#polls_head_show").show(); \ No newline at end of file diff --git a/app/views/poll/update_poll_question.js.erb b/app/views/poll/update_poll_question.js.erb new file mode 100644 index 000000000..e0727df67 --- /dev/null +++ b/app/views/poll/update_poll_question.js.erb @@ -0,0 +1,22 @@ +$("#poll_questions_<%= @poll_question.id%>").html("
    " + + "<% if @poll_question.question_type == 1%>" + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:poll_question => @poll_question}) %>" + + "<% elsif @poll_question.question_type == 2%>" + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:poll_question => @poll_question}) %>" + + "<% elsif @poll_question.question_type == 3%>" + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:poll_question => @poll_question}) %>" + + "<% elsif @poll_question.question_type == 4%>" + + "<%= escape_javascript(render :partial => 'show_mulit', :locals => {:poll_question => @poll_question}) %>" + + "<% end%>" + + "
    " + + ""); diff --git a/app/views/projects/_join_project.html.erb b/app/views/projects/_join_project.html.erb new file mode 100644 index 000000000..c7ce29dae --- /dev/null +++ b/app/views/projects/_join_project.html.erb @@ -0,0 +1,83 @@ + + + + + 快速进入项目通道 + + + + + +
    +
    +
    +

    快速进入项目通道

    +

    只要持有项目的ID,就可快速申请加入所在项目。项目页面搜索不到的私有项目只能从此通道进入哦!

    +
    +
    + <%= form_tag({:controller => 'applied_project', + :action => 'applied_join_project'}, + :remote => true, + :method => :post, + :id => 'new-watcher-form') do %> + + <% end%> +
    +
    +
    + + + diff --git a/app/views/projects/join_project.js.erb b/app/views/projects/join_project.js.erb new file mode 100644 index 000000000..f3bdfb50a --- /dev/null +++ b/app/views/projects/join_project.js.erb @@ -0,0 +1,9 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/join_project') %>'); +showModal('ajax-modal', '510px'); +$('#ajax-modal').css('height','260px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("alert_box"); diff --git a/app/views/users/_mail_notifications.html.erb b/app/views/users/_mail_notifications.html.erb index a8d3edc55..7dd4ad77f 100644 --- a/app/views/users/_mail_notifications.html.erb +++ b/app/views/users/_mail_notifications.html.erb @@ -1,5 +1,5 @@

    -<%= label_tag "user_mail_notification", l(:description_user_mail_notification), :class => "hidden-for-sighted_bak" %> +<%= label_tag "user_mail_notification", l(:description_user_mail_notification), :class => "hidden-for-sighted_bak" , :style=> 'margin-right: 5px;'%> <%= select_tag( 'user[mail_notification]', options_for_select( diff --git a/app/views/welcome/_search_course.html.erb b/app/views/welcome/_search_course.html.erb index 5721af9fb..895f696fb 100644 --- a/app/views/welcome/_search_course.html.erb +++ b/app/views/welcome/_search_course.html.erb @@ -49,7 +49,7 @@ form #search_type{ <%= form_tag({controller: :welcome, action: :search }, method: :get) do %>