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

dev_aliyun_beta
杨树林 5 years ago
commit 51796f73c1

@ -890,7 +890,7 @@ class CoursesController < ApplicationController
name = worksheet.cell(row, 1).to_s name = worksheet.cell(row, 1).to_s
if @course.course_groups.where(:name => name).blank? if @course.course_groups.where(:name => name).blank?
@course.course_groups << CourseGroup.new(:name => name) @course.course_groups << CourseGroup.new(:name => name, :position => @course.course_groups_count + 1)
group_count += 1 group_count += 1
end end
end end

@ -1,6 +1,7 @@
class QuestionBanksController < ApplicationController class QuestionBanksController < ApplicationController
before_action :require_login, :check_auth before_action :require_login, :check_auth
before_action :params_filter, except: [:my_courses] before_action :params_filter, except: [:my_courses]
before_action :teacher_or_admin, except: [:bank_list]
# 题库选用列表 # 题库选用列表
# object_type: # normal 普通作业题库; group 分组作业题库; poll问卷题库 exercise试卷题库; gtask 毕设选题题库gtopic 毕设任务 # object_type: # normal 普通作业题库; group 分组作业题库; poll问卷题库 exercise试卷题库; gtask 毕设选题题库gtopic 毕设任务
@ -81,24 +82,29 @@ class QuestionBanksController < ApplicationController
def my_courses def my_courses
@courses = current_user.manage_courses.where(is_delete: 0, is_end: 0) @courses = current_user.manage_courses.where(is_delete: 0, is_end: 0)
unless params[:search].blank?
@courses = @courses.where("name like ?", "%#{params[:search].strip}%")
end
end end
def send_to_course def send_to_course
bank = current_bank banks = object_banks
course = current_user.manage_courses.find_by(id: params[:course_id]) course = current_user.manage_courses.find_by!(id: params[:course_id])
case @object_type banks.each do |bank|
when 'HomeworkBank' # 作业 case @object_type
quote_homework_bank bank, course when 'HomeworkBank' # 作业
when 'ExerciseBank' quote_homework_bank bank, course
if bank.container_type == 'Exercise' # 试卷 when 'ExerciseBank'
quote_exercise_bank bank, course if bank.container_type == 'Exercise' # 试卷
else # 问卷 quote_exercise_bank bank, course
quote_poll_bank bank, course else # 问卷
quote_poll_bank bank, course
end
when 'GtaskBank'
quote_gtask_bank bank, course
when 'GtopicBank'
quote_gtopic_bank bank, course
end end
when 'GtaskBank'
quote_gtask_bank bank, course
when 'GtopicBank'
quote_gtopic_bank bank, course
end end
normal_status("发送成功") normal_status("发送成功")
end end
@ -106,7 +112,7 @@ class QuestionBanksController < ApplicationController
def destroy def destroy
bank = current_bank bank = current_bank
unless user.admin? || bank.user_id == user.id unless current_user.admin? || bank.user_id == current_user.id
render_forbidden render_forbidden
return return
end end
@ -121,11 +127,32 @@ class QuestionBanksController < ApplicationController
render_ok render_ok
end end
def multi_delete
@objects = object_banks
@objects.destroy_all
normal_status("删除成功")
end
def multi_public
@objects = object_banks
@objects.update_all(is_public: true)
normal_status("更新成功")
end
private private
def object_banks
banks ||= @object_type.classify.constantize.where(@object_filter).where(id: params[:object_id])
unless current_user.admin?
banks = banks.where(user_id: current_user.id)
end
banks
end
def current_bank def current_bank
@_current_bank ||= @object_type.classify.constantize.where(@object_filter).find(params[:id]) @_current_bank ||= @object_type.classify.constantize.where(@object_filter).find(params[:id])
end end
def params_filter def params_filter
type = ["normal", "group", "poll", "exercise", "gtask", "gtopic"] type = ["normal", "group", "poll", "exercise", "gtask", "gtopic"]
tip_exception("object_type类型不正确") unless type.include?(params[:object_type]) tip_exception("object_type类型不正确") unless type.include?(params[:object_type])
@ -152,6 +179,10 @@ class QuestionBanksController < ApplicationController
end end
end end
def teacher_or_admin
tip_exception(403, "无权限操作") unless current_user.is_certification_teacher || current_user.admin?
end
def quote_homework_bank homework, course def quote_homework_bank homework, course
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
# 复制作业的基本信息 # 复制作业的基本信息

@ -17,15 +17,16 @@
</td> </td>
<td> <td>
<!-- 图片上传,稍后添加--> <!-- 图片上传,稍后添加-->
--
<a href="javascript:void(0);" id="object_upload_img_<%= shixun.id %>" onclick="$('#upload_img_<%= shixun.id %>').click();"> <!-- <a href="javascript:void(0);" id="object_upload_img_<%#= shixun.id %>" onclick="$('#upload_img_<%= shixun.id %>').click();">-->
<%= File.exist?(disk_filename("Shixun",shixun.id)) ? "重新上传" : "上传图片" %> <%#= File.exist?(disk_filename("Shixun",shixun.id)) ? "重新上传" : "上传图片" %>
</a> <!-- </a>-->
<% if File.exist?(disk_filename("Shixun",shixun.id)) %> <%# if File.exist?(disk_filename("Shixun",shixun.id)) %>
<%= image_tag(url_to_avatar(shixun), :class => "w80 h80 fl ml5 shixun_image_show", :id => "shixun_image_show_#{shixun.id}") %> <%#= image_tag(url_to_avatar(shixun), :class => "w80 h80 fl ml5 shixun_image_show", :id => "shixun_image_show_#{shixun.id}") %>
<% else %> <%# else %>
<img src="" class="w80 h80 fl ml5 shixun_image_show none" id="shixun_image_show_<%= shixun.id %>"/> <!-- <img src="" class="w80 h80 fl ml5 shixun_image_show none" id="shixun_image_show_<%#= shixun.id %>"/>-->
<% end %> <%# end %>
</td> </td>
<td><%= link_to shixun.owner.try(:show_real_name),"/users/#{shixun.owner.login}",target:'_blank' %></td> <td><%= link_to shixun.owner.try(:show_real_name),"/users/#{shixun.owner.login}",target:'_blank' %></td>

@ -632,6 +632,8 @@ Rails.application.routes.draw do
post :save_banks post :save_banks
get :my_courses get :my_courses
post :send_to_course post :send_to_course
delete :multi_delete
post :multi_public
end end
end end

File diff suppressed because one or more lines are too long

@ -38362,46 +38362,37 @@ $(document).on('turbolinks:load', function() {
; ;
$(document).on('turbolinks:load', function() { $(document).on('turbolinks:load', function() {
if ($('body.admins-shixun-settings-index-page').length > 0) { if ($('body.admins-shixun-settings-index-page').length > 0) {
$(".shixun-settings-select").on("change", function () {
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
json[s_name] = s_value;
$.ajax({
url: "/admins/shixun_settings",
type: "GET",
dataType:'script',
data: json
})
});
$(".shixun-setting-form").on("change",function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
var s_index = $(this).parent("td").siblings(".shixun-line-no").text();
json[s_name] = s_value;
json["page_no"] = s_index;
$.ajax({
url: "/admins/shixun_settings/" + s_id,
type: "PUT",
dataType:'script',
data: json
})
})
} }
}); });
function update_change(target) {
var s_id = $(target).attr("data-id");
var s_value = $(target).val();
var s_name = $(target).attr("name");
var json = {};
var s_index = $(target).parent("td").siblings(".shixun-line-no").text();
json[s_name] = s_value;
json["page_no"] = s_index;
$.ajax({
url: "/admins/shixun_settings/" + s_id,
type: "PUT",
dataType:'script',
data: json,
success: function (data) {
}
})
}
function select_change(target) {
var s_value = $(target).val();
var s_name = $(target).attr("name");
var json = {};
json[s_name] = s_value;
$.ajax({
url: "/admins/shixun_settings/",
type: "GET",
dataType:'script',
data: json,
success: function (data) {
}
})
}
;
$(document).on('turbolinks:load', function() { $(document).on('turbolinks:load', function() {
$('select#tag-choosed').select2({ $('select#tag-choosed').select2({
placeholder: "请选择分类", placeholder: "请选择分类",

@ -18726,6 +18726,13 @@ input[type="checkbox"] {
border: 1px solid #eee !important; border: 1px solid #eee !important;
} }
/* line 10, app/assets/stylesheets/admins/shixun_settings.scss */
.setting-chosen {
font-weight: 400;
font-size: 10px;
color: #333;
}
/* line 1, app/assets/stylesheets/admins/sidebar.scss */ /* line 1, app/assets/stylesheets/admins/sidebar.scss */
#sidebar { #sidebar {
min-width: 200px; min-width: 200px;

@ -38362,46 +38362,37 @@ $(document).on('turbolinks:load', function() {
; ;
$(document).on('turbolinks:load', function() { $(document).on('turbolinks:load', function() {
if ($('body.admins-shixun-settings-index-page').length > 0) { if ($('body.admins-shixun-settings-index-page').length > 0) {
$(".shixun-settings-select").on("change", function () {
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
json[s_name] = s_value;
$.ajax({
url: "/admins/shixun_settings",
type: "GET",
dataType:'script',
data: json
})
});
$(".shixun-setting-form").on("change",function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
var s_index = $(this).parent("td").siblings(".shixun-line-no").text();
json[s_name] = s_value;
json["page_no"] = s_index;
$.ajax({
url: "/admins/shixun_settings/" + s_id,
type: "PUT",
dataType:'script',
data: json
})
})
} }
}); });
function update_change(target) {
var s_id = $(target).attr("data-id");
var s_value = $(target).val();
var s_name = $(target).attr("name");
var json = {};
var s_index = $(target).parent("td").siblings(".shixun-line-no").text();
json[s_name] = s_value;
json["page_no"] = s_index;
$.ajax({
url: "/admins/shixun_settings/" + s_id,
type: "PUT",
dataType:'script',
data: json,
success: function (data) {
}
})
}
function select_change(target) {
var s_value = $(target).val();
var s_name = $(target).attr("name");
var json = {};
json[s_name] = s_value;
$.ajax({
url: "/admins/shixun_settings/",
type: "GET",
dataType:'script',
data: json,
success: function (data) {
}
})
}
;
$(document).on('turbolinks:load', function() { $(document).on('turbolinks:load', function() {
$('select#tag-choosed').select2({ $('select#tag-choosed').select2({
placeholder: "请选择分类", placeholder: "请选择分类",

@ -18726,6 +18726,13 @@ input[type="checkbox"] {
border: 1px solid #eee !important; border: 1px solid #eee !important;
} }
/* line 10, app/assets/stylesheets/admins/shixun_settings.scss */
.setting-chosen {
font-weight: 400;
font-size: 10px;
color: #333;
}
/* line 1, app/assets/stylesheets/admins/sidebar.scss */ /* line 1, app/assets/stylesheets/admins/sidebar.scss */
#sidebar { #sidebar {
min-width: 200px; min-width: 200px;
@ -19421,6 +19428,13 @@ input[type="checkbox"] {
.select2 .select2-selection__choice { .select2 .select2-selection__choice {
border: 1px solid #eee !important; border: 1px solid #eee !important;
} }
/* line 10, app/assets/stylesheets/admins/shixun_settings.scss */
.setting-chosen {
font-weight: 400;
font-size: 10px;
color: #333;
}
/* line 1, app/assets/stylesheets/admins/sidebar.scss */ /* line 1, app/assets/stylesheets/admins/sidebar.scss */
#sidebar { #sidebar {
min-width: 200px; min-width: 200px;
Loading…
Cancel
Save