Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

chromesetting
jingquan huang 5 years ago
commit c78355224e

@ -12,6 +12,11 @@ $(document).on('turbolinks:load', function() {
window.location.href = "/admins/shixun_settings.xls?" + searchForm.serialize();
});
// 基础数据导出
searchContainer.on('click', "#shixun-settings-base-export", function () {
window.location.href = "/admins/shixun_settings.xls?base_data=1" + searchForm.serialize();
});
$(".shixun-settings-list-container").on("change", '.shixun-setting-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();

@ -53,3 +53,8 @@ input.form-control {
position: absolute;
}
.export-base-absolute{
right:100px;
position: absolute;
}

@ -28,7 +28,13 @@ class Admins::ShixunSettingsController < Admins::BaseController
format.html
format.xls{
filename = "实训详情_#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}.xls"
send_data(shixun_list_xls(shixun_settings), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
export_url =
if params[:base_data].present?
shixun_base_list_xls(shixun_settings)
else
shixun_list_xls(shixun_settings)
end
send_data(export_url, :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
end
@ -91,6 +97,34 @@ class Admins::ShixunSettingsController < Admins::BaseController
xls_report.string
end
def shixun_base_list_xls shixuns
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "sheet"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "状态","创建者", "单位", "职业", "关卡序号","关卡名称"])
count_row = 1
shixuns.includes(:mirror_repositories, :challenges, user: [user_extension: :school]).find_each do |shixun|
sheet1[count_row, 0] = shixun.identifier
sheet1[count_row, 1] = shixun.name
sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name
sheet1[count_row, 3] = shixun.fork_from
sheet1[count_row, 4] = shixun.shixun_status
sheet1[count_row, 5] = shixun.user.show_real_name
sheet1[count_row, 6] = shixun.user.school_name
sheet1[count_row, 7] = shixun.user.identity
shixun.challenges.each do |challenge|
sheet1[count_row, 8] = "#{challenge.position}"
sheet1[count_row, 9] = challenge.subject
count_row += 1
end
count_row += 1
end
book.write xls_report
xls_report.string
end
def setting_params
params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass,:code_hidden,:page_no, :id,tag_repertoires:[])
end

@ -45,12 +45,12 @@ class ApplicationController < ActionController::Base
check_account
tip_exception(@course.excellent ? 410 : 409, "您没有权限进入")
end
if @user_course_identity == Course::STUDENT
if @user_course_identity > Course::CREATOR && @user_course_identity <= Course::STUDENT
# 实名认证和职业认证的身份判断
tip_exception(-2, "你的实名认证和职业认证审核未通过") if @course.authentication &&
tip_exception(411, "你的实名认证和职业认证审核未通过") if @course.authentication &&
@course.professional_certification && (!current_user.authentication && !current_user.professional_certification)
tip_exception(-2, "你的实名认证审核未通过") if @course.authentication && !current_user.authentication
tip_exception(-2, "你的职业认证审核未通过") if @course.professional_certification && !current_user.professional_certification
tip_exception(411, "你的实名认证审核未通过") if @course.authentication && !current_user.authentication
tip_exception(411, "你的职业认证审核未通过") if @course.professional_certification && !current_user.professional_certification
end
uid_logger("###############user_course_identity:#{@user_course_identity}")
end

@ -635,7 +635,7 @@ class CoursesController < ApplicationController
teacher_member = CourseMember.create!(course_id: @course.id, user_id: params[:user_id], role: params[:roles].include?("PROFESSOR") ? 2 : 3)
# 如果有未审批的申请教师/助教的记录,则修改状态为已审批
apply_teacher = CourseMessage.where(course_id: @course.id, course_message_id: params[:user_id], status: 0).last
apply_teacher.update!(status: 1, apply_user_id: current_user.id)
apply_teacher.update!(status: 1, apply_user_id: current_user.id) if apply_teacher.present?
elsif course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR])
teacher_member = course_members.where(role: %i[PROFESSOR ASSISTANT_PROFESSOR]).take
if params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")

@ -1,8 +1,8 @@
class HacksController < ApplicationController
before_action :require_login, except: [:index]
before_action :require_teacher_identity, only: [:create, :edit, :update]
before_action :require_auth_identity, only: [:update, :edit, :publish]
before_action :find_hack, only: [:edit, :update, :publish, :start]
before_action :require_teacher_identity, only: [:create, :update_set]
before_action :require_auth_identity, only: [:update, :edit, :publish, :update_set, :delete_set]
before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set]
# 开启编程,如果第一次开启,创建一条记录,如果已经开启过的话,直接返回标识即可
def start
@ -75,6 +75,20 @@ class HacksController < ApplicationController
end
end
# 更新测试集接口
def update_set
set = @hack.hack_sets.find_by(id: params[:id])
set.update_attributes!(hack_set_params)
render_ok
end
# 单独删除测试集
def delete_set
set = @hack.hack_sets.find_by(id: params[:id])
set.destroy!
render_ok
end
# 发布功能
def publish
@hack.update_attribute(:status, 1)
@ -119,6 +133,10 @@ class HacksController < ApplicationController
params.permit(hack_sets: [:input, :output, :position])[:hack_sets]
end
def hack_set_params
params.require(:hack_set).permit(:id, :input, :output, :position)
end
def hack_code_params
params.require(:hack_codes).permit(:code, :language)
end
@ -144,7 +162,8 @@ class HacksController < ApplicationController
if params[:come_from]
hacks = Hack.select(select_sql).mine(current_user.id)
else
hacks = Hack.select(select_sql).published.opening
# 全部包括已经发布的,和我的未发布的
hacks = Hack.select(select_sql).published.opening.merge(Hack.select(select_sql).unpublish.mine(current_user.id))
end
# 搜索
if params[:search]

@ -64,6 +64,9 @@ class HomeworkCommonsController < ApplicationController
end
unless order.blank?
if @course.is_end
@homework_commons = @homework_commons.none
else
case order
when '1'
sql_str = %Q(homework_detail_manuals.comment_status = #{order} and homework_commons.end_time > '#{Time.now}')
@ -80,6 +83,7 @@ class HomeworkCommonsController < ApplicationController
end
@homework_commons = @homework_commons.joins(:homework_detail_manual).where(sql_str)
end
end
@task_count = @homework_commons.size
order_str = @homework_type == 4 ? "position DESC" : "IF(ISNULL(homework_commons.publish_time),0,1), homework_commons.publish_time DESC,

@ -235,9 +235,9 @@ class PollQuestionsController < ApplicationController
end
def validates_params
normal_status(-1, "问题标题不能为空!") if params[:question_title].blank?
normal_status(-1, "题目不能为空!") if params[:question_title].blank?
normal_status(-1, "是否要求必答的值不能为空!") if params[:is_necessary].blank?
normal_status(-1, "题类型不能为空!") if params[:question_type].blank?
normal_status(-1, "类型不能为空!") if params[:question_type].blank?
if params[:min_choices].present? && params[:max_choices].present? && (params[:min_choices].to_i > params[:max_choices].to_i)
normal_status(-1, "最小可选不能大于最大可选!")
elsif params[:question_answers].present? && (params[:max_choices].to_i > params[:question_answers].count)
@ -247,9 +247,9 @@ class PollQuestionsController < ApplicationController
elsif params[:question_type] == 3 && (params[:question_answers] || params[:question_other_answer])
normal_status(-1, "主观问题不需要可选答案!")
elsif params[:question_type] != 3
if params[:question_answers].present? && params[:question_answers].include?("")
normal_status(-1, "择题不能有空值!")
elsif params[:question_other_answer].present? && params[:question_other_answer].length > 0
if params[:question_answers].present? && params[:question_answers].select{|answer| answer.blank?}.count > 0
normal_status(-1, "不能有空值!")
elsif params[:question_other_answer].present? && !params[:question_other_answer].blank?
normal_status(-1, "其他选项不能有值!")
elsif params[:question_type] == 1 && params[:question_answers].count < 2
normal_status(-1, "单选题选项不能小于2")

@ -82,6 +82,7 @@ class Weapps::CoursesController < Weapps::BaseController
# 批量修改角色
def change_member_roles
@course = current_course
tip_exception("请至少选择一个角色") if params[:roles].blank?
tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR")
@ -97,7 +98,7 @@ class Weapps::CoursesController < Weapps::BaseController
teacher_member = CourseMember.create!(course_id: @course.id, user_id: user_id, role: params[:roles].include?("PROFESSOR") ? 2 : 3)
# 如果有未审批的申请教师/助教的记录,则修改状态为已审批
apply_teacher = CourseMessage.where(course_id: @course.id, course_message_id: user_id, status: 0).last
apply_teacher.update!(status: 1, apply_user_id: current_user.id)
apply_teacher.update!(status: 1, apply_user_id: current_user.id) if apply_teacher
elsif course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR])
teacher_member = course_members.where(role: %i[PROFESSOR ASSISTANT_PROFESSOR]).take
if params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")

@ -12,6 +12,7 @@ class Hack < ApplicationRecord
belongs_to :user
scope :published, -> { where(status: 1) }
scope :unpublish, -> { where(status: 0) }
scope :opening, -> {where(open_or_not: 1)}
scope :mine, -> (author_id){ where(user_id: author_id) }

@ -1,4 +1,6 @@
class HackSet < ApplicationRecord
validates :input, presence: { message: "测试集输入不能为空" }
validates :output, uniqueness: { message: "测试集输出不能为空" }
# 编程题测试集
belongs_to :hack
end

@ -24,6 +24,7 @@
<%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with': '搜索中...') %>
<%= link_to "清除",admins_shixun_settings_path,class: "btn btn-default",'data-disable-with': '清除中...' %>
<div class="">
<a href="javascript:void(0)" class="btn btn-primary export-base-absolute" id="shixun-settings-base-export" data-disable-with = '导出中...'>导出基础数据</a>
<a href="javascript:void(0)" class="btn btn-primary export-absolute" id="shixun-settings-export" data-disable-with = '导出中...'>导出</a>
</div>
</div>

@ -1,7 +1,6 @@
json.id discuss.id
json.content content_safe(discuss.content)
json.time time_from_now(discuss.created_at)
json.position discuss.position
json.hack_id discuss.dis_id
# 主贴和回复有一些不同点
if discuss.parent_id

@ -43,9 +43,11 @@ Rails.application.routes.draw do
post :publish
get :start
get :result
post :update_set
delete :delete_set
end
resources :comments do
post :reply
end
end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -33,12 +33,17 @@ Released under the MIT license
(function() {
(function() {
var cspNonce;
var nonce;
cspNonce = Rails.cspNonce = function() {
var meta;
meta = document.querySelector('meta[name=csp-nonce]');
return meta && meta.content;
nonce = null;
Rails.loadCSPNonce = function() {
var ref;
return nonce = (ref = document.querySelector("meta[name=csp-nonce]")) != null ? ref.content : void 0;
};
Rails.cspNonce = function() {
return nonce != null ? nonce : Rails.loadCSPNonce();
};
}).call(this);
@ -617,24 +622,29 @@ Released under the MIT license
return setData(form, 'ujs:submit-button-formmethod', button.getAttribute('formmethod'));
};
Rails.handleMetaClick = function(e) {
var data, link, metaClick, method;
Rails.preventInsignificantClick = function(e) {
var data, insignificantMetaClick, link, metaClick, method, primaryMouseKey;
link = this;
method = (link.getAttribute('data-method') || 'GET').toUpperCase();
data = link.getAttribute('data-params');
metaClick = e.metaKey || e.ctrlKey;
if (metaClick && method === 'GET' && !data) {
insignificantMetaClick = metaClick && method === 'GET' && !data;
primaryMouseKey = e.button === 0;
if (!primaryMouseKey || insignificantMetaClick) {
return e.stopImmediatePropagation();
}
};
}).call(this);
(function() {
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMetaClick, handleMethod, handleRemote, refreshCSRFTokens;
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens;
fire = Rails.fire, delegate = Rails.delegate, getData = Rails.getData, $ = Rails.$, refreshCSRFTokens = Rails.refreshCSRFTokens, CSRFProtection = Rails.CSRFProtection, enableElement = Rails.enableElement, disableElement = Rails.disableElement, handleDisabledElement = Rails.handleDisabledElement, handleConfirm = Rails.handleConfirm, handleRemote = Rails.handleRemote, formSubmitButtonClick = Rails.formSubmitButtonClick, handleMetaClick = Rails.handleMetaClick, handleMethod = Rails.handleMethod;
fire = Rails.fire, delegate = Rails.delegate, getData = Rails.getData, $ = Rails.$, refreshCSRFTokens = Rails.refreshCSRFTokens, CSRFProtection = Rails.CSRFProtection, loadCSPNonce = Rails.loadCSPNonce, enableElement = Rails.enableElement, disableElement = Rails.disableElement, handleDisabledElement = Rails.handleDisabledElement, handleConfirm = Rails.handleConfirm, preventInsignificantClick = Rails.preventInsignificantClick, handleRemote = Rails.handleRemote, formSubmitButtonClick = Rails.formSubmitButtonClick, handleMethod = Rails.handleMethod;
if ((typeof jQuery !== "undefined" && jQuery !== null) && (jQuery.ajax != null) && !jQuery.rails) {
if ((typeof jQuery !== "undefined" && jQuery !== null) && (jQuery.ajax != null)) {
if (jQuery.rails) {
throw new Error('If you load both jquery_ujs and rails-ujs, use rails-ujs only.');
}
jQuery.rails = Rails;
jQuery.ajaxPrefilter(function(options, originalOptions, xhr) {
if (!options.crossDomain) {
@ -663,12 +673,13 @@ Released under the MIT license
delegate(document, Rails.linkDisableSelector, 'ajax:stopped', enableElement);
delegate(document, Rails.buttonDisableSelector, 'ajax:complete', enableElement);
delegate(document, Rails.buttonDisableSelector, 'ajax:stopped', enableElement);
delegate(document, Rails.linkClickSelector, 'click', preventInsignificantClick);
delegate(document, Rails.linkClickSelector, 'click', handleDisabledElement);
delegate(document, Rails.linkClickSelector, 'click', handleConfirm);
delegate(document, Rails.linkClickSelector, 'click', handleMetaClick);
delegate(document, Rails.linkClickSelector, 'click', disableElement);
delegate(document, Rails.linkClickSelector, 'click', handleRemote);
delegate(document, Rails.linkClickSelector, 'click', handleMethod);
delegate(document, Rails.buttonClickSelector, 'click', preventInsignificantClick);
delegate(document, Rails.buttonClickSelector, 'click', handleDisabledElement);
delegate(document, Rails.buttonClickSelector, 'click', handleConfirm);
delegate(document, Rails.buttonClickSelector, 'click', disableElement);
@ -686,10 +697,12 @@ Released under the MIT license
});
delegate(document, Rails.formSubmitSelector, 'ajax:send', disableElement);
delegate(document, Rails.formSubmitSelector, 'ajax:complete', enableElement);
delegate(document, Rails.formInputClickSelector, 'click', preventInsignificantClick);
delegate(document, Rails.formInputClickSelector, 'click', handleDisabledElement);
delegate(document, Rails.formInputClickSelector, 'click', handleConfirm);
delegate(document, Rails.formInputClickSelector, 'click', formSubmitButtonClick);
document.addEventListener('DOMContentLoaded', refreshCSRFTokens);
document.addEventListener('DOMContentLoaded', loadCSPNonce);
return window._rails_loaded = true;
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 56 KiB

@ -349,6 +349,7 @@ class App extends Component {
});
}
componentDidMount() {
document.title = "loading...";
this.disableVideoContextMenu();
// force an update if the URL changes
history.listen(() => {

@ -616,7 +616,7 @@ class NewShixunModel extends Component{
}
</Checkbox.Group>
{shixun_list===undefined||shixuns_count===undefined?"":shixun_list.length===0||shixuns_count===0?"":shixuns_count>15?<div className={" edu-txt-center pd303010"}>
{shixun_list===undefined||shixuns_count===undefined?"":shixun_list.length===0||shixuns_count===0?"":shixuns_count>15?<div className={" edu-txt-center pd303010 newshixunmodels"}>
<Pagination
showQuickJumper
defaultCurrent={1}

@ -5,6 +5,7 @@
.newshixunheadersear{
display: flex;
justify-content: center;
margin: 0 auto;
}
.packinput .ant-input{
height: 55px;
@ -376,3 +377,11 @@
display: flex;
flex-direction:initial;
}
.newshixunheadersear{
margin: 0 auto;
}
.newshixunmodels{
margin: 0 auto;
}

@ -386,6 +386,7 @@ class LoginDialog extends Component {
axios.interceptors.response.use((response) => {
if(response!=undefined)
if (response&&response.data.status === 401) {
document.title = "提示";
this.setState({
isRender: true
})

@ -65,7 +65,7 @@ class AccountPhoneemail extends Component {
width="530px"
>
<div className="task-popup-content">
<p className="task-popup-text-center font-16"> 您需要完成手机号码邮箱的绑定才能使用此功能</p>
<p className="task-popup-text-center font-16"> 您需要完成手机号码或者邮箱的绑定才能使用此功能</p>
<div className="clearfix mt30 edu-txt-center">
<a className="task-btn mr30" onClick={()=>this.gotoback()}>稍后绑定</a>
<a className="task-btn task-btn-orange" href={ "/account/secure" }> {'立即绑定'}</a>

@ -19,6 +19,7 @@ class AccountProfile extends Component {
axios.interceptors.response.use((response) => {
if (response != undefined)
if (response && response.data.status === 402) {
document.title = "提示";
this.setState({
AccountProfiletype: true
})

@ -10,9 +10,11 @@ class Accountnewprofile extends Component {
}
}
componentDidMount() {
axios.interceptors.response.use((response) => {
if(response!=undefined)
if (response&&response.data.status === 411) {
document.title = "提示";
this.setState({
newAccountProfiletype:true,
content:response.data.message,

Loading…
Cancel
Save