Merge branch 'develop' into cxt_course

This commit is contained in:
cxt 2016-03-08 09:13:20 +08:00
commit 40754bff0e
13 changed files with 191 additions and 144 deletions

View File

@ -406,10 +406,14 @@ class FilesController < ApplicationController
@container_type = 2
@containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
@organization = Organization.find(@containers.first.organization_id)
if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization)
show_attachments @containers
@tag_list = attachment_tag_list @all_attachments
@page = params[:page] || 1
render :layout => 'base_org'
else
render_403
end
# @subfield = params[:org_subfield_id]
end
@ -859,7 +863,15 @@ class FilesController < ApplicationController
q = "%#{@q.strip}%"
@result = find_org_subfield_attache q,@org_subfield,sort
@result = visable_attachemnts @result
if params[:other]
@result = @result.select{|attachment|
attachment.tag_list.exclude?('软件') &&
attachment.tag_list.exclude?('媒体') &&
attachment.tag_list.exclude?('代码')
}
else
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
end
@searched_attach = paginateHelper @result,10
@tag_list = get_org_subfield_tag_list @org_subfield

View File

@ -33,6 +33,7 @@ class OrgSubfieldsController < ApplicationController
domain = Secdomain.where("subname=?", request.subdomain).first
@organization = Organization.find(domain.pid)
end
if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization)
@org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+
"subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+
" org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first
@ -82,12 +83,15 @@ class OrgSubfieldsController < ApplicationController
sort = "#{Attachment.table_name}.created_on desc"
end
@container_type = 2
@containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
@containers = [OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
@organization = Organization.find(@containers.first.organization_id)
show_attachments @containers
@tag_list = attachment_tag_list @all_attachments
end
@page = params[:page] || 1
else
render_403
end
#render :layout => 'base_org'
end

View File

@ -425,9 +425,9 @@ class UsersController < ApplicationController
homework = HomeworkCommon.find params[:homework].to_i
if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%"
@course = @user.courses.where("#{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
else
@course = @user.courses.where("#{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)}
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)}
end
@search = params[:search]
#这里仅仅是传递需要发送的资源id
@ -1693,17 +1693,17 @@ class UsersController < ApplicationController
@flag = true
if params[:send_id].present?
send_id = params[:send_id]
ori = Attachment.find_by_id(send_id)
@ori = Attachment.find_by_id(send_id)
course_ids = params[:course_ids]
if course_ids.nil?
@flag = false
end
unless course_ids.nil?
course_ids.each do |id|
next if ori.blank?
next if @ori.blank?
@exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from
att.created_on = Time.now
att.save
@exist = true
@ -1711,21 +1711,21 @@ class UsersController < ApplicationController
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj = @ori.copy
attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
if attach_copied_obj.save
# 更新引用次数
quotes = ori.quotes.to_i + 1
ori.update_attribute(:quotes, quotes) unless ori.nil?
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
quotes = @ori.quotes.to_i + 1
@ori.update_attribute(:quotes, quotes) unless @ori.nil?
@ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end
@save_message = attach_copied_obj.errors.full_messages
end
@ -1837,6 +1837,7 @@ class UsersController < ApplicationController
Project.find(project_id).project_score.attach_num + 1)
end
end
@ori = ori
end
elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ")
@ -1941,6 +1942,7 @@ class UsersController < ApplicationController
end
end
end
@ori = ori
elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ")
subfield_id = params[:subfield]

View File

@ -2049,9 +2049,11 @@ module ApplicationHelper
course = attachment.container
candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
elsif attachment.container.is_a?(OrgSubfield)
candown = true
org = attachment.container.organization
candown = User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
elsif attachment.container.is_a?(OrgDocumentComment)
candown = true
org = attachment.container.organization
candown = User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
attachment.container.board.course
course = attachment.container.board.course

View File

@ -126,7 +126,7 @@ module FilesHelper
(attachment.container_type == "Course" && User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id)))||
(attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)) && attachment.is_publish == 1)||
attachment.author_id == User.current.id ||
attachment.container_type == "OrgSubfield"
(attachment.container_type == "OrgSubfield" and User.current.member_of_org?(attachment.container.organization))
result << attachment
end
end

View File

@ -1,6 +1,7 @@
<% delete_allowed = User.current.admin? %>
<% org_subfield_attachments.each do |file| %>
<% if file.is_public == 1 or User.current.member_of_org?(file.container.organization) %>
<div class="resources mt10" id="container_files_<%= file.id %>">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
@ -8,7 +9,7 @@
</div>
<div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4">
<%= link_to truncate(file.filename,length: 35, omission: '...'),
<%= link_to file.is_public? ? truncate(file.filename, length: 70) : truncate(file.filename,length: 50, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %>
<%= file_preview_eye(file, class: 'preview') %>
@ -25,7 +26,7 @@
<span class="fontGrey2 fl mr15">上传类型:<%= file.tag_list[0] %></span>
<% end %>
<p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p>
<p class="fl ml15 fontGrey2">下载<%= file.downloads%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
<p class="fl ml15 fontGrey2">下载<%= file.downloads%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<span id="reference_number_<%= file.id %>"><%= file.quotes.nil? ? 0:file.quotes %></span></p>
</div>
<div class="cl"></div>
<div class="tag_h">
@ -65,6 +66,7 @@
</div>
</div><!---re_con_box end-->
<% end %>
<% end %>
<% if org_subfield_attachments.count == 10 %>

View File

@ -54,7 +54,7 @@
<%= render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}%>
</div>
<div class="cl"></div>
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count %></span>&nbsp;个资源</p>
<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;

View File

@ -12,8 +12,8 @@
<% homework.homework_tests.each_with_index do |test, index| %>
<div class="mt10">
<label class="fl mt5" name="inputs_label"><%=index+1 %>&nbsp;&nbsp;</label>
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" id="textarea_input_test"><%= test.input %></textarea>
<textarea class="InputBox W320 fl mr5" placeholder="测试输出" id="textarea_output_test"><%= test.output %></textarea>
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" name="program[input][]"><%= test.input %></textarea>
<textarea class="InputBox W320 fl mr5" placeholder="测试输出" name="program[output][]"><%= test.output %></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<% if index != 0 %>
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
@ -24,8 +24,8 @@
<% else %>
<div class="mt10">
<label class="fl mt5" name="inputs_label">1&nbsp;&nbsp;</label>
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" id="textarea_input_test"></textarea>
<textarea class="InputBox W320 fl mr5" placeholder="测试输出" id="textarea_output_test"></textarea>
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" name="program[input][]" id="textarea_input_test"></textarea>
<textarea class="InputBox W320 fl mr5" placeholder="测试输出" name="program[output][]" id="textarea_output_test"></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<div class="cl"></div>
</div>
@ -41,8 +41,10 @@
</div><!----HomeWorkCon end-->
<script>
<% if !edit_mode %>
var text = document.getElementById("textarea_input_test");
var text2 = document.getElementById("textarea_output_test");
autoTextarea2(text,text2);
autoTextarea2(text2,text);
<% end %>
</script>

View File

@ -4,7 +4,8 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
hideModal();
alert("发送成功")
alert("发送成功");
<% else%>
<% end %>

View File

@ -4,7 +4,10 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
<% if @ori.present? and @ori.quotes.present? %>
$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
<% end %>
hideModal();
alert("发送成功")
alert("发送成功");
<% else%>
<% end %>

View File

@ -4,7 +4,10 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
<% if @ori and @ori.quotes.present? %>
$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
<% end %>
hideModal();
alert("发送成功")
alert("发送成功");
<% else%>
<% end %>

View File

@ -97,7 +97,7 @@
<div class="mt10">
<a href="javascript:void(0);" class="BlueCirBtn fl" data-homework-id="<%=@homework.id%>" data-student-work-id="<%=@student_work.id%>" id="test-program-btn">测试代码</a>
<% if @is_test %>
<%=link_to '返 回',course_path(@course),:class=>'fr mt6' %>
<%=link_to '返 回',homework_common_index_path(:course => @course.id),:class=>'fr mt6' %>
<% else @is_test %>
<a href="javascript:void(0);" class="BlueCirBtn fr" id="commit-program-work-btn">提交代码</a>
<% end %>

View File

@ -127,7 +127,15 @@ $(function(){
$("a.CloseBtn").on('click', function(){
$("#BluePopupBox" ).dialog("close");
});
$('#textarea_input_test').focus();
var inputs = document.getElementsByName("program[input][]");
var outputs = document.getElementsByName("program[output][]");
if (inputs.length == outputs.length) {
for (var i=0; i<inputs.length; i++) {
autoTextarea2(inputs[i], outputs[i]);
autoTextarea2(outputs[i], inputs[i]);
}
}
$(inputs[0]).focus();
} else if($("input[name=homework_type]").val() == "2") {
$("#NoticePopupBox" ).dialog("close");
$("input[name=homework_type]").val(1);
@ -168,7 +176,7 @@ $(function(){
$("#cancel_switch").on('click', function(){
$("#NoticePopupBox" ).dialog("close");
});
$("#switch_homework_type_notice").text("您的作业类型将改为“分组作业”,并且您的编程设置将被清除。请问是否继续?");
$("#switch_homework_type_notice").text("您的作业类型将改为“编程作业”,并且您的分组设置将被清除。请问是否继续?");
}
else {
$("#BluePopupBox").dialog("open");
@ -176,7 +184,15 @@ $(function(){
$("a.CloseBtn").on('click', function(){
$("#BluePopupBox" ).dialog("close");
});
$('#textarea_input_test').focus();
var inputs = document.getElementsByName("program[input][]");
var outputs = document.getElementsByName("program[output][]");
if (inputs.length == outputs.length) {
for (var i=0; i<inputs.length; i++) {
autoTextarea2(inputs[i], outputs[i]);
autoTextarea2(outputs[i], inputs[i]);
}
}
$(inputs[0]).focus();
}
});
@ -280,7 +296,7 @@ $(function(){
$("#cancel_switch").on('click', function(){
$("#NoticePopupBox" ).dialog("close");
});
$("#switch_homework_type_notice").text("您的作业类型将改为“编程作业”,并且您的分组设置将被清除。请问是否继续?");
$("#switch_homework_type_notice").text("您的作业类型将改为“分组作业”,并且您的编程设置将被清除。请问是否继续?");
}
else {
$("#GroupPopupBox").dialog("open");