Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-03-25 15:37:15 +08:00
commit 46a05d1000
18 changed files with 95 additions and 36 deletions

View File

@ -225,7 +225,7 @@ class OrganizationsController < ApplicationController
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})"
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0"
#user_courses = Course.find_by_sql(sql)
@courses = Course.find_by_sql(sql)
# @added_course_ids = @organization.courses.map(&:id)
@ -269,7 +269,7 @@ class OrganizationsController < ApplicationController
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" +
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})"
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id}) and status=1"
#user_projects = Course.find_by_sql(sql)
@projects = Course.find_by_sql(sql)
# @added_course_ids = @organization.projects.map(&:id)

View File

@ -63,6 +63,13 @@ class StudentWorkController < ApplicationController
homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0
end
end
#修改作品提示消息更新
student_work_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, StudentWork.name, 0)
student_work_messages.each do |message|
message.update_attribute(:viewed, true)
end
# 作品打分消息状态更新
studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0)
studentworks_scores.each do |studentworks_score|
@ -369,6 +376,8 @@ class StudentWorkController < ApplicationController
@work.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@work)
if @work.save
#如果学生作品被打分后修改,应该给老师提示
send_message_to_teacher(@work)
if @homework.homework_type == 3
@student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first
student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0)

View File

@ -717,6 +717,7 @@ class UsersController < ApplicationController
end
student_work.save
send_message_to_teacher(student_work)
homework.update_attributes(:updated_at => Time.now)
update_course_activity(homework.class,homework.id)
update_user_activity(homework.class,homework.id)
@ -2475,13 +2476,13 @@ class UsersController < ApplicationController
# 资源库 分为全部 课程资源 项目资源 附件
def user_resource
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
# 别人的资源库是没有权限去看的
if User.current.id.to_i != params[:id].to_i
render_403
return
end
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
@ -2565,6 +2566,10 @@ class UsersController < ApplicationController
end
def import_resources_search
if User.current.id.to_i != params[:id].to_i
render_403
return
end
@resource_id = params[:mul_id]
@resource_type = params[:mul_type]
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@ -2573,11 +2578,6 @@ class UsersController < ApplicationController
@switch_search = params[:name].nil? ? " " : params[:name]
search = "%#{@switch_search.strip.downcase}%"
# 别人的资源库是没有权限去看的
if User.current.id.to_i != params[:id].to_i
render_403
return
end
@resource_id = params[:mul_id]
if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
user_course_ids = User.current.courses.map { |c| c.id}

View File

@ -2137,6 +2137,20 @@ module ApplicationHelper
end
#如果学生作品被打分后修改,应该给老师提示
def send_message_to_teacher student_work
if StudentWork === student_work
if student_work.student_works_scores.any?
course = student_work.homework_common.course
course.members.map(&:user_id).uniq.each do|user_id|
if User.find(user_id).allowed_to?(:as_teacher, course)
student_work.course_messages << CourseMessage.new(:user_id => user_id, :course_id => course.id, :viewed => false, :status => 1)
end
end
end
end
end
private
def wiki_helper

View File

@ -42,9 +42,9 @@ class Principal < ActiveRecord::Base
if q.blank?
where({})
else
pattern = "%#{q}%"
pattern = "%#{q}%".gsub("/","//").gsub("_","/_")
# sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ")
sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) or LOWER(login) LIKE LOWER(:p) or LOWER(mail) LIKE LOWER(:p)"
sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) or LOWER(login) LIKE LOWER(:p) or LOWER(mail) LIKE LOWER(:p) escape '/'"
params = {:p => pattern}
if q =~ /^(.+)\s+(.+)$/
a, b = "#{$1}%", "#{$2}%"

View File

@ -0,0 +1,9 @@
<% if @order == "asc" %>
按&nbsp;<%= link_to "时间",params.merge(:sort => "created_on:desc", :order => order,:tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort => "downloads:desc", :order => order,:tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort => "quotes:desc", :order => order,:tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort => "created_on:asc", :order => order, :tag_name => tag_name,:name => search_name),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort => "downloads:asc", :order => order, :tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort =>"quotes:asc", :order => order, :tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>

View File

@ -56,16 +56,8 @@
</div>
<div class="cl"></div>
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= User.current.member_of_org?(@org_subfield.organization) ? @all_attachments.count : @all_attachments.select{|attach| attach.is_public == 1 }.count %></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080">
<% if @order == "asc" %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>
<p class="f_r" style="color: #808080" id="org_sort">
<%= render :partial => 'files/org_order_filter', :locals => {:order => @order, :sort => @sort, :tag_name => @tag_name, :search_name => nil} %>
</p>
</div>
<div class="cl"></div>

View File

@ -5,4 +5,6 @@
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list',
:locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>");
$("#attachment_count").html("<%= @result.count %>");
$("#org_sort").html("<%= escape_javascript(render :partial => 'org_order_filter',
:locals => {:sort => @sort, :order => @order, :tag_name => @tag_name, :search_name => @q}) %>");
<% end %>

View File

@ -1,3 +1,5 @@
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list',
:locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>");
$("#attachment_count").html("<%= @result.count %>");
$("#attachment_count").html("<%= @result.count %>");
$("#org_sort").html("<%= escape_javascript(render :partial => 'org_order_filter',
:locals => {:sort => @sort, :order => @order, :tag_name => @tag_name,:search_name => @q}) %>");

View File

@ -90,8 +90,8 @@
<% end%>
</div>
<!--<div class="orgName fl mb5 f14">组织id<%#= @organization.id %></div>-->
<div class="orgName fl mb5 f14">
<%= link_to @organization.name, organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %>
<div class="orgName fl mb5 f14" title="<%= @organization.name %>">
<%= link_to truncate(@organization.name,:length => 26), organization_path(@organization.id), :class=>"pr_info_name c_dark fb break_word" %>
<% if User.current.logged? %>
<% if @organization.is_public? %>
<span class="img_private"><%= l(:label_public)%></span>

View File

@ -32,7 +32,10 @@
location.href = document.referrer;
}
</script>
<div class="resources" nhname="new_topic_form">
<div class="homepageRightBanner" style="margin-top:<%= User.current.logged? ? '0px':'10px' %>; margin-bottom:10px;">
<div class="NewsBannerName"><%= OrgSubfield.try(:find, params[:field_id]).try(:name) %></div>
</div>
<div class="resources" nhname="new_topic_form" style="padding-top:<%= params[:field_id].present? ? '0px': '15px' %>">
<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %>
<div>
<textarea class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" placeholder="请输入文章标题"></textarea>

View File

@ -63,7 +63,7 @@
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuCourses" style="display:<%= organization.courses.count == 0 ?'none':'' %>">
<ul >
<%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
<%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.where("is_delete=0").reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul>
</div>
</div>
@ -77,7 +77,7 @@
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuProjects" style="display:<%= organization.projects.count == 0?'none':'' %>">
<ul>
<%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
<%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.where("status=1").reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul>
</div>
</div>

View File

@ -10,6 +10,9 @@
TO&nbsp;&nbsp;<%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %>
|
<span style="color:#269ac9;"><%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %></span>
<% if @organization.home_id == document.id %>
<span class="red_homework_btn_cir ml5">已设为首页</span>
<% end %>
</div>
<div class="homepagePostTitle postGrey"><%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %></div>
<div class="homepagePostDate fl">

View File

@ -19,8 +19,11 @@
'<%= check_uniq_organizations_path%>'+'?org_name='+$("#organization_name").val().trim()+"&config_page=Y" + "&org_id="+id
)
}
function update_org(id){
check_uniq(id);
function update_org(id, old_value, input_value){
if (old_value == input_value)
{
check_uniq(id);
}
if( $checkName){
$("#edit_organization_"+id).submit();
}
@ -77,7 +80,7 @@
&nbsp;<span>允许游客下载</span>
<span class="c_green f12" id="allow_down_hint"><%= @organization.is_public? ? "" : "(私有组织不允许游客下载资源)" %></span>
</div>
<a href="javascript:void(0);" class="saveBtn ml80 db fl" onclick="update_org(<%=@organization.id %>);">保存</a>
<a href="javascript:void(0);" class="saveBtn ml80 db fl" onclick="update_org('<%=@organization.id %>','<%= @organization.name %>', $('#organization_name'));">保存</a>
<% end %>
</div>
<div class="undis ml15 mr15" id="orgContent_2">

View File

@ -46,8 +46,8 @@
<% end%>
<script type="text/javascript">
$(function(){
<% if !@is_evaluation && !@is_teacher %>
<% work=@homework.student_works.where("user_id = ?",User.current.id).first %>
<% if !@is_evaluation && (!@is_teacher || params[:show_work_id].present?) %>
<% work= params[:show_work_id].nil? ? @homework.student_works.where("user_id = ?",User.current.id).first : StudentWork.find(params[:show_work_id]) %>
<% unless work.nil? %>
<% if @homework.homework_type == 2 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");

View File

@ -370,7 +370,7 @@
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">回复了作品评论:</span>
</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<!--:onmouseover => "message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
</a>
@ -424,6 +424,28 @@
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "StudentWork" && ma.status == 1 %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a>
</li>
<li class="homepageNewsPubType fl">
<%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "同学",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">重新提交了作品:</span>
</li>
<li class="homepageNewsContent fl">
<%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.homework_common_id, :show_work_id => ma.course_message_id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<%#= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}" %>
<!--:onmouseover => "message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
</li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<!-- 创建课程消息 -->
<% if ma.course_message_type == "Course" %>
<ul class="homepageNewsList fl">

View File

@ -1,2 +1,2 @@
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type} )%>");
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type, :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id)} )%>");

View File

@ -54,7 +54,7 @@ function nh_check_field(params){
params.content.sync();
if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空');
params.contentmsg.html('请输入文章描述');
params.contentmsg.css({color:'#ff0000'});
}else{
params.contentmsg.html('填写正确');
@ -131,7 +131,7 @@ function init_des_data(){
});
params.submit_btn.click(function () {
params.editor.sync();
params.form[0].submit();
params.form.submit();
});
params.textarea.data('init', 1);
$(this).show();