Merge branches 'dev_aliyun' and 'dev_new_shixunsrepository' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_new_shixunsrepository

dev_new_shixunsrepository
杨树明 5 years ago
commit 63f4347674

@ -224,7 +224,7 @@ class CoursesController < ApplicationController
normal_status(0, "成功")
rescue => e
uid_logger_error(e.message)
tip_exception("课堂更新失败")
tip_exception("课堂更新失败,原因: #{e.message}")
raise ActiveRecord::Rollback
end
end
@ -1554,7 +1554,7 @@ class CoursesController < ApplicationController
end
def course_statistics course, max_exp, limit
max_rate = max_exp.nil? ? 0 : 20.0 / max_exp
max_rate = max_exp.nil? || max_exp <= 0 ? 0 : 20.0 / max_exp
sql_select = %Q{ SELECT a.*, (message_num*0.2 + message_reply_num*0.1 + resource_num*0.5 + homework_journal_num*0.1 + graduation_num +
homework_num + exercise_num + poll_num*0.7 + exercise_score * 0.7 + graduation_score * 0.7 + homework_score * 0.7 + exp*#{max_rate})

@ -1,9 +1,9 @@
class GraduationTasksController < ApplicationController
before_action :require_login, :check_auth, except: [:index]
before_action :find_course, except: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment,
:cross_comment_setting, :assign_works, :commit_comment_setting]
:cross_comment_setting, :assign_works, :commit_comment_setting, :sonar]
before_action :find_task, only: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment,
:cross_comment_setting, :assign_works, :commit_comment_setting]
:cross_comment_setting, :assign_works, :commit_comment_setting, :sonar]
before_action :user_course_identity
before_action :task_publish, only: [:show, :show_comment, :tasks_list, :settings]
before_action :teacher_allowed, only: [:new, :create, :edit, :update, :set_public,:multi_destroy, :publish_task, :end_task,
@ -66,62 +66,8 @@ class GraduationTasksController < ApplicationController
(@user_course_identity == Course::STUDENT && @work.present? && @work.take.work_status > 0 &&
((!@task.allow_late && @task.status > 1) || (@task.allow_late && @task.late_time && @task.late_time < Time.now)) &&
(@task.open_work || @task.open_score)))
# 如有有分班则看分班内的学生,否则看所有学生的作品
user_ids =
if @user_course_identity < Course::STUDENT
@course.teacher_group_user_ids(current_user.id)
else
course_group_id = @course.course_member(current_user.id).course_group_id
@course.students.where(course_group_id: course_group_id).pluck(:user_id)
end
@work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension])
@all_work_count = @work_list.count
@teachers = @course.teachers.where.not(user_id: current_user.id).includes(:user)
# 教师评阅搜索 0: 未评, 1 已评
unless params[:teacher_comment].blank?
graduation_work_ids = GraduationWorkScore.where(graduation_work_id: @work_list.map(&:id)).pluck(:graduation_work_id)
if params[:teacher_comment].to_i == 0
@work_list = @work_list.where("work_status != 0")
elsif params[:teacher_comment].to_i == 1
@work_list = @work_list.where("work_status != 0").where(id: graduation_work_ids)
end
end
# 作品状态 0 未提交, 1 按时提交, 2 延迟提交
unless params[:task_status].blank?
@work_list = @work_list.where(work_status: params[:task_status])
end
# 分班情况
unless params[:course_group].blank?
group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id)
# 有分组只可能是老师身份查看列表
@work_list = @work_list.where(user_id: group_user_ids)
end
# 只看我的交叉评阅
unless params[:cross_comment].blank?
graduation_work_id = @task.graduation_work_comment_assignations.where(:user_id =>current_user.id)
.pluck(:graduation_work_id).uniq if @task.graduation_work_comment_assignations
@work_list = @task.graduation_works.where(id: graduation_work_id)
end
# 组员、组长作品的筛选
if @task.task_type == 2 && !params[:member_work].blank?
if params[:member_work].to_i == 1
@work_list = @work_list.where("user_id = commit_user_id")
elsif params[:member_work].to_i == 0
@work_list = @work_list.where("user_id != commit_user_id")
end
end
# 输入姓名和学号搜索
# TODO user_extension 如果修改 请调整
unless params[:search].blank?
@work_list = @work_list.joins(user: :user_extension).where("concat(lastname, firstname) like ?
or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
end
_tasks_list
# 排序
rorder = params[:order].blank? ? "update_time" : params[:order]
@ -265,6 +211,33 @@ class GraduationTasksController < ApplicationController
end
end
# 代码检测
def sonar
tip_exception(403, "无权限访问") unless current_user.admin_or_business?
_tasks_list
person_list = @work_list.map do |work|
o = {
name: "#{work.user&.real_name}",
uid: "#{work.user&.student_id}",
downloadUrl: ''
}
attachment = work.attachments.last
if attachment
o[:downloadUrl] = "https://#{edu_setting('host_name')}/"+download_url(attachment)
end
o
end
filename = "#{@task.name}_#{Time.now.strftime('%Y%m%d%H%M%S')}.json"
json = File.open("/tmp/#{filename}", "w+")
json.puts(person_list.to_json)
json.close
send_file json.path, filename: filename
end
# 设为公开
def set_public
tip_exception("仅公开课堂才能公开毕设任务") if @course.is_public == 0
@ -657,6 +630,65 @@ class GraduationTasksController < ApplicationController
tip_exception("请先开启交叉评阅再设置") unless @task.cross_comment
end
def _tasks_list
# 如有有分班则看分班内的学生,否则看所有学生的作品
user_ids =
if @user_course_identity < Course::STUDENT
@course.teacher_group_user_ids(current_user.id)
else
course_group_id = @course.course_member(current_user.id).course_group_id
@course.students.where(course_group_id: course_group_id).pluck(:user_id)
end
@work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension])
@all_work_count = @work_list.count
@teachers = @course.teachers.where.not(user_id: current_user.id).includes(:user)
# 教师评阅搜索 0: 未评, 1 已评
unless params[:teacher_comment].blank?
graduation_work_ids = GraduationWorkScore.where(graduation_work_id: @work_list.map(&:id)).pluck(:graduation_work_id)
if params[:teacher_comment].to_i == 0
@work_list = @work_list.where("work_status != 0")
elsif params[:teacher_comment].to_i == 1
@work_list = @work_list.where("work_status != 0").where(id: graduation_work_ids)
end
end
# 作品状态 0 未提交, 1 按时提交, 2 延迟提交
unless params[:task_status].blank?
@work_list = @work_list.where(work_status: params[:task_status])
end
# 分班情况
unless params[:course_group].blank?
group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id)
# 有分组只可能是老师身份查看列表
@work_list = @work_list.where(user_id: group_user_ids)
end
# 只看我的交叉评阅
unless params[:cross_comment].blank?
graduation_work_id = @task.graduation_work_comment_assignations.where(:user_id =>current_user.id)
.pluck(:graduation_work_id).uniq if @task.graduation_work_comment_assignations
@work_list = @task.graduation_works.where(id: graduation_work_id)
end
# 组员、组长作品的筛选
if @task.task_type == 2 && !params[:member_work].blank?
if params[:member_work].to_i == 1
@work_list = @work_list.where("user_id = commit_user_id")
elsif params[:member_work].to_i == 0
@work_list = @work_list.where("user_id != commit_user_id")
end
end
# 输入姓名和学号搜索
# TODO user_extension 如果修改 请调整
unless params[:search].blank?
@work_list = @work_list.joins(user: :user_extension).where("concat(lastname, firstname) like ?
or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
end
end
#
# def graduation_work_to_xls items
# xls_report = StringIO.new

@ -17,7 +17,7 @@
</td>
<td>
<% if department.identifier.present? %>
<%= link_to department.identifier.to_s, statistics_college_path(department.identifier), target: '_blank' %>
<%= link_to department.identifier.to_s, "/colleges/#{department.identifier}/statistics", target: '_blank' %>
<% else %>
--
<% end %>

@ -3,6 +3,7 @@ json.message "评测完成"
json.data do
json.(@result, :id, :status, :error_line, :error_msg,
:input, :output, :execute_time, :execute_memory)
json.passed @my_hack.passed
# 提交模式多了一个预计输出
if @mode == "submit"
json.expected_output @result.expected_output

@ -8,6 +8,7 @@ json.hack do
json.submit_count @hack.submit_num
json.notes @my_hack.notes
json.modify_code @modify
json.passed @my_hack.passed
json.comments_count @hack.discusses.count
json.user_praise @hack.praise_treads.select{|pt| pt.user_id == current_user.id}.length > 0
end

@ -694,6 +694,7 @@ Rails.application.routes.draw do
get :cross_comment_setting
post :assign_works
post :commit_comment_setting
get :sonar
end
collection do

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-17 17:32:55
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 16:50:43
* @LastEditTime : 2020-01-06 18:42:09
*/
import './index.scss';
import React, { useState } from 'react';
@ -28,11 +28,12 @@ function CommentForm (props) {
const [focus, setFocus] = useState(false);
const options = [
['bold', 'italic', 'underline'],
[{header: [1,2,3,false]}],
['blockquote', 'code-block'],
['link', 'image'],
['formula']
// ['bold', 'italic', 'underline'],
// [{header: [1,2,3,false]}],
'code-block',
'link',
'image',
'formula'
];
// const { form: { getFieldDecorator } } = props;
const [showQuill, setShowQuill] = useState(false);

@ -1,4 +1,6 @@
.quill_editor_for_react_area{
// background: #fff;
// margin: 0 15px;
.ql-editing{
left: 0 !important;
}

@ -4,11 +4,11 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-03 18:56:36
* @LastEditTime : 2020-01-07 15:46:24
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
import { Select, notification } from 'antd';
import { Select, notification, Modal, Form, Input, Button } from 'antd';
const { Option } = Select;
@ -17,7 +17,10 @@ function KnowLedge (props) {
const {
options = [], // 下拉选项
values = [], // 已选择的下拉项
onChange // 获取选择的值
onChange, // 获取选择的值
form,
showAdd, // 显示新增图标
addKnowledge // 调用新增知识点接口
} = props;
useEffect(() => {
@ -38,9 +41,12 @@ function KnowLedge (props) {
const [selectOptions, setSelectOptions] = useState(options);
// 已选择的下拉项
const [selectValue, setSelectValue] = useState([]);
const [visible, setVisible] = useState(false);
//
const [value] = useState([]);
const { getFieldDecorator } = form;
const FormItem = Form.Item;
// 渲染下拉选项
const renderOptions = (options = []) => {
return options.map((opt, i) => (
@ -58,10 +64,10 @@ function KnowLedge (props) {
}
return item.id !== value;
});
if (tempArr.length > 50) {
if (tempArr.length > 5) {
notification.warning({
message: '提示',
description: '知识点不能超过50个'
description: '知识点不能超过5个'
});
return;
}
@ -114,15 +120,75 @@ function KnowLedge (props) {
)
}
// 添加知识点
const handleAddKnowledge = () => {
setVisible(true);
};
const handleResetForm = () => {
form.resetFields();
setVisible(false);
}
const handleSubmitForm = (e) => {
e.preventDefault();
form.validateFieldsAndScroll((err, values) => {
if (err) {
return;
}
setVisible(false);
form.resetFields();
// console.log(values);
addKnowledge && addKnowledge(values);
})
}
const _styles = {
display: showAdd ? 'inline-block' : 'none'
};
return (
<div className="knowledge-select-area">
{ renderSelect(selectOptions) }
{/* 渲染下拉选择项 */}
<div className="knowledge-result">
{ renderResult(selectValue) }
<React.Fragment>
<div className="knowledge-select-area">
{ renderSelect(selectOptions) }
{/* 渲染下拉选择项 */}
<div className="knowledge-result">
<i
style={_styles}
className="iconfont icon-roundaddfill icon-add-knowledge"
onClick={handleAddKnowledge}
></i>
{ renderResult(selectValue) }
</div>
</div>
</div>
<Modal
closable={false}
title="新增知识点"
visible={visible}
footer={null}
>
<Form className="knowledge-form">
<FormItem>
{
getFieldDecorator('name', {
rules: [{
required: true, message: '知识点名称不能为空'
}]
})(
<Input />
)
}
</FormItem>
<FormItem style={{ textAlign: 'center' }}>
<Button style={{ marginRight: '20px' }} onClick={handleResetForm}>取消</Button>
<Button type="primary" onClick={handleSubmitForm}>确定</Button>
</FormItem>
</Form>
</Modal>
</React.Fragment>
);
}
export default KnowLedge;
export default Form.create()(KnowLedge);

@ -38,5 +38,19 @@
}
}
}
.icon-add-knowledge{
line-height: 36px;
margin-top: 10px;
margin-right: 10px;
// cursor: ;
color: rgb(78, 188, 126)
}
}
}
.knowledge-form{
.ant-form-explain{
padding: 0;
}
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-06 16:17:22
* @LastEditTime : 2020-01-07 15:29:18
*/
import './index.scss';
// import 'katex/dist/katex.css';
@ -61,6 +61,7 @@ class EditTab extends React.Component {
top: 500,
bottom: 20,
offsetTop: 0,
showAdd: false
// knowledges: [],
// coursers: [] // 选中的课程
}
@ -147,13 +148,15 @@ class EditTab extends React.Component {
item.sub_disciplines && item.sub_disciplines.forEach(c => {
if (value[1] && c.id === value[1]) {
saveKnowledge(c.tag_disciplines)
console.log(c.tag_disciplines);
} else if (!value[1]) {
saveKnowledge([]);
}
});
}
});
this.setState({
showAdd: value[1] ? true : false
});
// this.props.validateOjCategory(value[1] || '');
this.props.validateOjSubDisciplineId(value[1] || '');
}
@ -167,6 +170,8 @@ class EditTab extends React.Component {
}
render () {
const { showAdd } = this.state;
const {
ojForm,
ojFormValidate,
@ -177,9 +182,10 @@ class EditTab extends React.Component {
openTestCodeIndex = [],
courseQuestions,
tag_discipline_id,
knowledges
knowledges,
tagDisciplines,
} = this.props;
console.log('knowledge======>>>>>>', knowledges);
// console.log('knowledge======>>>>>>', knowledges);
// const {knowledges} = this.state;
// 表单label
const myLabel = (name, subTitle, nostar) => {
@ -321,7 +327,6 @@ class EditTab extends React.Component {
}
});
console.log(choid_ids);
return (
<Cascader
placeholder="请选择"
@ -340,11 +345,20 @@ class EditTab extends React.Component {
values.forEach(v => {
_result.push(v.id);
});
console.log('下拉选择的值:===>>>', _result);
// console.log('下拉选择的值:===>>>', _result);
// 保存选择的知识点
this.props.saveTagDisciplineId(_result);
}
// 新增知识点
const handleAddKnowledge = (values) => {
// console.log('调用了新增知识点并返回了结果: ', values);
// 获取课程id
const {sub_discipline_id} = this.props.ojForm;
const obj = Object.assign({}, values, {sub_discipline_id})
tagDisciplines(obj);
}
return (
<div className={'editor_area'} id="textCase">
<Form className={'editor_form'}>
@ -384,9 +398,11 @@ class EditTab extends React.Component {
label={<span>{myLabel(jcLabel['knowledge'], '', 'nostar')}</span>}
>
<KnowLedge
showAdd={showAdd}
options={knowledges}
values={tag_discipline_id}
onChange={handleKnowledgeChange}
addKnowledge={handleAddKnowledge}
/>
</FormItem>
@ -514,7 +530,8 @@ const mapDispatchToProps = (dispatch) => ({
addTestCase: (value) => dispatch(actions.addTestCase(value)),
// 删除测试用例
deleteTestCase: (value) => dispatch(actions.deleteTestCase(value)),
saveKnowledge: (value) => dispatch(actions.saveKnowledge(value))
saveKnowledge: (value) => dispatch(actions.saveKnowledge(value)),
tagDisciplines: (params) => dispatch(actions.tagDisciplines(params))
// 获取题库
// getQuestion: (params) => dispatch(actions.getQuestion(params))
});

@ -3,7 +3,7 @@
flex-direction: column;
justify-content: space-between;
background: #fff;
padding: 20px 30px 0;
padding: 0px 20px 0;
height: calc(100vh - 177px);
box-sizing: border-box;
overflow-y: auto;

@ -53,6 +53,7 @@
.commit_record_area{
padding: 0 20px;
background: #fff;
// height: calc(100vh - 178px);
}
.task_description_area{
@ -61,7 +62,8 @@
.task_desc_area{
height: calc(100vh - 242px);
overflow-y: auto;
padding: 0 0 0 15px;
// padding: 0 0 0 15px;
background: #fff;
}
.desc_area_header{
display: flex;
@ -69,14 +71,20 @@
align-items: center;
height: 64px;
padding: 0 20px;
background: #fff;
box-sizing: border-box;
border-bottom: 1px solid #f4f4f4;
.header_flex{
font-size: 14px;
.flex_label{
color: #999999;
color: #888888;
margin-right: 10px;
}
.flex_value{
font-weight: bold;
font-weight: 500;
color: #333;
// color: green;
}
}
}

@ -278,6 +278,8 @@ class VNCContainer extends Component {
.vncDrawer .ant-drawer-body {
padding: 0px;
}
.vncDrawer .rc-tree {
padding: 16px;
max-width: 220px;
@ -286,6 +288,7 @@ class VNCContainer extends Component {
.vncDrawer .ant-drawer-wrapper-body {
background: #242324;
height: 100%;
}
.codeInDrawer .ant-drawer-wrapper-body {
background: #1D1C1D;
@ -294,6 +297,10 @@ class VNCContainer extends Component {
.vncDrawer .ant-drawer-header, .codeInDrawer .ant-drawer-header {
border-bottom: 0;
}
.codeInDrawer .ant-drawer-header,
.codeInDrawer .ant-drawer-content{
background: rgb(28, 28, 28) !important;
}
.vncDrawer > div:nth-child(1) {
opacity: 1 !important;

@ -858,11 +858,6 @@ class TPMBanner extends Component {
const antIcon = <Icon type="loading" style={{fontSize: 24}} spin/>;
const MyRate = ({defaultValue, ...rest}) => {
let myValue = defaultValue;
// console.log(myValue-Math.floor(myValue))
// if (myValue < Math.ceil(myValue)) {
// myValue = Math.floor(myValue) + 0.5;
// }
return <Rating {...rest} value={myValue}/>;
};
//

@ -64,6 +64,7 @@ const types = {
CHANGE_RECORD_PAGINATION_PAGE: 'CHANGE_RECORD_PAGINATION_PAGE', // 改变提交分页
UPDATE_OJ_FOR_USER_COMMENT_COUNT: 'UPDATE_OJ_FOR_USER_COMMENT_COUNT', // 更新 hack 中的评论数,
UPDATE_NOTE_CONTENT: 'UPDATE_NOTE_CONTENT', // 更新笔记内容
UPDATE_HACK_PASSED: 'UPDATE_HACK_PASSED',
/*** jupyter */
GET_JUPYTER_DATA_SETS: 'GET_JUPYTER_DATA_SETS', // jupyter 数据集
GET_JUPYTER_TPI_URL: 'GET_JUPYTER_TPI_URL', // 获取 jupyter url

@ -36,7 +36,8 @@ import {
handleClickCancelPublish,
getQuestion,
saveKnowledge,
setOjInitialValue
setOjInitialValue,
tagDisciplines
} from './ojForm';
import {
@ -125,6 +126,7 @@ export default {
getQuestion,
saveKnowledge,
setOjInitialValue,
tagDisciplines,
//
addTestCase,
deleteTestCase,

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:42:11
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 14:17:49
* @LastEditTime : 2020-01-07 17:27:40
*/
import types from "./actionTypes";
import { Base64 } from 'js-base64';
@ -18,7 +18,7 @@ import {
fetchUpdateCode,
fetchUserCodeSubmit,
fetchRestoreInitialCode,
fetchAddNotes
fetchAddNotes,
} from "../../services/ojService";
import { notification } from "antd";
@ -148,11 +148,12 @@ export const saveUserCodeForInterval = (identifier, code) => {
* @param {*} type 测评类型 debug | submit
*/
export const updateCode = (identifier, inputValue, type) => {
console.log(1111);
return (dispatch, getState) => {
const { userCode, isUpdateCode } = getState().ojForUserReducer;
if (isUpdateCode) {
fetchUpdateCode(identifier, {
code: userCode
code: Base64.encode(userCode)
}).then(res => {
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
// TODO 需要优化
@ -178,7 +179,7 @@ export const updateCode = (identifier, inputValue, type) => {
}
// 代码评测
export const codeEvaluate = (dispatch, identifier, type, time_limit) => {
export const codeEvaluate = (dispatch, identifier, type, time_limit, hackStatus, score, passed) => {
// 调试代码成功后,调用轮循接口, 注意: 代码执行的时间要小于设置的时间限制
const intervalTime = 500;
let count = 1;
@ -218,7 +219,7 @@ export const codeEvaluate = (dispatch, identifier, type, time_limit) => {
type,
data: returnData
}
});
});
if (!type || type === 'debug') {
dispatch({ // 改变 loading 值
type: types.LOADING_STATUS,
@ -243,6 +244,18 @@ export const codeEvaluate = (dispatch, identifier, type, time_limit) => {
// 重新调用一下提交记录接口
dispatch(getUserCommitRecord(identifier));
dispatch(saveOpacityType(type));
// 首次通过时,提示评测通过并获得金币
// console.log('hack status ===>>', hackStatus);
if (hackStatus === 1 && !passed) {
dispatch({
type: types.UPDATE_HACK_PASSED,
payload: true
});
notification.success({
message: '提示',
description: `恭喜您获得金币奖励: ${score}`
});
}
}
}
}).catch(err => { // 评测异常时
@ -280,7 +293,7 @@ export const debuggerCode = (identifier,value, type) => {
// 调用之前 先保存 code
// TODO
// console.log(identifier, value);
const {hack: {time_limit = 0}} = getState().ojForUserReducer;
const { hack } = getState().ojForUserReducer;
if (!type || type === 'debug') {
dispatch({ // 加载中...
type: types.TEST_CODE_STATUS,
@ -300,7 +313,7 @@ export const debuggerCode = (identifier,value, type) => {
return;
};
// 测评
codeEvaluate(dispatch, identifier, type, time_limit);
codeEvaluate(dispatch, identifier, type, hack.time_limit);
}
}).catch(() => {
dispatch({
@ -386,7 +399,7 @@ export const changeUserCodeTab = (key) => {
*/
export const submitUserCode = (identifier, inputValue, type) => {
return (dispatch, getState) => {
const { userCode, isUpdateCode, hack: {time_limit = 0} } = getState().ojForUserReducer;
const { userCode, isUpdateCode, hack} = getState().ojForUserReducer;
function userCodeSubmit () {
fetchUserCodeSubmit(identifier).then(res => {
@ -400,7 +413,8 @@ export const submitUserCode = (identifier, inputValue, type) => {
return;
};
// 测评
codeEvaluate(dispatch, identifier, type, time_limit);
console.log('hack=====', hack);
codeEvaluate(dispatch, identifier, type, hack.time_limit, hack.status, hack.score, hack.passed);
}
}).catch(() => {
dispatch({
@ -523,4 +537,4 @@ export const addNotes = (identifier, params, cb) => {
});
})
}
}
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 16:35:46
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-03 17:39:32
* @LastEditTime : 2020-01-07 16:45:34
*/
import types from './actionTypes';
import CONST from '../../constants';
@ -13,7 +13,8 @@ import {
fetchGetOjById,
publishTask,
cancelPublicTask,
fetchQuestion
fetchQuestion,
fetchTagDisciplines
} from '../../services/ojService';
import { Base64 } from 'js-base64';
import { notification } from 'antd';
@ -677,30 +678,46 @@ export const updateOpenTestCaseIndex = (value) => {
export const getQuestion = (params) => {
return (dispatch, getState) => {
const {ojForm: {sub_discipline_id}} = getState().ojFormReducer;
fetchQuestion(params, ).then(res => {
fetchQuestion(params).then(res => {
const { data = {} } = res;
const { disciplines = [] } = data;
dispatch({
type: types.GET_COURSE_QUESTION,
payload: disciplines
});
let temp_knowledges = [];
// console.log('选择的课程: =====>>>>>>', sub_discipline_id);
disciplines.forEach(c => {
if (sub_discipline_id && c.sub_disciplines) {
c.sub_disciplines.forEach(sub => {
if (+sub.id === +sub_discipline_id) {
temp_knowledges = sub.tag_disciplines || [];
}
});
}
});
dispatch({
type: types.CHANGE_KNOWLEDGES,
payload: temp_knowledges
});
})
// 如果课程id号存在 同步更新知识点
if (sub_discipline_id) {
let temp_knowledges = [];
disciplines.forEach(c => {
if (sub_discipline_id && c.sub_disciplines) {
c.sub_disciplines.forEach(sub => {
if (+sub.id === sub_discipline_id) {
temp_knowledges = sub.tag_disciplines || [];
}
});
}
});
dispatch({
type: types.CHANGE_KNOWLEDGES,
payload: temp_knowledges
})
}
// let temp_knowledges = [];
// // console.log('选择的课程: =====>>>>>>', sub_discipline_id);
// disciplines.forEach(c => {
// if (sub_discipline_id && c.sub_disciplines) {
// c.sub_disciplines.forEach(sub => {
// if (+sub.id === +sub_discipline_id) {
// temp_knowledges = sub.tag_disciplines || [];
// }
// });
// }
// });
// dispatch({
// type: types.CHANGE_KNOWLEDGES,
// payload: temp_knowledges
// });
});
}
}
@ -727,3 +744,22 @@ export const setOjInitialValue = (params) => {
payload: params
}
}
// 新增知识点
export const tagDisciplines = (params) => {
return (dispatch) => {
fetchTagDisciplines(params).then(res => {
// console.log('新增知识点成功======>>>>', res);
if (res.data.status === 0) {
notification.success({
message: '提示',
description: '新增知识点成功'
});
// 重新调用获取课程列表接口
dispatch(getQuestion({
source: 'question'
}));
}
});
}
}

@ -3,8 +3,8 @@
* @Author: tangjiang
* @Github:
* @Date: 2019-11-27 16:27:09
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-12 17:36:51
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-07 15:23:39
*/
import types from "../actions/actionTypes";
@ -22,7 +22,7 @@ const initialState = {
}
const commonReducer = (state = initialState, action) => {
console.log(action)
// console.log(action)
switch (action.type) {
case types.SHOW_OR_HIDE_CONTROL:
return {

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 14:24:09
* @LastEditTime : 2020-01-07 17:26:19
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@ -228,6 +228,13 @@ const ojForUserReducer = (state = initialState, action) => {
...state,
hack: _hack1
}
// 修改 hack passed值
case types.UPDATE_HACK_PASSED:
const _hack2 = Object.assign({}, state.hack, {passed: action.payload });
return {
...state,
hack: _hack2
}
default:
return state;
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:55:38
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-30 09:44:56
* @LastEditTime : 2020-01-07 15:23:19
*/
import axios from 'axios';
@ -71,7 +71,7 @@ export async function fetchUserProgramDetail (identifier) {
// 获取提交记录
export async function fetchUserCommitRecord (identifier, params) {
console.log('identifier=====', identifier);
// console.log('identifier=====', identifier);
const url = `/myproblems/${identifier}/submit_records.json`;
return axios.get(url, { params });
}
@ -148,4 +148,10 @@ export async function fetchAddNotes (identifier, params) {
export async function fetchQuestion (params) {
const url = `/disciplines.json`;
return axios.get(url, { params });
}
// 新增选题
export async function fetchTagDisciplines (params) {
const url = `/tag_disciplines.json`;
return axios.post(url, params);
}
Loading…
Cancel
Save