Merge branch 'develop' into hjq_course
This commit is contained in:
commit
0b34be5a30
|
@ -488,6 +488,23 @@ class FilesController < ApplicationController
|
|||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||
Mailer.run.attachments_added(attachments[:files])
|
||||
end
|
||||
if !attachments.empty? && attachments[:files]
|
||||
attachments[:files].each do |attachment|
|
||||
if params[:publish_time]
|
||||
if params[:publish_time] == ""
|
||||
attachment.publish_time = Date.today
|
||||
else
|
||||
attachment.publish_time = params[:publish_time]
|
||||
end
|
||||
else
|
||||
attachment.publish_time = Date.today
|
||||
end
|
||||
if attachment.publish_time > Date.today
|
||||
attachment.is_publish = 0
|
||||
end
|
||||
attachment.save
|
||||
end
|
||||
end
|
||||
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
|
||||
params[:course_attachment_type].each do |type|
|
||||
tag_name = get_tag_name_by_type_number type
|
||||
|
|
|
@ -98,14 +98,22 @@ class StudentWorkController < ApplicationController
|
|||
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
|
||||
if @homework.homework_type == 3
|
||||
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
|
||||
if pro.nil?
|
||||
@stundet_works = []
|
||||
else
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
end
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
|
||||
if @homework.homework_type == 3
|
||||
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
|
||||
my_work = @homework.student_works.where(:id => pro.student_work_id)
|
||||
if pro.nil?
|
||||
my_work = []
|
||||
else
|
||||
my_work = @homework.student_works.where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
end
|
||||
|
@ -113,7 +121,11 @@ class StudentWorkController < ApplicationController
|
|||
elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的
|
||||
if @homework.homework_type == 3
|
||||
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
|
||||
if pro.nil?
|
||||
my_work = []
|
||||
else
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
end
|
||||
|
@ -134,14 +146,22 @@ class StudentWorkController < ApplicationController
|
|||
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
|
||||
if @homework.homework_type == 3
|
||||
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
|
||||
if pro.nil?
|
||||
@stundet_works = []
|
||||
else
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
end
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
|
||||
if @homework.homework_type == 3
|
||||
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
|
||||
my_work = @homework.student_works.where(:id => pro.student_work_id)
|
||||
if pro.nil?
|
||||
my_work = []
|
||||
else
|
||||
my_work = @homework.student_works.where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
end
|
||||
|
@ -149,7 +169,11 @@ class StudentWorkController < ApplicationController
|
|||
elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的
|
||||
if @homework.homework_type == 3
|
||||
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
|
||||
if pro.nil?
|
||||
my_work = []
|
||||
else
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
end
|
||||
|
|
|
@ -2144,22 +2144,22 @@ class UsersController < ApplicationController
|
|||
if(params[:type].blank? || params[:type] == "1") #全部
|
||||
if User.current.id.to_i == params[:id].to_i
|
||||
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and is_publish = 1 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)").order("created_on desc")
|
||||
else
|
||||
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and is_publish = 1 " +
|
||||
"and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
|
||||
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
|
||||
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1)").order("created_on desc")
|
||||
end
|
||||
elsif params[:type] == "2" #课程资源
|
||||
if User.current.id.to_i == params[:id].to_i
|
||||
user_course_ids = User.current.courses.map { |c| c.id}
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc")
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
|
||||
else
|
||||
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+
|
||||
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' and is_publish = 1)"+
|
||||
"or (container_type = 'Course' and is_public = 1 and is_publish = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
|
||||
end
|
||||
elsif params[:type] == "3" #项目资源
|
||||
if User.current.id.to_i == params[:id].to_i
|
||||
|
|
|
@ -746,7 +746,7 @@ module CoursesHelper
|
|||
return[] unless course
|
||||
result = []
|
||||
course.attachments.each do |attachment|
|
||||
if attachment.is_public? || User.current.member_of_course?(course) || User.current.admin?
|
||||
if attachment.is_public? ||User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id))|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin?
|
||||
result << attachment
|
||||
end
|
||||
end
|
||||
|
|
|
@ -123,7 +123,8 @@ module FilesHelper
|
|||
attachments.each do |attachment|
|
||||
if attachment.is_public? ||
|
||||
(attachment.container_type == "Project" && User.current.member_of?(attachment.project)) ||
|
||||
(attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)))||
|
||||
(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"
|
||||
result << attachment
|
||||
|
|
|
@ -139,6 +139,6 @@
|
|||
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
}
|
||||
$("#time").click(select);
|
||||
$("#term").click(select);
|
||||
//$("#time").click(select);
|
||||
//$("#term").click(select);
|
||||
</script>
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
<span class="img_private ml5">私有</span>
|
||||
<%end %>
|
||||
</span>
|
||||
<% if file.is_publish == 0 %>
|
||||
<span class="grey_homework_btn_cir ml5"><%=file.publish_time %> 0点发布</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="mt5">
|
||||
<span class="fontGrey2 mr15 fl">上传时间:<%= format_time(file.created_on)%></span>
|
||||
|
|
|
@ -21,10 +21,20 @@
|
|||
<%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<a href="javascript:void(0);" class=" fr grey_btn mr40" onclick="hideModal();"><%= l(:button_cancel)%></a>
|
||||
<!--<a id="submit_resource" href="javascript:void(0);" class="blue_btn fr" onclick="submit_resource();"><%#= l(:button_confirm)%></a>-->
|
||||
<%= submit_tag '确定',:onclick=>'submit_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %>
|
||||
<% if User.current.allowed_to?(:as_teacher,course) %>
|
||||
<div class="mb5">
|
||||
<label class="fl c_dark f14" style="margin-top: 4px;">延迟发布:</label>
|
||||
<div class="calendar_div fl">
|
||||
<input type="text" name="publish_time" id="attachment_publish_time" placeholder="发布日期(可选)" class="InputBox fl W120 calendar_input" readonly="readonly">
|
||||
<%#= calendar_for('attachment_publish_time')%>
|
||||
</div>
|
||||
<span class="fl c_red" style="margin-top: 4px;" id="publish_time_notice"></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<a href="javascript:void(0);" class=" fr courseSendCancel mr40" onclick="hideModal();"><%= l(:button_cancel)%></a>
|
||||
<a id="submit_resource" href="javascript:void(0);" class="c_white courseSendSubmit fr" onclick="submit_course_resource();"><%= l(:button_confirm)%></a>
|
||||
<%#= submit_tag '确定',:onclick=>'submit_course_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
@ -35,8 +45,39 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
function submit_resource()
|
||||
function regex_publish_time()
|
||||
{
|
||||
$('#submit_resource').parent().submit();
|
||||
var myDate = new Date();
|
||||
if($.trim($("#attachment_publish_time").val()) == "")
|
||||
{
|
||||
return true;
|
||||
} else{
|
||||
var publish_time = Date.parse($("#attachment_publish_time").val());
|
||||
if(Date.parse(formate_date(myDate)) > publish_time)
|
||||
{
|
||||
$("#publish_time_notice").text("发布日期不能小于当前日期");
|
||||
return false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#publish_time_notice").text("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
function submit_course_resource()
|
||||
{
|
||||
<% if User.current.allowed_to?(:as_teacher,course) %>
|
||||
if(regex_publish_time()) {
|
||||
$('#submit_resource').parent().submit();
|
||||
}
|
||||
<% else %>
|
||||
$('#submit_resource').parent().submit();
|
||||
<% end %>
|
||||
}
|
||||
$(function(){
|
||||
var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: 0, showOn: 'button', buttonImageOnly: true, buttonImage: '/images/public_icon.png', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};
|
||||
$('#attachment_publish_time').datepicker(datepickerOptions);
|
||||
});
|
||||
</script>
|
|
@ -44,8 +44,8 @@
|
|||
</li>
|
||||
<% if User.current.logged? %>
|
||||
<li class="navOrgMenu fr" id="orgUser" style="cursor:pointer;">
|
||||
<%= link_to image_tag(url_to_avatar(User.current),:width => '23',:height => '23'), user_path(User.current),:alt => '用户头像', :target => '_blank',:style=>'border-radius:3px; vertical-align:top; margin-top:3px; display:inline-block; margin-right:3px;' %>
|
||||
<%= link_to User.current, user_path(User.current),:id => "orgUserName",:class => 'fontGrey2 f14 mr5',:target => '_blank' %>
|
||||
<%= link_to image_tag(url_to_avatar(User.current),:width => '23',:height => '23'), request.local? ? user_path(User.current):("https://www.trustie.net/users/" + User.current.id.to_s),:alt => '用户头像', :target => '_blank',:style=>'border-radius:3px; vertical-align:top; margin-top:3px; display:inline-block; margin-right:3px;' %>
|
||||
<%= link_to User.current, (request.local? || request.subdomain.blank?) ? user_path(User.current):("https://www.trustie.net/users/" + User.current.id.to_s),:id => "orgUserName",:class => 'fontGrey2 f14 mr5',:target => '_blank' %>
|
||||
<%= link_to "退出",logout_organization_path(@organization), :class =>"menuGrey", :method => 'post', :rel => "nofollow" %>
|
||||
</li>
|
||||
<!--<li class="navOrgMenu fr"><%#=link_to User.current, user_path(User.current), :class => "linkGrey8 f14" %></li>-->
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class UpdateCourseTerm < ActiveRecord::Migration
|
||||
def up
|
||||
count = Course.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
Course.page(i).per(30).each do |course|
|
||||
if course.end_time.nil? && course.end_term.nil?
|
||||
course.end_time = course.time
|
||||
course.end_term = course.term
|
||||
course.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
class AddPublishToAttachments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :attachments, :is_publish, :integer, :default => 1
|
||||
add_column :attachments, :publish_time, :date
|
||||
=begin
|
||||
count = Attachment.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
Attachment.page(i).per(30).each do |atta|
|
||||
begin
|
||||
atta.publish_time = atta.created_on.strftime('%d-%b-%Y')
|
||||
atta.save
|
||||
ensure
|
||||
logger.error("===================>>container_id is null")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
=end
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160202034530) do
|
||||
ActiveRecord::Schema.define(:version => 20160220100507) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1219,7 +1219,6 @@ ActiveRecord::Schema.define(:version => 20160202034530) do
|
|||
create_table "org_members", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "organization_id"
|
||||
t.string "role"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#coding=utf-8
|
||||
|
||||
namespace :resource_publish do
|
||||
desc "start publish resource"
|
||||
task :publish => :environment do
|
||||
attachments = Attachment.where("publish_time = '#{Date.today}'")
|
||||
attachments.each do |attachment|
|
||||
attachment.update_column('is_publish', 1)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,6 +3,15 @@
|
|||
module Trustie
|
||||
module Gitlab
|
||||
module Helper
|
||||
GUEST = 10
|
||||
REPORTER = 20
|
||||
DEVELOPER = 30
|
||||
MASTER = 40
|
||||
OWNER = 50
|
||||
# 项目公开和私有
|
||||
PUBLIC = 20
|
||||
PRIVATE = 0
|
||||
|
||||
def change_password(uid, en_pwd, salt)
|
||||
return unless uid
|
||||
options = {:encrypted_password=>en_pwd, :password_salt=>salt}
|
||||
|
@ -44,6 +53,21 @@ module Trustie
|
|||
self.g.delete_user(user.gid)
|
||||
end
|
||||
|
||||
def get_gitlab_role m
|
||||
case m.roles.first.position
|
||||
when 1,2
|
||||
GUEST
|
||||
when 5
|
||||
REPORTER
|
||||
when 4
|
||||
DEVELOPER
|
||||
when 3
|
||||
MASTER
|
||||
else
|
||||
GUEST
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -61,7 +61,7 @@ module Trustie
|
|||
unless gid
|
||||
gid = sync_user(m.user).id
|
||||
end
|
||||
self.g.add_team_member(gproject.id, gid, UserLevel::DEVELOPER)
|
||||
self.g.add_team_member(gproject.id, gid, get_gitlab_role(m))
|
||||
rescue => e
|
||||
puts e
|
||||
end
|
||||
|
@ -111,7 +111,7 @@ module Trustie
|
|||
unless gid
|
||||
gid = sync_user(m.user).id
|
||||
end
|
||||
self.g.add_team_member(gproject.id, gid, UserLevel::DEVELOPER)
|
||||
self.g.add_team_member(gproject.id, gid, get_gitlab_role(m))
|
||||
rescue => e
|
||||
puts e
|
||||
end
|
||||
|
@ -125,7 +125,7 @@ module Trustie
|
|||
unless gid
|
||||
gid = sync_user(m.user).id
|
||||
end
|
||||
self.g.add_team_member(project.gpid, gid, UserLevel::DEVELOPER)
|
||||
self.g.add_team_member(project.gpid, gid, get_gitlab_role(m))
|
||||
rescue => e
|
||||
puts e
|
||||
end
|
||||
|
@ -134,6 +134,8 @@ module Trustie
|
|||
|
||||
def remove_project
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue