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

dev_tj
daiao 5 years ago
commit 5f65b9d25f

@ -223,7 +223,7 @@ class StudentWork < ApplicationRecord
game_score = adjust_score.score game_score = adjust_score.score
elsif game.present? elsif game.present?
setting = homework_common.homework_group_setting game.user_id setting = homework_common.homework_group_setting game.user_id
if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time)) if game.status == 2 && ((game.end_time && setting.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && homework_common.late_time && game.end_time && game.end_time < homework_common.late_time))
answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation
game_score = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0) game_score = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0)
end end

@ -1,51 +1,78 @@
# 执行示例 bundle exec rake zip_pack:shixun_pack args=123,2323 # 执行示例 bundle exec rake zip_pack:shixun_pack class=Course ids=123,2323
# 执行示例 bundle exec rake zip_pack:shixun_pack class=HomeworkCommon ids=123,2323
namespace :zip_pack do namespace :zip_pack do
desc "手工打包作品" desc "手工打包作品"
OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip" OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip"
task :shixun_pack => :environment do task :shixun_pack => :environment do
if ENV['args'] if ENV['class'] && ENV['ids']
homework_ids = ENV['args'].split(",").map(&:to_i) env_ids = ENV['ids'].split(",").map(&:to_i)
homeworks = HomeworkCommon.where(id: homework_ids) folders = []
homeworks.includes(:score_student_works).each do |homework| if ENV['class'] == "Course"
out_file_name = "#{Time.now.strftime("%Y%m%d%H%M%S").to_s}-#{homework.course_id}-#{homework.name}.zip" courses = Course.where(id: env_ids)
out_file_name.gsub!(" ", "-") courses.each do |course|
out_file_name.gsub!("/", "_") homeworks = course.practice_homeworks.homework_published
new_dir_name = "#{course.name.to_s.strip}_#{Time.now.strftime("%Y%m%d%H%M%S").to_s}"
new_dir_name.gsub!(" ", "-")
new_dir_name.gsub!("/", "_")
new_folder = "#{OUTPUT_FOLDER}/#{new_dir_name}"
zip_homework_pdf homeworks, new_folder
folders << new_folder
end
else
homeworks = HomeworkCommon.where(id: env_ids)
new_dir_name = "#{homeworks.first&.course&.name.to_s.strip}_#{Time.now.strftime("%Y%m%d%H%M%S").to_s}"
new_dir_name.gsub!(" ", "-")
new_dir_name.gsub!("/", "_")
new_folder = "#{OUTPUT_FOLDER}/#{new_dir_name}"
zip_homework_pdf homeworks, new_folder
folders << new_folder
end
puts "下载路径: #{folders.join("")}"
end
end
zipfile_name = "#{OUTPUT_FOLDER}/#{out_file_name}" def zip_homework_pdf homeworks, folder
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) Dir.mkdir(folder) unless File.directory?(folder)
student_works = homework.score_student_works homeworks.includes(:score_student_works).each do |homework|
out_file_name = "#{Time.now.strftime("%Y%m%d%H%M%S").to_s}-#{homework.course_id}-#{homework.name}.zip"
out_file_name.gsub!(" ", "-")
out_file_name.gsub!("/", "_")
if student_works.size > 0 zipfile_name = "#{folder}/#{out_file_name}"
pdfs = [] # Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zip|
student_works.find_each.map do |student_work|
export = ExportShixunReportService.new(homework, student_work)
pdf = export.to_pdf
pdfs << pdf
begin
zip.add(export.filename, pdf.path)
puts "out: #{export.filename}_#{pdf.path}"
rescue => ex
Rails.logger.error(ex.message)
zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } student_works = homework.score_student_works
next
end if student_works.size > 0
pdfs = []
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zip|
student_works.find_each.map do |student_work|
export = ExportShixunReportService.new(homework, student_work)
pdf = export.to_pdf
pdfs << pdf
begin
zip.add(export.filename, pdf.path)
puts "out: #{export.filename}_#{pdf.path}"
rescue => ex
Rails.logger.error(ex.message)
zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") }
next
end end
end end
zipfile = zipfile_name
else
zipfile = {:message => "no file"}
end end
puts "out: #{zipfile}" zipfile = zipfile_name
else
zipfile = {:message => "no file"}
end end
end end
end end
# 执行示例 bundle exec rake zip_pack:homework_attach_pack args=123
task :homework_attach_pack => :environment do task :homework_attach_pack => :environment do
include ExportHelper include ExportHelper
if ENV['args'] if ENV['args']
@ -61,7 +88,4 @@ namespace :zip_pack do
end end
end end
def filename_for_content_disposition(name)
request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident|Edge} ? ERB::Util.url_encode(name) : name
end
end end

@ -75,6 +75,7 @@
"react-codemirror": "^1.0.0", "react-codemirror": "^1.0.0",
"react-codemirror2": "^6.0.0", "react-codemirror2": "^6.0.0",
"react-content-loader": "^3.1.1", "react-content-loader": "^3.1.1",
"react-cookies": "^0.1.1",
"react-dev-utils": "^5.0.0", "react-dev-utils": "^5.0.0",
"react-dom": "^16.9.0", "react-dom": "^16.9.0",
"react-hot-loader": "^4.0.0", "react-hot-loader": "^4.0.0",

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2020-01-15 09:56:34 * @Date: 2020-01-15 09:56:34
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-16 15:22:25 * @LastEditTime : 2020-01-17 10:19:51
*/ */
import './index.scss'; import './index.scss';
import React, {useState, useEffect, useRef} from 'react'; import React, {useState, useEffect, useRef} from 'react';
@ -12,6 +12,7 @@ import MonacoEditor from '@monaco-editor/react';
import { Input, Icon } from 'antd'; import { Input, Icon } from 'antd';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import actions from '../../redux/actions'; import actions from '../../redux/actions';
import cookie from 'react-cookies';
const { TextArea } = Input; const { TextArea } = Input;
const App = (props) => { const App = (props) => {
@ -37,6 +38,17 @@ const App = (props) => {
} = props; } = props;
const {identifier} = props.match.params; const {identifier} = props.match.params;
// 获取路径参数
const _params = window.location.search;
if (_params) {
let _cookie = '';
let _search = _params.split('?')[1];
if(_search.split('=')) {
_cookie = _search.split('=')[1];
cookie.save('_educoder_session', _cookie);
}
console.log(_cookie);
}
const [isActive, setIsActive] = useState(-1); const [isActive, setIsActive] = useState(-1);
// const [isVisible, setIsVisible] = useState(false); // const [isVisible, setIsVisible] = useState(false);
const editorRef = useRef(null); const editorRef = useRef(null);

@ -4,41 +4,47 @@
* @Github: * @Github:
* @Date: 2020-01-15 15:44:36 * @Date: 2020-01-15 15:44:36
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-16 11:20:24 * @LastEditTime : 2020-01-17 10:06:45
*/ */
import axios from 'axios'; import axios from 'axios';
// 获取代码块 // 获取代码块
export async function fetchWxCode (identifier, params) { export async function fetchWxCode (identifier, params) {
const url = `/tasks/${identifier}/rep_content.json`; const url = `/tasks/${identifier}/rep_content.json`;
params = Object.assign({}, params, {withCredentials: true});
return axios.get(url, {params}); return axios.get(url, {params});
} }
// 获取测试值 // 获取测试值
export async function fetchWxCodeTextCase (identifier) { export async function fetchWxCodeTextCase (identifier) {
const url = `/tasks/${identifier}.json`; const url = `/tasks/${identifier}.json`;
return axios.get(url); const params = Object.assign({}, {withCredentials: true});
return axios.get(url, {params});
} }
// 更新代码块内容 // 更新代码块内容
export async function fetchUpdateWxCode (identifier, params) { export async function fetchUpdateWxCode (identifier, params) {
// /myshixuns/8etu3pilsa/update_file.json // /myshixuns/8etu3pilsa/update_file.json
const url = `/myshixuns/${identifier}/update_file.json`; const url = `/myshixuns/${identifier}/update_file.json`;
params = Object.assign({}, params, {withCredentials: true});
return axios.post(url, params); return axios.post(url, params);
} }
// 恢复初始化 // 恢复初始化
export async function fetchRestoreWxCode (identifier, params) { export async function fetchRestoreWxCode (identifier, params) {
const url = `/tasks/${identifier}/reset_original_code.json`; const url = `/tasks/${identifier}/reset_original_code.json`;
params = Object.assign({}, params, {withCredentials: true});
return axios.get(url, {params}); return axios.get(url, {params});
} }
// 评测 // 评测
export async function fetchWxCodeGameBuild (identifier, params) { export async function fetchWxCodeGameBuild (identifier, params) {
const url = `/tasks/${identifier}/game_build.json`; const url = `/tasks/${identifier}/game_build.json`;
params = Object.assign({}, params, {withCredentials: true});
return axios.get(url, {params}); return axios.get(url, {params});
} }
export async function fetchWxCodeGameStatus (identifier) { export async function fetchWxCodeGameStatus (identifier) {
const url = `/tasks/${identifier}/game_status.json`; const url = `/tasks/${identifier}/game_status.json`;
return axios.get(url); const params = Object.assign({}, {withCredentials: true});
return axios.get(url, {params});
} }

Loading…
Cancel
Save