Merge branch 'dev_aliyun' into dev_cs

topic_bank
caicai8 5 years ago
commit 3b76bb8a9c

@ -1,22 +0,0 @@
$(document).on('turbolinks:load', function() {
var $editModal = $('.department-apply-edit-modal');
if($editModal.length > 0){
var $form = $editModal.find('form.department-apply-form');
var $applyIdInput = $form.find('input[name="id"]');
$editModal.on('show.bs.modal', function (event) {
var $link = $(event.relatedTarget);
var applyId = $link.data('id');
$applyIdInput.val(applyId);
});
$editModal.on('click', '.submit-btn', function(){
$.ajax({
method: "PUT",
dataType: 'script',
url: "/admins/department_applies/"+ $applyIdInput.val(),
data: $form.serialize(),
}).done(function(){
$editModal.modal('hide');
});
});
}
});

@ -1,14 +1,22 @@
$(document).on('turbolinks:load', function() {
var $modal = $('.modal.admin-message-modal');
var $submitBtn = $modal.find('.submit-btn');
if ($modal.length > 0) {
$modal.on('hide.bs.modal', function(){
$modal.find('.modal-body').html('');
$submitBtn.unbind();
});
}
});
function showMessageModal(html) {
function showMessageModal(html, callback) {
var $modal = $('.modal.admin-message-modal');
var $submitBtn = $modal.find('.submit-btn');
$submitBtn.unbind();
if(callback !== undefined && typeof callback === 'function'){
$submitBtn.on('click', callback);
}
$modal.find('.modal-body').html(html);
$modal.modal('show');
}

@ -0,0 +1,78 @@
$(document).on('turbolinks:load', function() {
var $modal = $('.modal.admin-import-course-member-modal');
if ($modal.length > 0) {
var $form = $modal.find('form.admin-import-course-member-form');
var resetFileInputFunc = function(file){
file.after(file.clone().val(""));
file.remove();
}
$modal.on('show.bs.modal', function(){
$modal.find('.file-names').html('选择文件');
$modal.find('.upload-file-input').trigger('click');
});
$modal.on('hide.bs.modal', function(){
resetFileInputFunc($modal.find('.upload-file-input'));
});
$modal.on('change', '.upload-file-input', function(e){
var file = $(this)[0].files[0];
$modal.find('.file-names').html(file ? file.name : '请选择文件');
})
var importFormValid = function(){
if($form.find('input[name="file"]').val() == undefined || $form.find('input[name="file"]').val().length == 0){
$form.find('.error').html('请选择文件');
return false;
}
return true;
};
var buildResultMessage = function(data){
var messageHtml = "<div>导入结果:成功" + data.success + "条,失败"+ data.fail.length + "条</div>";
if(data.fail.length > 0){
messageHtml += '<table class="table"><thead class="thead-light"><tr><th>数据</th><th>失败原因</th></tr></thead><tbody>';
data.fail.forEach(function(item){
messageHtml += '<tr><td>' + item.data + '</td><td>' + item.message + '</td></tr>';
});
messageHtml += '</tbody></table>'
}
return messageHtml;
}
$modal.on('click', '.submit-btn', function(){
$form.find('.error').html('');
if (importFormValid()) {
$('body').mLoading({ text: '正在导入...' });
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/import_course_members',
data: new FormData($form[0]),
processData: false,
contentType: false,
success: function(data){
$('body').mLoading('destroy');
$modal.modal('hide');
showMessageModal(buildResultMessage(data), function(){
window.location.reload();
});
},
error: function(res){
$('body').mLoading('destroy');
var data = res.responseJSON;
$form.find('.error').html(data.message);
}
});
}
});
}
});

@ -66,10 +66,11 @@ $(document).on('turbolinks:load', function() {
var $link = $(event.relatedTarget);
var schoolId = $link.data('schoolId');
var url = $link.data('url');
$schoolIdInput.val(schoolId);
$originDepartmentIdInput.val($link.data('departmentId'));
$form.data('url', url);
$.ajax({
url: '/api/schools/' + schoolId + '/departments/for_option.json',
dataType: 'json',

@ -122,14 +122,18 @@ $(document).on('turbolinks:load', function(){
// 导入学生
var $importUserModal = $('.modal.admin-import-user-modal');
var $importUserForm = $importUserModal.find('form.admin-import-user-form')
var resetFileInputFunc = function(file){
file.after(file.clone().val(""));
file.remove();
}
$importUserModal.on('show.bs.modal', function(){
resetFileInputFunc($importUserModal.find('.upload-file-input'));
$importUserModal.find('.file-names').html('选择文件');
$importUserModal.find('.upload-file-input').trigger('click');
});
$importUserModal.find('.upload-file-input').on('change', function(e){
$importUserModal.on('change', '.upload-file-input', function(e){
var file = $(this)[0].files[0];
$importUserModal.find('.file-names').html(file ? file.name : '请选择文件');
})
@ -175,7 +179,9 @@ $(document).on('turbolinks:load', function(){
$('body').mLoading('destroy');
$importUserModal.modal('hide');
showMessageModal(buildResultMessage(data));
showMessageModal(buildResultMessage(data), function(){
window.location.reload();
});
},
error: function(res){
$('body').mLoading('destroy');

@ -1,6 +1,7 @@
class Admins::DepartmentAppliesController < Admins::BaseController
before_action :get_apply,only:[:agree,:edit,:update,:destroy]
before_action :get_apply,only:[:agree,:destroy]
def index
params[:status] ||= 0
params[:sort_by] = params[:sort_by].presence || 'created_at'
@ -19,46 +20,77 @@ class Admins::DepartmentAppliesController < Admins::BaseController
end
end
def update
depart_name = params[:name]
def merge
apply_id = params[:origin_department_id]
apply_add =ApplyAddDepartment.find(apply_id)
origin_id = apply_add&.department_id
new_id = params[:department_id]
return render_error('请选择其它部门') if origin_id.to_s == new_id.to_s
origin_department = apply_add&.department
to_department = Department.find(new_id)
return render_error('部门所属单位不相同') if origin_department&.school_id != to_department&.school_id
ActiveRecord::Base.transaction do
@depart_apply.update_attribute("name",depart_name)
@depart_apply&.department&.update_attribute("name",depart_name)
extra = depart_name + "(#{@depart_apply&.department&.school&.try(:name)})"
applied_message = AppliedMessage.where(applied_id: origin_id, applied_type: "ApplyAddDepartment")
applied_message.update_all(:status => 4)
apply_add.update_attribute(:status, 2)
apply_add.tidings.update_all(:status => 1)
extra = to_department&.name + "(#{apply_add&.department&.school&.try(:name)})"
tiding_params = {
user_id: @depart_apply.user_id,
user_id: apply_add.user_id,
trigger_user_id: 0,
container_id: @depart_apply.id,
container_id: apply_add.id,
container_type: 'ApplyAddDepartment',
belong_container_id: @depart_apply.department.school_id,
belong_container_id: apply_add&.department&.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 3,
extra: extra
}
Tiding.create(tiding_params)
render_success_js
origin_department.apply_add_departments.delete_all
origin_department.user_extensions.update_all(department_id: new_id)
if to_department.identifier.blank? && origin_department.identifier.present?
to_department.update!(identifier: origin_department.identifier)
end
origin_department.destroy!
apply_add.destroy!
end
render_ok
end
def destroy
ActiveRecord::Base.transaction do
@depart_apply.update_attribute("status",3)
@depart_apply&.applied_messages&.update_all(status:3)
if params[:tip] == 'unapplied' #未审批时候删除
UserExtension.where(department_id: @depart_apply.department_id).update_all(department_id:nil)
tiding_params = {
user_id: @depart_apply.user_id,
trigger_user_id: 0,
container_id: @depart_apply.id,
container_type: 'ApplyAddDepartment',
belong_container_id: @depart_apply&.department&.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 2,
extra: params[:reason]
}
Tiding.create(tiding_params)
end
@depart_apply&.department&.destroy
@depart_apply&.user&.user_extension&.update_attribute("department_id", nil)
tiding_params = {
user_id: @depart_apply.user_id,
trigger_user_id: 0,
container_id: @depart_apply.id,
container_type: 'ApplyAddDepartment',
belong_container_id: @depart_apply.department.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 2,
extra: params[:reason]
}
Tiding.create(tiding_params)
@depart_apply.destroy
render_success_js
end
end

@ -0,0 +1,122 @@
class Admins::UnitAppliesController < Admins::BaseController
before_action :get_apply,only: [:agree,:destroy,:edit,:update]
def index
params[:sort_by] ||= 'created_at'
params[:sort_direction] ||= 'desc'
unit_applies = Admins::UnitApplyQuery.call(params)
@unit_applies = paginate unit_applies.preload(:school, :user)
end
def agree
ActiveRecord::Base.transaction do
begin
@unit_apply.update_attribute("status",1)
@unit_apply&.applied_messages&.update_all(status:1)
@unit_apply&.school&.update_attribute("province",@unit_apply.province)
# #申请信息的创建
apply_message_params = {
user_id: @unit_apply&.user_id,
status: 1,
viewed: 0,
applied_id: @unit_apply.school_id,
applied_type: "ApplyAddSchools",
name: @unit_apply.name,
}
AppliedMessage.new(apply_message_params).save(validate: false)
Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
#消息的创建
tiding_params = {
user_id: @unit_apply.user_id,
trigger_user_id: 0,
container_id: @unit_apply.id,
container_type: 'ApplyAddSchools',
belong_container_id: @unit_apply.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 1
}
Tiding.create(tiding_params)
render_success_js
rescue Exception => e
Rails.logger.info("############_________________#########{e}")
end
end
end
def destroy
Admins::DeleteUnitApplyService.call(@unit_apply, params)
render_success_js
end
def edit
@all_schools = School.where.not(id: @unit_apply.school_id).pluck("name","id")
end
def update
school = School.find_by(id: params[:school_id])
ActiveRecord::Base.transaction do
@unit_apply&.applied_messages&.update_all(status:4)
Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
#消息的创建
tiding_params = {
user_id: @unit_apply.user_id,
trigger_user_id: 0,
container_id: @unit_apply.id,
container_type: 'ApplyAddSchools',
belong_container_id: params[:school_id],
belong_container_type: "School",
tiding_type: "System",
status: 3,
extra: school.try(:name).to_s
}
Tiding.create(tiding_params)
UserExtension.where(school_id: @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
ApplyAddDepartment.where(:school_id => @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
# 判断重复
before_apply_departments = Department.where(school_id: @unit_apply.school_id)
before_apply_departments.each do |department|
after_dep = Department.where(school_id: params[:school_id].to_i, name: department.name)&.first
if after_dep.present?
UserExtension.where(school_id: @unit_apply.school_id, department_id: department.id).update_all(department_id: after_dep.id)
department.destroy
department.apply_add_departments.destroy_all
else
department.apply_add_departments.update_all(school_id: school.id)
department.update_attribute(:school_id, school.id)
end
end
@unit_apply&.school&.destroy
apply_params = {
status: 2,
name: school&.name.to_s,
school_id: params[:school_id],
province: params[:province],
city: params[:city],
address: params[:address]
}
@unit_apply.update_attributes(apply_params)
# render_success_js
end
end
private
def get_apply
@unit_apply = ApplyAddSchool.find_by(id:params[:id])
end
def disk_auth_filename(source_type, source_id, type)
File.join(storage_path, "#{source_type}", "#{source_id}#{type}")
end
end

@ -212,7 +212,7 @@ class CoursesController < ApplicationController
@course.update_attributes!(course_params.merge(extra_params))
@course.update_course_modules(params[:course_module_types])
Rails.logger.info("###############course_update_end")
normal_status(0, "成功")
rescue => e
uid_logger_error(e.message)
@ -1484,8 +1484,10 @@ class CoursesController < ApplicationController
shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"]
# 更新实训作业成绩
shixun_homeworks.includes(:homework_challenge_settings, :published_settings, :homework_commons_shixun).each do |homework|
homework.update_homework_work_score
unless course.is_end
shixun_homeworks.includes(:homework_challenge_settings, :published_settings, :homework_commons_shixun).each do |homework|
homework.update_homework_work_score
end
end
shixun_homeworks = shixun_homeworks&.includes(score_student_works: :user)

@ -916,7 +916,8 @@ class GamesController < ApplicationController
# 更新关卡状态和一些学习进度
def update_game_parameter game
game.update_attribute(:status, 0) if game.status == 1
game.update_attributes(status: 0, open_time: Time.now) if game.status == 3
# 第一次进入关卡更新时间
game.update_attributes(status: 0, open_time: Time.now) if game.open_time.blank? || game.status == 3
# 开启实训更新myshixuns的时间方便跟踪用于的学习进度。
game.myshixun.update_column(:updated_at, Time.now)
end

@ -230,6 +230,7 @@ class GraduationTopicsController < ApplicationController
topic_repeat: topic.topic_repeat,
province: topic.province,
city: topic.city,
topic_type: topic.topic_type,
course_list_id: @course.course_list_id)
topic_bank.attachments.destroy_all
else
@ -241,6 +242,7 @@ class GraduationTopicsController < ApplicationController
topic_repeat: topic.topic_repeat,
province: topic.province,
city: topic.city,
topic_type: topic.topic_type,
course_list_id: @course.course_list_id,
user_id: current_user.id,
graduation_topic_id: topic.id)

@ -930,6 +930,7 @@ class HomeworkCommonsController < ApplicationController
shixuns.each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, @category, current_user
@homework_ids << homework.id
CreateStudentWorkJob.perform_later(homework.id)
end
rescue Exception => e
uid_logger(e.message)
@ -1031,6 +1032,7 @@ class HomeworkCommonsController < ApplicationController
stage.shixuns.where.not(shixuns: {id: none_shixun_ids}).unhidden.each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
@homework_ids << homework.id
CreateStudentWorkJob.perform_later(homework.id)
end
end
end

@ -8,11 +8,11 @@ class ShixunsController < ApplicationController
before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
:propaedeutics, :departments, :apply_shixun_mirror,
:get_mirror_script, :download_file]
:get_mirror_script, :download_file, :shixun_list]
before_action :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
:propaedeutics, :departments, :apply_shixun_mirror,
:get_mirror_script, :download_file]
:get_mirror_script, :download_file, :shixun_list]
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, :add_file]
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish,
@ -98,6 +98,45 @@ class ShixunsController < ApplicationController
.each_with_object({}) { |r, obj| obj[r.shixun_id] = r.name }
end
def shixun_list
# 全部实训/我的实训
type = params[:type] || "all"
# 状态:已发布/未发布
status = params[:status] || "all"
# 超级管理员用户显示所有未隐藏的实训、非管理员显示所有已发布的实训(对本单位公开且未隐藏未关闭)
if type == "mine"
@shixuns = current_user.shixuns.none_closed
else
if current_user.admin?
@shixuns = Shixun.none_closed.where(hidden: 0)
else
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
@shixuns = Shixun.where.not(id: none_shixun_ids).none_closed.where(hidden: 0)
end
end
unless status == "all"
@shixuns = status == "published" ? @shixuns.where(status: 2) : @shixuns.where(status: [0, 1])
end
## 筛选 难度
if params[:diff].present? && params[:diff].to_i != 0
@shixuns = @shixuns.where(trainee: params[:diff])
end
page = params[:page] || 1
limit = params[:limit] || 10
offset = (page.to_i - 1) * limit
order = params[:order] || "desc"
## 搜索关键字创建者、实训名称、院校名称
keyword = params[:search]
@shixuns = Shixun.search keyword, where: {id: @shixuns.pluck(:id)}, order: {"myshixuns_count" => order}, limit: limit, offset: offset
@total_count = @shixuns.total_count
end
## 获取顶部菜单
def menus
@repertoires = Repertoire.includes(sub_repertoires: [:tag_repertoires]).order("updated_at asc")
@ -601,7 +640,7 @@ class ShixunsController < ApplicationController
challenges.each_with_index do |challenge, index|
status = (index == 0 ? 0 : 3)
game_identifier = generate_identifier(Game, 12)
worker.add(base_attr.merge(challenge_id: challenge.id, status: status, open_time: Time.now,
worker.add(base_attr.merge(challenge_id: challenge.id, status: status,
identifier: game_identifier, modify_time: challenge.modify_time))
end
end
@ -865,6 +904,7 @@ class ShixunsController < ApplicationController
def send_to_course
@course = Course.find(params[:course_id])
homework = HomeworksService.new.create_homework @shixun, @course, nil, current_user
CreateStudentWorkJob.perform_later(homework.id)
end
# 二维码扫描下载

@ -214,6 +214,7 @@ class SubjectsController < ApplicationController
stage.shixuns.where(id: params[:shixun_ids], status: 2).each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
CreateStudentWorkJob.perform_later(homework.id)
end
end
rescue Exception => e

@ -1,7 +1,10 @@
class Wechats::JsSdkSignaturesController < ApplicationController
def create
signature = Util::Wechat.js_sdk_signature(params[:url], params[:noncestr], params[:timestamp])
render_ok(signature: signature)
timestamp = (Time.now.to_f * 1000).to_i
noncestr = ('A'..'z').to_a.sample(8).join
signature = Util::Wechat.js_sdk_signature(params[:url], noncestr, timestamp)
render_ok(appid: Util::Wechat.appid, timestamp: timestamp, noncestr: noncestr, signature: signature)
rescue Util::Wechat::Error => ex
render_error(ex.message)
end

@ -1,10 +1,12 @@
class ApplyAddSchool < ApplicationRecord
belongs_to :school
belongs_to :user
has_many :applied_messages, as: :applied
has_many :tidings, as: :container, dependent: :destroy
after_create :send_notify
# after_destroy :after_delete_apply
private
@ -12,4 +14,9 @@ class ApplyAddSchool < ApplicationRecord
Tiding.create!(user_id: 1, status: 0, container_id: id, container_type: 'ApplyAddSchools',
trigger_user_id: user_id, belong_container: school, tiding_type: 'Apply')
end
# def after_delete_apply
#
# end
end

@ -16,6 +16,8 @@ class School < ApplicationRecord
has_many :customers, dependent: :destroy
has_many :partners, dependent: :destroy
has_many :apply_add_departments, dependent: :destroy
# 学校管理员
def manager?(user)
ec_school_users.exists?(user_id: user.id)

@ -14,7 +14,9 @@ module Searchable::Shixun
def search_data
{
name: name,
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH]
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH],
status: status,
myshixuns_count: myshixuns_count
}.merge!(searchable_user_data)
.merge!(searchable_challenge_data)
end
@ -37,7 +39,7 @@ module Searchable::Shixun
end
def should_index?
status == 2 # published
[0, 1, 2].include?(status) # published
end
def to_searchable_json

@ -59,6 +59,7 @@ class Shixun < ApplicationRecord
scope :visible, -> { where.not(status: -1) }
scope :published, lambda{ where(status: 2) }
scope :published_closed, lambda{ where(status: [2, 3]) }
scope :none_closed, lambda{ where(status: [0, 1, 2]) }
scope :unhidden, lambda{ where(hidden: 0, status: 2) }
scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) }
scope :find_by_ids,lambda{|k| where(id:k)}

@ -0,0 +1,24 @@
class Admins::UnitApplyQuery < ApplicationQuery
include CustomSortable
attr_reader :params
sort_columns :created_at, default_by: :created_at, default_direction: :desc
def initialize(params)
@params = params
end
def call
unit_applies = ApplyAddSchool.where(status:0)
# 关键字模糊查询
keyword = params[:keyword].to_s.strip
if keyword.present?
unit_applies = unit_applies.where("name like ?","%#{keyword}%")
end
custom_sort(unit_applies, params[:sort_by], params[:sort_direction])
end
end

@ -0,0 +1,56 @@
class Admins::DeleteUnitApplyService < ApplicationService
attr_reader :department, :params
def initialize(unit_apply, params)
@unit_apply = unit_apply
@params = params
end
def call
ActiveRecord::Base.transaction do
@unit_apply.update_attribute("status",3)
@unit_apply&.applied_messages&.update_all(status:3)
@unit_apply&.school&.apply_add_departments&.update_all(status:3)
applied_departments = ApplyAddDepartment.where(school_id: @unit_apply.school_id)
applied_departments.update_all(status: 3)
use_extensions = UserExtension&.where(school_id: @unit_apply.school_id)
user_ids = UserExtension&.where(school_id: @unit_apply.school_id)&.pluck(:user_id)
User.where(id: user_ids).update_all(profile_completed: false)
use_extensions.update_all(school_id: nil,department_id: nil)
@unit_apply&.user&.user_extension&.update_attribute("department_id", nil)
# 申请了职业认证的用户撤销申请
apply_user_auth = ApplyUserAuthentication.where(user_id: user_ids, auth_type: 2, status: 0)
apply_user_auth.each do |apply|
apply.tidings.destroy_all
apply.update_attribute('status', 3)
diskfile2 = disk_auth_filename('UserAuthentication', apply.user_id, 'PRO')
diskfilePRO = diskfile2 + 'temp'
File.delete(diskfilePRO) if File.exist?(diskfilePRO)
File.delete(diskfile2) if File.exist?(diskfile2)
end
# 未审批删除
if params[:tip] == "unapplied"
Tiding.where(:user_id => 1, :trigger_user_id => @unit_apply.user_id, :container_id => @unit_apply.id, :container_type => 'ApplyAddSchools', :status => 0, :tiding_type => "Apply").update_all(status: 1)
Tiding.create(:user_id => @unit_apply.user_id, :trigger_user_id => 0, :container_id => @unit_apply.id, :container_type =>'ApplyAddSchools', :belong_container_id => @unit_apply.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2, :extra => params[:reason])
Tiding.where(:user_id => 1, :container_id => applied_departments.pluck(:id), :container_type => 'ApplyAddDepartment', :status => 0, :tiding_type => "Apply").update_all(status: 1)
if applied_departments&.first.present?
Tiding.create(:user_id => applied_departments.first.user_id, :trigger_user_id => 0, :container_id => applied_departments.first.id, :container_type =>'ApplyAddDepartment', :belong_container_id => @unit_apply.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2)
AppliedMessage.create(:user_id => applied_departments.first.user_id, :status => 3, :viewed => 0, :applied_id => applied_departments.first.id, :applied_type => "ApplyAddDepartment", :name => applied_departments.first.name )
end
@unit_apply&.school&.destroy
@unit_apply&.school&.departments&.destroy_all
elsif params[:tip] == "applied"
applied_departments.destroy_all
@unit_apply.destroy
end
end
end
end

@ -15,7 +15,6 @@ class HomeworksService
homework_detail_manual.save! if homework_detail_manual
HomeworkCommonsShixun.create!(homework_common_id: homework.id, shixun_id: shixun.id)
HomeworksService.new.create_shixun_homework_cha_setting(homework, shixun)
CreateStudentWorkJob.perform_later(homework.id)
# HomeworksService.new.create_works_list(homework, course)
end
homework

@ -14,10 +14,12 @@ class SearchService < ApplicationService
private
def search_options
{
model_options = {
index_name: index_names,
model_includes: model_includes
}.merge(default_options)
}
model_options.merge(where: { status: 2 }) if index_names == [Shixun]
model_options.merge(default_options)
end
def index_names

@ -0,0 +1,30 @@
<div class="modal fade admin-import-course-member-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">导入课堂成员</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form class="admin-import-course-member-form" enctype="multipart/form-data">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">文件</span>
</div>
<div class="custom-file">
<input type="file" name="file" id="import-course-member-input" class="upload-file-input" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<label class="custom-file-label file-names" for="import-course-member-input">选择文件</label>
</div>
</div>
<div class="error text-danger"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -1,2 +0,0 @@
//$("#apply-id-<%= @depart_apply.id %>").remove()
//pop_box_new("批准成功", 400, 248);

@ -15,4 +15,4 @@
</div>
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>
<%= render partial: 'admins/department_applies/shared/edit_modal' %>
<%= render 'admins/departments/shared/merge_department_modal' %>

@ -1,26 +0,0 @@
<div class="modal fade department-apply-edit-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">修改为</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form class="department-apply-form" data-remote="true">
<%= hidden_field_tag(:id, nil) %>
<div class="form-group">
<label for="grade" class="col-form-label">名称:</label>
<%= text_field_tag(:name,nil,class:"form-control",placeholder:"输入新的名称") %>
</div>
<div class="error text-danger"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -1,12 +1,12 @@
<table class="table table-hover text-center department_applies-list-table">
<thead class="thead-light">
<tr>
<th width="9%">ID</th>
<th width="25%" class="edu-txt-left">部门名称</th>
<th width="20%" class="edu-txt-left">单位名称</th>
<th width="8%">ID</th>
<th width="22%" class="text-left">部门名称</th>
<th width="20%" class="text-left">单位名称</th>
<th width="15%">创建者</th>
<th width="15%"><%= sort_tag('创建于', name: 'created_at', path: admins_department_applies_path) %></th>
<th>操作</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
@ -14,8 +14,8 @@
<% applies.each do |apply| %>
<tr class="department-apply-<%= apply.id %>">
<td><%= apply.id %></td>
<td class="edu-txt-left"> <%= apply.name %></td>
<td class="edu-txt-left"> <%= apply.school.try(:name) %></td>
<td class="text-left"> <%= apply.name %></td>
<td class="text-left"> <%= apply.school.try(:name) %></td>
<td><%= apply.user.show_real_name %></td>
<td><%= format_time apply.created_at %></td>
<td class="action-container">
@ -23,17 +23,16 @@
<%= javascript_void_link('删除', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id, title: "删除原因", type: "delete",
url: admins_department_apply_path(apply, element: ".department-apply-#{apply.id}")
url: admins_department_apply_path(apply,tip:"unapplied", element: ".department-apply-#{apply.id}")
}) %>
<%= javascript_void_link('修改', class: 'action department-apply-action', data: { toggle: 'modal', target: '.department-apply-edit-modal', id: apply.id }) %>
<%= javascript_void_link '更改', class: 'action', data: { school_id: apply.school_id, department_id: apply.id,
toggle: 'modal', target: '.admin-merge-department-modal', url: merge_admins_department_applies_path } %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -28,7 +28,8 @@
<%= javascript_void_link '添加管理员', class: 'action', data: { department_id: department.id, toggle: 'modal', target: '.admin-add-department-member-modal' } %>
<%= javascript_void_link '更改', class: 'action', data: { school_id: department.school_id, department_id: department.id, toggle: 'modal', target: '.admin-merge-department-modal' } %>
<%= javascript_void_link '更改', class: 'action', data: { school_id: department.school_id, department_id: department.id,
toggle: 'modal', target: '.admin-merge-department-modal', url: merge_admins_departments_path } %>
<%= delete_link '删除', admins_department_path(department, element: ".department-item-#{department.id}"), class: 'delete-department-action' %>
</td>

@ -18,7 +18,6 @@
<select id="department_id" name="department_id" class="form-control department-select"></select>
</div>
</div>
<div class="error text-danger"></div>
</form>
</div>

@ -56,7 +56,8 @@
<%= sidebar_item_group('#apply-review-submenu', '审核', icon: 'gavel') do %>
<li><%= sidebar_item(admins_identity_authentications_path, '实名认证', icon: 'id-card-o', controller: 'admins-identity_authentications') %></li>
<li><%= sidebar_item(admins_professional_authentications_path, '职业认证', icon: 'drivers-license', controller: 'admins-professional_authentications') %></li>
<li><%= sidebar_item(admins_department_applies_path, '部门审批', icon: 'building', controller: 'admins-department_applies') %></li>
<li><%= sidebar_item(admins_department_applies_path, '部门审批', icon: 'newspaper-o', controller: 'admins-department_applies') %></li>
<li><%= sidebar_item(admins_unit_applies_path, '单位审批', icon: 'building-o', controller: 'admins-unit_applies') %></li>
<li><%= sidebar_item(admins_shixun_authorizations_path, '实训发布', icon: 'object-ungroup', controller: 'admins-shixun_authorizations') %></li>
<li><%= sidebar_item(admins_subject_authorizations_path, '实践课程发布', icon: 'object-group', controller: 'admins-subject_authorizations') %></li>
<li><%= sidebar_item(admins_library_applies_path, '教学案例发布', icon: 'language', controller: 'admins-library_applies') %></li>

@ -11,7 +11,7 @@
保存成功
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">确认</button>
<button type="button" class="btn btn-primary submit-btn" data-dismiss="modal">确认</button>
</div>
</div>
</div>

@ -0,0 +1,56 @@
$("body").append("<%= j render partial: "admins/unit_applies/shared/edit_modal",locals: {apply: @unit_apply, schools: @all_schools} %>")
var uni_edit_modal = $(".admin-unit-edit-modal")
uni_edit_modal.modal("show")
uni_edit_modal.on("hidden.bs.modal",function () {
$(".admin-unit-edit-modal").remove()
$("body").removeClass("modal-open")
})
// 初始化学校选择器
var matcherFunc = function(params, data){
if ($.trim(params.term) === '') {
return data;
}
if (typeof data.text === 'undefined') {
return null;
}
if (data.name && data.name.indexOf(params.term) > -1) {
var modifiedData = $.extend({}, data, true);
return modifiedData;
}
// Return `null` if the term should not be displayed
return null;
}
$.ajax({
url: '/api/schools/for_option.json',
dataType: 'json',
type: 'GET',
success: function(data) {
$("#all-schools").select2({
theme: 'bootstrap4',
placeholder: '查询学校/单位',
minimumInputLength: 1,
data: data.schools,
templateResult: function (item) {
if(!item.id || item.id === '') return item.text;
return item.name;
},
templateSelection: function(item){
return item.name || item.text;
},
matcher: matcherFunc
})
}
});
$("#all-schools").select2({})
$("#show-province-<%= @unit_apply.id %>").select2()
$("#schoolCity_<%= @unit_apply.id %>").select2()
// **************** 地区选择 ****************
$('.province-city-select').cxSelect({
url: '/javascripts/educoder/province-data.json',
selects: ['province-select', 'city-select']
});

@ -0,0 +1,17 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('单位审批') %>
<% end %>
<div class="box search-form-container flex-column mb-0 pb-0 unit-applies-list-form">
<%= form_tag(admins_unit_applies_path(unsafe_params), method: :get, class: 'form-inline search-form mt-3', remote: true) do %>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '单位名称检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with':"搜索中...") %>
<%= link_to "清除",admins_unit_applies_path(keyword:nil),class:"btn btn-default",remote:true %>
<% end %>
</div>
<div class="box unit-applies-list-container">
<%= render(partial: 'admins/unit_applies/shared/list', locals: { applies: @unit_applies }) %>
</div>
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>

@ -0,0 +1 @@
$(".unit-applies-list-container").html("<%= j render partial: "admins/unit_applies/shared/list", locals: {applies: @unit_applies} %>")

@ -0,0 +1,17 @@
<td><%= apply.id %></td>
<td class="text-left"><%= overflow_hidden_span apply.name %></td>
<td class="text-left">
<%= "#{apply&.province.to_s}"+"#{apply&.city.to_s}" %>
</td>
<td class="text-left"><%= overflow_hidden_span apply.address %></td>
<td><%= apply.user.try(:show_real_name) %></td>
<td><%= format_time apply.created_at %></td>
<td class="action-container">
<%= agree_link '批准', agree_admins_unit_apply_path(apply, element: ".unit-apply-#{apply.id}"), 'data-confirm': '确认批准通过?' %>
<%= javascript_void_link('删除', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id, title: "删除原因", type: "delete",
url: admins_unit_apply_path(apply, tip: "unapplied", element: ".unit-apply-#{apply.id}")
}) %>
<%= link_to "更改",edit_admins_unit_apply_path(apply), remote: true, class:"action",'data-disable-with': '打开中...' %>
</td>

@ -0,0 +1,43 @@
<div class="modal fade admin-unit-edit-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">修改申请</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_tag(admins_unit_apply_path, method: :put, remote: true) do %>
<div class="modal-body">
<div class="form-group d-flex">
<label for="school_id" class="col-form-label">更改学校:</label>
<div class="d-flex flex-column-reverse w-75">
<%= select_tag :school_id, [apply&.school_id], class: 'form-control school-select optional',id: "all-schools" %>
</div>
</div>
<div class="form-group d-flex">
<label for="school_id" class="col-form-label">更改城市:</label>
<div class="d-flex w-75 province-city-select">
<div class="w-50 mr-3">
<%= select_tag('province', [], class: 'form-control province-select optional', 'data-value': apply.province, 'data-first-title': '请选择', id:"show-province-#{apply.id}") %>
</div>
<div class="w-50">
<%= select_tag('city', [], class: 'form-control city-select optional', 'data-value': apply.city, id: "schoolCity_#{apply.id}") %>
</div>
</div>
</div>
<div class="form-group d-flex">
<label for="school_id" class="col-form-label">更改地址:</label>
<div class="d-flex w-75 flex-column-reverse">
<%= text_field_tag :address,apply.address,class:"form-control" %>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= submit_tag "确认",class:"btn btn-primary" %>
</div>
<% end %>
</div>
</div>
</div>

@ -0,0 +1,26 @@
<table class="table table-hover text-center unit-applies-list-table">
<thead class="thead-light">
<tr>
<th width="8%">ID</th>
<th width="20%" class="text-left">单位名称</th>
<th width="12%" class="text-left">地区</th>
<th width="20%" class="text-left">详细地址</th>
<th width="10%">申请者</th>
<th width="15%"><%= sort_tag('创建于', name: 'created_at', path: admins_unit_applies_path) %></th>
<th width="15%">操作</th>
</tr>
</thead>
<tbody>
<% if applies.present? %>
<% applies.each do |apply| %>
<tr class="unit-apply-<%= apply.id %>">
<%= render partial: "admins/unit_applies/shared/apply_item", locals: {apply: apply} %>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>

@ -0,0 +1,3 @@
$('.modal.admin-unit-edit-modal').modal('hide');
$('.unit-applies-list-table .unit-apply-<%= @unit_apply.id %>').remove()
$.notify({ message: '操作成功' });

@ -28,6 +28,7 @@
<% end %>
<%= javascript_void_link '导入用户', class: 'btn btn-secondary btn-sm', data: { toggle: 'modal', target: '.admin-import-user-modal'} %>
<%= javascript_void_link '导入课堂成员', class: 'btn btn-secondary btn-sm ml-2', data: { toggle: 'modal', target: '.admin-import-course-member-modal'} %>
</div>
<div class="box users-list-container">
@ -35,4 +36,7 @@
</div>
<%= render partial: 'admins/users/shared/reward_grade_modal' %>
<%= render partial: 'admins/users/shared/import_user_modal' %>
<%= render partial: 'admins/users/shared/import_user_modal' %>
<!-- TODO: move to course list page -->
<%= render partial: 'admins/courses/shared/import_course_member_modal' %>

@ -14,8 +14,8 @@
<span class="input-group-text">文件</span>
</div>
<div class="custom-file">
<input type="file" name="file" class="upload-file-input" id="upload-file-input" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<label class="custom-file-label file-names" for="upload-file-input">选择文件</label>
<input type="file" name="file" class="upload-file-input" id="import-user-input" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<label class="custom-file-label file-names" for="import-user-input">选择文件</label>
</div>
</div>
<div class="error text-danger"></div>

@ -0,0 +1,17 @@
json.shixuns_count @total_count
json.shixun_list do
json.array! @shixuns.with_highlights(multiple: true) do |obj, highlights|
puts obj
json.merge! obj.to_searchable_json
json.challenge_names obj.challenges.pluck(:subject)
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
# json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('<br/>')
json.content highlights
json.level level_to_s(obj.trainee)
json.subjects obj.subjects do |subject|
json.(subject, :id, :name)
end
end
end

@ -20,6 +20,7 @@ if @course
json.group_info @course.teacher_group(@user.id) if @course_identity < Course::STUDENT
end
json.first_category_url module_url(@course.none_hidden_course_modules.first, @course)
json.course_is_end @course.is_end
end
if params[:school]

@ -179,6 +179,7 @@ Rails.application.routes.draw do
get :get_mirror_script
post :apply_shixun_mirror
get :download_file
get :shixun_list
end
member do
@ -776,6 +777,10 @@ Rails.application.routes.draw do
end
post 'callbacks/aliyun_vod', to: 'callbacks/aliyun_vods#create'
namespace :wechats do
resource :js_sdk_signature, only: [:create]
end
end
namespace :admins do
@ -851,7 +856,15 @@ Rails.application.routes.draw do
end
resources :shixuns, only: [:index,:destroy]
resources :shixun_settings, only: [:index,:update]
resources :department_applies,only: [:index,:edit,:update,:destroy] do
resources :department_applies,only: [:index,:destroy] do
collection do
post :merge
end
member do
post :agree
end
end
resources :unit_applies,only: [:index,:destroy,:edit,:update] do
member do
post :agree
end
@ -884,10 +897,6 @@ Rails.application.routes.draw do
end
end
namespace :wechats do
resource :js_sdk_signature, only: [:create]
end
#git 认证回调
match 'gitauth/*url', to: 'gits#auth', via: :all

Binary file not shown.

@ -0,0 +1,152 @@
#coding=utf-8
# 执行示例 RAILS_ENV=production bundle exec rake public_classes:student args=3,3056,'2019-03-01','2019-03-31',10,1
# args 第一个参数是subject_id第二个参数是课程course_id
# 第一期时间2018-12-16 至2019-03-31
# 第二期时间2019-04-07 至2019-07-28
#
# 这次学习很有收获,感谢老师提供这么好的资源和细心的服务🎉🎉🎉
#
desc "同步精品课数据"
namespace :public_classes do
if ENV['args']
subject_id = ENV['args'].split(",")[0] # 对应课程的id
course_id = ENV['args'].split(",")[1] # 对应课堂的id
start_time = ENV['args'].split(",")[2] # 表示课程模块
end_time = ENV['args'].split(",")[3] # 表示课程模块
limit = ENV['args'].split(",")[4] # 限制导入的数量
type = ENV['args'].split(",")[5] # 表示课程模块
end
task :student => :environment do
puts "subject_id is #{subject_id}"
puts "course_id is #{course_id}"
puts "start time is #{start_time}"
puts "end time is #{end_time}"
puts "limt is #{limit}"
user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where created_at between '#{start_time}' and '#{end_time}' and shixun_id in (select shixun_id from stage_shixuns
where stage_id in (select id from stages where subject_id=#{subject_id})) limit #{limit}").map(&:user_id)
puts "user_ids count is #{user_ids.count}"
if user_ids.present?
user_ids.each do |user_id|
puts user_id
begin
CourseMember.create!(course_id: course_id, user_id: user_id, role: 4)
rescue Exception => e
Rails.logger(e.message)
end
end
end
end
task :test_user => :environment do
users = User.where(is_test: true).limit(limit)
users.find_each do |user|
puts user.id
CourseMember.create!(course_id: course_id, user_id: user.id, role: 4)
end
end
# 更新某个课程的某类时间
# 执行示例 RAILS_ENV=production bundle exec rake public_course:time args=-1,2932,1,1
task :time => :environment do
# course_id = ENV['args'].split(",")[0] # 对应课堂的id
# type = ENV['args'].split(",")[1]
course = Course.find(course_id)
case type.to_i
when 1
# 讨论区
messages = Message.where(board_id: course.boards)
messages.each do |message|
created_on = random_time start_time, end_time
puts created_on
message.update_columns(created_on: created_on, updated_on: created_on)
MessageDetail.where(message_id: message.id).each do |detail|
rand_created_on = random_time start_time, end_time
detail.update_columns(created_at: rand_created_on, updated_at: rand_created_on)
end
end
when 2
# 作业
course.homework_commons.each do |homework|
created_at = random_time(start_time, end_time)
publish_time = random_larger_time created_at, start_time, end_time
end_time = random_larger_time publish_time, start_time, end_time
updated_at = end_time
homework.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at)
homework.homework_detail_manual.update_columns(comment_status: 6, created_at: created_at, updated_at: updated_at)
homework.student_works.where("work_status !=0 and update_time > '#{end_time}'").update_all(update_time: end_time)
end
when 3
# 试卷
course.exercises.each do |exercise|
created_at = random_time start_time, end_time
publish_time = random_larger_time created_at, start_time, end_time
end_time = random_larger_time publish_time, start_time, end_time
updated_at = end_time
exercise.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at, exercise_status: 3)
end
when 4
# 资源
course.attachments.each do |atta|
created_on = random_time start_time, end_time
atta.update_columns(is_publish: 1, created_on: created_on, publish_time: created_on)
end
end
end
task :create_homework_work => :environment do
course = Course.find(course_id)
course.practice_homeworks.each do |homework|
if homework.student_works.count == 0
str = ""
CourseMember.students(course).each do |student|
str += "," if str != ""
str += "(#{homework.id},#{student.user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into student_works (homework_common_id, user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
end
def min_swith(time)
puts time
return time < 9 ? "0#{time}" : time
end
def random_time(start_time, end_time)
hour = (6..23).to_a.sample(1).first
min = rand(60)
sec = rand(60)
start_time = Date.parse(start_time)
end_time = Date.parse(end_time)
date = (start_time..end_time).to_a.sample(1).first
time = "#{date} #{min_swith(hour)}:#{min_swith(min)}:#{min_swith(sec)}"
puts time
time
end
def random_larger_time(time, start_time, end_time)
large_time = random_time(start_time, end_time)
while large_time <= time
large_time = random_time(start_time, end_time)
end
large_time
end
end

@ -1,30 +1,22 @@
# bundle exec rake sync:public_message args=149,2903
namespace :sync do
task :public_message => :environment do
if ENV['args']
subject_id = ENV['args'].split(",")[0] # 对应课程的id
shixun_id = ENV['args'].split(",")[1] # 对应课程的id
board_id = ENV['args'].split(",")[2]
message_id = ENV['args'].split(",")[3]
status = ENV['args'].split(",")[4] # 表示相应的期数
if status.to_i == 1
start_time = '2018-12-16'
end_time = '2019-04-01'
elsif status.to_i == 2
start_time = '2019-04-07'
end_time = '2019-07-28'
else
# 这种情况是取所有的
start_time = '2015-01-01'
end_time = '2022-07-28'
end
start_time = ENV['args'].split(",")[4] # 表示课程模块
end_time = ENV['args'].split(",")[5] # 表示课程模块
limit = ENV['args'].split(",")[6] # 限制导入的数量
end
task :public_message => :environment do
shixun_ids = Shixun.find_by_sql("select shixun_id from stage_shixuns where stage_id in (select id from stages where
subject_id=#{subject_id}) ").map(&:shixun_id)
discusses = Discuss.where(dis_id: shixun_ids).where("created_at >? and created_at <?", start_time, end_time)
if discusses.present?
discusses.find_each do |discuss|
discusses.limit(limit).find_each do |discuss|
puts discuss.user_id
puts board_id
puts message_id
@ -35,23 +27,6 @@ namespace :sync do
end
task :sigle_message => :environment do
subject_id = ENV['args'].split(",")[0] # 对应课程的id
shixun_id = ENV['args'].split(",")[1] # 对应课程的id
board_id = ENV['args'].split(",")[2]
message_id = ENV['args'].split(",")[3]
status = ENV['args'].split(",")[4] # 表示相应的期数
if status.to_i == 1
start_time = '2018-12-16'
end_time = '2019-04-01'
elsif status.to_i == 2
start_time = '2019-04-07'
end_time = '2019-07-28'
else
# 这种情况是取所有的
start_time = '2015-01-01'
end_time = '2022-07-28'
end
if subject_id.to_i == -1
discusses = Discuss.where("parent_id is null and dis_id=?", shixun_id)
@ -119,18 +94,8 @@ namespace :sync do
end
end
task :board_count => :environment do
Course.find_each do |course|
puts course.id
begin
messages_count = Message.find_by_sql("select count(*) as count from messages where board_id in (select id from boards where course_id=#{course.id})").first.try(:count)
Board.update_column(messages_count: messages_count)
rescue
end
end
task :delete_boards => :environment do
course = Course.find(course_id)
course.boards.destroy
end
end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -23,7 +23,6 @@
<title>EduCoder</title>
<script type="text/javascript">
window.__isR = true;
// 不支持ie9 ie10
if (
( navigator.userAgent.indexOf('MSIE 9') != -1
@ -32,8 +31,11 @@
location.pathname.indexOf("/compatibility") == -1) {
// location.href = './compatibility'
location.href = '/compatibility.html'
location.href = '/compatibility.html'
}
const isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
if (isMobile) {
document.write('<script type="text/javascript" src="/javascripts/wx/jweixin-1.3.0.js"><\/script>');
}
</script>

@ -3601,9 +3601,9 @@
return text;
};
markedRenderer.em = function (text) {
if (text && text.indexOf('$$') != -1) {
return text;
markedRenderer.em = function (text, capInput) {
if (text && text.indexOf('$$') != -1 || (capInput && capInput.indexOf('$$') != -1)) {
return '_' + text + '_';
} else {
return '<em>' + text + '</em>';
}

File diff suppressed because one or more lines are too long

@ -281,7 +281,62 @@ class App extends Component {
mydisplay:true,
})
};
initWXShare = () => {
if (window.wx) {
const wx = window.wx
const url = '/wechats/js_sdk_signature.json'
axios.post(url, {
url: 'http://pre-newweb.educoder.net',
}).then((response) => {
console.log('got res')
const data = response.data;
wx.config({
debug: false,
appId: data.appid,
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: [
'onMenuShareTimeline',//
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'onMenuShareQZone'
]
});
wx.ready(function () {
console.log('wx is ready')
var shareData = {
title: '这是是分享标题',
desc: '这是是摘要',
link: 'http://pre-newweb.educoder.net',
imgUrl: 'http://pre-newweb.educoder.net/images/educoder/index/subject/subject15.jpg'
};
wx.onMenuShareAppMessage(shareData);//分享给好友
wx.onMenuShareTimeline(shareData);//分享到朋友圈
wx.onMenuShareQQ(shareData);//分享给手机QQ
wx.onMenuShareWeibo(shareData);//分享腾讯微博
wx.onMenuShareQZone(shareData);//分享到QQ空间
});
wx.error(function (res) {
console.log('wx is error')
console.log(res)
//alert(res.errMsg);//错误提示
});
}).catch((error) => {
console.log(error)
})
}
}
componentDidMount() {
// force an update if the URL changes
history.listen(() => {
this.forceUpdate()
@ -291,7 +346,7 @@ class App extends Component {
});
initAxiosInterceptors(this.props)
this.initWXShare()
//
// axios.interceptors.response.use((response) => {
// // console.log("response"+response);

@ -1,3 +1,6 @@
export function isDev() {
return window.location.port === "3007";
}
}
// const isMobile
export const isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));

@ -20,8 +20,7 @@ export { markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, ap
downloadFile, sortDirections } from './TextUtil'
export { handleDateString, getNextHalfHourOfMoment,formatDuring } from './DateUtil'
export { isDev as isDev } from './Env'
export { isDev as isDev, isMobile } from './Env'
export { toStore as toStore, fromStore as fromStore } from './Store'

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 KiB

@ -383,12 +383,12 @@ class Comments extends Component {
{/* <span className="ml5 mr5 color-grey-8">|</span>*/}
<a href={`javascript:void(0)`} className="color-grey-8"
{(this.props.showReply == undefined || this.props.showReply == true) && <a href={`javascript:void(0)`} className="color-grey-8"
onClick={() => this.initReply(item) } >
<Tooltip title={ "回复" }>
<i className="iconfont icon-huifu1 mr5"></i>
</Tooltip>
</a>
</a>}
{/* <span className="ml5 mr5 color-grey-8">|</span>*/}

@ -30,7 +30,8 @@ class Fileslistitem extends Component{
showfiles=(list)=>{
if(list.is_history_file===false){
// this.props.DownloadFileA(list.title,list.url)
window.location.href=list.url;
//window.location.href=list.url;
window.open(list.url, '_blank');
}else{
let {discussMessage,coursesId}=this.props
let file_id=discussMessage.id
@ -49,7 +50,7 @@ class Fileslistitem extends Component{
//
// }
// this.props.DownloadFileA(result.data.title,result.data.url)
window.location.href=list.url;
window.open(list.url, '_blank');
}else{
this.setState({
Showoldfiles:true,

@ -287,7 +287,7 @@ class BoardsNew extends Component{
const isAdmin = this.props.isAdmin()
const courseId=this.props.match.params.coursesId;
const boardId = this.props.match.params.boardId
const isCourseEnd = this.props.isCourseEnd()
return(
<div className="newMain ">
<AddDirModal {...this.props}
@ -381,7 +381,7 @@ class BoardsNew extends Component{
<div>
{menu}
{
isAdmin &&
isAdmin && !isCourseEnd &&
<React.Fragment>
<Divider style={{ margin: '4px 0' }} />
<div style={{ padding: '8px', cursor: 'pointer' }} onMouseDown={() => this.refs['addDirModal'].open()}>

@ -527,6 +527,7 @@ class TopicDetail extends Component {
// TODO 图片上传地址
const courseId=this.props.match.params.coursesId;
const boardId = this.props.match.params.boardId
const isCourseEnd = this.props.isCourseEnd()
return (
<div className="edu-back-white edu-class-container edu-position course-message topicDetail" id="yslforum_index_list"> {/* fl with100 */}
<style>{`
@ -678,8 +679,8 @@ class TopicDetail extends Component {
}
</div>
<MemoDetailMDEditor ref="editor" memo={memo} usingMockInput={true} placeholder="说点什么"
height={160} showError={true} buttonText={'发表'} className={comments && comments.length && 'borderBottom'}></MemoDetailMDEditor>
{!isCourseEnd && <MemoDetailMDEditor ref="editor" memo={memo} usingMockInput={true} placeholder="说点什么"
height={160} showError={true} buttonText={'发表'} className={comments && comments.length && 'borderBottom'}></MemoDetailMDEditor>}
{/* onClick={ this.createNewComment }
enableReplyTo={true}
@ -704,6 +705,7 @@ class TopicDetail extends Component {
loadMoreChildComments={this.loadMoreChildComments}
initReply={this.initReply}
showRewardButton={false}
showReply={!isCourseEnd}
onlySuperAdminCouldHide={true}
></Comments>
@ -720,7 +722,7 @@ class TopicDetail extends Component {
{ total_count > REPLY_PAGE_COUNT &&
<Pagination showQuickJumper onChange={this.onPaginationChange} current={pageCount} total={total_count} pageSize={10}/>
}
<div className="writeCommentBtn" onClick={this.showCommentInput}>写评论</div>
{!isCourseEnd && <div className="writeCommentBtn" onClick={this.showCommentInput}>写评论</div>}
</div>
</div>

@ -51,10 +51,7 @@ class Boards extends Component{
const sort_type = this.state.sort_type
// page_size
const url = `/boards/${bid}/messages.json?page_size=15&search=${_serachText || ''}&page=${_page}&sort=0&sort_type=${sort_type}`
axios.get(url, {
})
.then((response) => {
axios.get(encodeURI(url)).then((response) => {
if (response.data.status == 0 && response.data.data) {
let _newBoards = response.data.data.messages
// if (_page > 1) {
@ -327,6 +324,7 @@ class Boards extends Component{
}
render(){
const isAdmin = this.props.isAdmin()
const isCourseEnd = this.props.isCourseEnd()
const isAdminOrStudent = this.props.isAdminOrStudent()
let { boardName, searchValue, boards, messages, checkBoxValues,
checkAllValue, pagination, sort_type, parent_id } = this.state;
@ -350,9 +348,9 @@ class Boards extends Component{
searchPlaceholder={ '请输入帖子名称进行搜索' }
firstRowRight={
<React.Fragment>
{ isAdmin && !parent_id && <WordsBtn style="blue" className="mr30" onClick={()=>this.addDir()}>添加目录</WordsBtn> }
{ !isCourseEnd && isAdmin && !parent_id && <WordsBtn style="blue" className="mr30" onClick={()=>this.addDir()}>添加目录</WordsBtn> }
{ isAdmin && !!parent_id && <WordsBtn style="blue" className="mr30" onClick={()=>this.renameDir()}>目录重命名</WordsBtn> }
{ isAdminOrStudent && <WordsBtn style="blue" className="" onClick={()=>this.onToBoardsNew()}>我要发贴</WordsBtn> }
{ !isCourseEnd && isAdminOrStudent && <WordsBtn style="blue" className="" onClick={()=>this.onToBoardsNew()}>我要发贴</WordsBtn> }
</React.Fragment>
}
secondRowLeft={
@ -390,7 +388,7 @@ class Boards extends Component{
return <li onClick={() => this.moveTo(item)} title={item.name}>{item.name}</li>
})
}
{ isAdmin &&
{ isAdmin && !isCourseEnd &&
<p className="drop_down_btn">
<a href="javascript:void(0)" className="color-grey-6"
onClick={()=>this.addDir()}

@ -646,7 +646,7 @@ render(){
{/*<span className="color-grey-9 ml3 mr3">&gt;</span>*/}
{/*</WordsBtn>*/}
<span>{`${current_user ? current_user.username : ''} ${ this.isEdit ? '编辑' : '提交'}作品` }</span>
<span>{`${current_user ? current_user.real_name : ''} ${ this.isEdit ? '编辑' : '提交'}作品` }</span>
</p>
<div style={{ width:'100%',height:'75px'}} >

@ -124,7 +124,7 @@ class commonWork extends Component{
if(search!=""){
url+="&search="+search;
}
axios.get((url)).then((result)=>{
axios.get(encodeURI(url)).then((result)=>{
if(result.status==200){
this.setState({
mainList:result.data,

@ -426,7 +426,7 @@ class CoursesBanner extends Component {
render() {
let { Addcoursestypes, coursedata,excellent, modalsType, modalsTopval, loadtype,modalsBottomval,antIcon,is_guide,AccountProfiletype} = this.state;
const isCourseEnd = this.props.isCourseEnd()
return (
<div>
{
@ -625,7 +625,7 @@ class CoursesBanner extends Component {
)
: ""}
{this.props.isStudent()?<a className="fr user_default_btn user_blue_btn mr20 font-18"
{this.props.isStudent()?this.props.current_user&&this.props.current_user.course_is_end===true?"":<a className="fr user_default_btn user_blue_btn mr20 font-18"
onClick={() => this.exitclass()}
> 退出课堂 </a>:""}
@ -714,24 +714,24 @@ class CoursesBanner extends Component {
position: "relative"
}}
>
<li className={"mt7 mr10im"}>
{!isCourseEnd && <li className={"mt7 mr10im"}>
<a onClick={()=>this.addTeacher(true)}>
<span className="color-white fl font-16 bannerurli width100f">添加老师</span>
</a>
</li>
</li>}
<li className={"mt7 mr10im"}>
{!isCourseEnd && <li className={"mt7 mr10im"}>
<a onClick={()=>this.addTeacher(false)}>
<span className="color-white fl font-16 bannerurli width100f">添加助教</span>
</a>
</li>
</li>}
<li className={"mt7 mr10im"}>
{!isCourseEnd && <li className={"mt7 mr10im"}>
<a onClick={()=>this.addStudent()}>
<span className={"color-white fl font-16 bannerurli width100f"}>添加学生</span>
</a>
</li>
</li>}
{excellent===false?
<li className={"mt7 mr10im ml10"} style={{overflow:"hidden"}}>
<a>

@ -749,9 +749,9 @@ class Coursesleftnav extends Component{
{/*毕业设计*/}
{/*{item.type==="graduation"?<div onClick={()=>this.Navmodalnames(1,"attachment",item.id)}>添加目录</div>:""}*/}
{/*讨论区*/}
{item.type==="board"?<div onClick={e=>this.Navmodalnames(e,6,"board",item.main_id)}>添加目录</div>:""}
{item.type==="board"?this.props.current_user&&this.props.current_user.course_is_end===true?"":<div onClick={e=>this.Navmodalnames(e,6,"board",item.main_id)}>添加目录</div>:""}
{/*分班*/}
{item.type==="course_group"?<div onClick={e=>this.Navmodalnames(e,2,"course_group",item.id)}>添加分班</div>:""}
{item.type==="course_group"?this.props.current_user&&this.props.current_user.course_is_end===true?"":<div onClick={e=>this.Navmodalnames(e,2,"course_group",item.id)}>添加分班</div>:""}
{/*分班*/}
{/*{item.type==="course_group"? :""}*/}
<div onClick={e=>this.Navmodalnames(e,3,"editname",item.id,item.name)}>重命名</div>
@ -798,7 +798,6 @@ class Coursesleftnav extends Component{
// console.log("778");
// console.log("CoursesLeftNav");
// console.log(this.props);
// console.log(course_modules);
return(

@ -34,12 +34,15 @@ class AccessoryModal2 extends Component{
}
// 附件相关 START
handleChange = (info) => {
let fileList = info.fileList;
console.log(fileList)
// for(var list of fileList ){
// console.log(fileList)
// }
this.setState({ fileList });
if(info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed'){
let fileList = info.fileList;
console.log(fileList)
// for(var list of fileList ){
// console.log(fileList)
// }
this.setState({ fileList });
}
}
onAttachmentRemove = (file) => {

@ -253,19 +253,19 @@ class Selectsetting extends Component{
// 附件相关 START
handleChange = (info) => {
let fileList = info.fileList;
if(info.file.status!="removed"){
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
fileListtype:true
});
}else{
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
});
if(info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let fileList = info.fileList;
if (info.file.status != "removed") {
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
fileListtype: true
});
} else {
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
});
}
}
}
// onAttachmentRemove = (file) => {

@ -178,7 +178,7 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={allfiles.id}>
<li className="fl fontlefts">
<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>
<a className={"isabox"} href={allfiles.url} target="_blank" >{allfiles.title}</a>
{/*{allfiles.is_pdf===false?*/}
{/*<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>:*/}
{/*<a className={"isabox"} onClick={()=>this.showfiless(allfiles.url)} >{allfiles.title}</a>*/}
@ -198,7 +198,7 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={item.id} key={key}>
<li className="fl fontlefts">
<a className={"isabox"} href={item.url}>{item.title}</a>
<a className={"isabox"} href={item.url} target="_blank" >{item.title}</a>
{/*{item.is_pdf===false?*/}
{/*<a className={"isabox"} href={item.url}>{item.title}</a>:*/}
{/*<a className={"isabox"} onClick={()=>this.showfiless(item.url)} >{item.title}</a>*/}

@ -86,17 +86,18 @@ class Sendresource extends Component{
}
// 附件相关 START
handleChange = (info) => {
let fileList = info.fileList;
if(info.file.status!="removed"){
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
fileListtype:true
});
}else{
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
});
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let fileList = info.fileList;
if (info.file.status != "removed") {
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
fileListtype: true
});
} else {
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
});
}
}
}

@ -2,7 +2,7 @@ import React,{Component} from "React";
import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal,Spin,Tooltip} from "antd";
import {Link} from 'react-router-dom';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import { WordsBtn,getUrl ,bytesToSize,getImageUrl,appendFileSizeToUploadFileAll} from 'educoder';
import { WordsBtn,getUrl ,bytesToSize,getImageUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder';
import axios from 'axios';
import Modals from '../../../modals/Modals';
const Search = Input.Search;
@ -49,13 +49,23 @@ class GraduationTasksSubmitedit extends Component{
if(result){
console.log(result.data.description);
const fileList = result.data.attachments.map(item => {
return {
id: item.id,
uid: item.id,
name: appendFileSizeToUploadFile(item),
url: item.url,
filesize: item.filesize,
status: 'done'
}
})
this.setState({
workslist:result.data,
attachments:result.data.attachments,
selectmemberslist:result.data.members,
selectobjct:result.data.members,
description:result.data.description,
fileList:fileList
})
if(result.data.task_type===1){
@ -134,18 +144,7 @@ class GraduationTasksSubmitedit extends Component{
}
}
onAttachmentRemoves = (file) => {
if(!file.percent || file.percent == 100){
this.setState({
Modalstype:true,
Modalstopval:'确定要删除这个附件吗?',
ModalSave: ()=>this.deleteAttachments(file),
ModalCancel:this.cancelAttachment
})
return false;
}
}
cancelAttachment=()=>{
this.setState({
Modalstype:false,
@ -155,49 +154,7 @@ class GraduationTasksSubmitedit extends Component{
})
}
deleteAttachments = (id) => {
let {attachments,fileList}=this.state;
const url = `/attachments/${id}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
// const { status } = response.data;
if (response.data.status === 0) {
console.log('--- success')
let newattachments=attachments;
for(var i=0; i<newattachments.length; i++){
if(newattachments[i].id===id){
newattachments.splice(i, 1);
}
}
this.setState({
attachments:newattachments
})
this.cancelAttachment();
this.setState((state) => {
const index = state.fileList.indexOf(id);
const newFileList = state.fileList.slice();
newFileList.splice(index, 1);
return {
fileList: newFileList
};
});
}
}
})
.catch(function (error) {
console.log(error);
});
}
deleteAttachment = (file) => {
if(!file.percent || file.percent == 100){
let {attachments,fileList}=this.state;
@ -619,7 +576,7 @@ class GraduationTasksSubmitedit extends Component{
{/*<Link to={"/courses/"+courseId+"/graduation/graduation_tasks/"+category_id} className="color-grey-6">{workslist&&workslist.task_name}</Link>*/}
{/*<span className="color-grey-9 ml3 mr3">&gt;</span>*/}
{/*</WordsBtn>*/}
<span>{this.props.user&&this.props.user.username} 修改作品</span>
<span>{this.props.current_user&&this.props.current_user.real_name} 修改作品</span>
</p>
<div style={{ width:'100%',height:'75px'}} >
@ -672,34 +629,34 @@ class GraduationTasksSubmitedit extends Component{
</Upload>
{attachments&&attachments.map((item,key)=>{
return(
<div className="color-grey mt5"
key={key}
>
<a className="color-grey ml3">
<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>
</a>
<a
href={item.url}
className="mr12 color9B9B" length="58">
{item.title}
</a>
<span className="color656565 mt2 color-grey-6 font-12 mr8">
{item.filesize}
</span>
{item.delete===true?
<i className="font-14 iconfont icon-guanbi "
id={item.id}
onClick={()=>this.onAttachmentRemoves(item.id)}
aria-hidden="true">
</i>:""}
</div>
)
})}
{/*{attachments&&attachments.map((item,key)=>{*/}
{/*return(*/}
{/*<div className="color-grey mt5"*/}
{/*key={key}*/}
{/*>*/}
{/*<a className="color-grey ml3">*/}
{/*<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>*/}
{/*</a>*/}
{/*<a*/}
{/*href={item.url}*/}
{/*className="mr12 color9B9B" length="58">*/}
{/*{item.title}*/}
{/*</a>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.filesize}*/}
{/*</span>*/}
{/*{item.delete===true?*/}
{/*<i className="font-14 iconfont icon-guanbi "*/}
{/*id={item.id}*/}
{/*onClick={()=>this.onAttachmentRemoves(item.id)}*/}
{/*aria-hidden="true">*/}
{/*</i>:""}*/}
{/*</div>*/}
{/*)*/}
{/*})}*/}
{/*<style>*/}
{/*{*/}

@ -552,7 +552,7 @@ render(){
},
};
// console.log(this.props)
console.log(this.props)
@ -601,7 +601,7 @@ render(){
{/*<Link to={"/courses/"+courseId+"/graduation/graduation_tasks/"+category_id} className="color-grey-6">{workslist&&workslist.task_name}</Link>*/}
{/*<span className="color-grey-9 ml3 mr3">&gt;</span>*/}
{/*</WordsBtn>*/}
<span>{this.props.user&&this.props.user.username} 提交作品</span>
<span>{this.props.current_user&&this.props.current_user.real_name} 提交作品</span>
</p>
<div style={{ width:'100%',height:'75px'}} >

@ -2,7 +2,7 @@ import React,{Component} from "React";
import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal} from "antd";
import {Link} from 'react-router-dom';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import { WordsBtn,getUrl ,bytesToSize,appendFileSizeToUploadFileAll,AttachmentList} from 'educoder';
import { WordsBtn,getUrl ,bytesToSize,appendFileSizeToUploadFileAll,AttachmentList,appendFileSizeToUploadFile} from 'educoder';
import axios from 'axios';
import Modals from '../../../modals/Modals';
import '../../css/Courses.css';
@ -54,6 +54,17 @@ class GraduationTasksedit extends Component{
// }
let namelength=result.data.task_name.length;
// let sixlength=title_num-namelength
const fileList = result.data.attachments.map(item => {
return {
id: item.id,
uid: item.id,
name: appendFileSizeToUploadFile(item),
url: item.url,
filesize: item.filesize,
status: 'done'
}
})
this.setState({
// fileList:newfilelist,
description:result.data.description,
@ -62,6 +73,7 @@ class GraduationTasksedit extends Component{
data:result.data,
title_num:namelength,
attachments:result.data.attachments,
fileList:fileList,
})
@ -280,7 +292,7 @@ class GraduationTasksedit extends Component{
}
render(){
const { getFieldDecorator } = this.props.form;
let {title_num,pageType,name,description,Loadtype,attachments,
let {title_num,pageType,name,description,Loadtype,attachments,fileList,
Modalstype,Modalstopval,ModalCancel,ModalSave,shixunsreplace} =this.state;
let {coursedata}=this.props;
@ -289,6 +301,7 @@ class GraduationTasksedit extends Component{
let category_id=this.props.match.params.category_id;
const uploadProps = {
width: 600,
fileList,
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
@ -434,7 +447,7 @@ class GraduationTasksedit extends Component{
)}
</Form.Item>
<input type="hidden" id='descriptiontypes' />
<AttachmentList {...this.props} {...this.state} attachments={attachments&&attachments}></AttachmentList>
{/*<AttachmentList {...this.props} {...this.state} attachments={attachments&&attachments}></AttachmentList>*/}
{/*{attachments&&attachments.map((item,key)=>{*/}
{/*return(*/}

@ -58,7 +58,7 @@ class Boards extends Component{
let {pageSize}=this.state;
const cid = this.props.match.params.coursesId
let url = `/courses/${cid}/graduation_topics.json?limit=`+pageSize
let url = `/courses/${cid}/graduation_topics.json?limit=${pageSize}`
if(searchValue!=""){
url+="&search="+searchValue
}
@ -68,7 +68,17 @@ class Boards extends Component{
if(status!="" && status != "all"){
url+="&status="+status;
}
axios.get(url).then((response) => {
url=encodeURI(url);//IE11传参为乱码search
axios.get(url
// ,{
// params:{
// search:encodeURI(searchValue),
// page:page,
// status:status,
// limit:pageSize
// }
// }
).then((response) => {
if (response.status == 200 && response.status) {
this.setState({
data:response.data,

@ -29,7 +29,7 @@ class AddStudentModal extends Component{
const { name, school_name } = this.state
let url = `/courses/${courseId}/search_users.json?page=${page}&limit=${pageCount}&school_name=${school_name || ''}&name=${name || ''}`
this.setState({ loading: true })
axios.get(url)
axios.get(encodeURI(url))
.then((response) => {
if (!response.data.users || response.data.users.length == 0) {
this.setState({
@ -80,8 +80,9 @@ class AddStudentModal extends Component{
}
setVisible = (visible) => {
if (visible) {
this.setState({school_name: this.props.user.user_school})
this.fetchMemberList()
this.setState({school_name: this.props.user.user_school},()=>{
this.fetchMemberList();
})
this.fetchOptions()
}
this.refs.modalWrapper.setVisible(visible)

@ -324,7 +324,7 @@ class studentsList extends Component{
if(!!searchValue){
url+='&search='+searchValue;
}
axios.get((url)).then((result)=>{
axios.get(encodeURI(url)).then((result)=>{
if (result.data.students) {
this.setState({
students: result.data.students,
@ -497,6 +497,7 @@ class studentsList extends Component{
render(){
const isAdmin = this.props.isAdmin()
const isSuperAdmin = this.props.isSuperAdmin()
const isCourseEnd = this.props.isCourseEnd()
let {
page,
@ -591,7 +592,7 @@ class studentsList extends Component{
></CreateGroupByImportModal>
<WordsBtn style="blue" className="mr30" onClick={()=> this.refs['createGroupByImportModal'].setVisible(true)}>导入创建分班</WordsBtn>
</React.Fragment> }
{ isAdmin && isParent && <WordsBtn style="blue" className="mr30" onClick={()=>this.addDir()}>添加分班</WordsBtn> }
{ !isCourseEnd && isAdmin && isParent && <WordsBtn style="blue" className="mr30" onClick={()=>this.addDir()}>添加分班</WordsBtn> }
{ isAdmin && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="mr30" onClick={()=>this.deleteDir()}>删除分班</WordsBtn> }
{ isAdmin && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="mr30" onClick={()=>this.renameDir()}>分班重命名</WordsBtn> }
<style>{`
@ -674,7 +675,7 @@ class studentsList extends Component{
)
}) }
{ course_groups && course_groups.length > 0 && <Divider className="dividerStyle"></Divider> }
{ isAdmin &&
{ isAdmin && !isCourseEnd &&
<p className="drop_down_btn">
<a href="javascript:void(0)" className="color-grey-6"

@ -377,7 +377,7 @@ class studentsList extends Component{
if(searchValue!=""){
url+='&search='+searchValue;
}
const result = await axios.get(url)
const result = await axios.get(encodeURI(url))
// axios.get((url)).then((result)=>{
if (result.data.teacher_list) {
this.setState({

@ -116,6 +116,7 @@ class Poll extends Component{
if(search!=""&&search!=undefined){
url+="&search="+search
}
url=encodeURI(url);//IE11传参为乱码search
axios.get(url).then((result)=>{
if(result){
this.setState({

@ -2499,6 +2499,8 @@ class Listofworksstudentone extends Component {
// console.log(data);
// console.log(datas);
// console.log(this.props.isAdmin());
let course_is_end = this.props.current_user&&this.props.current_user.course_is_end;
return (
this.props.isAdmin() === true ?
(
@ -2639,7 +2641,7 @@ class Listofworksstudentone extends Component {
<ul className="clearfix" style={{padding: '20px 15px 10px 20px'}}>
<li className="clearfix ">
<span className="fl mr10 color-grey-6 ">计算成绩时间{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')}</span>
<span>
{course_is_end===true?"":<span>
{teacherdata&&teacherdata.publish_immediately===false&&computeTimetype===true?
(this.props.isNotMember()===false?<div className={"computeTime font-13"} onClick={this.setComputeTimet}>
计算成绩
@ -2649,7 +2651,7 @@ class Listofworksstudentone extends Component {
计算成绩
</div>:"")
}
</span>
</span>}
<div className="fr mr5 search-newysl" style={{marginBottom: '1px'}}>
<Search
@ -2944,7 +2946,7 @@ class Listofworksstudentone extends Component {
<div className="fr">
<span className="fl mr10 color-grey-6 ">计算成绩时间{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')}</span>
{teacherdata&&teacherdata.task_operation[0]==="开启挑战"?"":<span>
{ course_is_end===true?"":teacherdata&&teacherdata.task_operation[0]==="开启挑战"?"":<span>
{computeTimetype===true?
(this.props.isNotMember()===false?
<div className={"computeTime font-13"} onClick={this.setComputeTime}>
@ -3154,17 +3156,17 @@ class Listofworksstudentone extends Component {
<div className="fr">
<span className="fl mr10 color-grey-6 ">计算成绩时间{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')}</span>
{teacherdata&&teacherdata.task_operation&&teacherdata.task_operation[0]==="开启挑战"?"":<span>
{computeTimetype===true?
(this.props.isNotMember()===false?<div className={"computeTime font-13"} onClick={this.setComputeTime}>
计算成绩
</div>:""):
teacherdata&&teacherdata.homework_status!==undefined&&teacherdata.homework_status[0]=== "未发布"? "":
(this.props.isNotMember()===false?<div className={"computeTimes font-13"}>
计算成绩
</div>:"")
}
</span>}
{ course_is_end===true?"":teacherdata&&teacherdata.task_operation&&teacherdata.task_operation[0]==="开启挑战"?"":<span>
{computeTimetype===true?
(this.props.isNotMember()===false?<div className={"computeTime font-13"} onClick={this.setComputeTime}>
计算成绩
</div>:""):
teacherdata&&teacherdata.homework_status!==undefined&&teacherdata.homework_status[0]=== "未发布"? "":
(this.props.isNotMember()===false?<div className={"computeTimes font-13"}>
计算成绩
</div>:"")
}
</span>}
</div>
{/*因为计算按钮占了和这个位置,和设计沟通学生视角取消这个按钮*/}

@ -95,7 +95,7 @@ class ShixunWorkReport extends Component {
let homeworkid=this.props.match.params.homeworkid;
let url = `/student_works/${homeworkid}/shixun_work_report.json`
axios.get(url).then((result) => {
if (result.data.status === 403||result.data.status === 401||result.data.status === 407||result.data.status === 408) {
if (result.data.status === 403||result.data.status === 401||result.data.status === 407||result.data.status === 408||result.data.status === 409) {
}else{
this.setState({

@ -112,7 +112,7 @@ class ShixunHomework extends Component{
let coursesId=this.props.match.params.coursesId;
let url="/courses/"+coursesId+"/homework_commons.json?type=4";
axios.get(url,{
axios.get(encodeURI(url),{
params: {
search:undefined,
page:1,

@ -370,7 +370,7 @@ class Shixunechart extends Component {
</div>
<div className="fl with65" style={{paddingLeft: "5%"}}>
<li className="mt5 mb5">{data&&data.username}</li>
<li className="mt5 mb5">{data!==undefined?"--":data.student_id===undefined?"--":data.student_id===null?"--":data.student_id}</li>
<li className="mt5 mb5">{data===undefined?"--":data.student_id===undefined?"--":data.student_id===null?"--":data.student_id}</li>
<li className="mt5 mb5 color-orange03"><span className="color-orange03">{data&&data.echart_data===undefined?"":data&&data.echart_data.myself_eff[1]}</span></li>
<li className="mt5 mb5 color-orange03"><span className="color-orange03">{data&&data.echart_data===undefined?"":data&&data.echart_data.myself_eff[0]}</span></li>
</div>
@ -396,7 +396,7 @@ class Shixunechart extends Component {
</div>
<div className="fl with65" style={{paddingLeft: "5%"}}>
<li className="mt5 mb5">{data&&data.username}</li>
<li className="mt5 mb5">{data!==undefined?"--":data.student_id===undefined?"--":data.student_id===null?"--":data.student_id}</li>
<li className="mt5 mb5">{data===undefined?"--":data.student_id===undefined?"--":data.student_id===null?"--":data.student_id}</li>
<li className="mt5 mb5 color-orange03"><span className="color-orange03">{data&&data.echart_data===undefined?"":data&&data.echart_data.myself_object[1]}</span></li>
</div>
</div>

@ -145,6 +145,9 @@ class WebSSHTimer extends Component {
}
// 重置命令行的时候调用的接口会删pod
closeWebssh = (callback) => {
// 先关socket
this.closeWebsshSocket()
const { game } = this.props;
// const url = `/api/v1/games/${game.identifier}/close_webssh`
const url = `/tasks/${game.identifier}/close_webssh.json`

@ -188,6 +188,19 @@ function getLanguageByMirrorName(mirror_name) {
}
let notCallCodeMirrorOnChangeFlag = false;
/**
props :
mirror_name 决定语言
isEditablePath
repositoryCode
codemirrorDidMount
shixun.forbid_copy
showSettingDrawer, settingDrawerOpen
*/
class TPIMonaco extends Component {
constructor(props) {
@ -201,7 +214,7 @@ class TPIMonaco extends Component {
}
componentDidUpdate(prevProps, prevState, snapshot) {
const { game, mirror_name } = this.props
const { mirror_name } = this.props
const editor_monaco = this.editor_monaco;
if (editor_monaco && !_.isEqual(prevProps.mirror_name, mirror_name)) {
// TODO 后期考虑加入根据文件类型的不同使用不同的lang
@ -294,7 +307,7 @@ class TPIMonaco extends Component {
})
this.props.codemirrorDidMount && this.props.codemirrorDidMount()
if(this.props.shixun.forbid_copy == true) {
if(this.props.shixun && this.props.shixun.forbid_copy == true) {
// 禁用粘贴
// https://github.com/Microsoft/monaco-editor/issues/100
window.editor_monaco.onDidPaste( (a, b, c) => { window.__pastePosition = a })

@ -160,7 +160,7 @@ class DetailCardsEditAndAdd extends Component{
url+="&type="+id;
}
axios.get(url).then((result)=>{
axios.get(encodeURI(url)).then((result)=>{
if(result.status===200){
this.setState({
ChooseShixunList:result.data,
@ -322,7 +322,7 @@ class DetailCardsEditAndAdd extends Component{
if(type!=0){
url+="&type="+type;
}
axios.get(url).then((result)=>{
axios.get(encodeURI(url)).then((result)=>{
if(result.status===200){
let list =result.data.shixun_list;

@ -95,7 +95,7 @@ class DetailCardsEditAndEdit extends Component{
if(id!=0){
url+="&type="+id;
}
axios.get(url).then((result)=>{
axios.get(encodeURI(url)).then((result)=>{
if(result.status===200){
this.setState({
ChooseShixunList:result.data,
@ -369,7 +369,7 @@ class DetailCardsEditAndEdit extends Component{
if(type!=0){
url+="&type="+type;
}
axios.get(url).then((result)=>{
axios.get(encodeURI(url)).then((result)=>{
if(result.status===200){
let list =result.data.shixun_list;

@ -205,7 +205,7 @@ class TPMBanner extends Component {
SenttotheSearch=(value)=>{
let id = this.props.match.params.shixunId;
let url="/shixuns/" + id +"/search_user_courses.json?search="+value;
axios.get(url, {
axios.get(encodeURI(url), {
params: {
page:1,
limit:10

@ -244,6 +244,10 @@ export function TPMIndexHOC(WrappedComponent) {
return this.state.coursedata&&this.state.coursedata.course_identity >= 6
}
isCourseEnd = () => {
return this.state.current_user ? this.state.current_user.course_is_end : false
}
// setTrialapplication = ()=>{
// this.setState({
// isRenders:true
@ -411,6 +415,8 @@ export function TPMIndexHOC(WrappedComponent) {
isStudent: this.isStudent,
isAdminOrStudent: this.isAdminOrStudent,
isNotMember: this.isNotMember,
isCourseEnd: this.isCourseEnd,
isUserid:this.state.coursedata&&this.state.coursedata.userid,
fetchUser: this.fetchUser,

@ -15,7 +15,7 @@ import axios from 'axios';
import './css/TPMsettings.css';
import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll} from 'educoder';
import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder';
let origin = getUrl();
@ -1372,15 +1372,18 @@ export default class TPMsettings extends Component {
})
}
handleChange = (info) => {
let {fileList}=this.state;
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
console.log("handleChange1");
let {fileList}=this.state;
if(fileList.length===0){
// if(fileList.length===0){
let fileLists = info.fileList;
this.setState({ fileList:fileLists,
deleteisnot:false});
}
// }
}
}
@ -1497,10 +1500,13 @@ export default class TPMsettings extends Component {
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
action: `${getUploadActionUrl()}`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
beforeUpload: (file, fileList) => {
if (this.state.fileList.length >= 1) {
return false
}
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 50;
if (!isLt150M) {

@ -561,7 +561,8 @@ export default class TPMevaluation extends Component {
if(type==="sr"){
newevaluationlist[key].input=e.target.value
}else if(type==="yq"){
newevaluationlist[key].output=e.target.value
// 统一转成\r\n
newevaluationlist[key].output= e.target.value ? e.target.value.replace(/\r?\n/g, "\r\n") : e.target.value
}
this.setevaluationlist(newevaluationlist);
}

@ -2,7 +2,7 @@ import React, {Component} from 'react';
import {TPMIndexHOC} from '../TPMIndexHOC';
import {SnackbarHOC,appendFileSizeToUploadFileAll} from 'educoder';
import {SnackbarHOC,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder';
import {Input, Select, Radio, Checkbox, Modal, Icon, DatePicker,Upload,Button,message,Form,notification,Tooltip} from 'antd';
@ -757,21 +757,23 @@ class Newshixuns extends Component {
})
}
// 附件相关 START
handleChange = (info) => {
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let {fileList}=this.state;
console.log("handleChange1");
if(fileList.length===0){
if(info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let {fileList} = this.state;
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
console.log("handleChange1");
// if(fileList.length===0){
let fileLists = info.fileList;
this.setState({
// fileList:appendFileSizeToUploadFileAll(fileList),
fileList:fileLists,
deleteisnot:false});
}
}
fileList: fileLists,
deleteisnot: false
});
// }
}
}
}
onAttachmentRemove = (file) => {
if(!file.percent || file.percent == 100){
@ -872,10 +874,14 @@ class Newshixuns extends Component {
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
action: `${getUploadActionUrl()}`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
beforeUpload: (file, fileList) => {
if (this.state.fileList.length >= 1) {
return false
}
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 50;
if (!isLt150M) {

Loading…
Cancel
Save