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

issues25489
hjm 5 years ago
commit 16a6ea4563

@ -0,0 +1,126 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-laboratory-shixuns-index-page').length > 0) {
var $searchForm = $('.laboratory-shixun-list-form .search-form');
var laboratoryId = $('.laboratory-shixun-list-container').data('id');
$searchForm.find('select#tag_id').select2({
placeholder: "请选择",
allowClear: true
});
// 定义状态切换监听事件
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
$('.laboratory-shixun-list-container').on('click', doElement, function () {
var $doAction = $(this);
var $undoAction = $doAction.siblings(undoElement);
var laboratoryShixunId = $doAction.data('id');
customConfirm({
content: '确认进行该操作吗?',
ok: function () {
$.ajax({
url: '/admins/laboratories/' + laboratoryId + '/laboratory_shixuns/' + laboratoryShixunId + url,
method: 'POST',
dataType: 'json',
success: function () {
show_success_flash();
$doAction.hide();
$undoAction.show();
if (callback && typeof callback === "function") {
callback(laboratoryShixunId, url);
}
}
});
}
});
});
}
// 首页展示与取消首页展示
var homepageShowCallback = function (laboratoryShixunId, url) {
var $laboratoryShixunItem = $('.laboratory-shixun-list-container').find('.laboratory-shixun-item-' + laboratoryShixunId);
if (url === '/homepage') {
$laboratoryShixunItem.find('.homepage-badge').show();
} else {
$laboratoryShixunItem.find('.homepage-badge').hide();
}
}
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage', homepageShowCallback);
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage', homepageShowCallback);
// 添加实训功能
var $addModal = $('.modal.admin-add-laboratory-shixun-modal');
var $addForm = $addModal.find('form.admin-add-laboratory-user-form');
var $shixunSelect = $addForm.find('select.shixun-select');
$addModal.on('show.bs.modal', function(){
$addModal.find('.error').html('');
$shixunSelect.select2('val', ' ');
});
$shixunSelect.select2({
theme: 'bootstrap4',
placeholder: '请输入实训名称/创建者检索',
multiple: true,
closeOnSelect: false,
ajax: {
delay: 500,
url: '/admins/laboratories/' + laboratoryId + '/shixuns_for_select',
dataType: 'json',
data: function(params){
return { keyword: params.term, page: params.page || 1, per_page: 20 };
},
processResults: function(data, params){
params.page = params.page || 1;
return {
results: data.shixuns,
pagination: {
more: (params.page * 20) < data.count
}
};
}
},
templateResult: function (item) {
if(!item.id || item.id === '') return item.text;
var ele = '<span>'
ele += '<span>' + item.name + '</span>';
ele += '<span class="font-12"> -- ' + item.creator_name + '</span>';
ele += '<span class="font-12"> -- ' + item.status_text+ '</span>';
ele += '</span>';
return $(ele);
},
templateSelection: function(item){
if (item.id) {
}
var ele = '<span>' + (item.name || item.text) + '<span class="font-12"> -- ' + item.creator_name + '</span></span>'
return $(ele);
}
});
$addModal.on('click', '.submit-btn', function(){
$addModal.find('.error').html('');
var shixunIds = $shixunSelect.val();
if (shixunIds && shixunIds.length > 0) {
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/laboratories/' + laboratoryId + '/laboratory_shixuns',
data: { shixun_ids: shixunIds },
success: function(){
show_success_flash();
window.location.reload();
},
error: function(res){
$addModal.find('.error').html(res.responseJSON.message);
}
});
} else {
$addModal.find('.error').html('请选择实训');
}
});
}
})

@ -0,0 +1,148 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-laboratory-subjects-index-page').length > 0) {
var $searchForm = $('.laboratory-subject-list-form .search-form');
var laboratoryId = $('.laboratory-subject-list-container').data('id');
// ************** 学校选择 *************
$searchForm.find('.school-select').select2({
theme: 'bootstrap4',
placeholder: '请选择创建者单位',
minimumInputLength: 1,
ajax: {
delay: 500,
url: '/api/schools/search.json',
dataType: 'json',
data: function (params) {
return {keyword: params.term};
},
processResults: function (data) {
return {results: data.schools}
}
},
templateResult: function (item) {
if (!item.id || item.id === '') return item.text;
return item.name;
},
templateSelection: function (item) {
if (item.id) {
}
return item.name || item.text;
}
});
// 定义状态切换监听事件
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
$('.laboratory-subject-list-container').on('click', doElement, function () {
var $doAction = $(this);
var $undoAction = $doAction.siblings(undoElement);
var laboratorySubjectId = $doAction.data('id');
customConfirm({
content: '确认进行该操作吗?',
ok: function () {
$.ajax({
url: '/admins/laboratories/' + laboratoryId + '/laboratory_subjects/' + laboratorySubjectId + url,
method: 'POST',
dataType: 'json',
success: function () {
show_success_flash();
$doAction.hide();
$undoAction.show();
if (callback && typeof callback === "function") {
callback(laboratorySubjectId, url);
}
}
});
}
});
});
}
// 首页展示与取消首页展示
var homepageShowCallback = function (laboratoryShixunId, url) {
var $laboratoryShixunItem = $('.laboratory-subject-list-container').find('.laboratory-subject-item-' + laboratoryShixunId);
if (url === '/homepage') {
$laboratoryShixunItem.find('.homepage-badge').show();
} else {
$laboratoryShixunItem.find('.homepage-badge').hide();
}
}
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage', homepageShowCallback);
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage', homepageShowCallback);
// 添加实践课程功能
var $addModal = $('.modal.admin-add-laboratory-subject-modal');
var $addForm = $addModal.find('form.admin-add-laboratory-user-form');
var $subjectSelect = $addForm.find('select.subject-select');
$addModal.on('show.bs.modal', function(){
$addModal.find('.error').html('');
$subjectSelect.select2('val', ' ');
});
$subjectSelect.select2({
theme: 'bootstrap4',
placeholder: '请输入课程名称/创建者检索',
multiple: true,
closeOnSelect: false,
ajax: {
delay: 500,
url: '/admins/laboratories/' + laboratoryId + '/subjects_for_select',
dataType: 'json',
data: function(params){
return { keyword: params.term, page: params.page || 1, per_page: 20 }
},
processResults: function(data, params){
params.page = params.page || 1;
return {
results: data.subjects,
pagination: {
more: (params.page * 20) < data.count
}
};
}
},
templateResult: function (item) {
if(!item.id || item.id === '') return item.text;
var ele = '<span>'
ele += '<span>' + item.name + '</span>';
ele += '<span class="font-12"> -- ' + item.creator_name + '</span>';
ele += '<span class="font-12"> -- ' + item.status_text+ '</span>';
ele += '</span>';
return $(ele);
},
templateSelection: function(item){
if (item.id) {
}
var ele = '<span>' + (item.name || item.text) + '<span class="font-12"> -- ' + item.creator_name + '</span></span>'
return $(ele);
}
});
$addModal.on('click', '.submit-btn', function(){
$addModal.find('.error').html('');
var subjectIds = $subjectSelect.val();
if (subjectIds && subjectIds.length > 0) {
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/laboratories/' + laboratoryId + '/laboratory_subjects',
data: { subject_ids: subjectIds },
success: function(){
show_success_flash();
window.location.reload();
},
error: function(res){
$addModal.find('.error').html(res.responseJSON.message);
}
});
} else {
$addModal.find('.error').html('请选择课程');
}
});
}
})

@ -6,6 +6,7 @@ class Admins::BaseController < ApplicationController
layout 'admin'
skip_before_action :verify_authenticity_token
skip_before_action :setup_laboratory
before_action :require_login, :require_admin!

@ -6,6 +6,16 @@ class Admins::CompetitionPrizeUsersController < Admins::BaseController
include_class = [:competition_team, :competition_prize, :approver,
user: [:process_real_name_apply, :process_professional_apply, user_extension: :school]]
@prize_users = paginate(prize_users.preload(include_class))
respond_to do |format|
format.js
format.html
format.xlsx do
@all_prize_users = prize_users
filename = "#{@competition.name}竞赛获奖人信息列表_#{Time.current.strftime('%Y%m%d%H%M%S')}.xlsx"
render xlsx: 'index', filename: filename
end
end
end
def create

@ -12,10 +12,6 @@ class Admins::EnrollListsController < Admins::BaseController
respond_to do |format|
format.js
format.html
format.xls{
filename = "#{@competition.name}竞赛报名列表_#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}.xls"
send_data(shixun_list_xls(shixuns), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
end
end

@ -1,7 +1,6 @@
class Admins::LaboratoriesController < Admins::BaseController
def index
params[:sort_by] = params[:sort_by].presence || 'id'
params[:sort_direction] = params[:sort_direction].presence || 'desc'
default_sort('id', 'desc')
laboratories = Admins::LaboratoryQuery.call(params)
@laboratories = paginate laboratories.preload(:school, :laboratory_users)
@ -20,6 +19,37 @@ class Admins::LaboratoriesController < Admins::BaseController
render_delete_success
end
def shixuns_for_select
except_shixun_ids = current_laboratory.laboratory_shixuns.pluck(:shixun_id)
shixuns = Shixun.where.not(id: except_shixun_ids)
keyword = params[:keyword].to_s.strip
if keyword.present?
like_sql = 'shixuns.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword '\
'OR mirror_repositories.name LIKE :keyword'
shixuns = shixuns.joins(:user, :mirror_repositories).where(like_sql, keyword: "%#{keyword}%")
end
@count = shixuns.count
@shixuns = paginate(shixuns.includes(:user))
end
def subjects_for_select
except_subject_ids = current_laboratory.laboratory_subjects.pluck(:subject_id)
subjects = Subject.where.not(id: except_subject_ids)
keyword = params[:keyword].to_s.strip
if keyword.present?
like_sql = 'subjects.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword'
subjects = subjects.joins(:user).where(like_sql, keyword: "%#{keyword}%")
end
@count = subjects.count
@subjects = paginate(subjects.includes(:user))
end
private
def current_laboratory

@ -0,0 +1,41 @@
class Admins::LaboratoryShixunsController < Admins::BaseController
helper_method :current_laboratory, :current_laboratory_shixun
def index
laboratory_shixuns = Admins::LaboratoryShixunQuery.call(current_laboratory, params)
@laboratory_shixuns = paginate laboratory_shixuns.includes(shixun: %i[tag_repertoires user])
end
def create
shixun_ids = Array.wrap(params[:shixun_ids])
shixun_ids = Shixun.where(id: shixun_ids).pluck(:id)
exist_shixun_id = current_laboratory.laboratory_shixuns.where(shixun_id: shixun_ids).pluck(:shixun_id)
LaboratoryShixun.bulk_insert(*%i[shixun_id laboratory_id created_at updated_at]) do |worker|
(shixun_ids - exist_shixun_id).each do |shixun_id|
worker.add(shixun_id: shixun_id, laboratory_id: current_laboratory.id)
end
end
render_ok
end
def homepage
current_laboratory_shixun.update!(homepage: true)
render_ok
end
def cancel_homepage
current_laboratory_shixun.update!(homepage: false)
render_ok
end
private
def current_laboratory
@_current_laboratory ||= Laboratory.find(params[:laboratory_id])
end
def current_laboratory_shixun
@_current_laboratory_shixun ||= current_laboratory.laboratory_shixuns.find(params[:id])
end
end

@ -0,0 +1,43 @@
class Admins::LaboratorySubjectsController < Admins::BaseController
helper_method :current_laboratory, :current_laboratory_subject
def index
laboratory_subjects = Admins::LaboratorySubjectQuery.call(current_laboratory, params)
includes_tables = { subject: [:repertoire, :subject_level_system, user: {user_extension: :school}] }
@laboratory_subjects = paginate(laboratory_subjects.includes(includes_tables))
end
def create
subject_ids = Array.wrap(params[:subject_ids])
subject_ids = Subject.where(id: subject_ids).pluck(:id)
exist_subject_id = current_laboratory.laboratory_subjects.where(subject_id: subject_ids).pluck(:subject_id)
LaboratorySubject.bulk_insert(*%i[subject_id laboratory_id created_at updated_at]) do |worker|
(subject_ids - exist_subject_id).each do |subject_id|
worker.add(subject_id: subject_id, laboratory_id: current_laboratory.id)
end
end
render_ok
end
def homepage
current_laboratory_subject.update!(homepage: true)
render_ok
end
def cancel_homepage
current_laboratory_subject.update!(homepage: false)
render_ok
end
private
def current_laboratory
@_current_laboratory ||= Laboratory.find(params[:laboratory_id])
end
def current_laboratory_subject
@_current_laboratory_subject ||= current_laboratory.laboratory_subjects.find(params[:id])
end
end

@ -2,6 +2,8 @@ module LaboratoryHelper
extend ActiveSupport::Concern
included do
before_action :setup_laboratory
helper_method :current_laboratory
helper_method :default_setting
end
@ -17,4 +19,8 @@ module LaboratoryHelper
def default_setting
@_default_setting ||= LaboratorySetting.find_by(laboratory_id: 1)
end
def setup_laboratory
Laboratory.current = current_laboratory
end
end

@ -288,11 +288,11 @@ class CoursesController < ApplicationController
inform = @course.informs.find_by(id: params[:inform_id])
next_inform = inform.next_inform
ActiveRecord::Base.transaction do
if next_inform
if next_inform.blank?
render_error('已经到达最顶部')
else
inform.update_attribute(:position, (position + 1))
next_inform.update_attribute(:position, last_inform.position - 1)
inform.update_attribute(:position, (inform.position + 1))
next_inform.update_attribute(:position, inform.position - 1)
render_ok
end
end
@ -302,11 +302,11 @@ class CoursesController < ApplicationController
inform = @course.informs.find_by(id: params[:inform_id])
last_inform = inform.last_inform
ActiveRecord::Base.transaction do
if last_inform
if last_inform.blank?
render_error('已经到达最底部')
else
inform.update_attribute(:position, (position - 1))
last_inform.update_attribute(:position, last_inform.position + 1)
inform.update_attribute(:position, (inform.position - 1))
last_inform.update_attribute(:position, inform.position + 1)
render_ok
end
end
@ -317,7 +317,7 @@ class CoursesController < ApplicationController
inform = Inform.new(container: @course)
inform.name = params[:name]
inform.description = params[:description]
inform.position = @course.informs.maximum(:position) + 1
inform.position = @course.informs.maximum(:position).to_i + 1
inform.save!
normal_status("创建成功")
end

@ -514,6 +514,9 @@ class ExercisesController < ApplicationController
if exercise_group.present? && (exercise_group.first.publish_time < Time.now) && (exercise_publish_time != exercise_group.first.publish_time)
error_count += 1
end
if exercise_group.present? && (exercise_group.first.publish_time < Time.now && exercise_group.first.end_time > Time.now) && (exercise_end_time < Time.now)
error_count += 1
end
if error_count == 0
common_group = exercise_groups_ids & course_id #传入的班级与问卷已存在的班级的交集,即表示已有分班的
new_group_ids = course_id - common_group #新传入的班级id
@ -529,12 +532,12 @@ class ExercisesController < ApplicationController
if the_group_setting_status == 2
ex_group_params = {
:publish_time => the_group_setting.publish_time,
:end_time => exercise_end_time
:end_time => exercise_end_time < Time.now ? the_group_setting.end_time : exercise_end_time
}
elsif the_group_setting_status == 3
ex_group_params = {
:publish_time => the_group_setting.publish_time,
:end_time => the_group_setting.end_time
:end_time => exercise_end_time
}
end
the_group_setting.update_attributes!(ex_group_params)
@ -558,7 +561,7 @@ class ExercisesController < ApplicationController
if error_count > 0
error_count == 0
normal_status(-1,"已发布/已截止的试卷不允许修改时间")
normal_status(-1,"试卷发布/截止时间不能小于当前时间")
else
# 未发布的分班设置才能删除
if old_exercise_groups.size > 0

@ -26,13 +26,28 @@ class HomeController < ApplicationController
@rep_list << {rep_id: rep.id, rep_name: rep.name, sub_rep_list: sub_rep_list}
end
@shixuns = Shixun.where(homepage_show: 1).includes(:tag_repertoires, :challenges).limit(8)
shixuns = current_laboratory.shixuns
subjects = current_laboratory.subjects
if current_laboratory.main_site?
shixuns = shixuns.where(homepage_show: true)
subjects = subjects.where(homepage_show: true)
else
shixuns = shixuns.where(laboratory_shixuns: { homepage: true })
subjects = subjects.where(laboratory_subjects: { homepage: true })
end
@shixuns = shixuns.includes(:tag_repertoires, :challenges).limit(8)
@subjects = subjects.includes(:repertoire, :shixuns).limit(8)
@subjects = Subject.where(homepage_show: 1).includes(:shixuns, :repertoire).limit(8)
@main_shixuns = Shixun.where(homepage_show: true).includes(:tag_repertoires, :challenges).limit(8)
@main_subjects = Subject.where(homepage_show: true).includes(:shixuns, :repertoire).limit(8)
if current_laboratory.main_site?
@tea_users = User.where(homepage_teacher: 1).includes(:user_extension).limit(10).order("experience desc")
@stu_users = User.where(is_test: 0).includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc")
end
end
def search
@fuzzy_searchs = params[:keyword].split(" ").join("%")

@ -103,11 +103,14 @@ class MessagesController < ApplicationController
return normal_status(403, "您没有权限进行该操作") if current_user != @message.author && !current_user.teacher_of_course?(@message.board.course)
begin
h = {is_md: true}
email_notify = @message.email_notify ? 1 : @board.course.email_notify && params[:email_notify]
send_email = !@message.email_notify && email_notify
h = {is_md: true, email_notify: email_notify}
m_params = message_params.merge(h)
@message.update_attributes(m_params)
Attachment.associate_container(params[:attachment_ids], @message.id, @message.class.name)
@message.update_content(params[:content])
notify_course_students(@message, @board.course) if send_email
rescue Exception => e
uid_logger_error(e.message)
tip_exception("修改失败")
@ -123,6 +126,7 @@ class MessagesController < ApplicationController
@message.author = current_user
@message.board_id = params[:select_board_id]
@message.message_detail_attributes = {content: params[:content]}
@message.email_notify = @board.course.email_notify && params[:email_notify] ? 1 : 0
@message.save!
Attachment.associate_container(params[:attachment_ids], @message.id, @message.class.name)
if @board.course.email_notify && params[:email_notify]
@ -189,7 +193,7 @@ class MessagesController < ApplicationController
private
def validate_sort_type
normal_status(2, "参数sort_tyope暂时只支持 'time', 'hot'两种") if params.has_key?(:sort_type) && !SORT_TYPE.include?(params[:sort_type].strip)
normal_status(2, "参数sort_type暂时只支持 'time', 'hot'两种") if params.has_key?(:sort_type) && !SORT_TYPE.include?(params[:sort_type].strip)
end
def find_message
@ -207,7 +211,7 @@ class MessagesController < ApplicationController
def notify_course_students message, course
course.students.includes(:user).each do |student|
UserMailer.course_message_email(student&.user&.mail, message.id).deliver_now if student&.user&.mail
UserMailer.course_message_email(student&.user&.mail, message.id).deliver_later if student&.user&.mail
end
end
end

@ -35,6 +35,11 @@ class ShixunsController < ApplicationController
Shixun.unhidden
end
## 云上实验室过滤
unless current_laboratory.main_site?
@shixuns = @shixuns.joins(:laboratory_shixuns).where(laboratory_shixuns: { laboratory_id: current_laboratory.id })
end
## 方向
if params[:tag_level].present? && params[:tag_id].present?
@shixuns = @shixuns.filter_tag(params[:tag_level].to_i, params[:tag_id].to_i)
@ -335,6 +340,9 @@ class ShixunsController < ApplicationController
end
end
end
# 将实训标志为该云上实验室建立
Laboratory.current.laboratory_shixuns.create!(shixun: @shixun, ownership: true)
rescue Exception => e
uid_logger_error("copy shixun failed ##{e.message}")
# 删除版本库
@ -430,6 +438,9 @@ class ShixunsController < ApplicationController
GitService.add_repository(repo_path: repo_path)
# todo: 为什么保存的时候要去除后面的.git呢??
@shixun.update_column(:repo_name, repo_path.split(".")[0])
# 将实训标志为该云上实验室建立
Laboratory.current.laboratory_shixuns.create!(shixun: @shixun, ownership: true)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("实训创建失败")

@ -23,16 +23,17 @@ class SubjectsController < ApplicationController
# 最热排序
if reorder == "myshixun_count"
laboratory_join = current_laboratory.main_site? ? '' : " JOIN laboratory_subjects ls ON ls.subject_id = subjects.id AND ls.laboratory_id = #{current_laboratory.id} "
if select
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id #{laboratory_join} where
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%'
AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
else
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id #{laboratory_join} where
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%'
GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
end
@ -52,6 +53,11 @@ class SubjectsController < ApplicationController
@subjects = Subject.visible.unhidden
end
# 云上实验室过滤
unless current_laboratory.main_site?
@subjects = @subjects.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id })
end
# 类型
if select
@subjects = @subjects.where(repertoire_id: select)
@ -117,6 +123,9 @@ class SubjectsController < ApplicationController
@subject.user_id = current_user.id
@subject.save!
@subject.subject_members.create!(role: 1, user_id: current_user.id)
# 将实践课程标记为该云上实验室建立
Laboratory.current.laboratory_subjects.create!(subject: @subject, ownership: true)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("实训路径创建失败")

@ -414,6 +414,14 @@ module ApplicationHelper
m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{origin_url}") : m_t
end
def shixun_status_class(shixun)
case shixun.status
when 0 then 'text-info'
when 1 then 'text-warning'
when 2 then 'text-success'
when 3 then 'text-secondary'
end
end
end

@ -12,6 +12,6 @@ class UserMailer < ApplicationMailer
def course_message_email(mail, message_id)
@message = Message.find_by(id: message_id)
@course = @message&.board&.course
mail(to: mail, subject: '课堂通知') if @message.present? && @course.present?
mail(to: mail, subject: '课堂发布了新的帖子') if @message.present? && @course.present?
end
end

@ -41,6 +41,14 @@ class Exercise < ApplicationRecord
exercise_questions.pluck(:question_score).sum
end
def subjective_score
exercise_questions.where(question_type: [4]).pluck(:question_score).sum
end
def objective_score
exercise_questions.where(question_type: [0, 1, 2, 3, 5]).pluck(:question_score).sum
end
def create_exercise_list
str = ""
# TODO: 一次性为所有学生创建数据是否存在问题?

@ -7,11 +7,11 @@ class Inform < ApplicationRecord
has_many :attachments, as: :container, dependent: :destroy
def next_inform
Inform.where(position: self.position+1, container_id: self.course_id, container_type: 'Course')
Inform.find_by(position: self.position+1, container_id: self.container_id, container_type: self.container_type)
end
def last_inform
Inform.where(position: self.position-1, container_id: self.course_id, container_type: 'Course')
Inform.find_by(position: self.position-1, container_id: self.container_id, container_type: self.container_type)
end
end

@ -8,6 +8,9 @@ class Laboratory < ApplicationRecord
has_many :portal_images, dependent: :destroy
has_many :laboratory_shixuns, dependent: :destroy
has_many :laboratory_subjects, dependent: :destroy
validates :identifier, uniqueness: { case_sensitive: false }, allow_nil: true
delegate :name, :navbar, :footer, :login_logo_url, :nav_logo_url, :tab_logo_url, :default_navbar, to: :laboratory_setting
@ -27,4 +30,25 @@ class Laboratory < ApplicationRecord
find_by_identifier(subdomain)
end
def self.current=(laboratory)
Thread.current[:current_laboratory] = laboratory
end
def self.current
Thread.current[:current_laboratory] ||= Laboratory.find(1)
end
def shixuns
main_site? ? Shixun.all : Shixun.joins(:laboratory_shixuns).where(laboratory_shixuns: { laboratory_id: id })
end
def subjects
main_site? ? Subject.all : Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: id })
end
# 是否为主站
def main_site?
id == 1
end
end

@ -0,0 +1,4 @@
class LaboratoryShixun < ApplicationRecord
belongs_to :laboratory
belongs_to :shixun
end

@ -0,0 +1,4 @@
class LaboratorySubject < ApplicationRecord
belongs_to :laboratory
belongs_to :subject
end

@ -51,6 +51,8 @@ class Shixun < ApplicationRecord
# 实训审核记录
has_many :shixun_reviews, -> {order("shixun_reviews.created_at desc")}, :dependent => :destroy
has_many :laboratory_shixuns, dependent: :destroy
scope :search_by_name, ->(keyword) { where("name like ? or description like ? ",
"%#{keyword}%", "%#{keyword}%") }

@ -24,6 +24,8 @@ class Subject < ApplicationRecord
# 开放课堂
has_many :courses, -> { where("is_delete = 0").order("courses.created_at ASC") }
has_many :laboratory_subjects, dependent: :destroy
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 8000 }
validates :learning_notes, length: { maximum: 2000 }

@ -235,6 +235,28 @@ class User < ApplicationRecord
end
end
# 实名认证状态
def auth_status
status = if authentication
"已认证"
elsif process_real_name_apply.present?
"待审核"
else
"未认证"
end
end
# 职业认证状态
def pro_status
status = if professional_certification
"已认证"
elsif process_professional_apply.present?
"待审核"
else
"未认证"
end
end
# 判断当前用户是否通过职业认证
def pro_certification?
professional_certification

@ -0,0 +1,36 @@
class Admins::LaboratoryShixunQuery < ApplicationQuery
attr_reader :laboratory, :params
def initialize(laboratory, params)
@laboratory = laboratory
@params = params
end
def call
laboratory_shixuns = laboratory.laboratory_shixuns.joins(:shixun)
keyword = params[:keyword].to_s.strip
if keyword.present?
like_sql = 'shixuns.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword'
laboratory_shixuns = laboratory_shixuns.joins(shixun: :user).where(like_sql, keyword: "%#{keyword}%")
end
# 实训状态
laboratory_shixuns = laboratory_shixuns.where(shixuns: { status: params[:status] }) if params[:status].present?
# 技术平台
if params[:tag_id].present?
laboratory_shixuns = laboratory_shixuns.joins(shixun: :shixun_mirror_repositories)
.where(shixun_mirror_repositories: { mirror_repository_id: params[:tag_id] })
end
# 首页展示、单位自建
%i[homepage ownership].each do |column|
if params[column].present? && params[column].to_s == 'true'
laboratory_shixuns = laboratory_shixuns.where(column => true)
end
end
laboratory_shixuns
end
end

@ -0,0 +1,36 @@
class Admins::LaboratorySubjectQuery < ApplicationQuery
attr_reader :laboratory, :params
def initialize(laboratory, params)
@laboratory = laboratory
@params = params
end
def call
laboratory_subjects = laboratory.laboratory_subjects.joins(:subject)
keyword = params[:keyword].to_s.strip
if keyword.present?
like_sql = 'subjects.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword'
laboratory_subjects = laboratory_subjects.joins(subject: :user).where(like_sql, keyword: "%#{keyword}%")
end
# 状态
laboratory_subjects = laboratory_subjects.where(subjects: { status: params[:status] }) if params[:status].present?
# 创建者单位
if params[:school_id].present?
laboratory_subjects = laboratory_subjects.joins(subjects: { user: :user_extension })
.where(user_extensions: { school_id: params[:school_id] })
end
# 首页展示、单位自建
%i[homepage ownership].each do |column|
if params[column].present? && params[column].to_s == 'true'
laboratory_subjects = laboratory_subjects.where(column => true)
end
end
laboratory_subjects
end
end

@ -11,6 +11,9 @@ class Admins::ShixunSettingsQuery < ApplicationQuery
def call
all_shixuns = Shixun.all
all_shixuns = all_shixuns.where(id: params[:id]) if params[:id].present?
status =
case params[:status]
when "editing" then [0]

@ -12,6 +12,8 @@ class Admins::SubjectQuery < ApplicationQuery
def call
subjects = Subject.all
subjects = subjects.where(id: params[:id]) if params[:id].present?
# 状态过滤
status =
case params[:status].to_s.strip

@ -94,8 +94,8 @@ class DuplicateCourseService < ApplicationService
exercise = course.exercises.create!(attrs.merge(user_id: user.id))
origin_exercise.exercise_questions.find_each do |origin_question|
question_attrs = origin_question.as_json(only: %i[question_title question_type question_number question_score])
question_attrs[:question_type] ||= 1
question_attrs = origin_question.as_json(only: %i[question_title question_type question_number question_score shixun_name shixun_id is_ordered level])
# question_attrs[:question_type] ||= 1
question = exercise.exercise_questions.create!(question_attrs)
exercise_choice_map = {}
@ -103,15 +103,20 @@ class DuplicateCourseService < ApplicationService
choice_attrs = { choice_position: index + 1, choice_text: origin_choice.choice_text }
choice = question.exercise_choices.create!(choice_attrs)
exercise_choice_map[origin_choice.id] = choice.id
# exercise_choice_map[origin_choice.id] = choice.id 标准答案中存的是choice_position, 直接取原题的exercise_choice_id就行
end
origin_question.exercise_standard_answers.find_each do |origin_answer|
question.exercise_standard_answers.create!(
exercise_choice_id: exercise_choice_map[origin_answer.exercise_choice_id],
exercise_choice_id: origin_answer.exercise_choice_id,
answer_text: origin_answer.answer_text
)
end
origin_question.exercise_shixun_challenges.each_with_index do |sc, index|
question.exercise_shixun_challenges.create!({position: index+1, challenge_id: sc.challenge_id,
shixun_id: sc.shixun_id, question_score: sc.question_score})
end
end
origin_exercise.exercise_bank.increment!(:quotes) if exercise.exercise_bank

@ -50,6 +50,12 @@
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<%= link_to '清除', admins_competition_competition_prize_users_path(@competition), class: "btn btn-default",'data-disable-with': '清除中...' %>
<% end %>
<div class="mt-3 d-flex align-items-end">
<%= link_to '导出', admins_competition_competition_prize_users_path(competition_id: @competition.id, format: :xlsx), class: 'btn btn-primary' %>
<%#= javascript_void_link '导出', class: 'btn btn-primary', 'data-url': admins_competition_competition_prize_users_path(competition_id: @competition.id, format: :xlsx) %>
</div>
</div>
</div>

@ -0,0 +1,33 @@
wb = xlsx_package.workbook
wb.styles do |s|
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
wb.add_worksheet(name: "#{@competition.name}证书审批列表") do |sheet|
sheet.add_row %w(序号 排名 奖项 战队ID 战队名称 姓名 职业 学号 学校名称 学院名称 地区 实名认证 职业认证 手机号码 队长 签领/开户行及银行卡号 审批时间 审批人), :height => 25,:style => blue_cell
@all_prize_users.each_with_index do |prize_user, index|
user = prize_user.user
data = [
index + 1,
prize_user.rank,
prize_user.competition_prize.name,
prize_user.competition_team_id,
prize_user.competition_team.name,
user.real_name,
user.identity,
user.student_id,
user.school_name,
user.department_name,
user.location,
user.auth_status,
user.pro_status,
user.phone,
prize_user.leader? ? "是" : "-",
[prize_user.extra&.[]('bank'), prize_user.extra&.[]('second_bank'), prize_user.extra&.[]('card_no')].compact.join('/'),
prize_user.approved_at&.strftime('%Y-%m-%d %H:%M'),
prize_user.approver&.real_name
]
sheet.add_row(data)
end
end
end

@ -41,6 +41,9 @@
<div class="dropdown-menu more-action-dropdown">
<%= link_to '轮播图', admins_laboratory_carousels_path(laboratory), class: 'dropdown-item' %>
<%= link_to '查看实训项目', admins_laboratory_laboratory_shixuns_path(laboratory), class: 'dropdown-item' %>
<%= link_to '查看实践课程', admins_laboratory_laboratory_subjects_path(laboratory), class: 'dropdown-item' %>
<% if school.present? && laboratory.id != 1 %>
<%= delete_link '删除', admins_laboratory_path(laboratory, element: ".laboratory-item-#{laboratory.id}"), class: 'dropdown-item delete-laboratory-action' %>
<% end %>

@ -0,0 +1,8 @@
json.count @count
json.shixuns do
json.array! @shixuns do |shixun|
json.extract! shixun, :id, :name, :status
json.status_text I18n.t("shixun.status.#{shixun.status}")
json.creator_name shixun.user.real_name
end
end

@ -0,0 +1,8 @@
json.count @count
json.subjects do
json.array! @subjects do |subject|
json.extract! subject, :id, :name, :status
json.status_text I18n.t("subject.status.#{subject.status}")
json.creator_name subject.user.real_name
end
end

@ -0,0 +1,45 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('云上实验室', admins_laboratories_path) %>
<% add_admin_breadcrumb("#{current_laboratory.name} - 实训项目") %>
<% end %>
<div class="box search-form-container laboratory-shixun-list-form">
<%= form_tag(admins_laboratory_laboratory_shixuns_path(current_laboratory), method: :get, class: 'form-inline search-form', remote: true) do %>
<div class="form-group mr-1">
<label for="status">状态:</label>
<% status_options = [['全部', ''], ['编辑中', 0], ['审核中', 1], ['已发布', 2], ['已关闭', 3]] %>
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
</div>
<div class="form-group mr-4">
<label for="status">技术平台:</label>
<%= select_tag(:tag_id, options_for_select(MirrorRepository.pluck(:type_name,:id).unshift(['']), params[:tag_id]), class: 'form-control') %>
</div>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-12 col-md-2 mr-3', placeholder: '创建者/实训名称检索') %>
<div class="form-check mr-2">
<%= hidden_field_tag(:homepage, false, id:'') %>
<%= check_box_tag(:homepage, true, params[:homepage].to_s == 'true', class: 'form-check-input') %>
<label class="form-check-label" for="homepage">只看首页展示</label>
</div>
<div class="form-check mr-2">
<%= hidden_field_tag(:ownership, false, id:'') %>
<%= check_box_tag(:ownership, true, params[:ownership].to_s == 'true', class: 'form-check-input') %>
<label class="form-check-label" for="ownership">只看自建</label>
</div>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<%= link_to '清空', admins_laboratory_laboratory_shixuns_path(current_laboratory), class: 'btn btn-default','data-disable-with': '清空中...' %>
<% end %>
<%= javascript_void_link('添加实训', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-add-laboratory-shixun-modal' }) %>
</div>
<div class="box laboratory-shixun-list-container" data-id="<%= current_laboratory.id %>">
<%= render partial: 'admins/laboratory_shixuns/shared/list', locals: { laboratory_shixuns: @laboratory_shixuns } %>
</div>
<%= render partial: 'admins/laboratory_shixuns/shared/add_laboratory_shixun_modal' %>

@ -0,0 +1 @@
$('.laboratory-shixun-list-container').html("<%= j(render partial: 'admins/laboratory_shixuns/shared/list', locals: { laboratory_shixuns: @laboratory_shixuns }) %>");

@ -0,0 +1,28 @@
<div class="modal fade admin-add-laboratory-shixun-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-add-laboratory-user-form">
<div class="form-group d-flex">
<label class="col-form-label">选择实训:</label>
<div class="d-flex flex-column-reverse w-75">
<select id="shixun_ids" name="shixun_ids" class="form-control shixun-select" multiple></select>
</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>

@ -0,0 +1,27 @@
<table class="table text-center laboratory-shixun-list-table">
<thead class="thead-light">
<tr>
<th width="28%" class="text-left">实训名称</th>
<th width="12%">技术平台</th>
<th width="14%" class="text-left">技术体系</th>
<th width="10%">封面</th>
<th width="8%">创建者</th>
<th width="8%">状态</th>
<th width="10%">执行时间</th>
<th width="14%">操作</th>
</tr>
</thead>
<tbody>
<% if laboratory_shixuns.present? %>
<% laboratory_shixuns.each do |laboratory_shixun| %>
<tr class="laboratory-shixun-item-<%= laboratory_shixun.id %>">
<%= render partial: 'admins/laboratory_shixuns/shared/td', locals: { laboratory_shixun: laboratory_shixun } %>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: laboratory_shixuns } %>

@ -0,0 +1,28 @@
<%- shixun = laboratory_shixun.shixun -%>
<td class="text-left">
<%= link_to "/shixuns/#{shixun.identifier}", target: '_blank' do %>
<%= shixun.name %>
<span class="badge badge-pill badge-success homepage-badge" style="<%= laboratory_shixun.homepage? ? '' : 'display:none' %>">首页</span>
<span class="badge badge-pill badge-info ownership-badge" style="<%= laboratory_shixun.ownership ? '' : 'display:none' %>">自建</span>
<% end %>
</td>
<td><%= shixun.shixun_main_name %></td>
<td class="text-left">
<% shixun.tag_repertoires.each do |tag| %>
<span class="badge badge-secondary"><%= tag.name %></span>
<% end %>
</td>
<td>
<% imageExists = Util::FileManage.exists?(shixun) %>
<% imageUrl = imageExists ? '/' + url_to_avatar(shixun) : '' %>
<%= image_tag(imageUrl, width: 60, height: 40, class: "preview-image shixun-image-#{shixun.id}", data: { toggle: 'tooltip', title: '点击预览' }, style: imageExists ? '' : 'display:none') %>
</td>
<td><%= link_to shixun.user&.real_name, "/users/#{shixun.user&.login}", target:'_blank' %></td>
<td><span class="<%= shixun_status_class(shixun) %>"><%= t("shixun.status.#{shixun.status}") %></span></td>
<td><%= shixun.excute_time %></td>
<td class="action-container">
<%= link_to('去修改', admins_shixun_settings_path(id: laboratory_shixun.shixun_id)) %>
<%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_shixun.id }, style: laboratory_shixun.homepage? ? 'display:none' : '') %>
<%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_shixun.id }, style: laboratory_shixun.homepage? ? '' : 'display:none') %>
</td>

@ -0,0 +1,45 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('云上实验室', admins_laboratories_path) %>
<% add_admin_breadcrumb("#{current_laboratory.name} - 实践课程") %>
<% end %>
<div class="box search-form-container laboratory-subject-list-form">
<%= form_tag(admins_laboratory_laboratory_subjects_path(current_laboratory), method: :get, class: 'form-inline search-form', remote: true) do %>
<div class="form-group mr-1">
<label for="status">状态:</label>
<% status_options = [['全部', ''], ['编辑中', 0], ['审核中', 1], ['已发布', 2]] %>
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
</div>
<div class="form-group col-12 col-md-3">
<label for="school_name">单位:</label>
<%= select_tag :school_id, options_for_select([''], params[:school_id]), class: 'form-control school-select flex-1' %>
</div>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-12 col-md-2 mr-3', placeholder: '创建者/课程名称检索') %>
<div class="form-check mr-2">
<%= hidden_field_tag(:homepage, false, id:'') %>
<%= check_box_tag(:homepage, true, params[:homepage].to_s == 'true', class: 'form-check-input') %>
<label class="form-check-label" for="homepage">只看首页展示</label>
</div>
<div class="form-check mr-2">
<%= hidden_field_tag(:ownership, false, id:'') %>
<%= check_box_tag(:ownership, true, params[:ownership].to_s == 'true', class: 'form-check-input') %>
<label class="form-check-label" for="ownership">只看自建</label>
</div>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<%= link_to '清空', admins_laboratory_laboratory_subjects_path(current_laboratory), class: 'btn btn-default','data-disable-with': '清空中...' %>
<% end %>
<%= javascript_void_link('添加课程', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-add-laboratory-subject-modal' }) %>
</div>
<div class="box laboratory-subject-list-container" data-id="<%= current_laboratory.id %>">
<%= render partial: 'admins/laboratory_subjects/shared/list', locals: { laboratory_subjects: @laboratory_subjects } %>
</div>
<%= render partial: 'admins/laboratory_subjects/shared/add_laboratory_subject_modal' %>

@ -0,0 +1 @@
$('.laboratory-subject-list-container').html("<%= j(render partial: 'admins/laboratory_subjects/shared/list', locals: { laboratory_subjects: @laboratory_subjects }) %>");

@ -0,0 +1,28 @@
<div class="modal fade admin-add-laboratory-subject-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-add-laboratory-user-form">
<div class="form-group d-flex">
<label class="col-form-label">选择实践课程:</label>
<div class="d-flex flex-column-reverse w-75">
<select id="subject_ids" name="subject_ids" class="form-control subject-select" multiple></select>
</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>

@ -0,0 +1,48 @@
<table class="table text-center laboratory-subject-list-table">
<thead class="thead-light">
<tr>
<th width="28%" class="text-left">课程名称</th>
<th width="12%">技术体系</th>
<th width="10%">等级体系</th>
<th width="10%">封面</th>
<th width="8%">创建者</th>
<th width="10%">单位</th>
<th width="8%">状态</th>
<th width="14%">操作</th>
</tr>
</thead>
<tbody>
<% if laboratory_subjects.present? %>
<% laboratory_subjects.each do |laboratory_subject| %>
<tr class="laboratory-subject-item-<%= laboratory_subject.id %>">
<%- subject = laboratory_subject.subject -%>
<td class="text-left">
<%= link_to(subject.name, "/paths/#{subject.id}", target: '_blank') %>
<span class="badge badge-pill badge-success homepage-badge" style="<%= laboratory_subject.homepage? ? '' : 'display:none' %>">首页</span>
<span class="badge badge-pill badge-success ownership-badge" style="<%= laboratory_subject.ownership? ? '' : 'display:none' %>">自建</span>
</td>
<td><%= display_text subject.repertoire&.name %></td>
<td><%= display_text subject.subject_level_system&.name %></td>
<td>
<% image_exists = Util::FileManage.exists?(subject) %>
<%= image_tag(image_exists ? Util::FileManage.source_disk_file_url(subject) : '', height: 40, class: "w-100 preview-image subject-image-#{subject.id}", style: image_exists ? '' : 'display:none') %>
</td>
<td><%= subject.user.real_name %></td>
<td><%= subject.user.school_name %></td>
<td><%= display_subject_status(subject) %></td>
<td class="action-container">
<%= link_to('去修改', admins_subjects_path(id: laboratory_subject.subject_id)) %>
<%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? 'display:none' : '') %>
<%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? '' : 'display:none') %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: laboratory_subjects } %>

@ -16,6 +16,8 @@ json.exercise_types do
json.subjective @subjective_type #是否包含主观题1为包括0为不包括
json.exercise_end_time ((@ex_user_end_time.nil? || @ex_user_end_time < Time.now) ? "--" : how_much_time(@ex_user_end_time))
json.groups_count @c_group_counts
json.subjective_score @exercise.subjective_score
json.objective_score @exercise.objective_score
end
if @exercise_current_user_status == 0 #当为老师的时候

@ -3,13 +3,14 @@ json.images_url @images_url
json.reps @rep_list
json.shixuns do
json.partial! 'shixuns/shixun', locals: {shixuns: @shixuns}
json.partial! 'shixuns/shixun', locals: {shixuns: @shixuns.present? ? @shixuns : @main_shixuns}
end
json.subjects do
json.partial! 'subjects/subject', locals: {subjects: @subjects}
json.partial! 'subjects/subject', locals: {subjects: @subjects.present? ? @subjects : @main_subjects}
end
if current_laboratory.main_site?
json.teachers do
json.partial! 'users/user_small', users: @tea_users
end
@ -17,3 +18,4 @@ end
json.students do
json.partial! 'users/user_small', users: @stu_users
end
end

@ -1,2 +1,2 @@
json.extract! message, :id, :parent_id, :subject, :created_on, :total_replies_count, :total_praises_count,
:is_md, :praises_count, :visits, :sticky, :is_hidden, :is_public
:is_md, :praises_count, :visits, :sticky, :is_hidden, :is_public, :email_notify

@ -1,7 +1,7 @@
<html>
<head>
<meta charset="utf-8">
<title><%= @course.name %>通知</title>
<title><%= @course.name %> 发布了新的帖子</title>
<style type="text/css">
/* 验证链接页面 */
body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{ margin:0; padding:0;}
@ -37,21 +37,15 @@
您好!
</p>
<p style="color:#333; ">
正在注册Educoder请在10分钟内在注册页输入此验证码并进行下一步操作。
如非你本人操作,请忽略此邮件。
参与的课堂:<%= @course.name %>,有新的帖子发布了:
<a href="https://www.educoder.net/courses/<%= @course.id %>/boards/<%= @message.board_id %>/messages/<%= @message.id %>" style="font-weight: normal; color:#ff7500;"><%= @message.subject %></a>
</p>
<div style="text-align: center;">
<div style="display:block; height: 45px; line-height:45px;padding:0 30px; width:100px; font-size: 20px; font-weight: bold; background:#ffd9d9; color:#e72c37; margin:30px auto;">
<p><%= @code %></p>
</div>
<div style="text-align: center; margin-top:40px;">
<span style="font-weight: normal;color:#666;">
此邮件为系统所发,请勿直接回复。<br/>
要解决问题或了解您的帐户详情,您可以访问 <a href="https://www.educoder.net/help?index=5" style="font-weight: normal; color:#ff7500;">帮助中心</a>。
</span>
</div>
<p style="color:#666; margin-top:30px;">
如果您并未发过此请求,则可能是因为其他用户在注册时误输了您的邮件地址,而使您收到了这封邮件,那么您可以放心的忽略此邮件,无需进一步采取任何操作。
</p>
</div>
<div style="padding:20px; color:#333; line-height: 1.9;background:#46484c;border:1px solid #ddd; border-top:none; width: 558px;">
<a href="https:///www.educoder.net/" style="font-weight: normal; color:#fff;">www.educoder.net</a>

@ -1,6 +1,8 @@
admins-mirror_scripts: 'admins-mirror_repositories'
admins-laboratory_settings: 'admins-laboratories'
admins-carousels: 'admins-laboratories'
admins-laboratory_shixuns: 'admins-laboratories'
admins-laboratory_subjects: 'admins-laboratories'
admins-competition_settings: 'admins-competitions'
admins-enroll_lists: 'admins-competitions'
admins-competition_prize_users: 'admins-competitions'

@ -1034,12 +1034,30 @@ Rails.application.routes.draw do
post :replace_image_url, on: :member
end
resources :laboratories, only: [:index, :create, :destroy] do
member do
get :shixuns_for_select
get :subjects_for_select
end
resource :laboratory_setting, only: [:show, :update]
resource :laboratory_user, only: [:create, :destroy]
resources :carousels, only: [:index, :create, :update, :destroy] do
post :drag, on: :collection
end
resources :laboratory_shixuns, only: [:index, :create] do
member do
post :homepage
post :cancel_homepage
end
end
resources :laboratory_subjects, only: [:index, :create] do
member do
post :homepage
post :cancel_homepage
end
end
end
resources :competitions, only: [:index, :destroy, :create] do

@ -0,0 +1,13 @@
class CreateLaboratoryShixuns < ActiveRecord::Migration[5.2]
def change
create_table :laboratory_shixuns do |t|
t.references :laboratory
t.references :shixun
t.boolean :ownership, default: false
t.boolean :homepage, default: false
t.timestamps
end
end
end

@ -0,0 +1,13 @@
class CreateLaboratorySubjects < ActiveRecord::Migration[5.2]
def change
create_table :laboratory_subjects do |t|
t.references :laboratory
t.references :subject
t.boolean :ownership, default: false
t.boolean :homepage, default: false
t.timestamps
end
end
end

@ -0,0 +1,5 @@
class AddEmailNotifyToMessages < ActiveRecord::Migration[5.2]
def change
add_column :messages, :email_notify, :boolean, default: 0
end
end

File diff suppressed because one or more lines are too long

@ -137693,6 +137693,282 @@ $(document).on('turbolinks:load', function() {
});
}
});
$(document).on('turbolinks:load', function() {
if ($('body.admins-laboratory-shixuns-index-page').length > 0) {
var $searchForm = $('.laboratory-shixun-list-form .search-form');
var laboratoryId = $('.laboratory-shixun-list-container').data('id');
$searchForm.find('select#tag_id').select2({
placeholder: "请选择",
allowClear: true
});
// 定义状态切换监听事件
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
$('.laboratory-shixun-list-container').on('click', doElement, function () {
var $doAction = $(this);
var $undoAction = $doAction.siblings(undoElement);
var laboratoryShixunId = $doAction.data('id');
customConfirm({
content: '确认进行该操作吗?',
ok: function () {
$.ajax({
url: '/admins/laboratories/' + laboratoryId + '/laboratory_shixuns/' + laboratoryShixunId + url,
method: 'POST',
dataType: 'json',
success: function () {
show_success_flash();
$doAction.hide();
$undoAction.show();
if (callback && typeof callback === "function") {
callback(laboratoryShixunId, url);
}
}
});
}
});
});
}
// 首页展示与取消首页展示
var homepageShowCallback = function (laboratoryShixunId, url) {
var $laboratoryShixunItem = $('.laboratory-shixun-list-container').find('.laboratory-shixun-item-' + laboratoryShixunId);
if (url === '/homepage') {
$laboratoryShixunItem.find('.homepage-badge').show();
} else {
$laboratoryShixunItem.find('.homepage-badge').hide();
}
}
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage', homepageShowCallback);
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage', homepageShowCallback);
// 添加实训功能
var $addModal = $('.modal.admin-add-laboratory-shixun-modal');
var $addForm = $addModal.find('form.admin-add-laboratory-user-form');
var $shixunSelect = $addForm.find('select.shixun-select');
$addModal.on('show.bs.modal', function(){
$addModal.find('.error').html('');
$shixunSelect.select2('val', ' ');
});
$shixunSelect.select2({
theme: 'bootstrap4',
placeholder: '请输入实训名称/创建者检索',
multiple: true,
closeOnSelect: false,
ajax: {
delay: 500,
url: '/admins/laboratories/' + laboratoryId + '/shixuns_for_select',
dataType: 'json',
data: function(params){
return { keyword: params.term, page: params.page || 1, per_page: 20 };
},
processResults: function(data, params){
params.page = params.page || 1;
return {
results: data.shixuns,
pagination: {
more: (params.page * 20) < data.count
}
};
}
},
templateResult: function (item) {
if(!item.id || item.id === '') return item.text;
var ele = '<span>'
ele += '<span>' + item.name + '</span>';
ele += '<span class="font-12"> -- ' + item.creator_name + '</span>';
ele += '<span class="font-12"> -- ' + item.status_text+ '</span>';
ele += '</span>';
return $(ele);
},
templateSelection: function(item){
if (item.id) {
}
var ele = '<span>' + (item.name || item.text) + '<span class="font-12"> -- ' + item.creator_name + '</span></span>'
return $(ele);
}
});
$addModal.on('click', '.submit-btn', function(){
$addModal.find('.error').html('');
var shixunIds = $shixunSelect.val();
if (shixunIds && shixunIds.length > 0) {
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/laboratories/' + laboratoryId + '/laboratory_shixuns',
data: { shixun_ids: shixunIds },
success: function(){
show_success_flash();
window.location.reload();
},
error: function(res){
$addModal.find('.error').html(res.responseJSON.message);
}
});
} else {
$addModal.find('.error').html('请选择实训');
}
});
}
})
;
$(document).on('turbolinks:load', function() {
if ($('body.admins-laboratory-subjects-index-page').length > 0) {
var $searchForm = $('.laboratory-subject-list-form .search-form');
var laboratoryId = $('.laboratory-subject-list-container').data('id');
// ************** 学校选择 *************
$searchForm.find('.school-select').select2({
theme: 'bootstrap4',
placeholder: '请选择创建者单位',
minimumInputLength: 1,
ajax: {
delay: 500,
url: '/api/schools/search.json',
dataType: 'json',
data: function (params) {
return {keyword: params.term};
},
processResults: function (data) {
return {results: data.schools}
}
},
templateResult: function (item) {
if (!item.id || item.id === '') return item.text;
return item.name;
},
templateSelection: function (item) {
if (item.id) {
}
return item.name || item.text;
}
});
// 定义状态切换监听事件
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
$('.laboratory-subject-list-container').on('click', doElement, function () {
var $doAction = $(this);
var $undoAction = $doAction.siblings(undoElement);
var laboratorySubjectId = $doAction.data('id');
customConfirm({
content: '确认进行该操作吗?',
ok: function () {
$.ajax({
url: '/admins/laboratories/' + laboratoryId + '/laboratory_subjects/' + laboratorySubjectId + url,
method: 'POST',
dataType: 'json',
success: function () {
show_success_flash();
$doAction.hide();
$undoAction.show();
if (callback && typeof callback === "function") {
callback(laboratorySubjectId, url);
}
}
});
}
});
});
}
// 首页展示与取消首页展示
var homepageShowCallback = function (laboratoryShixunId, url) {
var $laboratoryShixunItem = $('.laboratory-subject-list-container').find('.laboratory-subject-item-' + laboratoryShixunId);
if (url === '/homepage') {
$laboratoryShixunItem.find('.homepage-badge').show();
} else {
$laboratoryShixunItem.find('.homepage-badge').hide();
}
}
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage', homepageShowCallback);
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage', homepageShowCallback);
// 添加实践课程功能
var $addModal = $('.modal.admin-add-laboratory-subject-modal');
var $addForm = $addModal.find('form.admin-add-laboratory-user-form');
var $subjectSelect = $addForm.find('select.subject-select');
$addModal.on('show.bs.modal', function(){
$addModal.find('.error').html('');
$subjectSelect.select2('val', ' ');
});
$subjectSelect.select2({
theme: 'bootstrap4',
placeholder: '请输入课程名称/创建者检索',
multiple: true,
closeOnSelect: false,
ajax: {
delay: 500,
url: '/admins/laboratories/' + laboratoryId + '/subjects_for_select',
dataType: 'json',
data: function(params){
return { keyword: params.term, page: params.page || 1, per_page: 20 }
},
processResults: function(data, params){
params.page = params.page || 1;
return {
results: data.subjects,
pagination: {
more: (params.page * 20) < data.count
}
};
}
},
templateResult: function (item) {
if(!item.id || item.id === '') return item.text;
var ele = '<span>'
ele += '<span>' + item.name + '</span>';
ele += '<span class="font-12"> -- ' + item.creator_name + '</span>';
ele += '<span class="font-12"> -- ' + item.status_text+ '</span>';
ele += '</span>';
return $(ele);
},
templateSelection: function(item){
if (item.id) {
}
var ele = '<span>' + (item.name || item.text) + '<span class="font-12"> -- ' + item.creator_name + '</span></span>'
return $(ele);
}
});
$addModal.on('click', '.submit-btn', function(){
$addModal.find('.error').html('');
var subjectIds = $subjectSelect.val();
if (subjectIds && subjectIds.length > 0) {
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/laboratories/' + laboratoryId + '/laboratory_subjects',
data: { subject_ids: subjectIds },
success: function(){
show_success_flash();
window.location.reload();
},
error: function(res){
$addModal.find('.error').html(res.responseJSON.message);
}
});
} else {
$addModal.find('.error').html('请选择课程');
}
});
}
})
;
$(document).on('turbolinks:load', function() {
if ($('body.admins-library-applies-index-page').length > 0) {
var $searchFrom = $('.library-applies-list-form');

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

@ -3,7 +3,7 @@ import React,{ Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Divider
Row, Col, Select, Modal, Divider,Tooltip
} from 'antd';
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
@ -29,7 +29,8 @@ class BoardsNew extends Component{
fileList: [],
boards: [],
title_num: 0,
email_notify:false
email_notify:false,
isemail_notify:false
}
}
addSuccess = () => {
@ -98,7 +99,7 @@ class BoardsNew extends Component{
}
})
this.setState({ fileList: _fileList, board_name: data.board_name, title_num: parseInt(data.subject.length) })
this.setState({ fileList: _fileList, board_name: data.board_name, title_num: parseInt(data.subject.length) ,isemail_notify:response.data.data.email_notify})
}
}
})
@ -136,6 +137,7 @@ class BoardsNew extends Component{
select_board_id: values.select_board_id,
content: values.content,
sticky: values.sticky,
email_notify:this.state.isemail_notify,
attachment_ids,
})
.then((response) => {
@ -160,7 +162,7 @@ class BoardsNew extends Component{
axios.post(url, {
...values,
email_notify:this.state.email_notify,
email_notify:this.state.isemail_notify,
course_id: cid,
attachment_ids,
})
@ -253,7 +255,7 @@ class BoardsNew extends Component{
setemailchange=(e)=>{
this.setState({
email_notify:e.target.checked
isemail_notify:e.target.checked
})
}
render() {
@ -299,6 +301,7 @@ class BoardsNew extends Component{
const isCourseEnd = this.props.isCourseEnd();
document.title=this.props.coursedata&&this.props.coursedata.name;
// console.log(this.state)
return(
<div className="newMain ">
<AddDirModal {...this.props}
@ -338,13 +341,17 @@ class BoardsNew extends Component{
{/* notRequired */}
<Form {...formItemLayout} onSubmit={this.handleSubmit}>
<div className="formBlock" style={{paddingBottom: '0px', position: 'relative'}}>
{this.state.boardsdata&&this.state.boardsdata.email_notify===true?this.props.isAdminOrTeacher()===true?<Tooltip placement="bottom" title={this.state.isemail_notify?"邮件只能发送一次":""}><span className={"setemail fr mr70 setemailposition"}>
<Checkbox onChange={this.setemailchange} checked={this.state.isemail_notify} disabled={this.state.isemail_notify}>发送邮件提醒</Checkbox>
</span></Tooltip>:"":""}
{ isAdmin &&
<React.Fragment>
{getFieldDecorator('sticky', {
valuePropName: 'checked',
})(
isAdmin && <Checkbox style={{ right: '22px',
top: '28px',
top: '17px',
position: 'absolute'
}}>置顶</Checkbox>
)}
@ -411,9 +418,7 @@ class BoardsNew extends Component{
</Select>
)}
</Form.Item>
{this.state.boardsdata&&this.state.boardsdata.email_notify===true?this.props.isAdminOrTeacher()===true?this.isEdit ?"":<span className={"setemail"}>
<Checkbox onChange={this.setemailchange} checked={this.state.email_notify}>发送邮件提醒</Checkbox>
</span>:"":""}
{/* { isAdmin && <Form.Item

@ -50,3 +50,9 @@
margin-left: 10px;
}
/* errorInline ----------- */
.setemailposition{
position: absolute;
right: 40px;
top: 10px;
}

@ -1030,9 +1030,9 @@ class Studentshavecompletedthelist extends Component {
render: (text, record) => (
<span>
{record.finalscore==="--"?
<span className="color-blue" style={{textAlign: "center", cursor: "pointer"}}
onClick={() => this.Adjustment(record)}
>调分</span>
<span style={{color: "#9A9A9A"}}>
--
</span>
:
<a style={{textAlign: "center"}} className="color-blue"
target="_blank"
@ -1227,9 +1227,9 @@ class Studentshavecompletedthelist extends Component {
render: (text, record) => (
<span>
{record.finalscore==="--"?
<span className="color-blue" style={{textAlign: "center", cursor: "pointer"}}
onClick={() => this.Adjustment(record)}
>调分</span>
<span style={{color: "#9A9A9A"}}>
--
</span>
:
<a style={{textAlign: "center"}} className="color-blue"
target="_blank"
@ -1244,6 +1244,14 @@ class Studentshavecompletedthelist extends Component {
order_type: "desc",
exeuserid: 0,
}
{/*<span className="color-blue" style={{textAlign: "center", cursor: "pointer"}}*/
}
{/* onClick={() => this.Adjustment(record)}*/
}
{/*>调分</span>*/
}
// //console.log("Studentshavecompletedthelist");
// //console.log(props.current_status);
// columnsys 老师列表

@ -1175,8 +1175,9 @@ class Listofworksstudentone extends Component {
className: 'font-14',
render: (text, record) => (
record.submitstate === "未提交" ?
<span style={{textAlign: "center", cursor: "pointer"}} className="color-blue"
onClick={() => this.Adjustment(record)}>调分</span> :
<span style={{color: "#9A9A9A"}}>
--
</span> :
<span>
<a style={{textAlign: "center"}} className="color-blue"
onMouseDown={(e) => this.Viewstudenttraininginformationtysl2(e, record)}
@ -1508,8 +1509,9 @@ class Listofworksstudentone extends Component {
className: 'font-14',
render: (text, record) => (
record.submitstate === "未提交" ?
<span style={{textAlign: "center", cursor: "pointer"}} className="color-blue"
onClick={() => this.Adjustment(record)}>调分</span> :
<span style={{color: "#9A9A9A"}}>
--
</span> :
<span>
<a style={{textAlign: "center"}} className="color-blue"
onMouseDown={(e) => this.Viewstudenttraininginformationtysl2(e, record)}

@ -394,6 +394,7 @@ class ShixunsHome extends Component {
{/*导师排行榜*/}
{ homedatalist !== undefined && homedatalist.teachers !== undefined && (
<div className="pt60 pb60 mb30 mentor-ranking">
<div className="educontent">
<div className="edu-txt-center">
@ -470,8 +471,10 @@ class ShixunsHome extends Component {
</div>
</div>
)}
{/*程序员排行榜*/}
{ homedatalist !== undefined && homedatalist.students !== undefined && (
<div className="pt60 pb60 mb30 pro-ranking">
<div className="educontent">
<div className="edu-txt-center">
@ -544,6 +547,7 @@ class ShixunsHome extends Component {
</div>
</div>
</div>
)}
</div>
</Spin>
</div>

@ -4,10 +4,15 @@
-ms-flex-direction: column;
flex-direction: column;
}
.textright{
text-align: right;
}
.textcenter{
text-align: center;
}
.Osshackathonfont{
width: 80px;
height: 28px;
@ -26,7 +31,7 @@
}
.OsshackathonCard{
width:1200px;
height:150px;
min-height:150px;
background:rgba(248,248,248,1);
border:1px solid rgba(235,235,235,1);
}
@ -67,3 +72,84 @@
.Searchant-btn-primary .ant-input-group .ant-input{
height:42px;
}
.Breadcrumbfont{
color:#4CACFF;
}
.ant-breadcrumb-separator{
color:#BCBCBC;
}
.minheight50px{
min-height: 50px;
}
.borderDEDEDE{
border-left:1px solid #DEDEDE;
}
.pl80pt6{
padding-top: 6px;
padding-left: 80px;
}
.OsshackprimaryButton{
width: 100%;
height: 45px;
}
.OsshackprimaryButtonsyle{
background: rgba(255,255,255,1) !important;
border: 1px solid rgba(76,172,255,1);
color: rgba(76,172,255,1);
line-height: 16px;
border-radius: unset;
box-shadow:none;
}
.h45input input{
height:45px;
}
.width14bai{
width: 14%;
}
.Osshackprimaryfonttop{
font-size: 20px;
color: rgba(5,16,26,1);
text-align: center;
}
.Osshackathonmodelinput{
width: 97% !important;
margin-left: 7px;
}
.Osshackathonmodelinput .ant-input::-webkit-input-placeholder{
color: #999;
font-size: 14px;
}
.Osshackathonmodelinput .ant-input::-moz-placeholder{color: #cccccc;font-size:14px;}
.Osshackathonmodelinput .ant-input::-webkit-input-placeholder{color: #cccccc;font-size:14px;}
.Osshackathonmodelinput .ant-input:-ms-input-placeholder{color: #cccccc;font-size:14px;}
.Osshackathonmodelinput .ant-input-group-addon {
color: #adadad !important;
}
.iscursor{
cursor: pointer;
}
.issignup:hover, .issignup:focus {
color: #fff !important;
background-color: #40a9ff;
border-color: #40a9ff;
}
.Osshackathon-btn-primary .ant-btn-primary:hover, .Osshackathon-btn-primary .ant-btn-primary:focus {
color: #fff !important;
background-color: #40a9ff;
border-color: #40a9ff;
}

@ -1,10 +1,12 @@
import React, {Component} from 'react';
import axios from 'axios';
import {SnackbarHOC, WordsBtn,getImageUrl,markdownToHTML} from 'educoder';
import {Row, Col,Input,Divider,Card,Button} from 'antd';
import {Row, Col,Input,Divider,Card,Button,Pagination,Breadcrumb,Icon,Spin} from 'antd';
import { TPMIndexHOC } from '../tpm/TPMIndexHOC';
import { CNotificationHOC } from '../courses/common/CNotificationHOC';
import Osshackathonmd from './Osshackathonmd';
import './Osshackathon.css';
import Osshackathonmodel from "./Osshackathonmodel";
const { Search } = Input;
class Osshackathon extends Component {
@ -14,16 +16,22 @@ class Osshackathon extends Component {
page:1,
limit:10,
search:undefined,
data:undefined
data:undefined,
hackathonedit:false,
Osshackathonmodeltype:false,
spinning:false,
}
}
componentDidMount() {
this.getosshackathon();
this.getosshackathonlist();
window.document.title = '竞赛报名';
}
getosshackathon=()=>{
let {page,limit,search}=this.state;
getosshackathon=(page,limit,search)=>{
this.setState({
spinning:true
})
let url=`/osshackathon.json`;
axios.get(url,{params:{
page:page,
@ -33,22 +41,150 @@ class Osshackathon extends Component {
if(result.status==200){
console.log(result)
this.setState({
data:result.data
data:result.data,
spinning:false
})
}
}).catch((error)=>{
console.log(error);
this.setState({
spinning:true
})
})
}
getosshackathonlist=()=>{
let {page,limit,search}=this.state;
this.setState({
page:1,
search:undefined
})
this.getosshackathon(1,limit,undefined)
}
componentDidUpdate = (prevProps) => {
}
PaginationTask=(pageNumber)=>{
this.setState({
page:pageNumber
})
let {page,limit,search}=this.state;
this.getosshackathon(pageNumber,limit,search)
}
hackathonedit=(id)=>{
//管理员编辑title
this.setState({
hackathonedit:true
})
}
hidehackathonedit=()=>{
this.setState({
hackathonedit:false
})
}
Signupentry=(id)=>{
// 用户报名
this.props.confirm({
content: `是否确认报名?`,
onOk: () => {
this.Signupentrys(id)
}
})
}
Signupentrys=(id)=>{
let url=`/osshackathon/${id}/entry.json`;
axios.post(url
).then((response) => {
if(response.data.status===0){
this.getosshackathonlist()
this.props.showNotification(`报名成功,预祝您夺得桂冠`);
}
}).catch((error) => {
console.log(error)
})
}
editSignupentry=(id,name,description)=>{
// 管理员编辑项目
this.setState({
Osshackathonmodeltype:true
})
if(id===undefined){
this.setState({
modelid:undefined,
modelname:undefined,
modeldescription:undefined
})
}else{
this.setState({
modelid:id,
modelname:name,
modeldescription:description
})
}
}
hideeditSignupentry=(id)=>{
// 管理员取消项目
this.setState({
Osshackathonmodeltype:false
})
}
delSignupentry=(id)=>{
// 管理员删除项目
this.props.confirm({
content: `是否确认删除该项目?`,
onOk: () => {
this.delSignupentrys(id)
}
})
}
delSignupentrys=(id)=>{
let url=`/osshackathon/${id}.json`;
axios.delete(url)
.then((response) => {
if (response.data.status == 0) {
// {"status":1,"message":"删除成功"}
this.getosshackathonlist()
this.props.showNotification(`删除成功`);
}
})
.catch(function (error) {
console.log(error);
});
}
onsearchvalue=(value)=>{
this.setState({
search:value
})
let {page,limit,search}=this.state;
this.getosshackathon(page,limit,value)
}
onsetsearchvalue=(e)=>{
this.setState({
search:e.target.value
})
}
render() {
let{data}=this.state;
console.log(this.state.data)
let {page,data,hackathonedit}=this.state;
return (
<div className="newMain clearfix newMainybot">
@ -59,6 +195,11 @@ class Osshackathon extends Component {
background: #4CACFF;
border-color: #4CACFF;
}
.ant-btn-primary:hover, .ant-btn-primary:focus {
color: #4CACFF;
background-color: #40a9ff;
border-color: #40a9ff;
}
`
}
</style>
@ -66,18 +207,20 @@ class Osshackathon extends Component {
<div className={"educontent mb20 persmstyle"} style={{width: "1200px", marginTop: "26px"}}>
<div className="registrationback"
style={{"background": `url(${getImageUrl(`images/educoder/competitions/tipregistit.jpg`)})`,"height":"360px"}}
style={{"background": `url(${getImageUrl(`images/educoder/competitions/heikesong.jpg`)})`,"height":"360px"}}
></div>
<Row className={"mt20"}>
<Spin spinning={this.state.spinning}>
{this.props.user&&this.props.user.admin===true?<Row className={"mt20"}>
<Col span={6}>
<Search
className={"Searchant-btn-primary"}
className={"Osshackathon-btn-primary"}
placeholder="请输入项目名称进行搜索"
enterButton="搜索"
size="large"
onSearch={value => console.log(value)}
value={this.state.search}
onInput={(e)=>this.onsetsearchvalue(e)}
onSearch={value => this.onsearchvalue(value)}
/>
</Col>
@ -87,17 +230,17 @@ class Osshackathon extends Component {
</div>
</Col>
</Row>
</Row>:""}
<Row className={"mt20"}>
{hackathonedit===true?"":<Row className={"mt20"}>
<Col span={6} className={"Osshackathonfont"}>
{data&&data.hackathon.name}
</Col>
<Col span={3} className={"fr textright"}>
<Button type="primary">编辑</Button>
</Col>
</Row>
<style>
{this.props.user&&this.props.user.admin===true?<Col span={3} className={"fr textright"}>
<Button type="primary" className={"OsshackprimaryButtonsyle"} onClick={()=>this.hackathonedit(data&&data.hackathon.id)}>编辑</Button>
</Col>:""}
</Row>}
{hackathonedit===true?"": <style>
{
`
.ant-divider-horizontal{
@ -105,59 +248,126 @@ class Osshackathon extends Component {
}
`
}
</style>
</style>}
<Divider />
{hackathonedit===true?"":<Divider />}
<p className={"Osshackathonfontlist mb30"}>
{hackathonedit===true?"":<p className={"Osshackathonfontlist mb30"}>
{data&&data.hackathon.description===null?"":<div className={"markdown-body"}
dangerouslySetInnerHTML={{__html: markdownToHTML(data&&data.hackathon.description).replace(/▁/g, "▁▁▁")}}></div>}
</p>
</p>}
{hackathonedit===true?<Osshackathonmd
getosshackathon={()=>this.getosshackathonlist()}
hidehackathonedit={()=>this.hidehackathonedit()}
{...this.props}
{...this.state}
/>:""}
{this.state.Osshackathonmodeltype===true?<Osshackathonmodel
getosshackathon={()=>this.getosshackathonlist()}
hideeditSignupentry={()=>this.hideeditSignupentry()}
{...this.props}
{...this.state}
/>:""}
{this.props.user&&this.props.user.admin===true?<Row className={"mb20"}>
<Col span={8}></Col>
<Col span={8}><Button type="primary" className={"OsshackprimaryButton OsshackprimaryButtonsyle"} onClick={()=>this.editSignupentry()}><Icon type="plus" />新建项目</Button></Col>
<Col span={8}></Col>
</Row>:""}
{/*学生身份*/}
{
data&&data.hacks.length==0?"":data&&data.hacks.map((item,key)=>{
this.props.user&&this.props.user.admin===false?data&&data.hacks.length==0?"":data&&data.hacks.map((item,key)=>{
return(
<span></span>
)
})
}
{/*学生身份*/}
<Card className={"OsshackathonCard mb20"}>
<Card className={"OsshackathonCard mb20"} key={key}>
<Row>
<Col span={6} className={"OsshackathonCardtitle"}>
大赛介绍
{item.name}
</Col>
<Col span={6} className={"fr textright"}>
<Button type="primary fr ">立即报名</Button>
<Button type="primary fr mr20" disabled>
{item.entry_info===true?<Button type="primary fr mr20" disabled>
已报名
</Button>
</Button>:<Button type="primary fr issignup" onClick={()=>this.Signupentry(item.id)}></Button>}
</Col>
</Row>
<p>Card content</p>
<p>Card content</p>
<p className={"mt20"}>{item.description}</p>
</Card>
)
}):""
}
{/*教师身份*/}
<Card className={"OsshackathonCard"}>
{/*教师身份*/}
{this.props.user&&this.props.user.admin===true?<style>
{
`
.ant-col-pull-6 {
right: 17%;
}
.ant-col-18 {
width: 82%;
}
.CompetitionsIndexbottomvalue{
text-align: center;
}
`
}
</style>:""}
{
this.props.user&&this.props.user.admin===true?data&&data.hacks.length==0?"":data&&data.hacks.map((item,key)=>{
return(
<Card className={"OsshackathonCard mb20"}>
<Row>
<Col span={6} className={"OsshackathonCardtitle"}>
大赛介绍
{item.name}
</Col>
<Col span={6} className={"fr textright"}>
<Button type="primary fr ">立即报名</Button>
<Button type="primary fr mr20" disabled>
已报名
</Button>
<Col span={4} className={"fr textcenter width14bai"}>
<Breadcrumb separator="">
<Breadcrumb.Item className={"Breadcrumbfont iscursor"} onClick={()=>this.editSignupentry(item.id,item.name,item.description)}>编辑</Breadcrumb.Item>
<Breadcrumb.Item className={"Breadcrumbfont iscursor"} onClick={()=>this.delSignupentry(item.id)}>删除</Breadcrumb.Item>
</Breadcrumb>
</Col>
</Row>
<p>Card content</p>
<p>Card content</p>
<Row className={"mt20"}>
<Col span={4} push={20} className={"minheight50px borderDEDEDE"}>
<div className={"pl80pt6"}>
<Row gutter={16}>
<Col className="gutter-row" span={15}>
<div className="gutter-box Osshackprimaryfonttop">{item.hack_users_count}</div>
</Col>
</Row>
<Row gutter={16}>
<Col className="gutter-row" span={15}>
<div className="gutter-box CompetitionsIndexbottomvalue">报名数</div>
</Col>
</Row>
</div>
</Col>
<Col span={18} pull={6} className={"minheight50px "}>
{item.description}
</Col>
</Row>
</Card>
)}):""
}
{data&&data.hacks_count>10?data&&data.hacks.length===0?"":<div className="mb40 edu-txt-center padding20-30" >
<Pagination
showQuickJumper
defaultCurrent={1}
pageSize={10}
total={data&&data.hacks_count}
current={page}
onChange={this.PaginationTask}
/>
</div>:""}
</Spin>
</div>
</div>

@ -0,0 +1,111 @@
import React, { Component } from 'react';
import {Button, Card, Row, Col ,Upload,Icon,message,Tabs,Form,Input} from 'antd';
import axios from 'axios';
import {getImageUrl,getUrl} from 'educoder';
import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor';
class Osshackathonmd extends Component{
constructor(props) {
super(props)
this.contentMdRef = React.createRef();
this.state={
title_num: 0,
title_value: undefined
}
}
componentDidUpdate =(prevState)=>{
// if(prevState!=this.props){
// let url=`/osshackathon/edit_hackathon.json`;
// axios.get(url).then((result)=>{
// if(result.status==200){
// this.setState({
// title_value:result.data.name
// })
// this.contentMdRef.current.setValue(result.data.description);
// }
// })
// }
}
componentDidMount(){
let url=`/osshackathon/edit_hackathon.json`;
axios.get(url).then((result)=>{
if(result.status==200){
this.setState({
title_value:result.data.name
})
this.contentMdRef.current.setValue(result.data.description);
}
})
}
// 输入title
changeTitle = (e) => {
// title_num: 60 - parseInt(e.target.value.length),
this.setState({
title_num: e.target.value.length,
title_value: e.target.value
})
}
handleSubmit = () => {
let {title_value}=this.state;
const mdContnet = this.contentMdRef.current.getValue().trim();
// if(mdContnet.length>10000){
// this.props.showNotification("内容超过10000个字");
// return
// }
let url=`/osshackathon/update_hackathon.json`;
axios.post(url,{
name:title_value,
description:mdContnet,
}
).then((response) => {
if(response.data.status===0){
this.props.getosshackathon()
this.props.hidehackathonedit()
this.props.showNotification(`提交成功`);
}
}).catch((error) => {
console.log(error)
})
}
render() {
// console.log(this.props.tabkey)
// console.log(chart_rules)
return (
<div className={"mt20"}>
<Form>
<Form.Item label="标题">
<Input placeholder="请输入标题"
value={this.state.title_value}
onInput={this.changeTitle}
className="searchView searchViewAfter h45input" style={{"width": "100%"}} maxLength="60"
addonAfter={String(this.state.title_value===undefined?0:this.state.title_value.length)+"/60"}
/>
</Form.Item>
<Form.Item label="描述">
<TPMMDEditor ref={this.contentMdRef} placeholder="请输入描述" mdID={'courseContentMD'} refreshTimeout={1500}
className="courseMessageMD" initValue={this.state.description}></TPMMDEditor>
</Form.Item>
</Form>
<div className="clearfix mt30 mb30">
<div className={"fr"}>
<Button type="primary" onClick={this.handleSubmit} className="defalutSubmitbtn fl mr20">提交</Button>
<a className="defalutCancelbtn fl" onClick={() => this.props.hidehackathonedit()}>取消</ a>
</div>
</div>
</div>
)
}
}
export default Osshackathonmd;

@ -0,0 +1,217 @@
import React, { Component } from 'react';
import {Button, Card, Row, Col ,Upload,Icon,message,Tabs,Form,Input,Modal} from 'antd';
import axios from 'axios';
import {getImageUrl,getUrl,WordNumberTextarea} from 'educoder';
class Osshackathonmodel extends Component{
constructor(props) {
super(props)
this.state={
title_num: 0,
title_value: undefined,
Textarea_comment:undefined
}
}
componentDidUpdate =(prevState)=>{
// if(prevState!=this.props){
// let name=this.props&&this.props.modelname;
// let mdvalue=this.props&&this.props.modeldescription;
// this.setState({
// title_value:name,
// Textarea_comment:mdvalue
// })
// }
}
componentDidMount(){
if(this.props.modelid===undefined){
this.setState({
title_value:undefined,
Textarea_comment:undefined
})
}else{
let url=`/osshackathon/${this.props.modelid}/edit.json`;
axios.get(url).then((result)=>{
if(result.status==200){
this.setState({
title_value:result.data.name,
Textarea_comment:result.data.description
})
}
})
}
}
handleSubmit = () => {
let {title_value,Textarea_comment}=this.state;
// if(mdContnet.length>10000){
// this.props.showNotification("内容超过10000个字");
// return
// }
//
if(this.props.modelid===undefined){
let url=`/osshackathon.json`;
axios.post(url,{
name:title_value,
description:Textarea_comment,
}
).then((response) => {
if(response.data.status===0){
this.props.getosshackathon()
this.props.hideeditSignupentry()
this.props.showNotification(`提交成功`);
}
}).catch((error) => {
console.log(error)
})
}else{
let url=`/osshackathon/${this.props.modelid}.json`
axios.put(url,{
name:title_value,
description:Textarea_comment,
}
).then((response) => {
if(response.data.status===0){
this.props.getosshackathon()
this.props.hideeditSignupentry()
this.props.showNotification(`提交成功`);
}
}).catch((error) => {
console.log(error)
})
}
}
changeTitle=(e)=>{
this.setState({
title_value:e.target.value,
title_num:e.target.value.length,
})
}
Textarea_comment=(e)=>{
this.setState({
Textarea_comment:e.target.value,
})
}
render() {
let {textareavaltype}=this.state;
// console.log(this.props.tabkey)
console.log(this.props.Osshackathonmodeltype)
return (
<div>
<style>
{
`
@media (max-width: 2000px) {
.WordNumberTextarea{
height: 130px !important;
}
}
@media (max-width: 1350px) {
.HomeworkModal{
top:10px !important;
}
.WordNumberTextarea{
height: 80px !important;
}
}
@media (max-width: 1250px) {
.HomeworkModal{
top:0px !important;
}
.WordNumberTextarea{
height: 40px !important;
}
}
`
}
</style>
<Modal
keyboard={false}
className={"HomeworkModal"}
title={"新建项目"}
visible={this.props.Osshackathonmodeltype}
closable={false}
footer={null}
destroyOnClose={true}
>
<div className={"pd015"}>
<style>
{
`
.pd015{
padding: 0px 15px 15px 15px;
}
.font{
font-size: 14px;
font-weight: 400;
color: rgba(5,16,26,1);
}
.newfont{
height: 16px;
font-size: 16px;
font-weight: 400;
color: rgba(5,16,26,1);
line-height: 16px;
margin-bottom: 5px;
}
.Osshackathonmodelinput .ant-input, .ant-input .ant-input-suffix{
background: #fff !important;
}
.Osshackathonmodelinput .ant-input-group-wrapper{
width:510px !important;
margin-left: 10px;
}
`
}
</style>
<div className="clearfix">
<p className={"font mt10 mb10 ml10"}>
名称
</p>
<Input placeholder="请输入项目名称"
value={this.state.title_value}
onInput={(e)=>this.changeTitle(e)}
className={"Osshackathonmodelinput"}
style={{"width": "100%"}} maxLength="60"
addonAfter={String(this.state.title_value===undefined?0:this.state.title_value.length)+"/60"}
/>
<p className={"font mt10 mb10 ml10"}>
描述
</p>
<WordNumberTextarea
placeholder={"请输入项目描述"}
onInput={(e)=>this.Textarea_comment(e)}
value={this.state.Textarea_comment}
maxlength={500}
/>
<li style={{height:"20px",lineHeight:"20px"}} className={textareavaltype===true?"color-red mt20 mb10":"none"}><span>评阅内容至少有一个不为空</span></li>
</div>
<div className={textareavaltype===false?"mt20 clearfix edu-txt-center":"clearfix edu-txt-center mt20"}>
<a className="task-btn color-white mr30" onClick={()=>this.props.hideeditSignupentry()}>取消</a>
<a className="task-btn task-btn-orange" onClick={()=>this.handleSubmit()}>确定</a>
</div>
</div>
</Modal>
</div>
)
}
}
export default Osshackathonmodel;

@ -26,6 +26,7 @@ import './leftView.css'
import CodeEvaluateMultiLevelAnswerUnlock from './CodeEvaluateMultiLevelAnswerUnlock'
import MUIDialogStyleUtil from '../component/MUIDialogStyleUtil'
import moment from 'moment';
// http://danilowoz.com/create-react-content-loader/
const MyLoader = () => (
<ContentLoader
@ -283,7 +284,9 @@ class LeftView extends Component {
}
.multiLevelAnswer .status{
color: #CDCDCD;
flex: 0 0 45px;
}
.multiLevelAnswer .lock-time{
margin-right: 15px;
}
.markdown-body ol, .markdown-body ul {
padding-left: 2.5em;
@ -292,13 +295,17 @@ class LeftView extends Component {
<div className="multiLevelAnswer">
{ unlockedAnswers && unlockedAnswers.map((item, index) => {
const {name, contents, view_time} = item;
return <div className="anwserSection">
<div className="df">
<div className="level">级别{index + 1}</div>
<div className="name">{item.name}</div>
<div className="status">已解锁</div>
<div className="name">{name}</div>
<div className="status">
<span className="lock-time">{view_time ? moment(view_time).format('YYYY-MM-DD HH:mm') : ''}</span>
已解锁
</div>
</div>
<div className="contents markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML(item.contents)}}>
<div className="contents markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML(contents)}}>
</div>
</div>
})}

@ -89,4 +89,35 @@
.rateRow .rc-rate-star-half .rc-rate-star-first, .rateRow .rc-rate-star-full .rc-rate-star-second {
color: #FFA800;
}
.tip-info-wrap{
background-color: #111C24;
padding: 20px 0px;
}
.tip-info-wrap .tip-info{
display: flex;
background: #707070;
border: 1px solid rgba(112,112,112,1);
border-radius: 100px;
width: 375px;
height: 52px;
font-size: 12px;
align-items: center;
align-items: space-around;
margin: 0 auto;
padding: 0 20px;
}
.finish-wrap{
display: flex;
padding: 0 0px 0 20px;
margin-top: 10px;
}
.finish-wrap .finish-time{
flex: 1;
}
.finish-time .time-title{
color: #747A7F;
margin-right: 5px;
}
/*------------------------------- TaskList End */

@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import { CircularProgress } from 'material-ui/Progress';
import moment from 'moment';
import Rate from 'rc-rate';
import 'rc-rate/assets/index.css';
@ -21,7 +21,7 @@ class TaskList extends Component {
challenge.experience = challenge.get_experience
challenge.gold = challenge.get_gold
challenge.subject = challenge.name
const {finished_time, view_answer_time} = challenge;
const showExp = (challenge.experience > 0 && challenge.status === 2) ? '+' + challenge.experience : challenge.experience
const showGold = (challenge.gold > 0 && challenge.status === 2) ? '+' + challenge.gold : challenge.gold
return (
@ -70,6 +70,15 @@ class TaskList extends Component {
</span>
</div>
<div className="finish-wrap">
<p class="finish-time font-12">
<span class="time-title">完成时间</span>
{ finished_time ? moment(finished_time).format('YYYY-MM-DD HH:mm') : '--' }
</p>
<p class="finish-time font-12">
<span class="time-title">查看答案时间</span>
{ view_answer_time ? moment(view_answer_time).format('YYYY-MM-DD HH:mm') : '--' } </p>
</div>
{ shixun.status >= 2 && <div className="rateRow">
{/* 已完成、未评分 */}
{challenge.status === 2 && challenge.star === 0?
@ -103,8 +112,15 @@ class TaskList extends Component {
render() {
const { taskListLoading } = this.props;
return (
<div className="page--over">
<div className="col-width-3 -scroll" style={{height: '100%'}} id="all_task_index">
<div className="page--over" style={{ width: '420px'}}>
{/** 增加提示信息 */}
<div className="tip-info-wrap">
<p className="tip-info">
<span><span style={{ color: '#FFBD4C'}}>温馨提示: </span> </span>
</p>
</div>
<div className="col-width-3 -scroll" style={{height: 'calc( 100% - 100px )', width: '420px'}} id="all_task_index">
{ taskListLoading ?
<CircularProgress size={40} thickness={3} style={{ marginLeft: 'auto', marginRight: 'auto', marginTop: '40%', display: 'block' }}/> :
this.renderTasks()

@ -1228,13 +1228,11 @@ submittojoinclass=(value)=>{
}
<li><a href={`/account/profile`}>账号管理</a></li>
{/*<li><a onClick={()=>this.educoderlogin()} >登入测试接口</a></li>*/}
{/*<li><a onClick={()=>this.trialapplications()} >试用申请</a> </li>*/}
{/*<li><Link to={`/interest`}>兴趣页</Link></li>*/}
<li className="bor-top-greyE">
{/*<a href={this.props.Headertop===undefined?"":this.props.Headertop.logout_url}>退出</a>*/}
{/*<a onClick={()=>this.educoderlogin()}>退出</a>*/}
{/*<a onClick={()=>this.educoderlogin()} >登录</a>*/}
<a onClick={()=>this.educoderloginysl()}>退出</a>
</li>

Loading…
Cancel
Save