diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 317383d5a..dd015ba9e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -285,7 +285,7 @@ class ApplicationController < ActionController::Base
def user_setup
# # reacct静态资源加载不需要走这一步
- return if params[:controller] == "main"
+ #return if params[:controller] == "main"
# Find the current user
#Rails.logger.info("current_laboratory is #{current_laboratory} domain is #{request.subdomain}")
User.current = find_current_user
diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb
index 0d8604aac..efc073c86 100644
--- a/app/controllers/concerns/git_helper.rb
+++ b/app/controllers/concerns/git_helper.rb
@@ -41,7 +41,8 @@ module GitHelper
# 更新文件代码
# content: 文件内容;message:提交描述
def update_file_content(content, repo_path, path, mail, username, message)
- GitService.update_file(repo_path: repo_path, file_path: path, message: message,
+ content = Base64.encode64(content)
+ GitService.update_file_base64(repo_path: repo_path, file_path: path, message: message,
content: content, author_name: username, author_email: mail)
end
diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb
index e8554300c..75a6012b0 100644
--- a/app/controllers/main_controller.rb
+++ b/app/controllers/main_controller.rb
@@ -1,5 +1,7 @@
class MainController < ApplicationController
skip_before_action :check_sign
+ skip_before_action :user_setup
+ skip_before_action :setup_laboratory
def first_stamp
render :json => { status: 0, message: Time.now.to_i }
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 442881df2..7009726d8 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -931,7 +931,7 @@ class ShixunsController < ApplicationController
page = params[:page] || 1
limit = params[:limit] || 20
@user_count = @users.count
- @users = @users.page(page).per(limit)
+ @users = @users.page(page).per(20)
end
@@ -995,7 +995,7 @@ class ShixunsController < ApplicationController
@courses = @courses.where(id: current_laboratory.all_courses)
@course_count = @courses.count
- @courses = @courses.page(page).per(limit)
+ @courses = @courses.page(page).per(10)
end
# 将实训发送到课程
diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb
index ca76ee953..22adf3005 100644
--- a/app/helpers/export_helper.rb
+++ b/app/helpers/export_helper.rb
@@ -850,7 +850,7 @@ module ExportHelper
def make_zip_name(work, file_name="")
Rails.logger.info("######################file_name: #{file_name}")
# name = file_name === "" ? "" : (file_name[0, file_name.rindex('.')]+"_")
- "#{work&.user&.student_id}_#{work&.user&.real_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ "#{work&.homework_common.course&.user_group_name(work.user_id)}_#{work&.user&.student_id}_#{work&.user&.real_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
end
def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[])
diff --git a/app/services/git_service.rb b/app/services/git_service.rb
index 7867d063e..eedac2595 100644
--- a/app/services/git_service.rb
+++ b/app/services/git_service.rb
@@ -2,16 +2,30 @@
#
# 文档在 https://www.showdoc.cc/127895880302646?page_id=1077512172693249
#
+require 'faraday'
+
class GitService
class << self
- ['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', 'file_content', 'commits', 'add_tree', 'delete_file'].each do |method|
+ ['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', 'file_content', 'commits',
+ 'add_tree', 'delete_file', 'update_file_base64'].each do |method|
define_method method do |params|
post(method, params)
end
end
+ def make_new_multipar_file(full_file_path)
+ Faraday::FilePart.new(full_file_path, 'application/octet-stream')
+ end
+
+ #上传二进制文件
+ #参数构造形式
+ # {a: 'a', file: make_new_multipar_file('1.txt') }
+ def update_file_binary(params)
+ post_form('update_file', params)
+ end
+
private
def root_url
@@ -24,6 +38,19 @@ class GitService
Rails.logger
end
+ def post_form(action,params)
+ conn = Faraday.new(root_url) do |f|
+ f.request :multipart
+ f.request :url_encoded
+ f.adapter :net_http
+ end
+
+ resp = conn.post("/api/#{action}", params)
+
+ body = resp.body
+ parse_return(body)
+ end
+
def post(action, params)
uri = URI.parse("#{root_url}/api/#{action}")
https = Net::HTTP.new(uri.host, uri.port)
@@ -32,6 +59,11 @@ class GitService
req.body = params.to_json
res = https.request(req)
body = res.body
+
+ parse_return(body)
+ end
+
+ def parse_return(body)
logger.info("--uri_exec: .....res is #{body}")
content = JSON.parse(body)
diff --git a/db/migrate/20200106092135_modify_viewed_count_for_subjects.rb b/db/migrate/20200106092135_modify_viewed_count_for_subjects.rb
new file mode 100644
index 000000000..ecef2df69
--- /dev/null
+++ b/db/migrate/20200106092135_modify_viewed_count_for_subjects.rb
@@ -0,0 +1,10 @@
+class ModifyViewedCountForSubjects < ActiveRecord::Migration[5.2]
+ def change
+
+ subjects = Subject.where(status: 2).includes(:shixuns)
+ subjects.find_each do |subject|
+ subject.update_attribute(:visits, subject.visits + subject.shixuns.pluck(:myshixuns_count).sum)
+ end
+
+ end
+end
diff --git a/lib/tasks/zip_pack.rake b/lib/tasks/zip_pack.rake
index 6e3140f47..393f7ab3c 100644
--- a/lib/tasks/zip_pack.rake
+++ b/lib/tasks/zip_pack.rake
@@ -1,7 +1,7 @@
# 执行示例 bundle exec rake zip_pack:shixun_pack args=123,2323
namespace :zip_pack do
desc "手工打包作品"
- OUTPUT_FOLDER = "/tmp"
+ OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip"
task :shixun_pack => :environment do
@@ -27,7 +27,7 @@ namespace :zip_pack do
pdfs << pdf
begin
zip.add(export.filename, pdf.path)
- puts "out: #{export.filename}"
+ puts "out: #{export.filename}_#{pdf.path}"
rescue => ex
Rails.logger.error(ex.message)
@@ -46,6 +46,21 @@ namespace :zip_pack do
end
end
+ task :homework_attach_pack => :environment do
+ include ExportHelper
+ if ENV['args']
+ homework_id = ENV['args']
+ homework = HomeworkCommon.find homework_id
+ zip_works = homework.student_works.where("work_status > 0")
+ if zip_works.size > 0
+ zipfile = zip_homework_common homework, zip_works
+ else
+ zipfile = {:message => "no file"}
+ end
+ puts "out: #{zipfile}"
+ end
+ end
+
def filename_for_content_disposition(name)
request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident|Edge} ? ERB::Util.url_encode(name) : name
end
diff --git a/public/react/src/common/quillForEditor/README.md b/public/react/src/common/quillForEditor/README.md
index bbec5eb50..0369164c7 100644
--- a/public/react/src/common/quillForEditor/README.md
+++ b/public/react/src/common/quillForEditor/README.md
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2020-01-06 16:20:03
* @LastEditors : tangjiang
- * @LastEditTime : 2020-01-06 16:46:44
+ * @LastEditTime : 2020-01-06 17:13:19
-->
## QuillForEditor 使用 [https://quilljs.com/]
@@ -17,14 +17,14 @@
| 字段 | 描述 |
| ----- | ----- |
| placeholder | 提示信息 |
- | readOnly | 只读(只读取模式时,没有 工具栏且内容不可编辑,通过用于展示quill内容) |
+ | readOnly | 只读(只读取模式时,没有 工具栏且内容不可编辑,通常用于展示quill内容) |
| autoFocus | 自动获得焦点 |
| options | 配置参数, 指定工具栏内容 |
| value | 文本编辑器内容 |
| imgAttrs | 指定上传图片的尺寸 |
| style | 指定quill容器样式 |
| wrapStyle | 指定包裹quill容器的样式|
- | onContentChange | 当编辑器内容变化时调用此回调函数 |
+ | onContentChange | 当编辑器内容变化时调用此回调函数(注: 此时返回的内容为对象,提交到后台时需要格式成 JSON 字符串: JSON.stringify(xx)) |
| showUploadImage | 点击放大上传成功后的图片, 返回上传成功后的图片 url, (评论时点击图片这么大)|
@@ -63,7 +63,32 @@
````
import QuillForEditor from 'xxx';
-
{coursedata.teacher_applies_count===undefined?"":coursedata.teacher_applies_count>0?
您有{coursedata.teacher_applies_count}条新的加入申请
- this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers?tab=2")}>
+ this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers?tab=2")}>
待审批
:""}
}>
- this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers")}>
+ this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers")}>
教师
{coursedata.teacher_count}
@@ -756,8 +755,8 @@ background:rgba(204,204,204,0.2) !important;
diff --git a/public/react/src/redux/actions/jupyter.js b/public/react/src/redux/actions/jupyter.js index 1a3654c3f..c4a723b3c 100644 --- a/public/react/src/redux/actions/jupyter.js +++ b/public/react/src/redux/actions/jupyter.js @@ -160,7 +160,8 @@ export const active_with_tpi = (identifier, msg) => { if (status === 0) { message.success(msg); // dispatch(addjypertime(Date.now() + 900 * 1000,false)) - setTimeout(()=>{dispatch(addjypertime(Date.now() + 900 * 1000, Date.now() + 300 * 1000))},800); + // setTimeout(()=>{dispatch(addjypertime(Date.now() + 900 * 1000, Date.now() + 300 * 1000))},800); + timeinfo_with_tpi(identifier,dispatch) } } })