Merge branch 'develop' into hjq_beidou

This commit is contained in:
huang 2016-05-16 14:21:07 +08:00
commit c15ef0b528
13 changed files with 63 additions and 47 deletions

View File

@ -123,7 +123,9 @@ class StudentWorkController < ApplicationController
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误 #-1 默认值 0全部正确并结束 2 超时 -2 编译错误
resultObj[:status] = -1 resultObj[:status] = -1
resultObj[:results] = result["results"].first #本次测试结果 resultObj[:results] = result["results"].first #本次测试结果
if result["status"].to_i == -2 #编译错误
result["error_msg"] = result["error_msg"][0..2047] result["error_msg"] = result["error_msg"][0..2047]
end
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息 resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
#该状态用于存入CodeTests #该状态用于存入CodeTests

View File

@ -2618,9 +2618,6 @@ class UsersController < ApplicationController
# 获取我的资源 # 获取我的资源
def get_my_resources author_id, user_course_ids, user_project_ids, order, score 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')) "+ 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 = '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}") "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) 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')) "+ @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 = '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}") "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 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')"+ 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(',')}) "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}") 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 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')"+ 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(',')}) "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}") 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 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') "+ 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(',')}) "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}") 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 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') "+ 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(',')}) "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}") 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 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', 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}") 'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我上传的附件搜索结果 # 获取我上传的附件搜索结果
def get_attch_resources_search author_id, order, score, search 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', 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}") 'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
@ -2714,13 +2704,11 @@ class UsersController < ApplicationController
# 获取我的用户类型资源 # 获取我的用户类型资源
def get_principal_resources author_id, order, score 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}") 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 end
# 获取我的用户类型资源搜索 # 获取我的用户类型资源搜索
def get_principal_resources_search author_id, order, score, search 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}") 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 end

View File

@ -166,7 +166,7 @@ class WechatsController < ActionController::Base
raise "非法操作, code不存在" unless params[:code] raise "非法操作, code不存在" unless params[:code]
openid = get_openid_from_code(params[:code]) openid = get_openid_from_code(params[:code])
raise "无法获取到openid" unless openid 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]) user, last_login_on = User.try_to_login(params[:username], params[:password])
raise "用户名或密码错误,请重新登录" unless user raise "用户名或密码错误,请重新登录" unless user

View File

@ -34,13 +34,6 @@ module ApplicationHelper
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter 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={}) # def user_blogs_path(resource,parameters={})
# super # super
# end # end

View File

@ -29,8 +29,8 @@ class HomeworkCommon < ActiveRecord::Base
:description => :description, :description => :description,
:author => :author, :author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
after_create :act_as_activity, :send_mail, :act_as_course_message after_create :act_as_activity, :send_mail
after_update :update_activity, :wechat_message after_update :update_activity
after_save :act_as_course_activity after_save :act_as_course_activity
after_destroy :delete_kindeditor_assets after_destroy :delete_kindeditor_assets
@ -60,11 +60,11 @@ class HomeworkCommon < ActiveRecord::Base
self.course.members.each do |m| self.course.members.each do |m|
# if m.user_id != self.user_id # if m.user_id != self.user_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) 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 #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 #if count == 0
ws = WechatService.new # 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") # 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
end end
end end

View File

@ -1103,9 +1103,6 @@ class User < Principal
# super # super
end end
def to_param
login
end
# Salts all existing unsalted passwords # Salts all existing unsalted passwords
# It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password)) # 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 # This method is used in the SaltPasswords migration and is to be kept as is

View File

@ -36,7 +36,7 @@
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_' name="new_form[course_message]"></textarea> <textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_' name="new_form[course_message]"></textarea>
<p nhname='contentmsg_'></p> <p nhname='contentmsg_'></p>
<a id="new_message_cancel_btn_" href="javascript:void(0)" class="grey_btn fr mt10">取消</a> <a id="new_message_cancel_btn_" href="javascript:void(0)" class="grey_btn fr mt10">取消</a>
<a href="javascript:void(0);" class="blue_btn fr ml10 mt10" id="new_message_submit_btn_" >留言</a> <a href="javascript:void(0);" class="blue_btn fr ml10 mt10" id="submit_feedback_course" >留言</a>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
@ -55,6 +55,9 @@
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
$("#submit_feedback_course").one('click',function() {
$("#course_feedback_new").submit();
});
KindEditor.ready(function(K){ KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){ $("a[nhname='reply_btn']").live('click',function(){
var params = {}; var params = {};
@ -65,7 +68,6 @@
params.textarea = $("textarea[name='user_notes']",params.div_form); params.textarea = $("textarea[name='user_notes']",params.div_form);
params.contentmsg = $("p[nhname='contentmsg']",params.div_form); params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.submit_btn = $("input[nhname='submit_btn']",params.div_form);
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form); params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
params.height = 55; params.height = 55;
if(params.textarea.data('init') == undefined){ if(params.textarea.data('init') == undefined){
@ -74,9 +76,6 @@
params.cancel_btn.click(function(){ params.cancel_btn.click(function(){
nh_reset_form(params); nh_reset_form(params);
}); });
params.submit_btn.one('click', function () {
params.form.submit();
});
} }
params.cancel_btn.click(); params.cancel_btn.click();
toggleAndSettingWordsVal(params.div_form, params.textarea); toggleAndSettingWordsVal(params.div_form, params.textarea);

View File

@ -26,7 +26,7 @@
<div class="sn-news-txt"> <div class="sn-news-txt">
<div class="sn-news-wrap"><%= activity.description.to_s.html_safe %></div> <div class="sn-news-wrap"><%= activity.description.to_s.html_safe %></div>
</div> </div>
<div class="sn-read-more"><%=link_to "查看全文>>", activity.name.to_s, student_work_index_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %></div> <div class="sn-read-more"><%=link_to "查看全文>>", student_work_index_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %></div>
</div> </div>
<% elsif act.org_act_type == "Message" %> <% elsif act.org_act_type == "Message" %>
<% activity = Message.find(act.org_act_id) %> <% activity = Message.find(act.org_act_id) %>

View File

@ -12,8 +12,8 @@
<%= hidden_field_tag 'show_name',params[:show_name],:value => show_name.nil? ? true : show_name %> <%= hidden_field_tag 'show_name',params[:show_name],:value => show_name.nil? ? true : show_name %>
<div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div> <div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div>
<input nhname="submit_btn" type="button" class="reply_btn" value="<%=l(:button_feedback_respond) %>"/> <!--<input nhname="submit_btn" type="button" class="reply_btn" value="<%#=l(:button_feedback_respond) %>"/>-->
<%#= submit_tag l(:button_feedback_respond), :name => nil , <%= submit_tag l(:button_feedback_respond), :name => nil ,
:class => "reply_btn"%> :class => "reply_btn"%>
<input nhname="cancel_btn" type="button" style="display:none;"/> <input nhname="cancel_btn" type="button" style="display:none;"/>
<% end %> <% end %>

View File

@ -53,6 +53,11 @@ module RedmineApp
# Configure the default encoding used in templates for Ruby 1.9. # Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8" config.encoding = "utf-8"
#disable [deprecated] I18n.enforce_available_locales will default to true in the future.
# If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false
# to avoid this message.
#I18n.config.enforce_available_locales = false
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password] config.filter_parameters += [:password]

View File

@ -0,0 +1,18 @@
class DeleteEmptyApplyHomework < ActiveRecord::Migration
def up
count = ApplyHomework.all.count / 30 + 2
transaction do
for i in 1 ... count do i
ApplyHomework.page(i).per(30).each do |ah|
homework = HomeworkCommon.where("id = ?",ah.homework_common_id)
if homework.empty?
ah.destroy
end
end
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160511055221) do ActiveRecord::Schema.define(:version => 20160513120002) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -1107,6 +1107,23 @@ ActiveRecord::Schema.define(:version => 20160511055221) do
t.integer "viewed_count", :default => 0 t.integer "viewed_count", :default => 0
end end
create_table "mess", :id => false, :force => true do |t|
t.string "课程名"
t.integer "课程ID", :default => 0, :null => false
t.string "教师姓", :default => "", :null => false
t.string "教师名", :limit => 30, :default => "", :null => false
t.string "主贴名", :default => "", :null => false
t.integer "主贴或回帖ID", :default => 0, :null => false
t.integer "回帖对应主贴ID"
t.integer "帖子点赞数"
t.integer "主贴回复数", :default => 0, :null => false
t.text "主贴或回帖内容"
t.datetime "发帖时间", :null => false
t.integer "发帖或回帖用户ID", :default => 0, :null => false
t.string "发帖或回帖用户姓", :default => "", :null => false
t.string "发帖或回帖用户名", :limit => 30, :default => "", :null => false
end
create_table "message_alls", :force => true do |t| create_table "message_alls", :force => true do |t|
t.integer "user_id" t.integer "user_id"
t.integer "message_id" t.integer "message_id"
@ -1328,6 +1345,7 @@ ActiveRecord::Schema.define(:version => 20160511055221) do
t.boolean "allow_guest_download", :default => true t.boolean "allow_guest_download", :default => true
t.integer "visits", :default => 0 t.integer "visits", :default => 0
t.integer "show_mode", :default => 0 t.integer "show_mode", :default => 0
t.integer "allow_teacher", :default => 0
end end
create_table "phone_app_versions", :force => true do |t| create_table "phone_app_versions", :force => true do |t|
@ -2043,6 +2061,7 @@ ActiveRecord::Schema.define(:version => 20160511055221) do
t.string "salt", :limit => 64 t.string "salt", :limit => 64
t.integer "gid" t.integer "gid"
t.integer "visits", :default => 0 t.integer "visits", :default => 0
t.integer "excellent_teacher", :default => 0
end end
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"

View File

@ -49,9 +49,6 @@ function nh_check_field(params){
if(params.content.isEmpty()){ if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空'); params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'}); params.contentmsg.css({color:'#ff0000'});
params.submit_btn.one('click', function(){
params.form.submit();
});
}else{ }else{
params.contentmsg.html('填写正确'); params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'}); params.contentmsg.css({color:'#008000'});
@ -71,9 +68,7 @@ function init_form(params){
issubmit:true, issubmit:true,
content:params.editor, content:params.editor,
contentmsg:params.contentmsg, contentmsg:params.contentmsg,
textarea:params.textarea, textarea:params.textarea
submit_btn:params.submit_btn,
form:params.form
}); });
if(is_checked){ if(is_checked){
if(flag){ if(flag){
@ -120,7 +115,7 @@ function init_KindEditor_data(id){
params.cancel_btn.click(function () { params.cancel_btn.click(function () {
nh_reset_form(params); nh_reset_form(params);
}); });
params.submit_btn.one('click', function () { params.submit_btn.click(function () {
params.form.submit(); params.form.submit();
}); });
params.textarea.data('init', 1); params.textarea.data('init', 1);