diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index deab2feb6..258bce756 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -123,7 +123,9 @@ class StudentWorkController < ApplicationController #-1 默认值 0全部正确并结束 2 超时 -2 编译错误 resultObj[:status] = -1 resultObj[:results] = result["results"].first #本次测试结果 - result["error_msg"] = result["error_msg"][0..2047] + if result["status"].to_i == -2 #编译错误 + result["error_msg"] = result["error_msg"][0..2047] + end resultObj[:error_msg] = result["error_msg"] #编译错误时的信息 #该状态用于存入CodeTests diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a81ade3fa..dd1d8f876 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2618,9 +2618,6 @@ class UsersController < ApplicationController # 获取我的资源 def get_my_resources author_id, user_course_ids, user_project_ids, order, score - unless author_id.to_i.to_s == author_id - author_id = User.find_by_login(author_id).id - end attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2628,7 +2625,6 @@ class UsersController < ApplicationController # 获取我的资源查询结果 def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search) - author_id = User.find_by_login(author_id).id @attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2636,7 +2632,6 @@ class UsersController < ApplicationController # 获取我的课程资源 def get_course_resources author_id, user_course_ids, order, score - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2644,7 +2639,6 @@ class UsersController < ApplicationController # 获取我的课程资源中搜索结果 def get_course_resources_search author_id, user_course_ids, order, score, search - author_id = User.find_by_login(author_id).id attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2662,7 +2656,6 @@ class UsersController < ApplicationController # 获取我的项目资源 def get_project_resources author_id, user_project_ids, order, score - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2670,7 +2663,6 @@ class UsersController < ApplicationController # 获取我的项目资源搜索 def get_project_resources_search author_id, user_project_ids, order, score, search - author_id = User.find_by_login(author_id).id attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2688,14 +2680,12 @@ class UsersController < ApplicationController # 获取我上传的附件 def get_attch_resources author_id, order, score - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', 'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我上传的附件搜索结果 def get_attch_resources_search author_id, order, score, search - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', 'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") end @@ -2714,13 +2704,11 @@ class UsersController < ApplicationController # 获取我的用户类型资源 def get_principal_resources author_id, order, score - author_id = User.find_by_login(author_id).id attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源搜索 def get_principal_resources_search author_id, order, score, search - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 0d75636f7..30f56a1d9 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -166,7 +166,7 @@ class WechatsController < ActionController::Base raise "非法操作, code不存在" unless params[:code] openid = get_openid_from_code(params[:code]) raise "无法获取到openid" unless openid - raise "此微信号已绑定用户, 不能得复绑定" if user_binded?(openid) + raise "此微信号已绑定用户, 不能重复绑定" if user_binded?(openid) user, last_login_on = User.try_to_login(params[:username], params[:password]) raise "用户名或密码错误,请重新登录" unless user diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 229aceb1c..798dd4a3a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -34,13 +34,6 @@ module ApplicationHelper def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter - def user_path(resource, parameters = {}) - if Fixnum === resource - resource = User.find(resource) - end - super - end - # def user_blogs_path(resource,parameters={}) # super # end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 998ace441..f11a48a80 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -29,8 +29,8 @@ class HomeworkCommon < ActiveRecord::Base :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail, :act_as_course_message - after_update :update_activity, :wechat_message + after_create :act_as_activity, :send_mail + after_update :update_activity after_save :act_as_course_activity after_destroy :delete_kindeditor_assets @@ -60,11 +60,11 @@ class HomeworkCommon < ActiveRecord::Base self.course.members.each do |m| # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count - if count == 0 - ws = WechatService.new - ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") - end + #count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count + #if count == 0 + # ws = WechatService.new + # ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + #end # end end end diff --git a/app/models/user.rb b/app/models/user.rb index 035aff625..3956d936e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1103,9 +1103,6 @@ class User < Principal # super end - def to_param - login - end # Salts all existing unsalted passwords # It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password)) # This method is used in the SaltPasswords migration and is to be kept as is diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index 4a9b07ec7..c7e4a7428 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -36,7 +36,7 @@

取消 - 留言 + 留言 <% end %> <% end %> @@ -55,6 +55,9 @@