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

dev_forum
杨树林 5 years ago
commit 320c3a2932

@ -32,8 +32,11 @@ class AccountsController < ApplicationController
end
uid_logger("start register: verifi_code is #{verifi_code}, code is #{code}, time is #{Time.now.to_i - verifi_code.try(:created_at).to_i}")
# check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
# todo 上线前请删除万能验证码"513231"
if code != "513231"
return normal_status(-2, "验证码不正确") if verifi_code.try(:code) != code.strip
return normal_status(-2, "验证码已失效") if !verifi_code&.effective?
end
code = generate_identifier User, 8
login = pre + code

@ -325,6 +325,7 @@ class ApplicationController < ActionController::Base
unless file_content.present?
raise("获取文件代码异常")
end
logger.info("#######game_id:#{game_id}, file_content:#{file_content}")
game_code = GameCode.where(:game_id => game_id, :path => path).first
if game_code.nil?
GameCode.create!(:game_id => game_id, :new_code => file_content, :path => path)

@ -169,7 +169,7 @@ class CoursesController < ApplicationController
extra_params[:school_id] = @school.id
extra_params[:is_public] = params[:is_public].present? ? params[:is_public] : 0
if @course.is_end && (course_params[:end_date].nil? || course_params[:end_date].to_date > Date.today)
if @course.is_end && (course_params[:end_date].blank? || course_params[:end_date].to_date > Date.today)
extra_params[:is_end] = 0
elsif !@course.is_end && !course_params[:end_date].blank? && course_params[:end_date].to_date < Date.today
extra_params[:is_end] = 1

@ -1,6 +1,6 @@
class DepartmentsController < ApplicationController
def for_option
render_ok(departments: Department.cached_names_data(current_school))
render_ok(departments: current_school.departments.select(:id, :name).as_json)
end
private

@ -1,5 +1,5 @@
class RepertoiresController < ApplicationController
def index
render_ok(repertoires: Repertoire.cache_data)
render_ok(repertoires: Repertoire.select(:id, :name).order(:created_at).as_json)
end
end

@ -11,6 +11,6 @@ class SchoolsController < ApplicationController
end
def for_option
render_ok(schools: School.cached_names_data)
render_ok(schools: School.select(:id, :name).as_json)
end
end

@ -2,26 +2,4 @@ class Department < ApplicationRecord
belongs_to :school
has_many :department_members, dependent: :destroy
after_create_commit :reset_data_cache
after_update_commit :reset_data_cache
def self.cached_names_data(school)
Rails.cache.fetch(names_data_cache_key(school.id), expires_in: 7.days) do
school.departments.select(:id, :name).as_json
end
end
private
def reset_data_cache
# 清除部门名称缓存
if new_record? || name_previously_changed?
Rails.cache.delete(self.class.names_data_cache_key(school_id))
end
end
def self.names_data_cache_key(school_id)
"schools/#{school_id}/department_names_data"
end
end

@ -3,23 +3,4 @@ class Repertoire < ApplicationRecord
has_many :tag_repertoires, through: :sub_repertoires
has_many :user_interests, dependent: :delete_all
after_create_commit :reset_cache_data
after_update_commit :reset_cache_data
def self.cache_data
Rails.cache.fetch(data_cache_key, expires_in: 1.days) do
Repertoire.select(:id, :name).order(:created_at).as_json
end
end
def self.data_cache_key
'repertoire/cache_data'
end
private
def reset_cache_data
Rails.cache.delete(self.class.data_cache_key)
end
end

@ -10,9 +10,6 @@ class School < ApplicationRecord
has_many :ec_major_schools, :dependent => :destroy
has_many :ec_majors, :through => :ec_major_schools
after_create_commit :reset_data_cache
after_update_commit :reset_data_cache
# 学校管理员
def manager?(user)
ec_school_users.exists?(user_id: user.id)
@ -33,23 +30,4 @@ class School < ApplicationRecord
def manage_permission?(user)
manager?(user) || major_manager?(user) || course_manager?(user)
end
def self.cached_names_data
Rails.cache.fetch(names_data_cache_key, expires_in: 7.days) do
School.select(:id, :name).as_json
end
end
private
def reset_data_cache
# 清除学校名称缓存
if new_record? || name_previously_changed?
Rails.cache.delete(self.class.names_data_cache_key)
end
end
def self.names_data_cache_key
'schools/names_data'
end
end

@ -2,7 +2,7 @@ import React from "react";
import axios from 'axios';
import { requestProxy } from "./indexEduplus2RequestProxy";
import { broadcastChannelOnmessage ,SetAppModel} from 'educoder';
import { broadcastChannelOnmessage ,SetAppModel, isDev, queryString } from 'educoder';
import { notification } from 'antd';
import './index.css'
broadcastChannelOnmessage('refreshPage', () => {
@ -18,10 +18,18 @@ function locationurl(list){
}
// TODO 开发期多个身份切换
const debugType =""
// window.location.search.indexOf('debug=t') != -1 ? 'teacher' :
// window.location.search.indexOf('debug=s') != -1 ? 'student' : 'admin'
// window._debugType = debugType;
let debugType =""
if (isDev) {
const _search = window.location.search;
let parsed = {};
if (_search) {
parsed = queryString.parse(_search);
}
debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' :
window.location.search.indexOf('debug=s') != -1 ? 'student' :
window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || ''
}
window._debugType = debugType;
export function initAxiosInterceptors(props) {
// TODO 避免重复的请求 https://github.com/axios/axios#cancellation

@ -20,7 +20,7 @@ import ShixunAnswer from './question/shixunAnswer'
import update from 'immutability-helper'
import axios from 'axios';
import './new/common.css'
const Textarea =Input.TextArea
const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',

@ -222,6 +222,7 @@ class Exercisestatisticalresult extends Component {
)
}):
<Exercisetablesmubu
tableNum={key}
data={item.ques_details}
type={item.ques_type}
effictive_counts={item.effictive_counts}

@ -1,8 +1,14 @@
import React, {Component} from "react";
import {WordsBtn} from 'educoder';
import {WordsBtn, MarkdownToHtml} from 'educoder';
import {Table,Progress} from "antd";
import {Link,Switch,Route,Redirect} from 'react-router-dom';
const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
]
class Exercisetablesmubus extends Component {
constructor(props) {
@ -19,12 +25,17 @@ class Exercisetablesmubus extends Component {
render() {
let {data,type,effictive_counts,choicetype}=this.props;
let {data,type,effictive_counts,choicetype, tableNum}=this.props;
let datas=[];
data&&data.forEach((item,key)=>{
datas.push({
commit_percent:{num:item.choice_position,value:type===4||type===5?choicetype[item.choice_text-1]:item.choice_text,type:item.choice_right_boolean},
commit_percent:{
num:item.choice_position,
value:type===4||type===5?choicetype[item.choice_text-1]:item.choice_text,
type:item.choice_right_boolean,
_type: type
},
min_score:{value:item.choice_users_count,type:item.choice_right_boolean},
max_score:item.choice_percent,
})
@ -40,13 +51,23 @@ class Exercisetablesmubus extends Component {
title: '选项',
dataIndex: 'commit_percent',
key: 'commit_percent',
render: (text, record) => (
<span style={{color:text.type===true? "#29BD8B":'#333333'}}>
{text.value!="有效填写量"&&text.value!="wrong"?text.value:false}
{text.value==="wrong"?"填写了错误答案":false}
{text.value==="有效填写量"?"有效填写量":false}
render: (text, record, index) => {
const _content = <span style={{color:text.type===true? "#29BD8B":'#333333'}}>
{text.value!="有效填写量"&&text.value!="wrong" &&
<MarkdownToHtml content={text.value} selector={(tableNum+1) + '' + (index+1)}></MarkdownToHtml>
}
{text.value==="wrong" && "填写了错误答案" }
{text.value==="有效填写量" && "有效填写量" }
</span>
),
return (
(text._type === 0 || text._type === 1) ? <div style={{ display: 'flex'}}>
{<span style={{ 'margin-right': '4px', 'margin-top': '-2px'}}>{tagArray[index]}.</span>}
{_content}
</div> : <React.Fragment>{_content}</React.Fragment>
)
},
}, {
title: '小计',
dataIndex: 'min_score',

@ -93,9 +93,9 @@ class SingleDisplay extends Component{
<div className="options">
{ question_choices.map((item, optionIndex) => {
let prefix = undefined
if (!isPreviewPage) {
// if (!isPreviewPage) {
prefix = `${tagArray[optionIndex]}.`
}
// }
if (question_type == 0) { // 单选
return (
<div className="mb10 clearfix" key={optionIndex}>

@ -34,3 +34,7 @@
.singleDisplay .options .markdown-body {
max-width: 1116px;
}
.singleDisplay .ant-radio-wrapper span:last-child
, .singleDisplay .ant-checkbox-wrapper span:last-child {
padding-right: 0px;
}

@ -4,9 +4,9 @@ import {markdownToHTML} from 'educoder'
import axios from 'axios'
const tagArray = [
// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
// 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
// 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
]
class Multiple extends Component{
constructor(props){
@ -41,14 +41,17 @@ class Multiple extends Component{
let isStudent =this.props.isStudent();
console.log(questionType);
return(
<div className="pl30 pr30">
<div className="pl30 pr30 singleDisplay">
<Checkbox.Group disabled={ user_exercise_status == 1 ? true : false } onChange={this.saveId} defaultValue={questionType.user_answer}>
{
questionType.question_choices && questionType.question_choices.map((item,key)=>{
let prefix = `${tagArray[key]}.`
return(
<p className="clearfix mb15 df">
<Checkbox className="fl lineh-20 " value={item.choice_id}></Checkbox>
<span class="fl lineh-20 mt1"></span><span style={{display:"inline-block"}} className="markdown-body mt1" dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span>
<Checkbox className="fl lineh-20 " value={item.choice_id}>{prefix}</Checkbox>
{/* <span class="fl lineh-20 mt1"></span> */}
<span style={{display:"inline-block"}} className="markdown-body " dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span>
</p>
)
})

@ -4,9 +4,9 @@ import {Checkbox,Radio, Input} from "antd";
import {markdownToHTML} from 'educoder'
import axios from 'axios'
const tagArray = [
// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
// 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
// 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
]
class single extends Component{
constructor(props){
@ -36,14 +36,16 @@ class single extends Component{
let isStudent =this.props.isStudent();
return(
<div className="pl30 pr30">
<div className="pl30 pr30 singleDisplay">
<Radio.Group disabled={ user_exercise_status == 1 ? true : false } defaultValue={questionType.user_answer[0]} onChange={this.changeItem}>
{
questionType.question_choices && questionType.question_choices.map((item,key)=>{
let prefix = `${tagArray[key]}.`
return(
<p className={parseInt(questionType.question_type) == 0 ? "clearfix mb15 df" : "fl mr40"}>
<Radio className="fl lineh-20" value={item.choice_id}></Radio>
<span className="fl lineh-20 mr3 mt1"></span><span style={{display:"inline-block"}} className="markdown-body fl mt1" dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span>
<Radio className="fl lineh-20" value={item.choice_id}>{prefix}</Radio>
{/* <span className="fl lineh-20 mr3 "></span> */}
<span style={{display:"inline-block", 'margin-top': '-1px'}} className="markdown-body fl " dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span>
</p>
)
})

Loading…
Cancel
Save