dev_local
cxt 6 years ago
commit 1ddfe358eb

@ -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过来的用户则不改变用户的使用状态及权限按现有模式即可
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

@ -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

@ -791,7 +791,14 @@ class ManagementsController < ApplicationController
def shixun_feedback_message
@menu_type = 8
@sub_type = 2
@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(/<img.*\/>/, "【图片评论】").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

@ -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

@ -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

@ -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

@ -340,9 +340,6 @@ module ApplicationHelper
# TPM查看权限
# result一般为页面权限
def shixun_view_allow shixun, result = nil
if params[:openi].to_i == 1
result ? false : true
else
if User.current.manager_of_shixun?(shixun)
result ? false : true
else
@ -351,7 +348,6 @@ module ApplicationHelper
end
end
end
end
# 判断TPM的代码是否被修改了
# 判断依据是看tpm的最新提交记录和tpi数据库中存储的commit_id是否一致
@ -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()

@ -1,3 +1,4 @@
# ket值license表示人数对应企业版duration表示月数对应个人版
class EcloudServieceServicepara < ActiveRecord::Base
attr_accessible :key, :value, :ecloud_service_id
belongs_to :ecloud_service

@ -3,16 +3,14 @@
<div class="head-nav pr">
<ul id="header-nav">
<li class="active" style="display: none"><%= link_to "首页", home_path %></li>
<li><%= link_to "实训课程", subjects_path %></li>
<li><%= link_to "翻转课堂", courses_path %></li>
<li class="<%= subjects_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "实训课程", subjects_path %></li>
<li class="<%= course_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "翻转课堂", courses_path %></li>
<li class="pr <%= shixuns_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "开发社区", shixuns_path %><img src="/images/educoder/hot-h.png" class="nav-img" /></li>
<li class="pr">
<%= link_to "开发社区", shixuns_path %>
<img src="/images/educoder/hot-h.png" class="nav-img" />
</li>
<% careers = Career.published.order("created_at asc") %>
<% if careers.present? %>
<li class="fl edu-menu-panel headIcon careershover" style="cursor: auto;">
<li class="fl edu-menu-panel headIcon careershover <%= params[:action] == "index" && params[:controller] == "careers" ? " active" : "" %>" style="cursor: auto;">
<p>职业路径</p>
<ul class="edu-menu-list edu-menu-listnew" style="top:60px">
<% careers.each do |career| %>
@ -21,8 +19,8 @@
</ul>
</li>
<% end %>
<li><%= link_to "竞赛", competitions_path %></li>
<li><%= link_to "问答", forums_path %></li>
<li class="<%= params[:controller] == "competitions" ? " active" : "" %>"><%= link_to "竞赛", competitions_path %></li>
<li class="<%= params[:controller] == "forums" ? " active" : "" %>"><%= link_to "问答", forums_path %></li>
<!--<li><%#= link_to "活动竞赛", competitions_path %></li>-->
</ul>
<div class="posi-search unlogin" id="posi-search" style="display: none" >
@ -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 %>
})
};
</script>

@ -1,14 +1,20 @@
<div class="edu-class-container">
<%#= form_tag(url_for(shixuns_managements_path), :id => "managements_shixuns_search", :method => "post", :remote => true ) do %>
<!--<div class="edu-con-top clearfix mb20">-->
<!--<input class="fl task-form-20 task-height-30 ml25" id="shixun_Look_name" name="search" maxlength="" placeholder="输入实训名称关键字进行搜索" type="text" style="height: 21px;">-->
<!--<li class="fl ml10">-->
<!--<a href="javascript:void(0)" class="task-btn task-btn-orange" onclick="$('#managements_shixuns_search').submit();">搜索</a>-->
<!--<a href="javascript:clearSearchCondition();" class="task-btn mr10">清除</a>-->
<!--</li>-->
<!--</div>-->
<%# end %>
<%= form_tag(url_for(shixun_feedback_message_managements_path), :id => "managements_shixuns_search", :method => "post", :remote => true ) do %>
<div class="edu-con-top clearfix mb20">
<input class="fl task-form-20 task-height-30 ml25" id="shixun_Look_name" name="search" maxlength="" placeholder="输入实训名称关键字进行搜索" type="text" style="height: 21px;">
<li class="fl ml10">
<a href="javascript:void(0)" class="task-btn task-btn-orange" onclick="$('#managements_shixuns_search').submit();">搜索</a>
<a href="javascript:clearSearchCondition();" class="task-btn mr10">清除</a>
</li>
<a href="<%= shixun_feedback_message_managements_path(:search => @search, :format => "xls") %>" id="shixun_search" class="task-btn mr10 task-btn-orange fr">导出</a>
</div>
<% end %>
<div class="ex_container" id="management_shixun_feedback_list">
<%= render :partial => "shixun_feedback_list" %>
</div>
</div>
<script>
function clearSearchCondition(){
$("#shixun_Look_name").val('')
}
</script>

@ -1 +1,2 @@
$("#management_shixun_feedback_list").html("<%= j(render :partial => 'shixun_feedback_list') %>");
$("#shixun_search").attr("href", "<%= shixun_feedback_message_managements_path(:search => @search, :format => "xls") %>")

@ -5,10 +5,6 @@
SearchByName_poll();
}
}
$(function () {
});
</script>
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
@ -24,7 +20,7 @@
</p>
<%= link_to "返回", poll_index_path(:course_id => @course.id), :class => "fr font-12 mr15 mt3 color-grey" %>
</div>
<div class="edu-tab clearfix mb20">
<div class="clearfix mb20">
<ul id="edu-tab-nav" class="border-bottom-orange">
<li id="edu-tab-nav-1" class="new-tab-nav background-orange" onclick="HoverLi(1);">
<a href="javascript:void(0);" class="tab_type">答题列表</a>
@ -78,7 +74,7 @@
<% end %>
<% end %>
</ul>
<div id="edu-tab-con-1">
<div id="edu-tab-con-1" class="edu-back-white">
<div id="list_count" class="user_bg_shadow bor-grey-e padding15">
<!--老师显示部分-->
<% if @is_teacher %>
@ -104,9 +100,9 @@
<span class="fl mr25">
<a href="javascript:void(0);" id="poll_status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl5 pr5">不限</a>
</span>
<input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="poll_status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>>
<input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="poll_status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %> />
<label for="work_status_1" class="fl mr25">未提交(<%= un_commit_num @poll %>)</label>
<input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="poll_status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>>
<input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="poll_status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %> />
<label for="work_status_2" class="fl mr25">按时提交(<%= has_commit_num @poll %>)</label>
</li>
<li class="clearfix mb5">
@ -121,7 +117,7 @@
<% groups = @course.course_groups %>
<% end %>
<% groups.each do |group| %>
<input id="group_<%= group.id %>" class="magic-checkbox fl" type="checkbox" value="<%= group.id %>" name="poll_group[]" <%= !@group.blank? && @group.include?(group.id) ? 'checked' : '' %>>
<input id="group_<%= group.id %>" class="magic-checkbox fl" type="checkbox" value="<%= group.id %>" name="poll_group[]" <%= !@group.blank? && @group.include?(group.id) ? 'checked' : '' %> />
<label for="group_<%= group.id %>" class="fl mr25"><%= group.name %>(<%= group.members.count %>)</label>
<% end %>
<% if !@group_teacher %>
@ -134,7 +130,7 @@
<li class="clearfix mt5 mb10">
<div class="edu-find fr mr20 with20 pr">
<div class="edu-find-input">
<input type="text" class="with100 panel-box-sizing" maxlength="20" placeholder="姓名、学号关键字检索" value="<%= @name %>" id="student_user_name">
<input type="text" class="with100 panel-box-sizing" maxlength="20" placeholder="姓名、学号关键字检索" value="<%= @name %>" id="student_user_name" />
<!--<i class="fa fa-close mr5 color-grey edu-close" onclick="colse_searchbox();"></i>-->
<span class="edu-close" onclick="clear_searchbox();" data-tip-down="关闭">×</span>
</div>
@ -235,11 +231,11 @@
<% poll_answers.each_with_index do |poll_answer, index| %>
<li class="clearfix">
<% if poll_answer.answer_text != '' %>
<input class="magic-checkbox fl mt5 magic-checkbox_show" id="poll_<%= poll_answer.id %>_poll_answer_id" type="checkbox">
<input class="magic-checkbox fl mt5 magic-checkbox_show" id="poll_<%= poll_answer.id %>_poll_answer_id" type="checkbox"/>
<label class="fl color-grey3" for="poll_<%= poll_answer.id %>_poll_answer_id"><%= poll_answer.answer_text %></label>
<% else %>
<span class="fl mr5">
<input class="ml-3 mr5 magic-checkbox" id="sx_<%= poll_answer.id %>" name="<%= poll_question %>" value="" type="checkbox">
<input class="ml-3 mr5 magic-checkbox" id="sx_<%= poll_answer.id %>" name="<%= poll_question %>" value="" type="checkbox"/>
<label for="sx_<%= poll_answer.id %>">其它</label>
</span>
<input type="text" readonly class="fl other_input with90 mt3"/>
@ -257,7 +253,7 @@
</div>
</div>
</div>
<div id="edu-tab-con-4" class="user_bg_shadow bor-grey-e undis">
<div id="edu-tab-con-4" class="user_bg_shadow bor-grey-e undis edu-back-white">
<%= render :partial => "poll_setting" %>
</div>
</div>

@ -101,7 +101,7 @@
<% end %>
<a href="javascript:void(0);" class="fr user_default_btn edu-greyback-btn mr15 font-18">已关闭</a>
<% end %>
<% if @shixun.can_copy %>
<% if @shixun.can_copy && User.current.logged? %>
<div href="javascript:void(0)" class="fr user_default_btn user_blue_btn mr20" style="display: flex;">
<% if User.current.mail.blank? %>
<a data-tip-down = "基于这个实训修改形成新的实训"

@ -86,6 +86,7 @@
<% end %>
</p>
<% if User.current.logged? %>
<div class="homepagePostSetting" style="right: 4px;top: 5px;display: block">
<ul>
<li class="edu-position edu-position-hidebox">
@ -105,6 +106,8 @@
</li>
</ul>
</div>
<% end %>
</div>
</div>
<% end %>

@ -600,7 +600,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'create_departments'
post 'add_department'
get 'shixun_feedback'
get 'shixun_feedback_message'
match 'shixun_feedback_message', :via => [:get, :post]
get 'leave_message'
get 'messages_list'
get 'course_messages_list'

Loading…
Cancel
Save