diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 8bb217cc..3d2960e7 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -76,48 +76,59 @@ class ApplicationController < ActionController::Base
# 包月+按license 9200109002
# 云启训练场(EduCoder))院校版 产品编码(appId) 9200109
- def ecloud_auth subject_id
- # euser = EcloudUser.where("userid =? and opttype not in(3, 5)", User.current.id).first
- # if euser.present? # 开通过业务
- # # 获取用户的套餐信息
- # e_service = euser.ecloud_services.where("opttype != 1")
- # # 如果用户开通过服务
- # if e_service.present?
- # if e_service.count >1 # 说明有重复开通过业务
- # else
- # code = e_service.first.try(:code)
- #
- # end
- # end
- # else
- # false # 没开通过服务,或者服务被禁用则不允许访问
- # end
- #
- #
- #
- #
- # if e_service.count > 1 # 说明有重复订购过套餐
- # else
- # code = e_service.try(:code)
- # end
- # service_count = euser.ecloud_services.where("opttype != 1").try(:code)
- #
- # end
- # 如果不是Ecloud过来的用户,则不改变用户的使用状态及权限,按现有模式即可
+
+ # 如果不是Ecloud过来的用户,则不改变用户的使用状态及权限,按现有模式即可
+ def ecloud_auth
+ euser = EcloudUser.where("userid =? and opttype not in(3, 5)", User.current.id).first
+
+ if euser.present? # 开通过业务
+ # 获取用户的套餐信息
+ e_services = euser.ecloud_services.where("opttype != 1").order("ecloud_services.code desc")
+ # 如果用户开通过服务
+ if e_services.present?
+ if e_services.count > 1 # 说明有重复开通过业务
+ # 开通多业务的话,以最大的套餐排序,如果最大套餐还可以用,则直接返回true,如果最大套餐不能用,则轮询返回,直到找到可用的套餐
+ e_services.each do |e_service|
+ # 使用期限内套餐才有效
+ ecloud_services_auth(e_service.code, e_service.begintime, e_service.endtime)
+ end
+ else
+ # 先看套餐,再看时间区间
+ e_service = e_services.first
+ ecloud_services_auth(e_service.code, e_service.begintime, e_service.endtime)
+ end
+ else
+ false # 没开通过服务,或者服务被禁用则不允许访问
+ end
+ end
end
# 根据业务确定权限
- def ecloud_services_auth code, subject_id
- subject = Subject.find(subject_id)
- subject_level = subject.subject_level_system.try(:level)
- # case code
- # when "9200108001"
- # subject_level.to_i == 1 ? true : false
- # when "9200108002"
- #
- # end
- # end
-
+ def ecloud_services_auth code, begintime, endtime
+ # 如果当前实训不在实训课堂等级体系中,则不允许访问
+ subject_id = @shixun.stage_shixuns.map(&:subject_id)
+ if subject_id.blank?
+ render_403
+ end
+ subject_level = Subject.find(subject_id).subject_level_system.try(:level)
+ # 当前时间转毫秒
+ current_time = DateTime.now.strftime('%Q').to_i
+ if current_time - begintime > 0 && endtime - current_time > 0
+ case code
+ when "9200108001"
+ subject_level.to_i == 1 ? true : false
+ when "9200108002"
+ subject_level.to_i == 2 ? true : false
+ when "9200108003"
+ subject_level.to_i == 3 ? true : false
+ when "9200109001" # 企业用户
+ subject_level.to_i < 3 ? true : false
+ when "9200109002" # 企业用户
+ subject_level.to_i <= 3 ? true : false
+ end
+ else
+ false
+ end
end
diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb
index 0c37a3ab..54f545e5 100644
--- a/app/controllers/challenges_controller.rb
+++ b/app/controllers/challenges_controller.rb
@@ -13,7 +13,7 @@ class ChallengesController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:create_choose_question, :update_choose_question]
#before_filter :find_shixun_language, :only => [:show, :new, :edit]
before_filter :base_index, :only => [:index, :index_down, :index_up, :destroy]
- before_filter :view_allow, :only => [:index, :show]
+ before_filter :view_allow, :only => [:show]
include ApplicationHelper
diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb
index a0aa01bc..5c9ef13c 100644
--- a/app/controllers/managements_controller.rb
+++ b/app/controllers/managements_controller.rb
@@ -791,7 +791,14 @@ class ManagementsController < ApplicationController
def shixun_feedback_message
@menu_type = 8
@sub_type = 2
- @discusses = Discuss.where(:dis_type => "Shixun").reorder("created_at desc")
+ @search = params[:search]
+ if @search.present?
+ shixun_ids = Shixun.where("name like ?", "%#{params[:search]}%").pluck(:id)
+ @discusses = Discuss.where(:dis_type => "Shixun", :dis_id => shixun_ids).reorder("created_at desc")
+ else
+ @discusses = Discuss.where(:dis_type => "Shixun").reorder("created_at desc")
+ end
+ @all_discusses = @discusses
@discusses_count = @discusses.count
@limit = 20
@is_remote = true
@@ -802,6 +809,11 @@ class ManagementsController < ApplicationController
respond_to do |format|
format.js
format.html
+ format.xls{
+ shixun_ids = @all_discusses.pluck(:dis_id).uniq
+ filename = "#{Time.now.strftime("%Y%m%d")}-实训反馈.xls"
+ send_data(shixun_feedback_xls(shixun_ids), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
+ }
end
end
@@ -4046,6 +4058,41 @@ end
return sheet.rows
end
+ def shixun_feedback_xls shixun_ids
+ xls_report = StringIO.new
+ book = Spreadsheet::Workbook.new
+ sheet1 = book.create_worksheet :name => "实训反馈"
+ blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
+ sheet1.row(0).default_format = blue
+ count_row = 1
+ shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user])
+ sheet1.row(0).concat(["序号", "实训ID", "实训名称", "实训作者", "作者单位", "评论数", "评论内容", "关卡", "评论者", "评论者职业",
+ "评论者单位", "评论时间", "社区导师是否已回复"])
+ shixuns.each_with_index do |shixun, i|
+ discusses = shixun.discusses.where("user_id != ?", 1)
+ sheet1[count_row, 0] = i + 1
+ sheet1[count_row, 1] = shixun.identifier
+ sheet1[count_row, 2] = shixun.name
+ sheet1[count_row, 3] = shixun.owner.show_real_name
+ sheet1[count_row, 4] = shixun.owner.school_name
+ sheet1[count_row, 5] = discusses.count
+ discusses.each_with_index do |discuss, j|
+ user = discuss.user
+ sheet1[count_row, 6] = discuss.content.gsub(//, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】")
+ sheet1[count_row, 7] = "第#{discuss.position}关"
+ sheet1[count_row, 8] = user.show_real_name
+ sheet1[count_row, 9] = user.identity
+ sheet1[count_row, 10] = user.school_name
+ sheet1[count_row, 11] = format_time discuss.created_at
+ sheet1[count_row, 12] = discuss.children.pluck(:user_id).include?(1) ? "是" : "否"
+ count_row += 1
+ end
+ #count_row += 1
+ end
+ book.write xls_report
+ xls_report.string
+ end
+
def competition_member_xls members, competition
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index e50827e3..18107cae 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -2,13 +2,16 @@
# REDO: 创建版本库权限控制
class ShixunsController < ApplicationController
layout 'base_shixun'
- before_filter :require_login, :except => [:ghook, :download_file]
- before_filter :check_authentication, :except => [:ghook, :download_file]
+ before_filter :require_login, :except => [:ghook, :download_file, :show, :index]
+ before_filter :check_authentication, :except => [:ghook, :download_file, :show, :index]
before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search, :shixun_courses, :new_disscuss, :shixun_migrate, :qrcode, :download_file, :departments, :get_mirror_script, :send_message_to_administrator]
+
skip_before_filter :verify_authenticity_token, :only => [:ghook, :download_file]
- before_filter :view_allow, :only => [:show, :collaborators, :propaedeutics, :shixun_discuss, :ranking_list]
+ before_filter :view_allow, :only => [:collaborators, :propaedeutics, :shixun_discuss, :ranking_list]
before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators, :update, :destroy]
before_filter :validation_email, :only => [:new]
+ # 移动云ToC模式权限控制
+ # before_filter :ecloud_auth, :except => [:show, :index]
include ApplicationHelper
include ShixunsHelper
diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb
index 3191899c..e526d468 100644
--- a/app/controllers/subjects_controller.rb
+++ b/app/controllers/subjects_controller.rb
@@ -1,8 +1,8 @@
# encoding: utf-8
class SubjectsController < ApplicationController
layout 'base_subject'
- before_filter :require_login, :except => [:show]
- before_filter :check_authentication, :except => [:show]
+ before_filter :require_login, :except => [:show, :index]
+ before_filter :check_authentication, :except => [:show, :index]
before_filter :find_subject, :except => [:index, :new, :create, :create_subject, :new_subject, :append_to_stage, :send_to_course]
include ApplicationHelper
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 2a4402b7..611b7803 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -54,7 +54,7 @@ class UsersController < ApplicationController
accept_api_auth :index, :show, :create, :update, :destroy, :tag_save, :tag_saveEx
#william
- before_filter :require_login, :only => [:tag_save, :tag_saveEx]
+ before_filter :require_login, :only => [:tag_save, :tag_saveEx, :search_user_course, :search_user_project]
#before_filter :refresh_changests, :only =>[:user_activities,:user_courses,:user_projects,:user_newfeedback]
#visitor
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 3d980718..79732e10 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -340,15 +340,11 @@ module ApplicationHelper
# TPM查看权限
# result一般为页面权限
def shixun_view_allow shixun, result = nil
- if params[:openi].to_i == 1
+ if User.current.manager_of_shixun?(shixun)
result ? false : true
else
- if User.current.manager_of_shixun?(shixun)
- result ? false : true
- else
- if shixun.status == 0 || (shixun.use_scope == 1 && !shixun.schools.map(&:name).include?(User.current.school_name))
- result ? true : (render_403)
- end
+ if shixun.status == 0 || (shixun.use_scope == 1 && !shixun.schools.map(&:name).include?(User.current.school_name))
+ result ? true : (render_403)
end
end
end
@@ -619,7 +615,7 @@ module ApplicationHelper
redirect_to user_info_path()
Rails.logger.info("check_authentication end")
return
- elsif User.current.certification != 1
+ elsif User.current.certification != 1 # 系统没有授权
day_cer = UserDayCertification.where(:user_id => User.current.id).last
unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400
redirect_to my_account_path()
diff --git a/app/models/ecloud_serviece_servicepara.rb b/app/models/ecloud_serviece_servicepara.rb
index 91bb0a0d..5dbff71f 100644
--- a/app/models/ecloud_serviece_servicepara.rb
+++ b/app/models/ecloud_serviece_servicepara.rb
@@ -1,3 +1,4 @@
+# ket值,license表示人数,对应企业版;duration表示月数,对应个人版;
class EcloudServieceServicepara < ActiveRecord::Base
attr_accessible :key, :value, :ecloud_service_id
belongs_to :ecloud_service
diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb
index 41fdfc64..6e239e5d 100644
--- a/app/views/layouts/_logined_header.html.erb
+++ b/app/views/layouts/_logined_header.html.erb
@@ -5,7 +5,7 @@
"><%= link_to "实训课程", subjects_path %>
"><%= link_to "翻转课堂", courses_path %>
- "><%= link_to "开发社区", shixuns_path %>
+ "><%= link_to "开发社区", shixuns_path %>
<% careers = Career.published.order("created_at asc") %>
<% if careers.present? %>
diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb
index fb1e901e..d970fffc 100644
--- a/app/views/layouts/_unlogin_header.html.erb
+++ b/app/views/layouts/_unlogin_header.html.erb
@@ -3,16 +3,14 @@
@@ -89,21 +87,5 @@
window.onscroll=function(){
var sl=-Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
document.getElementById('nHeader').style.left=sl+'px';
- }
- $(function () {
- var $header = $("#header-nav").children("li");
- <% if params[:controller] == "welcome" %>
- $("#header-nav").children("li").eq(0).addClass("active");
- <% elsif subjects_controller.include?(params[:controller]) %>
- $("#header-nav").children("li").eq(1).addClass("active");
- <% elsif course_controller.include?(params[:controller]) %>
- $("#header-nav").children("li").eq(2).addClass("active");
- <% elsif shixuns_controller.include?(params[:controller]) %>
- $header.length == 7 ? $header.eq(2).addClass("active") : $header.eq(3).addClass("active");
- <% elsif params[:controller] == "competitions" %>
- $header.length == 7 ? $header.eq(5).addClass("active") : $header.eq(4).addClass("active");
- <% elsif params[:controller] == "forums" %>
- $header.length == 7 ? $header.eq(6).addClass("active") : $header.eq(5).addClass("active");
- <% end %>
- })
+ };
\ No newline at end of file
diff --git a/app/views/managements/shixun_feedback_message.html.erb b/app/views/managements/shixun_feedback_message.html.erb
index 52d15e10..c987f283 100644
--- a/app/views/managements/shixun_feedback_message.html.erb
+++ b/app/views/managements/shixun_feedback_message.html.erb
@@ -1,14 +1,20 @@
- <%#= form_tag(url_for(shixuns_managements_path), :id => "managements_shixuns_search", :method => "post", :remote => true ) do %>
-
-
-
-
-
-
-
- <%# end %>
+ <%= form_tag(url_for(shixun_feedback_message_managements_path), :id => "managements_shixuns_search", :method => "post", :remote => true ) do %>
+
+ <% end %>
<%= render :partial => "shixun_feedback_list" %>
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/app/views/managements/shixun_feedback_message.js.erb b/app/views/managements/shixun_feedback_message.js.erb
index b25de121..135f4107 100644
--- a/app/views/managements/shixun_feedback_message.js.erb
+++ b/app/views/managements/shixun_feedback_message.js.erb
@@ -1 +1,2 @@
-$("#management_shixun_feedback_list").html("<%= j(render :partial => 'shixun_feedback_list') %>");
\ No newline at end of file
+$("#management_shixun_feedback_list").html("<%= j(render :partial => 'shixun_feedback_list') %>");
+$("#shixun_search").attr("href", "<%= shixun_feedback_message_managements_path(:search => @search, :format => "xls") %>")
\ No newline at end of file
diff --git a/app/views/poll/student_poll_list.html.erb b/app/views/poll/student_poll_list.html.erb
index d454fba3..2e570bc3 100644
--- a/app/views/poll/student_poll_list.html.erb
+++ b/app/views/poll/student_poll_list.html.erb
@@ -5,167 +5,163 @@
SearchByName_poll();
}
}
-
- $(function () {
-
- });
-
- <%= link_to @course.name, course_path(@course),:class => "color-grey-9" %> > <%= link_to "问卷列表", poll_index_path(:course_id => @course.id),:class => "color-grey-9" %> >
- #<%= get_poll_index(@poll, @course, @is_teacher) + 1 %>
-
-
-
- <% unless @poll.is_public %>
-
- <% end %>
- <%= @poll.polls_name %>
+
+ <%= link_to @course.name, course_path(@course),:class => "color-grey-9" %> > <%= link_to "问卷列表", poll_index_path(:course_id => @course.id),:class => "color-grey-9" %> >
+ #<%= get_poll_index(@poll, @course, @is_teacher) + 1 %>
- <%= link_to "返回", poll_index_path(:course_id => @course.id), :class => "fr font-12 mr15 mt3 color-grey" %>
-
-
+
+
+ <% unless @poll.is_public %>
+
+ <% end %>
+ <%= @poll.polls_name %>
+
+ <%= link_to "返回", poll_index_path(:course_id => @course.id), :class => "fr font-12 mr15 mt3 color-grey" %>
+
+
-
答题列表
<% if @is_teacher || (@poll.show_result == 1 && @poll.polls_status == 3) %>
- -
- 统计结果
-
+ -
+ 统计结果
+
<% end %>
<% if @is_teacher %>
- -
- 问卷内容
-
- -
- 设置
-
- <% if @poll.polls_status > 1 %>
- <%= link_to "导出统计", export_poll_poll_path(@poll, :course_id => @course.id, :format => 'xls'), :id => "export_poll_work", :class => "fr white-btn orange-btn mt10 ml15" %>
- <% end %>
- <% if @poll.polls_status < 3 %>
- <%= link_to "编辑问卷", edit_poll_path(@poll, :course_id => @course.id), :class => "fr white-btn orange-btn mt10 ml15" %>
- <% end %>
- <% if @poll.polls_status == 1 || @poll.poll_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %>
- <%= link_to '立即发布', publish_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %>
- <% end %>
- <% if (@poll.polls_status == 2 && @poll.end_time > Time.now) || @poll.poll_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %>
- <%= link_to '立即截止', end_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %>
- <% end %>
- <% if @poll.polls_status == 2 %>
- 撤销发布
- <% end %>
+ -
+ 问卷内容
+
+ -
+ 设置
+
+ <% if @poll.polls_status > 1 %>
+ <%= link_to "导出统计", export_poll_poll_path(@poll, :course_id => @course.id, :format => 'xls'), :id => "export_poll_work", :class => "fr white-btn orange-btn mt10 ml15" %>
+ <% end %>
+ <% if @poll.polls_status < 3 %>
+ <%= link_to "编辑问卷", edit_poll_path(@poll, :course_id => @course.id), :class => "fr white-btn orange-btn mt10 ml15" %>
+ <% end %>
+ <% if @poll.polls_status == 1 || @poll.poll_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %>
+ <%= link_to '立即发布', publish_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %>
+ <% end %>
+ <% if (@poll.polls_status == 2 && @poll.end_time > Time.now) || @poll.poll_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %>
+ <%= link_to '立即截止', end_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %>
+ <% end %>
+ <% if @poll.polls_status == 2 %>
+ 撤销发布
+ <% end %>
<% else %>
- -
- 查看设置
-
- <% if User.current.member_of_course?(@poll.course) %>
-
- <% poll_user = @poll.poll_users.where(:user_id => User.current).first %>
- <% member = @poll.course.members.where(:user_id => User.current.id).first %>
- <% setting_time = poll_group_setting @poll, member.try(:course_group) %>
- <% if poll_user %>
- <% if poll_user.commit_status > 0 %>
- <%= link_to '查看答题', poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
- <% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %>
- <%= link_to (poll_user.start_at.nil? ? "开始答题" : "继续答题"), poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
- <% end %>
- <% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %>
- <%= link_to "开始答题", poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
- <% end %>
-
- <% end %>
+ -
+ 查看设置
+
+ <% if User.current.member_of_course?(@poll.course) %>
+
+ <% poll_user = @poll.poll_users.where(:user_id => User.current).first %>
+ <% member = @poll.course.members.where(:user_id => User.current.id).first %>
+ <% setting_time = poll_group_setting @poll, member.try(:course_group) %>
+ <% if poll_user %>
+ <% if poll_user.commit_status > 0 %>
+ <%= link_to '查看答题', poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
+ <% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %>
+ <%= link_to (poll_user.start_at.nil? ? "开始答题" : "继续答题"), poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
+ <% end %>
+ <% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %>
+ <%= link_to "开始答题", poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
+ <% end %>
+
+ <% end %>
<% end %>
-