diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 325517e4b..b88ecf775 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -42,7 +42,7 @@ class PollController < ApplicationController if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?) redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id) else - @can_edit_poll = (!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin? + @can_edit_poll = @poll.user != User.current && ((!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin?) @percent = get_percent(@poll,User.current) @poll_questions = @poll.poll_questions @left_nav_type = 7 @@ -804,7 +804,7 @@ class PollController < ApplicationController current_index = 1 poll_questions.each_with_index do |poll_question, i| if poll_question.question_type == 1 || poll_question.question_type == 2 - sheet1[count_row ,current_index] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| poll_vote.poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") if poll_vote.poll_answer}.join(";") + sheet1[count_row ,current_index] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| (poll_vote.vote_text.nil? ? poll_vote.poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") : l(:label_other_answer) + " (" + poll_vote.vote_text.to_s + ") ") if poll_vote.poll_answer}.join(";") current_index += 1 elsif poll_question.question_type == 3 sheet1[count_row ,current_index] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/ /," ")}.join(";") diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0790696cc..93c0c18cd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2128,12 +2128,6 @@ class UsersController < ApplicationController when "course_journals" container_type = 'Course' act_type = 'JournalsForMessage' - when "user_journals" - container_type = 'Principal' - act_type = 'JournalsForMessage' - when "current_user" - container_type = 'Principal' - act_type = 'Principal' when "all" container_type = 'all' act_type = 'all' @@ -2142,23 +2136,12 @@ class UsersController < ApplicationController if container_type != '' && container_type != 'all' if container_type == 'Course' sql = "container_type = '#{container_type}' and container_id in #{user_course_ids} and act_type = '#{act_type}'" - elsif container_type == 'Principal' && act_type == 'JournalsForMessage' - sql = "container_type = '#{container_type}' and act_type= '#{act_type}' and container_id = #{@user.id}" - elsif container_type == 'Principal' && act_type == 'Principal' - sql = "user_id = #{@user.id} and (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})" end if User.current != @user sql += " and user_id = #{@user.id}" end else - if User.current != @user - blog_ids = "("+@user.blog.id.to_s+")" - else - blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" - end - sql = "(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})" + - "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})" + sql = "(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})" if container_type != 'all' && User.current != @user sql = "user_id = #{@user.id} and(" + sql + ")" end @@ -2191,12 +2174,6 @@ class UsersController < ApplicationController when "project_message" container_type = 'Project' act_type = 'Message' - when "user_journals" - container_type = 'Principal' - act_type = 'JournalsForMessage' - when "current_user" - container_type = 'Principal' - act_type = 'Principal' when "all" container_type = 'all' act_type = 'all' @@ -2205,23 +2182,12 @@ class UsersController < ApplicationController if container_type != '' && container_type != 'all' if container_type == 'Project' sql = "container_type = '#{container_type}' and container_id in #{user_project_ids} and act_type = '#{act_type}'" - elsif container_type == 'Principal' && act_type == 'JournalsForMessage' - sql = "container_type = '#{container_type}' and act_type= '#{act_type}' and container_id = #{@user.id}" - elsif container_type == 'Principal' && act_type == 'Principal' - sql = "user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}))" end if User.current != @user sql += " and user_id = #{@user.id}" end else - if User.current != @user - blog_ids = "("+@user.blog.id.to_s+")" - else - blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" - end - sql = "(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + - "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})" + sql = "(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" if container_type != 'all' && User.current != @user sql = "user_id = #{@user.id} and(" + sql + ")" end diff --git a/app/views/layouts/base_course_community.html.erb b/app/views/layouts/base_course_community.html.erb index 9a4a509a3..8eed02482 100644 --- a/app/views/layouts/base_course_community.html.erb +++ b/app/views/layouts/base_course_community.html.erb @@ -82,13 +82,13 @@ <% end %> -