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

dev_forum
cxt 6 years ago
commit c6f96a8f6a

@ -37,7 +37,8 @@ class GamesController < ApplicationController
# 上一关、下一关 # 上一关、下一关
prev_game = @game.prev_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) prev_game = @game.prev_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position)
next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) #next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position)
next_game = user_next_game(@shixun, game_challenge, @game, @identity)
# 关卡点赞数, praise_or_tread = 1则表示赞过 # 关卡点赞数, praise_or_tread = 1则表示赞过
praise_count = game_challenge.praises_count praise_count = game_challenge.praises_count
@ -962,4 +963,14 @@ class GamesController < ApplicationController
@identity = current_user.game_identity(@game) @identity = current_user.game_identity(@game)
raise Educoder::TipException.new(403, "..") if @identity > User::EDU_GAME_MANAGER raise Educoder::TipException.new(403, "..") if @identity > User::EDU_GAME_MANAGER
end end
# identity用户身份
def user_next_game(shixun, challenge, game, identity)
next_game = game.next_of_current_game(shixun.id, game.myshixun_id, challenge.position)
# 实训允许跳关 、 当前关卡已经通关、 用户是已认证的老师以上权限的人,允许跳关
if shixun.task_pass || game.status == 2 || identity <= User::EDU_CERTIFICATION_TEACHER
next_game
else
nil
end
end
end end

@ -7,9 +7,9 @@ class MyshixunsController < ApplicationController
## TPI关卡列表 ## TPI关卡列表
def challenges def challenges
# @challenges = Challenge.where(shixun_id: params[:shixun_id]) # @challenges = Challenge.where(shixun_id: params[:shixun_id])
@shixun = @myshixun.shixun
@shixun_status = @myshixun.shixun.status
@games = @myshixun.games.includes(:challenge).reorder("challenges.position") @games = @myshixun.games.includes(:challenge).reorder("challenges.position")
@identity = current_user.game_identity(@games.first)
end end
@ -42,7 +42,7 @@ class MyshixunsController < ApplicationController
if e.message != "ActiveRecord::RecordInvalid" if e.message != "ActiveRecord::RecordInvalid"
logger.error("######delete_repository_error:#{e.message}") logger.error("######delete_repository_error:#{e.message}")
end end
raise ActiveRecord::Rollback raise "delete_repository_error:#{e.message}"
end end
end end

@ -718,7 +718,7 @@ class ShixunsController < ApplicationController
logger.error("##########project_fork error #{e.message}") logger.error("##########project_fork error #{e.message}")
@current_task.destroy! @current_task.destroy!
end end
raise ActiveRecord::Rollback raise "实训云平台繁忙繁忙等级81"
end end
end end
end end

@ -1,2 +1,14 @@
module MyshixunsHelper module MyshixunsHelper
# 获取tpi的identifier,
# identity表示用户关卡的身份
# task_pass: 实训是否允许跳关
def get_game_identifier task_pass, game, game_identity
# 允许跳关、 关卡已经开启、 用户是已认证老师以上的身份
if task_pass || game.status != 3 || game_identity <= User::EDU_CERTIFICATION_TEACHER
game.identifier
else
nil
end
end
end end

@ -4,6 +4,7 @@ class Shixun < ApplicationRecord
# status: 0编辑 1申请发布 2正式发布 3关闭 -1软删除 # status: 0编辑 1申请发布 2正式发布 3关闭 -1软删除
# hide_code 隐藏代码窗口 # hide_code 隐藏代码窗口
# code_hidden: 隐藏代码目录 # code_hidden: 隐藏代码目录
# task_pass: 跳关
has_many :challenges, dependent: :destroy has_many :challenges, dependent: :destroy
has_many :challenge_tags, through: :challenges has_many :challenge_tags, through: :challenges
has_many :myshixuns, :dependent => :destroy has_many :myshixuns, :dependent => :destroy

@ -3,7 +3,7 @@ json.array! @games do |game|
json.partial! 'challenges/challenge', locals: { challenge: challenge } json.partial! 'challenges/challenge', locals: { challenge: challenge }
json.status game.status json.status game.status
json.star game.star json.star game.star
json.identifier game.identifier json.identifier get_game_identifier(@shixun.task_pass, game, @identity)
json.get_gold game.user_get_gold_and_experience(@shixun_status, challenge)[0] json.get_gold game.user_get_gold_and_experience(@shixun.status, challenge)[0]
json.get_experience game.user_get_gold_and_experience(@shixun_status, challenge)[1] json.get_experience game.user_get_gold_and_experience(@shixun.status, challenge)[1]
end end

@ -6,11 +6,9 @@ export function isImageExtension(fileName) {
export function markdownToHTML(oldContent, selector) { export function markdownToHTML(oldContent, selector) {
window.$('#md_div').html('') window.$('#md_div').html('')
// markdown to html // markdown to html
try { try {
var markdwonParser = window.editormd.markdownToHTML("md_div", { var markdwonParser = window.editormd.markdownToHTML("md_div", {
markdown: oldContent, markdown: oldContent, // .replace(/▁/g,"▁▁▁"),
emoji: true, emoji: true,
htmlDecode: "style,script,iframe", // you can filter tags decode htmlDecode: "style,script,iframe", // you can filter tags decode
taskList: true, taskList: true,

@ -1,27 +1,44 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import { markdownToHTML } from 'educoder' import { markdownToHTML } from 'educoder'
/**
selector 需要传入唯一的selector作为id不然会引起冲突
delay 如果有公式需要传入delay={true}
*/
class MarkdownToHtml extends Component{ class MarkdownToHtml extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this.state={ this.state={
} }
} }
_markdownToHTML = (content, selector) => {
if (this.props.delay == true) {
(function(content, selector) {
// console.log('selector: ', selector)
setTimeout(() => {
markdownToHTML(content, selector)
}, 600)
})(content, selector)
} else {
markdownToHTML(content, selector)
}
}
componentDidUpdate = (prevProps) => { componentDidUpdate = (prevProps) => {
if (this.props.content) { if (this.props.content) {
if ( prevProps.content != this.props.content ) { if ( prevProps.content != this.props.content ) {
markdownToHTML(this.props.content, `.markdown_to_html_${this.props.selector || ''}`) this._markdownToHTML(this.props.content, `.markdown_to_html_${this.props.selector || ''}`)
} }
} }
} }
componentDidMount () { componentDidMount () {
this.props.content && markdownToHTML(this.props.content, `.markdown_to_html_${this.props.selector || ''}`) this.props.content && this._markdownToHTML(this.props.content, `.markdown_to_html_${this.props.selector || ''}`)
} }
render(){ render(){
const { style, className } = this.props
return( return(
<div id="memo_content_editorMd" className={`new_li markdown-body ${this.props.className} markdown_to_html_${this.props.selector || ''}`} <div id="memo_content_editorMd" className={`new_li markdown-body ${className} markdown_to_html_${this.props.selector || ''}`}
// dangerouslySetInnerHTML={{__html: markdownToHTML(this.props.content)}} // dangerouslySetInnerHTML={{__html: markdownToHTML(this.props.content)}}
style={style}
> >
</div> </div>
) )

@ -7,7 +7,7 @@ import {
} from 'antd'; } from 'antd';
import axios from 'axios' import axios from 'axios'
import { qNameArray } from './common' import { qNameArray } from './common'
import {getUrl, ActionBtn, markdownToHTML} from 'educoder'; import {getUrl, ActionBtn, markdownToHTML, MarkdownToHtml} from 'educoder';
import QestionDisplayHeader from './QestionDisplayHeader' import QestionDisplayHeader from './QestionDisplayHeader'
const { TextArea } = Input; const { TextArea } = Input;
const confirm = Modal.confirm; const confirm = Modal.confirm;
@ -68,10 +68,14 @@ class MainDisplay extends Component{
{ standard_answer[0] && { standard_answer[0] &&
<React.Fragment> <React.Fragment>
<div style={{color: '#05101A'}} className="font-16 mb5 font-bd">参考答案</div> <div style={{color: '#05101A'}} className="font-16 mb5 font-bd">参考答案</div>
<div className="mainQuestionDisplay markdown-body"
<MarkdownToHtml content={standard_answer[0]} selector={'answer_' + qNumber}
delay={true} className=""
></MarkdownToHtml>
{/* <div className="mainQuestionDisplay markdown-body"
dangerouslySetInnerHTML={{__html: markdownToHTML(standard_answer[0])}} dangerouslySetInnerHTML={{__html: markdownToHTML(standard_answer[0])}}
> >
</div> </div> */}
</React.Fragment> </React.Fragment>
} }

@ -7,7 +7,7 @@ import {
} from 'antd'; } from 'antd';
import axios from 'axios' import axios from 'axios'
import { qNameArray } from './common' import { qNameArray } from './common'
import {getUrl, ActionBtn, markdownToHTML} from 'educoder'; import {getUrl, ActionBtn, markdownToHTML, MarkdownToHtml} from 'educoder';
import QestionDisplayHeader from './QestionDisplayHeader' import QestionDisplayHeader from './QestionDisplayHeader'
const { TextArea } = Input; const { TextArea } = Input;
const confirm = Modal.confirm; const confirm = Modal.confirm;
@ -108,8 +108,12 @@ class NullDisplay extends Component{
<span className="lineh-40">答案填空{index+1}</span> <span className="lineh-40">答案填空{index+1}</span>
<div className="answers"> <div className="answers">
{ answers.answer_text.map((item, itemIndex) => { { answers.answer_text.map((item, itemIndex) => {
return <span className="answer" key={itemIndex}>{item}</span> return <MarkdownToHtml
className="answer" key={itemIndex} delay={true}
content={item} selector={'null_' + (index + 1) + '' + (itemIndex + 1)}
></MarkdownToHtml>
})} })}
{/* <span className="answer" key={itemIndex}>{item}</span> */}
</div> </div>
</div> </div>
}) })

@ -7,7 +7,7 @@ import {
} from 'antd'; } from 'antd';
import axios from 'axios' import axios from 'axios'
import { qNameArray } from './common' import { qNameArray } from './common'
import {getUrl, ActionBtn, markdownToHTML} from 'educoder'; import {getUrl, ActionBtn, markdownToHTML, MarkdownToHtml} from 'educoder';
const { TextArea } = Input; const { TextArea } = Input;
const confirm = Modal.confirm; const confirm = Modal.confirm;
const $ = window.$ const $ = window.$
@ -80,8 +80,13 @@ class QestionDisplayHeader extends Component{
</React.Fragment>} </React.Fragment>}
</div> </div>
</div> </div>
<span className="markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML(question_title)}} { question_title &&
style={{ display: 'inline-block', width:'100%' , margin: '10px 0px 15px' }}></span> <MarkdownToHtml content={question_title} selector={'qtitle_' + (index + 1)} style={{ display: 'inline-block', width:'100%' , margin: '10px 0px 15px' }}
delay={true}
></MarkdownToHtml>
// <div className="markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML(question_title)}}
// style={{ display: 'inline-block', width:'100%' , margin: '10px 0px 15px' }}></div>
}
</React.Fragment> </React.Fragment>
) )
} }

@ -7,7 +7,7 @@ import {
} from 'antd'; } from 'antd';
import axios from 'axios' import axios from 'axios'
import QestionDisplayHeader from './QestionDisplayHeader' import QestionDisplayHeader from './QestionDisplayHeader'
import {getUrl, ActionBtn, markdownToHTML} from 'educoder'; import {getUrl, ActionBtn, markdownToHTML, MarkdownToHtml} from 'educoder';
const { TextArea } = Input; const { TextArea } = Input;
const confirm = Modal.confirm; const confirm = Modal.confirm;
const $ = window.$ const $ = window.$
@ -100,16 +100,22 @@ class SingleDisplay extends Component{
return ( return (
<div className="mb10 clearfix" key={optionIndex}> <div className="mb10 clearfix" key={optionIndex}>
<Radio disabled className="fl lineh-20" checked={item.standard_boolean}>{prefix}</Radio> <Radio disabled className="fl lineh-20" checked={item.standard_boolean}>{prefix}</Radio>
<span style={{ display: 'inline-block'}} className="markdown-body fl" <MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1) + '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }}
dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> delay={true}
></MarkdownToHtml>
{/* <span style={{ display: 'inline-block'}} className="markdown-body fl"
dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> */}
</div>) </div>)
} else { } else {
return ( return (
<div className="mb10 clearfix" key={optionIndex}> <div className="mb10 clearfix" key={optionIndex}>
<Checkbox disabled className="fl lineh-20" checked={item.standard_boolean}>{prefix}</Checkbox> <Checkbox disabled className="fl lineh-20" checked={item.standard_boolean}>{prefix}</Checkbox>
<span style={{ display: 'inline-block'}} className="markdown-body fl" <MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1)+ '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }}
dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> delay={true}
></MarkdownToHtml>
{/* <span style={{ display: 'inline-block'}} className="markdown-body fl"
dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> */}
</div>) </div>)
} }
})} })}

Loading…
Cancel
Save