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..739adfe1c 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,2 +1,391 @@ 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] + before_filter :find_container, :only => [:new,:create, :index] + before_filter :is_member_of_course, :only => [:index,:show] + before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_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 => l(:label_poll_new), + :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, + :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].empty? ? l(:label_poll_title) : params[:polls_name] + @poll.polls_description = params[:polls_description].empty? ? l(:label_poll_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 + redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id) + 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 + + 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 + render_403 unless(@course && User.current.allowed_to?(:as_teacher,@course)) + 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 4e81354f1..d3df57982 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -118,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 diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb new file mode 100644 index 000000000..17ef02a36 --- /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/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/views/layouts/_base_feedback.html.erb b/app/views/layouts/_base_feedback.html.erb index 62b3a01e3..52006e94d 100644 --- a/app/views/layouts/_base_feedback.html.erb +++ b/app/views/layouts/_base_feedback.html.erb @@ -60,18 +60,18 @@ function f_submit() + <%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id)%> +
diff --git a/app/views/poll/_choice_show.html.erb b/app/views/poll/_choice_show.html.erb new file mode 100644 index 000000000..d541386d3 --- /dev/null +++ b/app/views/poll/_choice_show.html.erb @@ -0,0 +1,28 @@ +
+ + + + + + + + <% 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..613fed371 --- /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..802832601 --- /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..de9dc9f08 --- /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_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..bbf71e0ce --- /dev/null +++ b/app/views/poll/_poll_form.html.erb @@ -0,0 +1,128 @@ + + + + + 问卷调查_问卷编辑 + <%= 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_submit.html.erb b/app/views/poll/_poll_submit.html.erb new file mode 100644 index 000000000..cdc41dd9d --- /dev/null +++ b/app/views/poll/_poll_submit.html.erb @@ -0,0 +1,43 @@ + + + + + + + +
+
+
+

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

+
+ <%= link_to "确 定",publish_poll_poll_path(poll.id), :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_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_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/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..e57674c7a --- /dev/null +++ b/app/views/poll/index.html.erb @@ -0,0 +1,63 @@ +<%= 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|%> +
    +
  • + <% if @is_teacher %> + <% if has_commit_poll?(poll.id ,User.current) %> + <%= poll.polls_name %> + <% else %> + <%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %> + <% end %> + <% else %> + <% if has_commit_poll?(poll.id ,User.current) && poll.polls_status == 2 %> + + <%= poll.polls_name %> + + <% elsif (!has_commit_poll?(poll.id ,User.current)) && poll.polls_status == 2 %> + <%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %> + <% end %> + <% end %> +
  • +
  • + <%if @is_teacher && poll.polls_status == 2%> + <%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%> + <% 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 && poll.polls_status == 1%> + + <%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%> + <% end%> +
  • +
  • + <%= format_time poll.created_at%> +
  • +
+
+ <% 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/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..a33daacfb --- /dev/null +++ b/app/views/poll/statistics_result.html.erb @@ -0,0 +1,37 @@ + + + + + <%= 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/config/locales/en.yml b/config/locales/en.yml index 22b0df023..dd79a546c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1817,8 +1817,10 @@ en: label_record: 湘ICP备09019772 label_check_comment: Check comment label_notification: Notification - - + label_must_answer: Will answer + label_poll_title: The questionnaire survey _ questionnaire page + label_question_number: 'question %{question_number}:' + label_complete_question: The answer has been completed #end # ajax异步验证 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 568a60cac..ac7c52fe2 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -964,6 +964,8 @@ zh: label_default: 默认 label_search_titles_only: 仅在标题中搜索 label_user_mail_option_all: "收取我的项目的所有通知" + label_must_answer: "必答" + label_poll_title: 问卷调查_问卷页面 #huang label_file_new: 下载 label_user_edit: "修改资料" @@ -1419,6 +1421,8 @@ zh: other: 参与了 %{count} 个项目: #end label_total_commit: 共%{total_commit}次提交 + label_question_number: 第%{question_number}题: + label_complete_question: 答题已完成 #modify by men label_x_total_commit: zero: 共 %{count} 次提交 @@ -2241,4 +2245,24 @@ zh: label_quote_resource_failed: ",此资源引用失败! " label_file_lost: 以下无法成功下载,请联系相关人员重新上传: label_file_exist: 该作品中有重复命名文件,请通过文件名学号和姓名信息进入该作业详细界面手动下载 + label_poll_new: 未命名问卷 + label_poll: 问卷调查 + label_new_poll: 新建问卷 + label_statistical_results: 统计结果 + label_MC: 单选题 + label_MCQ: 多选题 + label_single: 单行主观 + label_mulit: 多行主观 + label_enter_single_title: 请输入单选题标题 + label_new_answer: 新建选项 + label_poll_title: 问卷标题 + label_poll_description: 问卷描述 + label_poll_options: 选项 + label_poll_subtotal: 小计 + label_poll_proportion: 比例 + label_poll_valid_commit: 本题有效填写人次 + label_poll_result: 问卷调查_问卷统计 + label_answer: 答案: + label_poll_answer_valid_result: 以上为有效问答题答案! + label_answer_total: 总计: diff --git a/config/routes.rb b/config/routes.rb index 5611ed2b6..bd1b27dee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -58,6 +58,20 @@ RedmineApp::Application.routes.draw do end end + resources :poll do + member do + get 'statistics_result' + post 'commit_answer' + post 'create_poll_question' + post 'commit_poll' + get 'publish_poll' + end + collection do + delete 'delete_poll_question' + post 'update_poll_question' + end + end + resources :contest_notification resources :open_source_projects do diff --git a/db/migrate/20150112080435_add_description_to_polls.rb b/db/migrate/20150112080435_add_description_to_polls.rb new file mode 100644 index 000000000..135dc6bd4 --- /dev/null +++ b/db/migrate/20150112080435_add_description_to_polls.rb @@ -0,0 +1,9 @@ +class AddDescriptionToPolls < ActiveRecord::Migration + def up + add_column :polls, :polls_description, :text + end + + def down + remove_column :polls,:polls_description + end +end diff --git a/db/migrate/20150114022710_add_question_number_to_poll_questions.rb b/db/migrate/20150114022710_add_question_number_to_poll_questions.rb new file mode 100644 index 000000000..71f0328be --- /dev/null +++ b/db/migrate/20150114022710_add_question_number_to_poll_questions.rb @@ -0,0 +1,9 @@ +class AddQuestionNumberToPollQuestions < ActiveRecord::Migration + def self.up + add_column :poll_questions, :question_number, :integer + end + + def self.down + remove_column :poll_questions, :question_number + end +end diff --git a/db/schema.rb b/db/schema.rb index 9c6f4eac3..f9ea40ae9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150112024820) do +ActiveRecord::Schema.define(:version => 20150114022710) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -23,6 +23,18 @@ ActiveRecord::Schema.define(:version => 20150112024820) do add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" add_index "activities", ["user_id"], :name => "index_activities_on_user_id" + create_table "api_keys", :force => true do |t| + t.string "access_token" + t.datetime "expires_at" + t.integer "user_id" + t.boolean "active", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" + add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" + create_table "applied_projects", :force => true do |t| t.integer "project_id", :null => false t.integer "user_id", :null => false @@ -803,8 +815,9 @@ ActiveRecord::Schema.define(:version => 20150112024820) do t.integer "question_type" t.integer "is_necessary" t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_number" end create_table "poll_users", :force => true do |t| @@ -1055,6 +1068,14 @@ ActiveRecord::Schema.define(:version => 20150112024820) do t.string "description" end + create_table "social_groups", :force => true do |t| + t.string "name" + t.text "description" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1270,6 +1291,36 @@ ActiveRecord::Schema.define(:version => 20150112024820) do add_index "versions", ["project_id"], :name => "versions_project_id" add_index "versions", ["sharing"], :name => "index_versions_on_sharing" + create_table "voting_choices", :force => true do |t| + t.integer "poll_id", :null => false + t.string "text", :null => false + t.datetime "created_on", :null => false + t.integer "position", :default => 1 + end + + add_index "voting_choices", ["poll_id"], :name => "choices_poll_id" + + create_table "voting_polls", :force => true do |t| + t.integer "project_id", :null => false + t.string "question", :null => false + t.datetime "created_on", :null => false + t.boolean "revote" + end + + add_index "voting_polls", ["project_id"], :name => "polls_project_id" + + create_table "voting_votes", :force => true do |t| + t.integer "user_id", :null => false + t.integer "poll_id", :null => false + t.integer "choice_id", :null => false + t.datetime "created_on", :null => false + end + + add_index "voting_votes", ["choice_id"], :name => "votes_choice_id" + add_index "voting_votes", ["poll_id"], :name => "votes_poll_id" + add_index "voting_votes", ["user_id", "poll_id"], :name => "votes_user_poll_unique", :unique => true + add_index "voting_votes", ["user_id"], :name => "votes_user_id" + create_table "watchers", :force => true do |t| t.string "watchable_type", :default => "", :null => false t.integer "watchable_id", :default => 0, :null => false diff --git a/public/javascripts/polls.js b/public/javascripts/polls.js new file mode 100644 index 000000000..c10bf6d1f --- /dev/null +++ b/public/javascripts/polls.js @@ -0,0 +1,65 @@ +function add_MC(){ + var now = new Date().getTime(); + $("#poll_content").append("
"+ + "
"+ + "
" + + "
" + + "
" + + "" + + "" + + "" + + "" + + "" + + "
" + + "
" + + "
    " + + "
  • " + + "" + + "" + + "" + + "" + + "
  • " + + "
    " + + "
  • " + + "" + + "" + + "" + + "" + + "
  • " + + "
    " + + "
  • " + + "" + + "" + + "" + + "" + + "
  • " + + "
    " + + "
" + + "
" + + "" + + "
" + + "
" + + "
" + + "
" + + "
"); +} +function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_MCQ') %>");} +function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_single') %>");} +function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_mulit') %>");} +//问卷头 +function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();} +function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();} +//单选题 +function add_single_answer(doc) +{ + doc.parent().after("
  • " + + ""+ + "
  • "); +} +function remove_single_answer(doc) +{ + if(doc.parent().siblings("li").length == 0){doc.parent().parent().parent().parent().parent().parent().remove();}else{doc.parent().remove();} +} \ No newline at end of file diff --git a/public/plugin_assets/redmine_code_review/stylesheets/window_js/mac_os_x_dialog.css b/public/plugin_assets/redmine_code_review/stylesheets/window_js/mac_os_x_dialog.css index 4c89f602d..e663e3c5e 100644 --- a/public/plugin_assets/redmine_code_review/stylesheets/window_js/mac_os_x_dialog.css +++ b/public/plugin_assets/redmine_code_review/stylesheets/window_js/mac_os_x_dialog.css @@ -1,160 +1,160 @@ -.overlay_mac_os_x_dialog { - background-color: #FF7224; - filter:alpha(opacity=60); - -moz-opacity: 0.6; - opacity: 0.6; -} - -.mac_os_x_dialog_nw { - background: transparent url(mac_os_x_dialog/L.png) repeat-y top left; - width:16px; - height:16px; -} - -.mac_os_x_dialog_n { - background: transparent url(mac_os_x_dialog/bg.gif) repeat 0 0; - height:18px; -} - -.mac_os_x_dialog_ne { - background: transparent url(mac_os_x_dialog/R.png) repeat-y top left; - width:16px; - height:16px; -} - -.mac_os_x_dialog_w { - background: transparent url(mac_os_x_dialog/L.png) repeat-y top left; - width:16px; -} - -.mac_os_x_dialog_e { - background: transparent url(mac_os_x_dialog/R.png) repeat-y top right; - width:16px; -} - -.mac_os_x_dialog_sw { - background: transparent url(mac_os_x_dialog/BL.png) no-repeat 0 0; - width:31px; - height:40px; -} - -.mac_os_x_dialog_s { - background: transparent url(mac_os_x_dialog/B.png) repeat-x 0 0; - height:40px; -} - -.mac_os_x_dialog_se, .mac_os_x_dialog_sizer { - background: transparent url(mac_os_x_dialog/BR.png) no-repeat 0 0; - width:31px; - height:40px; -} - -.mac_os_x_dialog_sizer { - cursor:se-resize; -} - -.mac_os_x_dialog_close { - width: 19px; - height: 19px; - background: transparent url(mac_os_x_dialog/close.gif) no-repeat 0 0; - position:absolute; - top:12px; - left:25px; - cursor:pointer; - z-index:1000; -} - -.mac_os_x_dialog_minimize { - width: 19px; - height: 19px; - background: transparent url(mac_os_x_dialog/minimize.gif) no-repeat 0 0; - position:absolute; - top:12px; - left:45px; - cursor:pointer; - z-index:1000; -} - -.mac_os_x_dialog_maximize { - width: 19px; - height: 19px; - background: transparent url(mac_os_x_dialog/maximize.gif) no-repeat 0 0; - position:absolute; - top:12px; - left:65px; - cursor:pointer; - z-index:1000; -} - -.mac_os_x_dialog_title { - float:left; - height:14px; - font-family: Tahoma, Arial, sans-serif; - font-size:12px; - text-align:center; - margin-top:6px; - width:100%; - color:#000; -} - -.mac_os_x_dialog_content { - overflow:auto; - color: #222; - font-family: Tahoma, Arial, sans-serif; - font-size: 10px; - background: transparent url(mac_os_x_dialog/bg.gif) repeat 0 0; -} - -.mac_os_x_dialog_buttons { - text-align: center; -} -/* FOR IE */ -* html .mac_os_x_dialog_nw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/L.png", sizingMethod="scale"); -} - - -* html .mac_os_x_dialog_ne { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/R.png", sizingMethod="scale"); -} - -* html .mac_os_x_dialog_w { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/L.png", sizingMethod="scale"); -} - -* html .mac_os_x_dialog_e { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/R.png", sizingMethod="scale"); -} - -* html .mac_os_x_dialog_sw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BL.png", sizingMethod="crop"); -} - -* html .mac_os_x_dialog_s { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/B.png", sizingMethod="scale"); -} - -* html .mac_os_x_dialog_se { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BR.png", sizingMethod="crop"); -} - -* html .mac_os_x_dialog_sizer { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BR.png", sizingMethod="crop"); -} - +.overlay_mac_os_x_dialog { + background-color: #FF7224; + filter:alpha(opacity=60); + -moz-opacity: 0.6; + opacity: 0.6; +} + +.mac_os_x_dialog_nw { + background: transparent url(mac_os_x_dialog/L.png) repeat-y top left; + width:16px; + height:16px; +} + +.mac_os_x_dialog_n { + background: transparent url(mac_os_x_dialog/bg.gif) repeat 0 0; + height:18px; +} + +.mac_os_x_dialog_ne { + background: transparent url(mac_os_x_dialog/R.png) repeat-y top left; + width:16px; + height:16px; +} + +.mac_os_x_dialog_w { + background: transparent url(mac_os_x_dialog/L.png) repeat-y top left; + width:16px; +} + +.mac_os_x_dialog_e { + background: transparent url(mac_os_x_dialog/R.png) repeat-y top right; + width:16px; +} + +.mac_os_x_dialog_sw { + background: transparent url(mac_os_x_dialog/BL.png) no-repeat 0 0; + width:31px; + height:40px; +} + +.mac_os_x_dialog_s { + background: transparent url(mac_os_x_dialog/B.png) repeat-x 0 0; + height:40px; +} + +.mac_os_x_dialog_se, .mac_os_x_dialog_sizer { + background: transparent url(mac_os_x_dialog/BR.png) no-repeat 0 0; + width:31px; + height:40px; +} + +.mac_os_x_dialog_sizer { + cursor:se-resize; +} + +.mac_os_x_dialog_close { + width: 19px; + height: 19px; + background: transparent url(mac_os_x_dialog/close.gif) no-repeat 0 0; + position:absolute; + top:12px; + left:25px; + cursor:pointer; + z-index:1000; +} + +.mac_os_x_dialog_minimize { + width: 19px; + height: 19px; + background: transparent url(mac_os_x_dialog/minimize.gif) no-repeat 0 0; + position:absolute; + top:12px; + left:45px; + cursor:pointer; + z-index:1000; +} + +.mac_os_x_dialog_maximize { + width: 19px; + height: 19px; + background: transparent url(mac_os_x_dialog/maximize.gif) no-repeat 0 0; + position:absolute; + top:12px; + left:65px; + cursor:pointer; + z-index:1000; +} + +.mac_os_x_dialog_title { + float:left; + height:14px; + font-family: Tahoma, Arial, sans-serif; + font-size:12px; + text-align:center; + margin-top:6px; + width:100%; + color:#000; +} + +.mac_os_x_dialog_content { + overflow:auto; + color: #222; + font-family: Tahoma, Arial, sans-serif; + font-size: 10px; + background: transparent url(mac_os_x_dialog/bg.gif) repeat 0 0; +} + +.mac_os_x_dialog_buttons { + text-align: center; +} +/* FOR IE */ +* html .mac_os_x_dialog_nw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/L.png", sizingMethod="scale"); +} + + +* html .mac_os_x_dialog_ne { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/R.png", sizingMethod="scale"); +} + +* html .mac_os_x_dialog_w { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/L.png", sizingMethod="scale"); +} + +* html .mac_os_x_dialog_e { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/R.png", sizingMethod="scale"); +} + +* html .mac_os_x_dialog_sw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BL.png", sizingMethod="crop"); +} + +* html .mac_os_x_dialog_s { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/B.png", sizingMethod="scale"); +} + +* html .mac_os_x_dialog_se { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BR.png", sizingMethod="crop"); +} + +* html .mac_os_x_dialog_sizer { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BR.png", sizingMethod="crop"); +} + diff --git a/public/stylesheets/images/icons.png b/public/stylesheets/images/icons.png new file mode 100644 index 000000000..2d2b33fe1 Binary files /dev/null and b/public/stylesheets/images/icons.png differ diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css new file mode 100644 index 000000000..58ae913b0 --- /dev/null +++ b/public/stylesheets/polls.css @@ -0,0 +1,136 @@ +/* CSS Document */ +#polls{ font-size:12px; font-family:"微软雅黑","宋体" !important; line-height:1.9; background:#fff; font-style:normal;} +div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,span{ margin:0; padding:0;} +#polls div,img,tr,td{ border:0;} +#polls table,tr,td{border:0; cellspacing:0; cellpadding:0;} +#polls ul,li{ list-style-type:none} +#polls .cl{ clear:both; overflow:hidden; } +#polls a{ text-decoration:none; } +#polls a:hover{ text-decoration:underline; } +#polls .ml10{ margin-left:10px;} +#polls .ml20{ margin-left:20px;} +#polls .mr10{ margin-right:10px;} +#polls .fl{ float: left;} +#polls .fr{ float:right;} + +/*问卷按钮*/ +.polls_btn{ height:33px;border-top:1px solid #15bed1; border-bottom:1px solid #15bed1;border-right:1px solid #cee6e6; width:225px; padding:7px 0 0 15px; } +.polls_btn a{font-size:14px; color:#444444;font-weight:bold;} +.polls_btn span{ color:#15bed1; font-size:12px; font-weight:normal;} + +/*问卷列表*/ +.polls_content{ width:615px;} +.polls_head{ width:677px; height:48px; background:#eaeaea;} +.polls_head h2{ float:left; font-size:14px; color:#585858; margin:11px 0 0 10px;} +.polls_head span{ font-weight:normal; color:#15bccf;} +a.newbtn{ float:right; display:block; width:80px; height:30px; background:#64bdd9; color:#fff; font-size:14px; margin:10px; text-align:center;} +a:hover.newbtn{ background:#55a1b9; text-decoration:none;} +.polls_list ul{ padding-left:10px; border-bottom:1px dashed #c9c9c9; height:32px; padding-top:8px;} +a.polls_title{ font-weight:bold; color:#3e6d8e;max-width: 350px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;} +.polls_title{ font-weight:bold; color:#3e6d8e;} +a.pollsbtn{ display:block; width:66px; height:22px; text-align:center; border:1px solid #64bdd9; color:#64bdd9;} +a:hover.pollsbtn{ background:#64bdd9; color:#fff; text-decoration:none;} +.polls_date{ color:#666666;} +.polls_de{ color:#6883b6;} +/****翻页***/ +ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } +ul.wlist li{float: left;} +ul.wlist li a{ border:1px solid #15bccf; padding:4px; margin-left:3px;} +ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} +.wlist_select { background-color:#64bdd9; color:#fff; padding: 1px 5px 0px 5px; margin-left:3px;margin-top: -2px; border:1px solid #64bdd9;} + + +/*问卷页面*/ +.polls_box{ border:1px solid #dcdcdc; padding:15px 30px;} +.ur_page_title{ font-size:16px; text-align:center; color:#353535; word-break:break-all; word-wrap:break-word;} +.ur_prefix_content{ color:#656565; text-indent:30px; margin-top:10px; } +.ur_card{border-top:1px solid #dcdcdc;margin-top:20px; color:#3a3a3a;} +.ur_title{ padding:20px 0px ; float:left; width:604px; word-break: break-all; word-wrap: break-word;} +.ur_required{ font-weight: bold; color:red;} +.ur_inputs{ color:#666;} +.ur_table{border-top:1px solid #dcdcdc;} +.ur_inputs tr td{ height:40px;border-bottom:1px solid #dcdcdc; width:617px;word-break: break-all; word-wrap: break-word;} +.ur_inputs label{ padding-left:10px;word-break: break-all; word-wrap: break-word;} +.ur_inputs input{ margin-right:5px;} +.ur_text{ height:30px;} +.ur_textbox{ border:1px solid #dcdcdc !important; color:#676765;} +.ur_buttons{ width:250px; margin:20px auto 10px;} +a.ur_button{ display:block; width:106px; height:37px; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:3px; float:left; margin-right:15px;} +a:hover.ur_button{ background:#0fa9bb; text-decoration:none;} +.ur_progress_text{ text-align:center; font-size:14px;} + +/*问卷结果*/ +.title_index{ color:#62bcd7; } +.ur_title_result{ padding-top:20px; word-break:break-all; word-wrap:break-word;} +.ur_table_result{ color:#5d5d5d;border-right:1px solid #cbcbcb;border-bottom:1px solid #cbcbcb;} +.ur_table_result tr td{ border-left:1px solid #cbcbcb;border-top:1px solid #cbcbcb; height:20px;} +.table_bluebg{ background:#d7e5ee; color:#2f3a40; height:24px;} +.td327{ width:601px; padding-left:5px; word-break:break-all; word-wrap:break-word; } +.td42{ width:42px; text-align:center;} +.td287{ width:259px;padding-left:5px; text-align:center; } +.td111{ width:601px;padding-left:5px; word-break:break-all; word-wrap:break-word; } +.Bar{ position: relative; width: 120px; border: 1px solid #cbcbcb; float:left; height:10px; margin-top:5px; margin-right:3px; } +.Bar span{ display: block; position: relative;background:#64badb;/* 进度条背景颜色 */ color: #333333;height: 10px; /* 高度 */ line-height: 20px; } +.ur_progress_text{ color:#3a3a3a;} + +/*问卷编辑*/ +.polls_edit{ color:#767676;} +a:hover{ text-decoration:none; cursor:pointer;} +.tabs_1{ width:665px; height: auto; border:1px solid #cbcbcb; padding:10px 0 0 10px; margin-bottom:10px;} +.tab_item { float:left; height:30px; background:#eeeeee; margin-right:4px; padding:0 8px; margin-bottom:10px;} +.icon_delete{ font-size:16px;} +a:hover.icon_delete{ font-weight: bold;} +.current{ color:#4f4f4d; background:#c4c4c4;} +.tab_add{float:left; width:22px; height:22px; border:1px solid #cbcbcb; margin-top:6px; } +.icon_page_add{ background:url(images/icons.png) 4px -314px no-repeat; width:22px; height:27px; display:block;} +a:hover.icon_page_add{ background:url(images/icons.png) -16px -314px no-repeat;} +.tab_item02{ float:left; width:141px; height:30px;background:#eeeeee; margin-right:10px; padding:0 10px; margin-bottom:10px; padding:10px 0 0 15px;} +.tab_item02:hover{ background:#c9c9c9;} +.tab_icon{padding-left:25px;} +a:hover.tab_item02{ background:#fff;} +.icon_radio{background:url(images/icons.png) 0px 0px no-repeat;color: gray; padding-bottom: 5px;} +.icon_checkbox{background:url(images/icons.png) 0px -40px no-repeat;color: gray; padding-bottom: 5px;} +.icon_text{background:url(images/icons.png) 0px -80px no-repeat;color: gray; padding-bottom: 5px;} +.icon_textarea{background:url(images/icons.png) 0px -120px no-repeat; color: gray;padding-bottom: 5px;} + +.ur_editor {width:655px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;} +.ur_title_editor_title{ margin-bottom:10px;} +.input_title{ width:630px; height:40px; padding:0 10px; text-align:center; font-size:16px; font-weight:bold;border: 1px solid #DCDCDC !important;} +.textarea_editor{ width:632px; height:120px; padding:10px; margin-bottom:10px;border: 1px solid #DCDCDC !important;} +.btn_submit{ width:56px; height:24px; padding-top:4px;background:#15bccf; color:#fff; text-align:center; display:block; float:left; margin-right:10px;} +a:hover.btn_submit{background:#0fa9bb;} +.btn_cancel{width:54px; height:22px; padding-top:4px;background:#fff; color:#999; border:1px solid #999; text-align:center; display:block; float:left; } +a:hover.btn_cancel{ color:#666;} +.ur_question_title{ width:534px; height:30px; border:1px solid #cbcbcb; padding:0 5px !important; margin-right:10px;border: 1px solid #DCDCDC !important;} +.ur_editor_title{ margin-bottom:10px;} +.ur_editor_content{ } +.ur_item{ margin-bottom:5px; height:32px; } +.ur_item input{ width:324px; height:30px;border:1px solid #cbcbcb; padding:0 5px; float:left; margin-right:10px; } +.ur_item label{ float:left;} +.icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;} +a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;} +.icon_remove{background:url(images/icons.png) 0px -338px no-repeat; width:16px; height:27px; display:block;float:left;} +a:hover.icon_remove{background:url(images/icons.png) -20px -338px no-repeat;} +.ur_editor_toolbar{ margin-bottom:10px;} +.ur_editor_toolbar input{ width:40px; height:20px;} +.ur_editor02{width:655px; border:1px solid #cbcbcb; padding:10px; margin-bottom:10px;} +a.ur_button_submit{ display:block; width:106px; height:37px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:3px; margin-bottom:10px; } +a:hover.ur_button_submit{ background:#0fa9bb; text-decoration:none;} +a.ur_icon_de{ background:url(images/icons.png) 0px -338px no-repeat; width:16px; height:27px; display:block;float:right; margin-top:15px;} +a:hover.ur_icon_de{ background:url(images/icons.png) -20px -338px no-repeat;} +.ur_icon_edit{ background:url(images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; margin-top:15px; margin-right:10px;} +a:hover.ur_icon_edit{ background:url(images/icons.png) -21px -272px no-repeat;} + +/***弹框***/ +.popbox_polls{width:300px;height:100px;position:fixed;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} +.alert .close02{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-310px;background:url(/images/bid/close.png) no-repeat;cursor:pointer;} +.upload_box{ width:270px; margin:15px auto;} +.polls_box_p{ font-size:14px; text-align:center;} +a.upload_btn{ display:block; float:left; margin:15px 0 5px; width:60px; padding: 7px 0; text-align: center; color:#fff; font-size:14px; background:#15bccf; margin-right:10px;} +a:hover.upload_btn{ background:#06a9bc;} +a.upload_btn_grey{background:#a3a3a3;} +a:hover.upload_btn_grey{background:#8a8a8a;} +.upload_con p{ color:#808181;} +.upload_con a:hover{ text-decoration:none;} +.polls_btn_box{ width:145px; margin:0 auto; padding-left:10px;} +.polls_btn_box02{ width:80px; margin:0 auto; padding-left:10px;} diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index e10c5a91b..936610c6b 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -852,7 +852,7 @@ p.breadcrumb input[type="text"],input[type="password"],textarea,select { padding:2px; - border:1px solid #039ea0 + border:1px solid #039ea0 } input[type="text"],input[type="password"]