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

issues25489
hjm 5 years ago
commit e4223a3be6

@ -1084,14 +1084,23 @@ class ExercisesController < ApplicationController
@shixun_undo = 0 @shixun_undo = 0
@ques_undo = 0 @ques_undo = 0
ex_answer_time = @exercise.time.to_i ex_answer_time = @exercise.time.to_i
@ex_end_time = @exercise.get_exercise_end_time(current_user.id) if ex_answer_time > 0 #有剩余时间的时候
if ex_answer_time > 0 user_left_time = get_exercise_left_time(@exercise,current_user)
exercise_end_time = @exercise.exercise_users.exercise_commit_users(current_user.id) @ex_end_time = Time.now + user_left_time.to_i.seconds
if exercise_end_time.present? else
ex_end_times = exercise_end_time.first.start_at.nil? ? Time.now : exercise_end_time.first.start_at @ex_end_time = @exercise.get_exercise_end_time(current_user.id)
@ex_end_time = ex_end_times + ex_answer_time.minutes
end
end end
# @ex_end_time = @exercise.get_exercise_end_time(current_user.id)
# if ex_answer_time > 0
# left_answer_time = Time.now + ex_answer_time.minutes #判断试卷的倒计时和截止时间哪个先到
# if left_answer_time < @ex_end_time
# exercise_end_time = @exercise.exercise_users.exercise_commit_users(current_user.id)
# if exercise_end_time.present?
# ex_end_times = exercise_end_time.first.start_at.nil? ? Time.now : exercise_end_time.first.start_at
# @ex_end_time = ex_end_times + ex_answer_time.minutes
# end
# end
# end
@exercise_questions.each do |q| @exercise_questions.each do |q|
if q.question_type == Exercise::PRACTICAL #当为实训题时 if q.question_type == Exercise::PRACTICAL #当为实训题时
user_myshixun = q.shixun.myshixuns.search_myshixun_user(current_user.id) user_myshixun = q.shixun.myshixuns.search_myshixun_user(current_user.id)

@ -142,6 +142,9 @@ module ExercisesHelper
right_users_count = 0 right_users_count = 0
#该问题的正确率 #该问题的正确率
if ex.question_type == Exercise::MULTIPLE #多选题 if ex.question_type == Exercise::MULTIPLE #多选题
if standard_answer.size == 1 #以前的多选题答案存在一个表里
standard_answer = standard_answer.first.to_s.split("").map(&:to_i)
end
right_user_ids = user_ids right_user_ids = user_ids
standard_answer.each do |choice_position| standard_answer.each do |choice_position|
standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id
@ -896,7 +899,8 @@ module ExercisesHelper
if ex_time > 0 if ex_time > 0
exercise_user = exercise.exercise_users.find_by(user_id:user.id) exercise_user = exercise.exercise_users.find_by(user_id:user.id)
time_mill = ex_time * 60 #转为秒 time_mill = ex_time * 60 #转为秒
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0 exercise_end_time = exercise.get_exercise_end_time(user.id) #没有考虑分班的情况
# exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user&.start_at.present? ? exercise_user.start_at.to_i : 0 exercise_user_start = exercise_user&.start_at.present? ? exercise_user.start_at.to_i : 0
#用户未开始答题时即exercise_user_start为0 #用户未开始答题时即exercise_user_start为0
if exercise_user_start == 0 if exercise_user_start == 0

@ -6,6 +6,7 @@ module OmniAuth
authorize_url: '/oauth2.0/authorize', authorize_url: '/oauth2.0/authorize',
token_url: '/oauth2.0/token' token_url: '/oauth2.0/token'
} }
option :token_params, { parse: :query }
def request_phase def request_phase
super super
@ -21,7 +22,17 @@ module OmniAuth
end end
end end
uid { raw_info['openid'].to_s } uid do
@uid ||= begin
access_token.options[:mode] = :query
access_token.options[:param_name] = :access_token
# Response Example: "callback( {\"client_id\":\"11111\",\"openid\":\"000000FFFF\"} );\n"
response = access_token.get('/oauth2.0/me')
matched = response.body.match(/"openid":"(?<openid>\w+)"/)
matched[:openid]
end
end
info do info do
{ {
@ -35,18 +46,10 @@ module OmniAuth
{ raw_info: user_info } { raw_info: user_info }
end end
def raw_info
access_token.options[:mode] = :query
@raw_info ||= begin
res = access_token.get('/oauth2.0/me')
JSON.parse(res.body.to_s[10..-4])
end
end
def user_info def user_info
access_token.options[:mode] = :query access_token.options[:mode] = :query
params = { oauth_consumer_key: options.client_id, openid: raw_info['openid'], format: 'json' } param = { oauth_consumer_key: options[:client_id], openid: uid, format: 'json' }
@user_info ||= access_token.get('/user/get_user_info', params: params).parsed @user_info ||= access_token.get('/user/get_user_info', params: param, parse: :json).parsed
end end
end end
end end

@ -48,6 +48,29 @@ class CompetitionCommon extends Component{
} }
} }
componentDidUpdate = (prevProps) => {
if (prevProps.user != this.props.user) {
console.log("componentDidUpdatess");
console.log(this.props.user);
if (this.props.user && this.props.user.login != "") {
const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`;
axios.get((zul)).then((result) => {
if (result) {
if (result.data) {
this.setState({
signupdata: result.data
})
}
}
}).catch((error) => {
//console.log(error);
})
}
}
}
//获取头部信息
getbannerdata=()=>{ getbannerdata=()=>{
let menuid=this.props.location.search.replace('?menu=', ''); let menuid=this.props.location.search.replace('?menu=', '');
let url=`/competitions/${this.props.match.params.identifier}/common_header.json`; let url=`/competitions/${this.props.match.params.identifier}/common_header.json`;
@ -55,7 +78,8 @@ class CompetitionCommon extends Component{
if(response.status===200){ if(response.status===200){
this.setState({ this.setState({
data: response.data, data: response.data,
thiskeys: menuid === undefined || menuid === "" ? response.data.competition_modules[0].id : menuid thiskeys: menuid === undefined || menuid === "" ? response.data.competition_modules[0].id : menuid,
mode: response.data.mode
}) })
if(menuid===undefined||menuid===""){ if(menuid===undefined||menuid===""){
this.getrightdata( this.getrightdata(
@ -82,6 +106,8 @@ class CompetitionCommon extends Component{
console.log(error) console.log(error)
}) })
//this.props.user 有可能为空
if (this.props.user && this.props.user.login != "") { if (this.props.user && this.props.user.login != "") {
const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`;
axios.get((zul)).then((result) => { axios.get((zul)).then((result) => {

@ -369,7 +369,9 @@ function buildColumns(that, student_works, studentData) {
</Tooltip> } </Tooltip> }
{/* toWorkDetailPage */} {/* toWorkDetailPage */}
{/* /courses/"+courseId+"/common_homeworks/"+workId+ '/' + record.id +"/appraise */} {/* /courses/"+courseId+"/common_homeworks/"+workId+ '/' + record.id +"/appraise */}
<a style={{color:'#4CACFF', marginLeft: '4px'}} href={"javascript:void(0)"} onClick={() => that.props.toWorkDetailPage(courseId, workId, record.id)} >{ isAdmin ? '评阅': '查看'}</a> <a style={{color: '#4CACFF', marginLeft: '4px'}} id={"asdasdasdasd"}
onMouseDown={(e) => that.props.toWorkDetailPage2(e, courseId, workId, record.id)}
onClick={() => that.props.toWorkDetailPage(courseId, workId, record.id)}>{isAdmin ? '评阅' : '查看'}</a>
</div> </div>

@ -20,7 +20,7 @@ export function RouteHOC(options = {}) {
toCreateProject = () => { toCreateProject = () => {
let url = '/projects/new' let url = '/projects/new'
if (window.location.port == 3007) { if (window.location.port == 3007) {
// window.location.href // window.location.href
url = '/testbdweb.educoder.net/projects/new' url = '/testbdweb.educoder.net/projects/new'
} }
window.open( window.open(
@ -56,7 +56,7 @@ export function RouteHOC(options = {}) {
this.props.history.push(`/courses/${_courseId}/boards/${workId}/messages/${topicId}`) this.props.history.push(`/courses/${_courseId}/boards/${workId}/messages/${topicId}`)
} }
} }
toEditPage = (_courseId, _workId) => { toEditPage = (_courseId, _workId) => {
const secondName = this.getModuleName() const secondName = this.getModuleName()
if (typeof _courseId == "object") { if (typeof _courseId == "object") {
@ -78,6 +78,19 @@ export function RouteHOC(options = {}) {
window.open(`/courses/${_courseId}/${secondName}/${_workId}/${_studentWorkId}/appraise`); window.open(`/courses/${_courseId}/${secondName}/${_workId}/${_studentWorkId}/appraise`);
} }
} }
toWorkDetailPage2 = (e, _courseId, _workId, _studentWorkId) => {
console.log("鼠标中键点击了")
console.log(_studentWorkId)
const secondName = this.getModuleName()
if (typeof _courseId == "object") {
const workId = _courseId.workId
const courseId = _courseId.coursesId
const studentWorkId = _courseId.studentWorkId
window.open(`/courses/${courseId}/${secondName}/${_workId || workId}/${_studentWorkId || studentWorkId}/appraise`);
} else {
window.open(`/courses/${_courseId}/${secondName}/${_workId}/${_studentWorkId}/appraise`);
}
}
toNewPage = (courseId) => { toNewPage = (courseId) => {
const secondName = this.getModuleName() const secondName = this.getModuleName()
this.props.history.push(`/courses/${courseId.coursesId}/${secondName}/${courseId.category_id}/new`) this.props.history.push(`/courses/${courseId.coursesId}/${secondName}/${courseId.category_id}/new`)
@ -126,7 +139,7 @@ export function RouteHOC(options = {}) {
} }
} }
toWorkQuestionPage = (_courseId, _workId) => { toWorkQuestionPage = (_courseId, _workId) => {
const secondName = this.getModuleName() const secondName = this.getModuleName()
if (typeof _courseId == "object") { if (typeof _courseId == "object") {
const workId = _workId || _courseId.workId const workId = _workId || _courseId.workId
@ -149,33 +162,32 @@ export function RouteHOC(options = {}) {
} }
render() {
render() {
const { snackbarOpen} = this.state; const { snackbarOpen} = this.state;
return ( return (
<React.Fragment> <React.Fragment>
<WrappedComponent {...this.props} <WrappedComponent {...this.props}
toDetailPage={this.toDetailPage} toDetailPage={this.toDetailPage}
toEditPage={this.toEditPage} toEditPage={this.toEditPage}
toNewPage={this.toNewPage} toNewPage={this.toNewPage}
toListPage={this.toListPage} toListPage={this.toListPage}
toWorkDetailPage={this.toWorkDetailPage} toWorkDetailPage={this.toWorkDetailPage}
toWorkDetailPage2={this.toWorkDetailPage2}
toWorkPostPage={this.toWorkPostPage} toWorkPostPage={this.toWorkPostPage}
toWorkListPage={this.toWorkListPage} toWorkListPage={this.toWorkListPage}
toWorkAnswerPage={this.toWorkAnswerPage} toWorkAnswerPage={this.toWorkAnswerPage}
toWorkQuestionPage={this.toWorkQuestionPage} toWorkQuestionPage={this.toWorkQuestionPage}
toWorkSettingPage={this.toWorkSettingPage} toWorkSettingPage={this.toWorkSettingPage}
toCreateProject={this.toCreateProject} toCreateProject={this.toCreateProject}
isGroup={this.isGroup} isGroup={this.isGroup}
getModuleName={this.getModuleName} getModuleName={this.getModuleName}
getModuleType={this.getModuleType} getModuleType={this.getModuleType}
> >
</WrappedComponent> </WrappedComponent>
</React.Fragment> </React.Fragment>
) )
} }

@ -458,6 +458,7 @@ class Listofworksstudentone extends Component {
: :
<a style={{textAlign: "center"}} <a style={{textAlign: "center"}}
className="color-blue" className="color-blue"
onMouseDown={(e) => this.Viewstudenttraininginformationtysl2(e, record)}
onClick={() => this.Viewstudenttraininginformation(record)}>{record.operating}</a> onClick={() => this.Viewstudenttraininginformation(record)}>{record.operating}</a>
} }
@ -810,6 +811,7 @@ class Listofworksstudentone extends Component {
: :
<a style={{textAlign: "center"}} <a style={{textAlign: "center"}}
className="color-blue" className="color-blue"
onMouseDown={(e) => this.Viewstudenttraininginformationtysl2(e, record)}
onClick={() => this.Viewstudenttraininginformation(record)}>{record.operating}</a> onClick={() => this.Viewstudenttraininginformation(record)}>{record.operating}</a>
} }
@ -1175,6 +1177,7 @@ class Listofworksstudentone extends Component {
record.submitstate === "未提交" ? <span style={{color: '#9A9A9A'}}>--</span> : record.submitstate === "未提交" ? <span style={{color: '#9A9A9A'}}>--</span> :
<span> <span>
<a style={{textAlign: "center"}} className="color-blue" <a style={{textAlign: "center"}} className="color-blue"
onMouseDown={(e) => this.Viewstudenttraininginformationtysl2(e, record)}
onClick={() => this.Viewstudenttraininginformationt(record)}>查看</a> onClick={() => this.Viewstudenttraininginformationt(record)}>查看</a>
</span> </span>
) )
@ -1505,6 +1508,7 @@ class Listofworksstudentone extends Component {
record.submitstate === "未提交" ? <span style={{color: '#9A9A9A'}}>--</span> : record.submitstate === "未提交" ? <span style={{color: '#9A9A9A'}}>--</span> :
<span> <span>
<a style={{textAlign: "center"}} className="color-blue" <a style={{textAlign: "center"}} className="color-blue"
onMouseDown={(e) => this.Viewstudenttraininginformationtysl2(e, record)}
onClick={() => this.Viewstudenttraininginformationt(record)}>{record.operating}</a> onClick={() => this.Viewstudenttraininginformationt(record)}>{record.operating}</a>
</span> </span>
) )
@ -2779,7 +2783,16 @@ class Listofworksstudentone extends Component {
} }
// 调分 // 调分
Viewstudenttraininginformationtysl2 = (e, data) => {
// console.log("Viewstudenttraininginformationtysl2");
// console.log("shubiao zhongjian ");
// console.log(e);
this.setState({
userids: data.myid,
})
// this.viewtrainingt(e.myid);
window.open(`/courses/${this.state.props.match.params.coursesId}/shixun_homeworks/${data.myid}/shixun_work_report`, '_blank');
}
// 查看学员实训信息 // 查看学员实训信息
Viewstudenttraininginformationt = (e) => { Viewstudenttraininginformationt = (e) => {
// console.log("Viewstudenttraininginformation"); // console.log("Viewstudenttraininginformation");

@ -280,7 +280,7 @@ class Infos extends Component{
} }
></Route> ></Route>
{/* 实训 */} {/* 实训项目 */}
<Route exact path="/users/:username/shixuns" <Route exact path="/users/:username/shixuns"
render={ render={
(props) => (<InfosShixun {...this.props} {...props} {...this.state} {..._commonProps}/>) (props) => (<InfosShixun {...this.props} {...props} {...this.state} {..._commonProps}/>)
@ -294,7 +294,7 @@ class Infos extends Component{
} }
></Route> ></Route>
{/* 项目 */} {/* 开发项目 */}
<Route exact path="/users/:username/projects" <Route exact path="/users/:username/projects"
render={ render={
(props) => (<InfosProject {...this.props} {...props} {...this.state} {..._commonProps}/>) (props) => (<InfosProject {...this.props} {...props} {...this.state} {..._commonProps}/>)

@ -45,6 +45,7 @@ class InfosShixun extends Component{
status, status,
sort_by, sort_by,
page, page,
sort_direction,
per_page:this.props.is_current && category && page ==1?17:16 per_page:this.props.is_current && category && page ==1?17:16
}}).then((result)=>{ }}).then((result)=>{
if(result){ if(result){

Loading…
Cancel
Save