diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 557b06cea..30175a082 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -283,7 +283,6 @@ module Mobile requires :token, type: String requires :lastname, type: String requires :sex, type: Integer - requires :mail, type: String end post 'edit_userinfo' do @@ -298,41 +297,11 @@ module Mobile status = -1 end - if params[:mail].length > 60 then - message = "邮箱地址不能超过60个字符!" - status = -1 - end - - if !(params[:mail].match(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i)) - message = "请输入正确的邮箱地址!" - status = -1 - end - if status == 0 - # 修改邮箱的时候同步修改到gitlab - if user.mail != params[:mail] - g = Gitlab.client - begin - g.edit_user(user.gid, :email => params[:mail]) - rescue - Rails.logger.error "sync user's email of gitlab failed!" - end - end - - user.mail = params[:mail] - user.lastname = params[:lastname] - + user.update_attribute(:lastname, params[:lastname]) se = user.extensions - - se.gender = params[:sex] - - if user.save && se.save - status = 0 - else - message = "该邮箱地址已被使用!" - status = -1 - end + se.update_attribute(:gender, params[:sex]) end if status == 0 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 88e34d25f..4948d82df 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -830,7 +830,7 @@ class ApplicationController < ActionController::Base # Returns a string that can be used as filename value in Content-Disposition header def filename_for_content_disposition(name) - request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident} ? ERB::Util.url_encode(name) : name + request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident|Edge} ? ERB::Util.url_encode(name) : name end def api_request? diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 61b2377ac..5ddf69a2d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1831,7 +1831,7 @@ class UsersController < ApplicationController @message_alls = paginateHelper @message_alls, 20 @unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).order("updated_on desc").count # 用户待完成的作业 - my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")" + my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'") homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0") @@ -1847,10 +1847,13 @@ class UsersController < ApplicationController poll_users = PollUser.where("user_id = #{@user.id} and poll_id in #{poll_ids}") @unfinished_poll_count = polls.count - poll_users.count # 用户待匿评的作品 - student_work_evaluations = @user.student_works_evaluation_distributions - student_work_ids = student_work_evaluations.blank? ? "(-1)" : "(" + student_work_evaluations.map{|st| st.student_work_id}.join(",") + ")" - student_work_scores = @user.student_works_scores.where("student_work_id in #{student_work_ids} and reviewer_role = 3") - @anonymous_evaluation_count = student_work_evaluations.count - student_work_scores.count + homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status in (1,2)") + homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" + student_work_scores = @user.student_works_scores.where("reviewer_role = 3") + anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")" + unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}") + unfinished_evaluations_work_ids = unfinished_evaluations.blank? ? "(-1)" : "(" + unfinished_evaluations.map{|st| st.student_work_id}.join(",") + ")" + @anonymous_evaluation_count = StudentWork.where("student_works.id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").count # 待评阅的作业 暂不做 # @unreview_homework = 1 @@ -1989,7 +1992,7 @@ class UsersController < ApplicationController # 待完成的作业 def unfinished_homework_list - my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")" + my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'") homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0") @@ -2008,13 +2011,17 @@ class UsersController < ApplicationController # 待完成的测验 def unfinished_test_list - my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")" + my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" exercises = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2") exercise_ids = exercises.blank? ? "(-1)" : "(" + exercises.map{|ex| ex.id}.join(",") + ")" exercise_users = ExerciseUser.where("user_id = #{@user.id} and exercise_id in #{exercise_ids}") finished_test_ids = exercise_users.blank? ? "(-1)" : "(" + exercise_users.map{|eu| eu.exercise_id }.join(",") + ")" @unfinished_test = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2 and id not in #{finished_test_ids}") - + @unfinished_test_count = @unfinished_test.count + @limit = 20 + @unfinished_test_pages = Paginator.new @unfinished_test_count, @limit, params['page'] || 1 + @offset ||= @unfinished_test_pages.offset + @unfinished_test = paginateHelper @unfinished_test, @limit respond_to do |format| format.js end @@ -2022,7 +2029,7 @@ class UsersController < ApplicationController # 待完成的问卷 def unfinished_poll_list - my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")" + my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2") poll_ids = polls.blank? ? "(-1)" : "(" + polls.map{|poll| poll.id}.join(",") + ")" poll_users = PollUser.where("user_id = #{@user.id} and poll_id in #{poll_ids}") @@ -2040,12 +2047,20 @@ class UsersController < ApplicationController # 待匿评的作业 def anonymous_evaluation_list - student_work_evaluations = @user.student_works_evaluation_distributions - student_work_ids = student_work_evaluations.blank? ? "(-1)" : "(" + student_work_evaluations.map{|st| st.student_work_id}.join(",") + ")" - student_work_scores = @user.student_works_scores.where("student_work_id in #{student_work_ids} and reviewer_role = 3") + my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" + homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status in (1,2)") + homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" + student_work_scores = @user.student_works_scores.where("reviewer_role = 3") anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")" - @anonymous_evaluation = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}") - + unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}") + unfinished_evaluations_work_ids = unfinished_evaluations.blank? ? "(-1)" : "(" + unfinished_evaluations.map{|st| st.student_work_id}.join(",") + ")" + homework_ids = StudentWork.where("id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").blank? ? "(-1)" : "(" + StudentWork.where("id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").map{|st| st.homework_common_id}.join(",") + ")" + @anonymous_evaluation = HomeworkCommon.where("homework_commons.id in #{homework_ids}") + @anonymous_evaluation_count = @anonymous_evaluation.count + @limit = 20 + @anonymous_evaluation_pages = Paginator.new @anonymous_evaluation_count, @limit, params['page'] || 1 + @offset ||= @anonymous_evaluation_pages.offset + @anonymous_evaluation = paginateHelper @anonymous_evaluation, @limit respond_to do |format| format.js end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 56810e858..cc203ee63 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -85,10 +85,8 @@ module UsersHelper # 作业类型提示 def homework_type_tip homework_type case homework_type - when 0 - "普通作业" when 1 - "匿评作业" + "普通作业" when 2 "编程作业" when 3 diff --git a/app/models/poll.rb b/app/models/poll.rb index b0499b572..d2f5b40fe 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -44,7 +44,9 @@ class Poll < ActiveRecord::Base def act_as_course_activity if self.polls_type == "Course" if self.polls_status == 2 #问卷是发布状态 - self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + if CourseActivity.where(:course_id => self.polls_group_id, :user_id => self.user_id, :course_act_id => self.id, :course_act_type => 'Poll').count == 0 + self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + end elsif self.polls_status == 1 #问卷是新建状态 self.course_acts.destroy_all end diff --git a/app/views/users/_anonymous_evaluation_list.html.erb b/app/views/users/_anonymous_evaluation_list.html.erb index 4a3caa969..3a6be81ff 100644 --- a/app/views/users/_anonymous_evaluation_list.html.erb +++ b/app/views/users/_anonymous_evaluation_list.html.erb @@ -10,41 +10,41 @@ - <%# @anonymous_evaluation.student_common.each do |ae| %> + <% @anonymous_evaluation.each do |ae| %>
  • - 1 <%#= link_to ae.name.to_s, "", :target => "_blank", :class => "homepageTabTitle fl ml5" %> + <%= link_to ae.name.to_s, student_work_index_url(:homework => ae.id, :tab => 2), :target => "_blank", :class => "homepageTabTitle fl ml5" %>
  • - 1 <%#= link_to uh.course.try(:name),"", :target => "_blank", :class => "homepageTabTitle ml5"%> + <%= link_to ae.course.try(:name),"", :target => "_blank", :class => "homepageTabTitle ml5"%>
  • - <%= 1111 %> + <%= homework_type_tip(ae.homework_type) %>
  • - 1 - + <% end %>
  • - <%# end %> + <% end %> \ No newline at end of file diff --git a/app/views/users/_new_user_message.html.erb b/app/views/users/_new_user_message.html.erb index 511692ae5..fb8a4a717 100644 --- a/app/views/users/_new_user_message.html.erb +++ b/app/views/users/_new_user_message.html.erb @@ -1,27 +1,27 @@ -<% message_alls.each do |ma| %> - <%# 系统消息 %> - <%= render :partial => 'users/user_message_system', :locals => {:ma => ma} %> - - <%= render :partial => 'users/user_at_message', :locals => {:ma => ma} %> - - <%# 课程消息 %> - <%= render :partial => 'users/user_message_course', :locals => {:ma => ma} %> - - - <%= render :partial => 'users/user_message_forge', :locals => {:ma => ma} %> - - - <%= render :partial => 'users/user_message_forum', :locals => {:ma => ma} %> - - - <%= render :partial => 'users/user_message_userfeedaback', :locals => {:ma => ma} %> - - <%= render :partial => 'users/user_message_org', :locals => {:ma => ma} %> - - <%# 申请类消息 %> - <%= render :partial => 'users/user_message_applied', :locals => {:ma => ma} %> -<% end %> - -