From 67e49b2c2df81105fec077dcfe28c6f6e0e82b06 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 09:31:16 +0800 Subject: [PATCH 01/20] page 1 --- public/react/src/modules/courses/busyWork/CommonWorkList.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 251e39fcb..8484100f4 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -450,17 +450,17 @@ class CommonWorkList extends Component{ } teacherCommentOptionChange = (values, isAllChecked) => { - this.setState({arg_teacher_comment: isAllChecked ? [] : values}, () => { + this.setState({arg_teacher_comment: isAllChecked ? [] : values, page: 1}, () => { this.fetchList() }) } statusOptionChange = (values, isAllChecked) => { - this.setState({arg_work_status: isAllChecked ? [] : values}, () => { + this.setState({arg_work_status: isAllChecked ? [] : values, page: 1}, () => { this.fetchList() }) } courseGroupOptionChange = (values, isAllChecked) => { - this.setState({arg_course_group: isAllChecked ? [] : values}, () => { + this.setState({arg_course_group: isAllChecked ? [] : values, page: 1}, () => { this.fetchList() }) } From cc1bc813330bce8a65a0eb8099af272414c40709 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 09:35:55 +0800 Subject: [PATCH 02/20] 980px --- public/react/src/modules/courses/busyWork/CommonWorkList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 8484100f4..4d5676c5a 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -648,7 +648,7 @@ class CommonWorkList extends Component{ - {options_course_group.length > 1 && } + {options_course_group.length > 1 && } {/* value={search} */} From df193a6c5e230a89859356f0c482d61c06fdc5e0 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 09:43:52 +0800 Subject: [PATCH 03/20] normal --- .../src/modules/courses/busyWork/CommonWorkList.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 4d5676c5a..46d06e300 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -31,7 +31,7 @@ function renderScore(score, content) { } else if (score >= 60) { color = '#FF6800' } - return + return {score == null || score == undefined || score == '--' ? '--': (content || score)} } @@ -105,7 +105,7 @@ function buildColumns(that, student_works) { {record.student_id} ), @@ -121,7 +121,7 @@ function buildColumns(that, student_works) { render: (text, record) => ( - {record.group_name} + {record.group_name} ), } ) @@ -177,7 +177,7 @@ function buildColumns(that, student_works) { } return ( - + {status === 0 ? "未提交" : status === 1 ? "按时提交" : status === 2 ? "延时提交" : ""} @@ -190,7 +190,7 @@ function buildColumns(that, student_works) { render: (update_time, record) => ( - {update_time ? moment(update_time).format('YYYY-MM-DD HH:mm') : '--'} + {update_time ? moment(update_time).format('YYYY-MM-DD HH:mm') : '--'} ), }]) From 6d05c363fc1f3a98aa8d6c2a61533bf25ee3bf0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 29 Jun 2019 09:54:40 +0800 Subject: [PATCH 04/20] =?UTF-8?q?=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMIndexHOC.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index fff1ce231..279a0a71d 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -216,7 +216,7 @@ export function TPMIndexHOC(WrappedComponent) { // 非课堂成员 isNotMember = () => { // return this.state.coursedata&&this.state.coursedata.course_identity >= 0 && - return this.state.coursedata&&this.state.coursedata.course_identity === 6 + return this.state.coursedata&&this.state.coursedata.course_identity >6 } // setTrialapplication = ()=>{ From 17c4e3e33c9bae425374a02bf80061dc33063056 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 10:13:58 +0800 Subject: [PATCH 05/20] isNotMember --- public/react/src/modules/tpm/TPMIndexHOC.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index fff1ce231..5501ef499 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -216,7 +216,7 @@ export function TPMIndexHOC(WrappedComponent) { // 非课堂成员 isNotMember = () => { // return this.state.coursedata&&this.state.coursedata.course_identity >= 0 && - return this.state.coursedata&&this.state.coursedata.course_identity === 6 + return this.state.coursedata&&this.state.coursedata.course_identity >= 6 } // setTrialapplication = ()=>{ From ce5dfa17ce30ad57dbd579ad9a89e7469289599f Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 10:29:38 +0800 Subject: [PATCH 06/20] no_mr --- public/react/src/modules/courses/boards/TopicDetail.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/boards/TopicDetail.js b/public/react/src/modules/courses/boards/TopicDetail.js index 0c25910f5..e333c17ee 100644 --- a/public/react/src/modules/courses/boards/TopicDetail.js +++ b/public/react/src/modules/courses/boards/TopicDetail.js @@ -526,8 +526,11 @@ class TopicDetail extends Component { const courseId=this.props.match.params.coursesId; const boardId = this.props.match.params.boardId return ( -
{/* fl with100 */} +
{/* fl with100 */}
-
- {memberslist===undefined?"":memberslist.members.length===0?
+ {memberslist===undefined?"":memberslist.length===0?

未找到包含{search}的学生

-
:memberslist&&memberslist.members.map((item,key)=>{ +
:memberslist&&memberslist.map((item,key)=>{ return(
-
{item.user_name}
-
{item.group_name}
-
{item.student_id}
+
{item.user_name}
+
{item.group_name}
+
{item.student_id}
{item.commit_status===false?已提交 :""}
) @@ -719,22 +742,30 @@ class GraduationTasksSubmitedit extends Component{
-
+
{selectmemberslist&&selectmemberslist.map((item,key)=>{ - return( -
-
{item.user_name}
-
{item.group_name}
-
{item.student_id}
- {key>0?
this.delecttask_status(item.user_id)}>
:""} -
- ) + if(item.group_name!=undefined) { + return ( +
+
{item.user_name}
+
{item.group_name}
+
{item.student_id}
+ {key > 0 ? +
this.delecttask_status(item.user_id)}> +
: ""} +
+ ) + } })} +
diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js index a49d38212..87044ee61 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js @@ -32,7 +32,8 @@ class GraduationTasksSubmitnew extends Component{ selectobjct:undefined, Loadtype:false, spinnings:false, - shixunsreplace:false + shixunsreplace:false, + limit:20 } } @@ -58,7 +59,7 @@ class GraduationTasksSubmitnew extends Component{ if(result.data.task_type===1){ }else{ - this.searchList("",1,10) + this.searchList("",1,20) } this.setState({ workslist:result.data, @@ -219,25 +220,42 @@ class GraduationTasksSubmitnew extends Component{ } - searchList=(search,page,limit)=>{ - this.setState({ - search:search, - page:page, - limit:10 - }) + searchList=(search,page,limit,types)=>{ let id=this.props.match.params.task_Id; + let {memberslist}=this.state; + let newmemberslist=memberslist let url="/graduation_tasks/"+id+"/graduation_works/search_member_list.json"; + axios.post(url,{ search:search, page:page, - limit:limit + limit:15 }).then((result)=>{ if(result.status===200){ if(result.data.status!=403){ - this.setState({ - memberslist:result.data - }) + if(types===1){ + if(result.data.members.length>0){ + result.data.members.map((item,key)=>{ + newmemberslist.push(item) + }) + } + this.setState({ + memberslist:newmemberslist, + search:search, + page:page, + limit:limit + }) + + }else{ + this.setState({ + memberslist:result.data.members, + search:search, + page:page, + limit:limit + }) + } + } } @@ -256,7 +274,7 @@ class GraduationTasksSubmitnew extends Component{ let newpage=page+2 - this.searchList(search,newpage,limit) + this.searchList(search,newpage,limit,1) } @@ -265,7 +283,7 @@ class GraduationTasksSubmitnew extends Component{ funtaskstatus=(checkedValues)=>{ let{memberslist,selectobjct}=this.state; - let newlist =memberslist.members; + let newlist =memberslist; let newcheckedValues=checkedValues; let selects=[]; selects.push(selectobjct) @@ -318,7 +336,7 @@ class GraduationTasksSubmitnew extends Component{ let {search} = this.state; - this.searchList(search,1,10) + this.searchList(search,1,20) } } onSearchKeywordKeyUps= (e)=>{ @@ -648,8 +666,8 @@ render(){ text-overflow:ellipsis; white-space:nowrap } - .width87{ - width: 87px; + .width100{ + width: 100px; height: 24px; } img.edu-nodata-img { @@ -657,21 +675,25 @@ render(){ margin: 50px 90px 20px; display: block; } + .autos{ + overflow: auto; + } `}
-
- {memberslist===undefined?"":memberslist.members.length===0? + {memberslist===undefined?"":memberslist.length===0?
-

未找到包含{search}的学生

+ {/*

未找到包含{search}的学生

*/} +

未找到该学生

-
:memberslist&&memberslist.members.map((item,key)=>{ +
:memberslist&&memberslist.map((item,key)=>{ return(
-
{item.user_name}
-
{item.group_name}
-
{item.student_id}
+
{item.user_name}
+
{item.group_name}
+
{item.student_id}
{item.commit_status===true?已提交 :""}
) @@ -704,22 +726,25 @@ render(){ white-space:nowrap } `} -
+
{selectmemberslist&&selectmemberslist.map((item,key)=>{ - return( -
-
{item.user_name}
-
{item.group_name}
-
{item.student_id}
- {key>0?
this.delecttask_status(item.user_id)}>
:""} - -
- ) + if(item.group_name!=undefined){ + return( +
+
{item.user_name}
+
{item.group_name}
+
{item.student_id}
+ {key>0?
this.delecttask_status(item.user_id)}>
:""} + +
+ ) + } + })}
diff --git a/public/react/src/modules/courses/shixunHomework/Shixunworkdetails/ShixunWorkModal.js b/public/react/src/modules/courses/shixunHomework/Shixunworkdetails/ShixunWorkModal.js index 572bc5715..8b7bbb544 100644 --- a/public/react/src/modules/courses/shixunHomework/Shixunworkdetails/ShixunWorkModal.js +++ b/public/react/src/modules/courses/shixunHomework/Shixunworkdetails/ShixunWorkModal.js @@ -52,16 +52,17 @@ class ShixunWorkModal extends Component{ let types=false let{group_list}=this.state; group_list.map((item,key)=>{ - checkedValues.map((list,li)=>{ - if(item.id===list){ - if(item.works_count<2){ - this.props.showNotification(`有效作品数少于2个,无法查重`) - types=true - return + if(item!=undefined){ + checkedValues.map((list,li)=>{ + if(item.id===list){ + if(item.works_count<2){ + this.props.showNotification(`有效作品数少于2个,无法查重`) + types=true + return + } } - } - }) - + }) + } }) if(types===false){ From dc0051145ac18ba650069a39391c2667f3419ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 29 Jun 2019 11:01:59 +0800 Subject: [PATCH 08/20] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/index.js | 2 +- .../src/modules/courses/exercise/ExerciseReviewAndAnswer.js | 2 +- public/react/src/modules/courses/poll/Poll.js | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index c4b5d10b0..e2d6d1618 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -668,7 +668,7 @@ class Fileslists extends Component{
共 {total_count} 个资源 已发布:{public_count}个 - {this.props.isAdmin()||this.props.isStudent()?未发布:{private_count}个:""} + 未发布:{private_count}个
} onPressEnter={this.onPressEnter} diff --git a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js index b9da3f2eb..31c293659 100644 --- a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js +++ b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js @@ -561,7 +561,7 @@ class ExerciseReviewAndAnswer extends Component{

{ exercise && exercise.exercise_description && -

{exercise.exercise_description}

+

{exercise.exercise_description}

}

{ diff --git a/public/react/src/modules/courses/poll/Poll.js b/public/react/src/modules/courses/poll/Poll.js index a41f65ccd..0170cac00 100644 --- a/public/react/src/modules/courses/poll/Poll.js +++ b/public/react/src/modules/courses/poll/Poll.js @@ -523,9 +523,7 @@ class Poll extends Component{

共{polls_counts && polls_counts.polls_total_counts}个问卷 已发布:{polls_counts && polls_counts.polls_published_counts}个 - { - isAdmin && 未发布:{polls_counts && polls_counts.polls_unpublish_counts}个 - } + 未发布:{polls_counts && polls_counts.polls_unpublish_counts}个

Date: Sat, 29 Jun 2019 11:09:45 +0800 Subject: [PATCH 09/20] css --- public/react/src/modules/comment/Comment.css | 1 + .../src/modules/courses/boards/TopicDetail.js | 8 +++- .../modules/courses/common/CommentsHelper.js | 4 +- .../courses/common/comments/CommonReply.js | 2 +- .../tasks/GraduationTaskssettingReply.js | 2 +- .../graduation/topics/GraduateTopicReply.js | 2 +- .../src/modules/forums/MemoDetailMDEditor.js | 6 +-- public/react/src/scripts/concat.js | 48 +++++++++++++++++++ 8 files changed, 63 insertions(+), 10 deletions(-) diff --git a/public/react/src/modules/comment/Comment.css b/public/react/src/modules/comment/Comment.css index 2f85846b6..f21a9c8cf 100644 --- a/public/react/src/modules/comment/Comment.css +++ b/public/react/src/modules/comment/Comment.css @@ -238,6 +238,7 @@ width: 100%; word-wrap: break-word; margin-bottom: 4px; + margin-top: 4px; } .childComment .break_word_comments{ line-height: 22px; diff --git a/public/react/src/modules/courses/boards/TopicDetail.js b/public/react/src/modules/courses/boards/TopicDetail.js index e333c17ee..325bbde0d 100644 --- a/public/react/src/modules/courses/boards/TopicDetail.js +++ b/public/react/src/modules/courses/boards/TopicDetail.js @@ -416,7 +416,7 @@ class TopicDetail extends Component { const user = this._getUser(); this.setState({ - comments: addNewComment(comments, _id, content, user) + comments: addNewComment(comments, _id, content, user, this) }) const newMemo2 = Object.assign({}, this.state.memo); newMemo2.total_replies_count = newMemo2.total_replies_count + 1; @@ -531,6 +531,10 @@ class TopicDetail extends Component { .topicDetail #forum_list .return_btn.no_mr { margin-right: 1px; } + /* 有内容时,编辑器下方的边框*/ + .topicDetail .borderBottom.commentInputs { + border-bottom: 1px solid rgb(238, 238, 238); + } .independent { background: rgb(250, 250, 250); padding-bottom: 20px; @@ -661,7 +665,7 @@ class TopicDetail extends Component {
+ height={160} showError={true} buttonText={'发表'} className={comments && comments.length && 'borderBottom'}> {/* onClick={ this.createNewComment } enableReplyTo={true} diff --git a/public/react/src/modules/courses/common/CommentsHelper.js b/public/react/src/modules/courses/common/CommentsHelper.js index b4254445d..e513263bc 100644 --- a/public/react/src/modules/courses/common/CommentsHelper.js +++ b/public/react/src/modules/courses/common/CommentsHelper.js @@ -64,13 +64,13 @@ export function handleContentBeforeCreateNew(argContent) { return content } -export function addNewComment(comments, _id, content, user, isSuperAdmin) { +export function addNewComment(comments, _id, content, user, isSuperAdmin, parentComponent) { if (!comments) { comments = []; } comments.unshift( { "can_delete": true, - "admin": user.admin, + "admin": parentComponent ? parentComponent.props.isAdmin() : user.admin , isSuperAdmin: isSuperAdmin, "content": content, diff --git a/public/react/src/modules/courses/common/comments/CommonReply.js b/public/react/src/modules/courses/common/comments/CommonReply.js index 739e62c97..dae21949c 100644 --- a/public/react/src/modules/courses/common/comments/CommonReply.js +++ b/public/react/src/modules/courses/common/comments/CommonReply.js @@ -76,7 +76,7 @@ class CommonReply extends Component{ const isSuperAdmin = this.props.isSuperAdmin() this.setState({ - comments: addNewComment(this.state.comments, _id, content, user, isSuperAdmin), + comments: addNewComment(this.state.comments, _id, content, user, isSuperAdmin, this), total_count: this.state.total_count + 1 }) this.refs.editor.showEditor(); diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js index 664c4a629..4281d0ec6 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js @@ -73,7 +73,7 @@ class GraduationTaskssettingReply extends Component{ const user = this._getUser(); this.setState({ - comments: addNewComment(this.state.comments, _id, content, user), + comments: addNewComment(this.state.comments, _id, content, user, this.props.isSuperAdmin(), this), total_count: this.state.total_count + 1 }) this.refs.editor.showEditor(); diff --git a/public/react/src/modules/courses/graduation/topics/GraduateTopicReply.js b/public/react/src/modules/courses/graduation/topics/GraduateTopicReply.js index 114efa213..4e318a0c1 100644 --- a/public/react/src/modules/courses/graduation/topics/GraduateTopicReply.js +++ b/public/react/src/modules/courses/graduation/topics/GraduateTopicReply.js @@ -67,7 +67,7 @@ class GraduateTopicReply extends Component{ const user = this._getUser(); this.setState({ - comments: addNewComment(this.state.comments, _id, content, user), + comments: addNewComment(this.state.comments, _id, content, user, this.props.isSuperAdmin(), this), total_count: this.state.total_count + 1 }) this.refs.editor.showEditor(); diff --git a/public/react/src/modules/forums/MemoDetailMDEditor.js b/public/react/src/modules/forums/MemoDetailMDEditor.js index 6fd650cea..68445b0d7 100644 --- a/public/react/src/modules/forums/MemoDetailMDEditor.js +++ b/public/react/src/modules/forums/MemoDetailMDEditor.js @@ -117,7 +117,7 @@ class MemoDetailMDEditor extends Component { this.initMDEditor() } render() { - const { match, history, memo, placeholder } = this.props + const { match, history, memo, placeholder, className } = this.props const { isInited, errorMsg } = this.state if (!memo) { return
@@ -154,7 +154,7 @@ class MemoDetailMDEditor extends Component { } `}
+ className={`mockInputWrapper commentInput ${className}`} > @@ -172,7 +172,7 @@ class MemoDetailMDEditor extends Component { ` } */} -
diff --git a/public/react/src/scripts/concat.js b/public/react/src/scripts/concat.js index 3a40eef91..67e8d4836 100644 --- a/public/react/src/scripts/concat.js +++ b/public/react/src/scripts/concat.js @@ -97,3 +97,51 @@ return; // var uglified = uglify.minify(['file1.js', 'file2.js', 'file3.js']); + + +/** + 优化 + underscore被单独加载了,去掉'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\underscore.min.js', + marked + raphaeljs sequence diagrams 1.0.4 + + + 统计 js_min_all加载的js: + https://github.com/paulmillr/es6-shim + jQuery v1.8.3 jquery.com + Underscore.js 1.8.2 + marked v0.3.3 + ??? + Raphaël 2.1.3 - JavaScript Vector Library + flowchart, v1.3.4 + editormd.js + CodeMirror + cm active-line.js + cm mode javascript + cm merge.js + CodeMirror addon hint + cm showHint + cm anyword-hint + CodeMirror python + CodeMirror c-like(java) + CodeMirror matchbrackets + + + + ???——> + // Copyright (C) 2006 Google Inc. + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + + */ \ No newline at end of file From 53379b34877b56348b65521f86e6fb1a30650f47 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 13:44:55 +0800 Subject: [PATCH 10/20] css --- .../src/modules/comment/CommentItemMDEditor.js | 17 ++++++++++------- public/react/src/modules/comment/Comments.js | 1 + .../courses/common/comments/CCommentItem.js | 2 +- .../modules/courses/common/courseMessage.css | 4 +++- .../graduation/tasks/Graduationtaskitem.js | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/public/react/src/modules/comment/CommentItemMDEditor.js b/public/react/src/modules/comment/CommentItemMDEditor.js index 3c89d0800..98afa4228 100644 --- a/public/react/src/modules/comment/CommentItemMDEditor.js +++ b/public/react/src/modules/comment/CommentItemMDEditor.js @@ -96,7 +96,7 @@ class CommentItemMDEditor extends Component { } render() { - const { match, history, item, user } = this.props + const { match, history, item, user, buttonText } = this.props if (!item) { return
} @@ -111,7 +111,7 @@ class CommentItemMDEditor extends Component {
From 14a638c34ecd7648aa2b2b7a943ddc8d6be6fac9 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 15:23:39 +0800 Subject: [PATCH 13/20] =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/exercise/new/JudgeEditor.js | 10 +++++----- .../src/modules/courses/exercise/new/MainEditor.js | 6 +++--- .../src/modules/courses/exercise/new/NullEditor.js | 11 ++++++----- .../src/modules/courses/exercise/new/ShixunEditor.js | 2 +- .../src/modules/courses/exercise/new/SingleEditor.js | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/public/react/src/modules/courses/exercise/new/JudgeEditor.js b/public/react/src/modules/courses/exercise/new/JudgeEditor.js index 280faa2e3..586d77ed0 100644 --- a/public/react/src/modules/courses/exercise/new/JudgeEditor.js +++ b/public/react/src/modules/courses/exercise/new/JudgeEditor.js @@ -56,23 +56,23 @@ class SingleEditor extends Component{ const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1); if(!question_title) { this.refs['titleEditor'].showError() - this.props.showNotification('题目不能为空'); return; + this.props.showNotification('题目:不能为空'); return; } const intScore = parseFloat(question_score) if(!question_score || intScore == NaN) { - this.props.showNotification('分值不能为空'); return; + this.props.showNotification('分值:不能为空'); return; } else { if (intScore == 0) { - this.props.showNotification('分值必须大于0'); return; + this.props.showNotification('分值:必须大于0'); return; } } if(!answerArray || answerArray.length == 0) { - this.props.showNotification('请先点击本题的正确选项'); return; + this.props.showNotification('必须设置标准答案'); return; } if(!question_title) { this.refs['titleEditor'].showError() - this.props.showNotification('题目不能为空'); return; + this.props.showNotification('题目:不能为空'); return; } diff --git a/public/react/src/modules/courses/exercise/new/MainEditor.js b/public/react/src/modules/courses/exercise/new/MainEditor.js index 9f6e643df..e9dd3b105 100644 --- a/public/react/src/modules/courses/exercise/new/MainEditor.js +++ b/public/react/src/modules/courses/exercise/new/MainEditor.js @@ -46,16 +46,16 @@ class MainEditor extends Component{ const answerArray = standard_answers if(!question_title) { this.refs['titleEditor'].showError() - this.props.showNotification('题目不能为空'); return; + this.props.showNotification('题目:不能为空'); return; } const intScore = parseFloat(question_score) if(!question_score || intScore == NaN) { - this.props.showNotification('分值不能为空'); return; + this.props.showNotification('分值:不能为空'); return; } else { if (intScore == 0) { - this.props.showNotification('分值必须大于0'); return; + this.props.showNotification('分值:必须大于0'); return; } } // if(!answerArray || answerArray.length == 0 || !answerArray[0]) { diff --git a/public/react/src/modules/courses/exercise/new/NullEditor.js b/public/react/src/modules/courses/exercise/new/NullEditor.js index dddadcf0a..299daf904 100644 --- a/public/react/src/modules/courses/exercise/new/NullEditor.js +++ b/public/react/src/modules/courses/exercise/new/NullEditor.js @@ -70,15 +70,15 @@ class NullEditor extends Component{ let answerArray = [] if(!question_title) { this.refs['titleEditor'].showError() - this.props.showNotification('题目不能为空'); return; + this.props.showNotification('题目:不能为空'); return; } const intScore = parseFloat(question_score) if(!question_score || intScore == NaN) { - this.props.showNotification('分值不能为空'); return; + this.props.showNotification('分值:不能为空'); return; } else { if (intScore == 0) { - this.props.showNotification('分值必须大于0'); return; + this.props.showNotification('分值:必须大于0'); return; } } let isEmpty = false; @@ -91,7 +91,8 @@ class NullEditor extends Component{ answerArray[index].answer_text.push(item) if(!item) { this.refs[`nullChildEditor${index}`].showError(itemIndex) - this.props.showNotification(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`); + // this.props.showNotification(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`); + this.props.showNotification(`答案:不能为空`); isEmpty = true; } }) @@ -101,7 +102,7 @@ class NullEditor extends Component{ } if(!question_title) { this.refs['titleEditor'].showError() - this.props.showNotification('题目不能为空'); return; + this.props.showNotification('题目:不能为空'); return; } diff --git a/public/react/src/modules/courses/exercise/new/ShixunEditor.js b/public/react/src/modules/courses/exercise/new/ShixunEditor.js index 581467257..e4835ee10 100644 --- a/public/react/src/modules/courses/exercise/new/ShixunEditor.js +++ b/public/react/src/modules/courses/exercise/new/ShixunEditor.js @@ -98,7 +98,7 @@ class ShixunEditor extends Component{ // } for(let _i = 0; _i < question_scores.length; _i++) { if (!question_scores[_i] || question_scores[_i] == '0') { - this.props.showNotification(`第${_i+1}题的分值必须大于0`); return; + this.props.showNotification(`第${_i+1}题的分值:必须大于0`); return; } } diff --git a/public/react/src/modules/courses/exercise/new/SingleEditor.js b/public/react/src/modules/courses/exercise/new/SingleEditor.js index a9e8aa3f5..8e68a593c 100644 --- a/public/react/src/modules/courses/exercise/new/SingleEditor.js +++ b/public/react/src/modules/courses/exercise/new/SingleEditor.js @@ -88,7 +88,7 @@ class SingleEditor extends Component{ const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1); if(!question_title) { this.refs['titleEditor'].showError() - this.props.showNotification('题目不能为空'); return; + this.props.showNotification('题目:不能为空'); return; } @@ -105,7 +105,7 @@ class SingleEditor extends Component{ } if(!question_title) { this.refs['titleEditor'].showError() - this.props.showNotification('题目不能为空'); return; + this.props.showNotification('题目:不能为空'); return; } From 9cda4635ddcce5685e2fc89128b70b2c11f09599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 29 Jun 2019 16:08:48 +0800 Subject: [PATCH 14/20] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/comment/CommentsHOC.js | 1236 +++++++++-------- .../courses/coursesPublic/Addcourses.js | 23 +- .../exercise/Testpapersettinghomepage.js | 2 + .../graduation/tasks/GraduationTasksedit.js | 7 +- .../tasks/GraduationTaskssetting.js | 6 +- .../tasks/GraduationTaskssettinglist.js | 83 +- .../shixunHomework/ShixunStudentWork.js | 90 +- public/react/src/modules/tpm/SiderBar.js | 2 +- 8 files changed, 754 insertions(+), 695 deletions(-) diff --git a/public/react/src/modules/comment/CommentsHOC.js b/public/react/src/modules/comment/CommentsHOC.js index 4cdd852b4..cc5be1654 100644 --- a/public/react/src/modules/comment/CommentsHOC.js +++ b/public/react/src/modules/comment/CommentsHOC.js @@ -1,613 +1,625 @@ -import React from 'react' -import ReactDOM from 'react-dom' -import axios from 'axios' -import update from 'immutability-helper' - -import ImageLayer from '../page/layers/ImageLayer' - -const $ = window.$ -/* 需要的props: - shixun - id - myshixun - id - challenge - id - user - "image_url": user.image_url, - "username": user.username, - showSnackbar - - */ -/* - 这里提供props给WrappedComponent,用于封装特定的state和功能(评论列表) - 不要直接使用this.xxx调用WrappedComponent内的方法,尽量避免互相依赖,封装好后供不同场景使用(tpi、tpm) -*/ -export function commentHOC(WrappedComponent) { - // 这里如果extends WrappedComponent 会出现 WrappedComponent mount twice的问题 - return class II extends React.Component { - constructor(props) { - super(props) - - // ------------------------------------ - this.createNewComment = this.createNewComment.bind(this) - this.fetchCommentIfNotFetched = this.fetchCommentIfNotFetched.bind(this) - this.replyComment = this.replyComment.bind(this) - this.deleteComment = this.deleteComment.bind(this) - this.commentPraise = this.commentPraise.bind(this) - this.hiddenComment = this.hiddenComment.bind(this) - this.rewardCode = this.rewardCode.bind(this) - this.showNewReply = this.showNewReply.bind(this) - this.newMessage = this.newMessage.bind(this) - // ------------------------------------ - - this.onPaginationChange = this.onPaginationChange.bind(this) - - this.state = { - // 评论 - comments: [], - comment_count_without_reply: 0, - // 默认pageSize为10 - currentPage: 1, - loadingComments: true, - - // 图片最大化 - showImage: false, - imageSrc: '', - } - } - - // ----------------------------------------------------------------------------------------------评论 Start - - // ----------------------------------------------------------------------------------------------评论 Start - onPaginationChange(page) { - this.fetchComment(page) - this.setState({ - currentPage: page, - }); - } - /* - email: "1843820944@qq.com" - grade: 2138 - image_url: "avatar/User/36497" - login: "p24891375" - name: "杨俊男" - user_url: "/users/p24891375" -*/ - handleComments(comments, responseData) { - comments.forEach(element => { - if (element.children) { - this.handleComments(element.children, responseData) - } - element.admin = responseData.all - element.manager = element.manage - - element.username = element.author.name - element.user_login = element.author.login - element.image_url = element.author.image_url - element.user_id = element.author.user_id - - }); - } - responseDataParse(response) { - const comments = response.data.comments - this.handleComments(comments, response.data) - } - fetchComment(page = 1) { - const { challenge, shixun, match } = this.props; - // const url = `/api/v1/shixuns/${shixun.id}/shixun_discusses?page=${page-1}&container_type=Shixun` - const url = - `/discusses.json?page=${page-1}&container_identifier=${shixun && shixun.identifier ? - shixun.identifier : match.params.shixunId}&container_type=Shixun` - - this.setState({ - loadingComments: true, - }); - - // test - // if (true) { - if (false) { - var data = {"children_list":[{"id":1165,"content":"\u7535\u8111\u6ca1\u6709pi\u554a","time":"4\u5929\u524d","position":2,"user_id":31542,"reward":null,"image_url":"avatars/User/b","username":"\u8d75\u94f6\u7fd4","user_login":"p81572036","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":null},{"id":1142,"content":"\u6700\u540e\u4e00\u9898\u4e09\u5929\u6253\u9c7c\uff0c\u4e24\u5929\u6652\u7f51\uff0c\u4e0d\u5e94\u8be5\u662f1.01*1.01*1.01*0.99*0.99\uff0c\u800c\u4e0d\u662f\u52a0\u5417\uff1f","time":"4\u5929\u524d","position":1,"user_id":33714,"reward":null,"image_url":"avatars/User/b","username":"\u843d\u5c18","user_login":"p52769048","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":[{"content":"\u672c\u5173\u5e76\u6ca1\u6709\u5199\u5230\u201c1.01*1.01*1.01*0.99*0.99\u201d\uff0c\u4e0d\u77e5\u9053\u4f55\u6765\u6b64\u95ee\uff1f","time":"4\u5929\u524d","position":1,"reward":null,"image_url":"avatars/User/1","username":"Coder","user_id":1,"user_login":"innov","can_delete":false,"id":1144}]},{"id":1112,"content":"\u8fd9\u4e2a\u5b9e\u8bad\u5f88\u8d5e\uff01","time":"10\u5929\u524d","position":2,"user_id":12,"reward":null,"image_url":"avatars/User/12","username":"\u9ec4\u4e95\u6cc9","user_login":"Hjqreturn","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":null},{"id":1057,"content":"\u4e0d\u9519","time":"20\u5929\u524d","position":2,"user_id":30403,"reward":null,"image_url":"avatars/User/b","username":"Jimmy","user_login":"p69243850","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":null},{"id":975,"content":"q","time":"1\u4e2a\u6708\u524d","position":2,"user_id":30403,"reward":null,"image_url":"avatars/User/b","username":"Jimmy","user_login":"p69243850","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":[{"content":"\u4e0b\u6b21\u518d\u53d1\u65e0\u610f\u4e49\u7684\u5185\u5bb9\uff0c\u5c06\u88ab\u6263\u91d1\u5e01\u54e6","time":"1\u4e2a\u6708\u524d","position":2,"reward":null,"image_url":"avatars/User/1","username":"Coder","user_id":1,"user_login":"innov","can_delete":false,"id":980}]},{"id":974,"content":"k","time":"1\u4e2a\u6708\u524d","position":2,"user_id":30403,"reward":null,"image_url":"avatars/User/b","username":"Jimmy","user_login":"p69243850","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":[{"content":"\u4e0b\u6b21\u518d\u53d1\u65e0\u610f\u4e49\u7684\u5185\u5bb9\uff0c\u5c06\u88ab\u6263\u91d1\u5e01\u54e6","time":"1\u4e2a\u6708\u524d","position":2,"reward":null,"image_url":"avatars/User/1","username":"Coder","user_id":1,"user_login":"innov","can_delete":false,"id":981}]},{"id":859,"content":"\u5f88\u68d2\uff01\uff01\uff01","time":"1\u4e2a\u6708\u524d","position":4,"user_id":1,"reward":null,"image_url":"avatars/User/1","username":"Coder","user_login":"innov","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":null},{"id":802,"content":"\u4e0d\u9519\uff01","time":"2\u4e2a\u6708\u524d","position":1,"user_id":30403,"reward":null,"image_url":"avatars/User/b","username":"Jimmy","user_login":"p69243850","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":null},{"id":619,"content":"\u770b\u6765\u8001\u5e08\u5bf9\u9f50\u7528\u7684\u90fd\u662f\u7a7a\u683c","time":"5\u4e2a\u6708\u524d","position":3,"user_id":29145,"reward":null,"image_url":"avatars/User/b","username":"yang","user_login":"m02945638","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":null},{"id":553,"content":"

\r\n\t666\r\n

\r\n

\r\n\t
\r\n

","time":"6\u4e2a\u6708\u524d","position":4,"user_id":26838,"reward":null,"image_url":"avatars/User/b","username":"\u5189\u529b","user_login":"m54013296","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":null}],"disscuss_count":183} - - this.setState({ - comments: data.children_list, - comment_count_without_reply: data.disscuss_count, - - currentPage: page, - loadingComments: false, - }) - return; - } - - axios.get(url, - { - // withCredentials: true - } - ).then((response) => { - // test - - if (response.data) { - this.responseDataParse(response) - this.setState({ - comments: response.data.comments, - comment_count_without_reply: response.data.disscuss_count, - - currentPage: page, - loadingComments: false, - }, ()=>{ - // keditor代码美化 - window.prettyPrint() - }) - } - // console.log(response) - }).catch((error) => { - console.log(error) - }) - } - // 切换关卡时,清空state - clearCommentsInState = () => { - this.setState({ comments: [] }) - } - fetchCommentIfNotFetched() { - if (this.state.comments && this.state.comments.length) { - return; - } - - // http://localhost:3000/api/v1/shixuns/cz7yw3en/shixun_discusses?page=0 - - this.fetchComment(); - } - // 新增父级评论 - createNewComment() { - console.log('createNewComment...') - - const { challenge, shixun, showSnackbar } = this.props; - let content = window._commentInput.html(); - if (!content || content.length === 0) { - showSnackbar('必须填写内容!') - return; - } - - // const url = `/api/v1/discusses` - const url = `/discusses.json` - - if(content != undefined){ - var beforeImage = content.split(""); - if(beforeImage[0] == "" && afterImage[1] == ""){ - window.notice_box('不支持纯图片评论
请在评论中增加文字信息'); - return; - } - } - - $("#new_message_submit_btn_" + this.props.challenge.shixun_id).hide(); - - if (content) { // 去掉尾部的回车换行 - content = content.replace(/(\n

\n\t
\n<\/p>)*$/g,''); - } - - axios.post(url, { - container_type: "Shixun", - container_id: shixun.id, - challenge_id: challenge.id, - content, - position: challenge.position - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data.discuss) { - - window._commentInput.html(''); - window._commentInput.afterBlur() - // this.setState({ - // runTesting: false, - // }) - this.fetchComment() - } - console.log(response) - }).catch((error) => { - console.log(error) - }) - return true; - } - _findCommentById(id, arg_comments) { - let comments; - if (!arg_comments) { - comments = this.state.comments; - } else { - comments = arg_comments; - } - for(let i = 0; i < comments.length; i++) { - if (id === comments[i].id) { - return i; - } - } - } - replyComment(commentContent, id, editor) { - // http://localhost:3000/api/v1/discusses/812/reply - const { challenge, shixun, user, showSnackbar, match } = this.props; - - if (!commentContent || commentContent.length === 0) { - showSnackbar('必须填写内容!') - return; - } - // const url = `/api/v1/discusses/${id}/reply` - const url = `/discusses/${id}/reply.json` - if (commentContent) { - commentContent = commentContent.replace(/(\n

\n\t
\n<\/p>)*$/g,''); - } - if (!user.login && user.user_url) { - const loginAr = user.user_url.split('/') - user.login = loginAr[loginAr.length - 1] - } - axios.post(url, { - content: commentContent, - // TODO - "container_id": match.params.shixunId, - "container_type": "Shixun", - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data.discuss) { - let newDiscuss = response.data.discuss; - let { comments } = this.state; - var commentIndex = this._findCommentById(id); - let comment = comments[commentIndex] - comment = Object.assign({}, comment) - if (!comment.children ) { - comment.children = [] - } else { - comment.children = comment.children.slice(0); - } - // TODO userName iamge_url - comment.children.push( { - "can_delete": true, - "content": commentContent, - - "image_url": user.image_url, - "username": user.username, - "user_login": user.login, - "id": newDiscuss.id, - "position": newDiscuss.position, - "time": "1分钟前", - "praise_count": newDiscuss.praise_count, - - "user_id": newDiscuss.user_id, - - }) - - comments = comments.slice(0) - comments[commentIndex] = comment - - // ke - editor.html && editor.html('') - // md - if (editor.setValue) { - editor.setValue('') - const $ = window.$ - var view_selector = `.commentItemMDEditorView_${id}` - $(view_selector).hide(); - } - - - this.setState({ - // runTesting: false, - comments: comments - }, ()=>{ - // keditor代码美化 - editor.html && window.prettyPrint() - }) - } - console.log(response) - }).catch((error) => { - console.log(error) - }) - } - hiddenComment(item, childCommentId) { - const id = item.id - const { challenge, shixun, user, showSnackbar, match } = this.props; - // const url = `/api/v1/discusses/${id}/hidden` - const url = `/discusses/${id}/hidden.json` - - const commentIndex = this._findCommentById(id); - const { comments } = this.state; - const comment = Object.assign({}, comments[commentIndex]); - axios.post(url, { - hidden: !comment.hidden ? "1" : "0", - container_identifier: match.params.shixunId || shixun.identifier - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data.status === -1) { - showSnackbar(response.data.message) - return; - } - if (response.data.status === 1) { - - if (!childCommentId) { - comment.hidden = !comment.hidden; - const commentsCopy = this.state.comments.slice(0) - commentsCopy[commentIndex] = comment - this.setState({ - comments: commentsCopy - }) - } else { // TODO 目前子回复没hidden字段 - let childCommentIndex = this._findCommentById(childCommentId, comments[commentIndex].children); - const childComment = comments[commentIndex].children[childCommentIndex] - childComment.hidden = !childComment.hidden; - this.setState({ comments }) - } - - } - // {"message":"Couldn't find Discuss with id=911","status":-1} - console.log(response) - }).catch((error) => { - console.log(error) - }) - } - deleteComment(parrentComment, childCommentId) { - const { challenge, shixun } = this.props; - let deleteCommentId = parrentComment.id - if (childCommentId) { - deleteCommentId = childCommentId; - } - // const url = `/api/v1/discusses/${deleteCommentId}` - const url = `/discusses/${deleteCommentId}.json` - - axios.delete(url, - { - // withCredentials: true - } - ).then((response) => { - // TODO 删除成功或失败 - if (response.data && response.data.status === 1) { - const commentIndex = this._findCommentById(parrentComment.id); - - // https://stackoverflow.com/questions/29527385/removing-element-from-array-in-component-state - if (!childCommentId) { - this.setState((prevState) => ({ - comments: update(prevState.comments, {$splice: [[commentIndex, 1]]}) - })) - - if (this.state.comments.length <= 5) { - this.fetchComment() - } - } else { - let comments = this.state.comments; - let newComments = Object.assign({}, comments) - let childCommentIndex = this._findCommentById(childCommentId, newComments[commentIndex].children); - newComments[commentIndex].children = update(newComments[commentIndex].children, {$splice: [[childCommentIndex, 1]]}) - this.setState({ newComments }) - } - } - console.log(response) - }).catch((error) => { - console.log(error) - }) - } - - rewardCode(parrentComment, childComment, amount) { - const { challenge, shixun, showSnackbar } = this.props; - let handleComment = parrentComment - if (childComment) { - handleComment = childComment; - } - let handleCommentId = handleComment.id; - // const url = `/api/v1/discusses/${handleCommentId}/reward_code` - const url = `/discusses/${handleCommentId}/reward_code.json` - - axios.post(url, { - // id: handleCommentId, - - // container_id: shixun.id, - container_type: 'Discusses', - score: amount, - user_id: handleComment.user_id - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data && response.data.code) { - const commentIndex = this._findCommentById(parrentComment.id); - let { comments } = this.state; - const newComments = comments.slice(0) - - if (childComment) { - const childCommentIndex = this._findCommentById(handleComment.id, parrentComment.children); - const newChildComment = Object.assign({}, childComment); - newChildComment.reward = response.data.code - parrentComment = Object.assign({}, parrentComment) - parrentComment.children = parrentComment.children.slice(0) - parrentComment.children[childCommentIndex] = newChildComment - - newComments[commentIndex] = parrentComment; - - - } else { - const newComment = Object.assign({}, newComments[commentIndex]); - newComment.reward = response.data.code; - newComments[commentIndex] = newComment; - } - this.setState({ - comments: newComments - }) - } - }).catch((error) => { - console.log(error) - showSnackbar('奖励失败,请联系系统管理员!') - }) - } - - // 评论点赞 - commentPraise(discussId) { - const commentIndex = this._findCommentById(discussId); - const { comments } = this.state; - - const { challenge } = this.props; - // const url = `/api/v1/discusses/${discussId}/plus` - const url = `/discusses/${discussId}/plus.json` - axios.post(url, { - // id: discussId, - // container_id: challenge.id, - container_type: 'Discuss', //Discuss - type: comments[commentIndex].user_praise === true ? 0 : 1, // "踩0;赞1" - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data.praise_count === 0 || response.data.praise_count) { - const newComments = comments.slice(0) - const comment = Object.assign({}, newComments[commentIndex]) - comment.user_praise = !comment.user_praise; - comment.praise_count = response.data.praise_count; - newComments[commentIndex] = comment; - this.setState({ - comments: newComments - }) - } - console.log(response) - }).catch((error) => { - console.log(error) - }) - } - - newMessage() { - return; // newMessage 暂时不用了 - const { shixun, myshixun } = this.props; - const url = `/api/v1/shixuns/${shixun.id}/new_message?container_type=Shixun&myshixun_id=${myshixun.id}` - // this.setState({ - // gotNewReply: true - // }) - axios.get(url, - { - // withCredentials: true - } - ).then((response) => { - const new_message = response.data.new_message; - if (response.data.new_message) { - this.setState({ - gotNewReply: new_message - }) - } - // console.log(response) - }).catch((error) => { - console.log(error) - }) - } - - showNewReply() { - const { shixun, myshixun } = this.props; - const commentId = 929 // TODO - const url = `/api/v1/shixuns/${shixun.id}/anchor?container_type=Shixun&myshixun_id=${myshixun.id}&discuss_id=${commentId}` - - this.setState({ - loadingComments: true, - gotNewReply: false, - - }); - axios.get(url, - { - // withCredentials: true - } - ).then((response) => { - const data = response.data; - const new_message = data.new_message; - - this.setState({ - comments: data.children_list, - comment_count_without_reply: data.disscuss_count, - - currentPage: data.page, - loadingComments: false, - - }, () => { - if (response.data.find_status) { // 没找到评论的话,默认会返回第一页的评论 - const comment_J = window.$(`#reply_content_${commentId}`); - if (comment_J.length) { - comment_J[0].scrollIntoView() - comment_J.parents('.comment_item_cont').css('border', '1px solid #4CACFF') - } - } - }) - console.log(response) - }).catch((error) => { - console.log(error) - }) - } - - // ----------------------------------------------------------------------------------------------评论 End - - // ----------------------------------------------------------------------------------------------评论 End - - componentDidMount() { - // commentsDelegateParent #game_left_contents #tab_con_4 - $(".commentsDelegateParent") - .delegate(".J_Comment_Reply .comment_content img, .J_Comment_Reply .childrenCommentsView img","click", (event) => { - - const imageSrc = event.target.src - // 非回复里的头像图片; 非emoticons - if (imageSrc.indexOf('/images/avatars/User') === -1 && - imageSrc.indexOf('kindeditor/plugins/emoticons') === -1 ) { - this.setState({ - showImage: true, - imageSrc, - }) - } - }); - } - onImageLayerClose = () => { - this.setState({ - showImage: false, - imageSrc: '', - }) - } - render() { - return ( - - - - - - - ) - } - } -} -/* -

-

- HOC Debugger Component -

-

- Props -

-
{stringify(this.props)}
-

- State -

-
{stringify(this.state)}
- {super.render()} -
- +import React from 'react' +import ReactDOM from 'react-dom' +import axios from 'axios' +import { notification } from 'antd' +import update from 'immutability-helper' + +import ImageLayer from '../page/layers/ImageLayer' + +const $ = window.$ +/* 需要的props: + shixun + id + myshixun + id + challenge + id + user + "image_url": user.image_url, + "username": user.username, + showSnackbar + + */ +/* + 这里提供props给WrappedComponent,用于封装特定的state和功能(评论列表) + 不要直接使用this.xxx调用WrappedComponent内的方法,尽量避免互相依赖,封装好后供不同场景使用(tpi、tpm) +*/ +export function commentHOC(WrappedComponent) { + // 这里如果extends WrappedComponent 会出现 WrappedComponent mount twice的问题 + return class II extends React.Component { + constructor(props) { + super(props) + + // ------------------------------------ + this.createNewComment = this.createNewComment.bind(this) + this.fetchCommentIfNotFetched = this.fetchCommentIfNotFetched.bind(this) + this.replyComment = this.replyComment.bind(this) + this.deleteComment = this.deleteComment.bind(this) + this.commentPraise = this.commentPraise.bind(this) + this.hiddenComment = this.hiddenComment.bind(this) + this.rewardCode = this.rewardCode.bind(this) + this.showNewReply = this.showNewReply.bind(this) + this.newMessage = this.newMessage.bind(this) + // ------------------------------------ + + this.onPaginationChange = this.onPaginationChange.bind(this) + + this.state = { + // 评论 + comments: [], + comment_count_without_reply: 0, + // 默认pageSize为10 + currentPage: 1, + loadingComments: true, + + // 图片最大化 + showImage: false, + imageSrc: '', + } + } + + // ----------------------------------------------------------------------------------------------评论 Start + + // ----------------------------------------------------------------------------------------------评论 Start + onPaginationChange(page) { + this.fetchComment(page) + this.setState({ + currentPage: page, + }); + } + /* + email: "1843820944@qq.com" + grade: 2138 + image_url: "avatar/User/36497" + login: "p24891375" + name: "杨俊男" + user_url: "/users/p24891375" +*/ + handleComments(comments, responseData) { + comments.forEach(element => { + if (element.children) { + this.handleComments(element.children, responseData) + } + element.admin = responseData.all + element.manager = element.manage + + element.username = element.author.name + element.user_login = element.author.login + element.image_url = element.author.image_url + element.user_id = element.author.user_id + + }); + } + responseDataParse(response) { + const comments = response.data.comments + this.handleComments(comments, response.data) + } + fetchComment(page = 1) { + const { challenge, shixun, match } = this.props; + // const url = `/api/v1/shixuns/${shixun.id}/shixun_discusses?page=${page-1}&container_type=Shixun` + const url = + `/discusses.json?page=${page-1}&container_identifier=${shixun && shixun.identifier ? + shixun.identifier : match.params.shixunId}&container_type=Shixun` + + this.setState({ + loadingComments: true, + }); + + // test + // if (true) { + if (false) { + var data = {"children_list":[{"id":1165,"content":"\u7535\u8111\u6ca1\u6709pi\u554a","time":"4\u5929\u524d","position":2,"user_id":31542,"reward":null,"image_url":"avatars/User/b","username":"\u8d75\u94f6\u7fd4","user_login":"p81572036","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":null},{"id":1142,"content":"\u6700\u540e\u4e00\u9898\u4e09\u5929\u6253\u9c7c\uff0c\u4e24\u5929\u6652\u7f51\uff0c\u4e0d\u5e94\u8be5\u662f1.01*1.01*1.01*0.99*0.99\uff0c\u800c\u4e0d\u662f\u52a0\u5417\uff1f","time":"4\u5929\u524d","position":1,"user_id":33714,"reward":null,"image_url":"avatars/User/b","username":"\u843d\u5c18","user_login":"p52769048","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":[{"content":"\u672c\u5173\u5e76\u6ca1\u6709\u5199\u5230\u201c1.01*1.01*1.01*0.99*0.99\u201d\uff0c\u4e0d\u77e5\u9053\u4f55\u6765\u6b64\u95ee\uff1f","time":"4\u5929\u524d","position":1,"reward":null,"image_url":"avatars/User/1","username":"Coder","user_id":1,"user_login":"innov","can_delete":false,"id":1144}]},{"id":1112,"content":"\u8fd9\u4e2a\u5b9e\u8bad\u5f88\u8d5e\uff01","time":"10\u5929\u524d","position":2,"user_id":12,"reward":null,"image_url":"avatars/User/12","username":"\u9ec4\u4e95\u6cc9","user_login":"Hjqreturn","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":null},{"id":1057,"content":"\u4e0d\u9519","time":"20\u5929\u524d","position":2,"user_id":30403,"reward":null,"image_url":"avatars/User/b","username":"Jimmy","user_login":"p69243850","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":null},{"id":975,"content":"q","time":"1\u4e2a\u6708\u524d","position":2,"user_id":30403,"reward":null,"image_url":"avatars/User/b","username":"Jimmy","user_login":"p69243850","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":[{"content":"\u4e0b\u6b21\u518d\u53d1\u65e0\u610f\u4e49\u7684\u5185\u5bb9\uff0c\u5c06\u88ab\u6263\u91d1\u5e01\u54e6","time":"1\u4e2a\u6708\u524d","position":2,"reward":null,"image_url":"avatars/User/1","username":"Coder","user_id":1,"user_login":"innov","can_delete":false,"id":980}]},{"id":974,"content":"k","time":"1\u4e2a\u6708\u524d","position":2,"user_id":30403,"reward":null,"image_url":"avatars/User/b","username":"Jimmy","user_login":"p69243850","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":[{"content":"\u4e0b\u6b21\u518d\u53d1\u65e0\u610f\u4e49\u7684\u5185\u5bb9\uff0c\u5c06\u88ab\u6263\u91d1\u5e01\u54e6","time":"1\u4e2a\u6708\u524d","position":2,"reward":null,"image_url":"avatars/User/1","username":"Coder","user_id":1,"user_login":"innov","can_delete":false,"id":981}]},{"id":859,"content":"\u5f88\u68d2\uff01\uff01\uff01","time":"1\u4e2a\u6708\u524d","position":4,"user_id":1,"reward":null,"image_url":"avatars/User/1","username":"Coder","user_login":"innov","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":null},{"id":802,"content":"\u4e0d\u9519\uff01","time":"2\u4e2a\u6708\u524d","position":1,"user_id":30403,"reward":null,"image_url":"avatars/User/b","username":"Jimmy","user_login":"p69243850","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":null},{"id":619,"content":"\u770b\u6765\u8001\u5e08\u5bf9\u9f50\u7528\u7684\u90fd\u662f\u7a7a\u683c","time":"5\u4e2a\u6708\u524d","position":3,"user_id":29145,"reward":null,"image_url":"avatars/User/b","username":"yang","user_login":"m02945638","shixun_id":61,"hidden":false,"manager":false,"praise_count":1,"user_praise":false,"admin":false,"children":null},{"id":553,"content":"

\r\n\t666\r\n

\r\n

\r\n\t
\r\n

","time":"6\u4e2a\u6708\u524d","position":4,"user_id":26838,"reward":null,"image_url":"avatars/User/b","username":"\u5189\u529b","user_login":"m54013296","shixun_id":61,"hidden":false,"manager":false,"praise_count":0,"user_praise":false,"admin":false,"children":null}],"disscuss_count":183} + + this.setState({ + comments: data.children_list, + comment_count_without_reply: data.disscuss_count, + + currentPage: page, + loadingComments: false, + }) + return; + } + + axios.get(url, + { + // withCredentials: true + } + ).then((response) => { + // test + + if (response.data) { + this.responseDataParse(response) + this.setState({ + comments: response.data.comments, + comment_count_without_reply: response.data.disscuss_count, + + currentPage: page, + loadingComments: false, + }, ()=>{ + // keditor代码美化 + window.prettyPrint() + }) + } + // console.log(response) + }).catch((error) => { + console.log(error) + }) + } + // 切换关卡时,清空state + clearCommentsInState = () => { + this.setState({ comments: [] }) + } + fetchCommentIfNotFetched() { + if (this.state.comments && this.state.comments.length) { + return; + } + + // http://localhost:3000/api/v1/shixuns/cz7yw3en/shixun_discusses?page=0 + + this.fetchComment(); + } + // 新增父级评论 + createNewComment() { + console.log('createNewComment...') + + const { challenge, shixun, showSnackbar } = this.props; + let content = window._commentInput.html(); + if (!content || content.length === 0) { + showSnackbar('必须填写内容!') + return; + } + + // const url = `/api/v1/discusses` + const url = `/discusses.json` + + if(content != undefined){ + var beforeImage = content.split(""); + if(beforeImage[0] == "" && afterImage[1] == ""){ + window.notice_box('不支持纯图片评论
请在评论中增加文字信息'); + return; + } + } + + $("#new_message_submit_btn_" + this.props.challenge.shixun_id).hide(); + + if (content) { // 去掉尾部的回车换行 + content = content.replace(/(\n

\n\t
\n<\/p>)*$/g,''); + } + + axios.post(url, { + container_type: "Shixun", + container_id: shixun.id, + challenge_id: challenge.id, + content, + position: challenge.position + }, + { + // withCredentials: true + } + ).then((response) => { + if (response.data.discuss) { + + window._commentInput.html(''); + window._commentInput.afterBlur() + // this.setState({ + // runTesting: false, + // }) + this.fetchComment() + } + console.log(response) + }).catch((error) => { + console.log(error) + }) + return true; + } + _findCommentById(id, arg_comments) { + let comments; + if (!arg_comments) { + comments = this.state.comments; + } else { + comments = arg_comments; + } + for(let i = 0; i < comments.length; i++) { + if (id === comments[i].id) { + return i; + } + } + } + replyComment(commentContent, id, editor) { + // http://localhost:3000/api/v1/discusses/812/reply + const { challenge, shixun, user, showSnackbar, match } = this.props; + + if (!commentContent || commentContent.length === 0) { + showSnackbar('必须填写内容!') + return; + } + // const url = `/api/v1/discusses/${id}/reply` + const url = `/discusses/${id}/reply.json` + if (commentContent) { + commentContent = commentContent.replace(/(\n

\n\t
\n<\/p>)*$/g,''); + } + if (!user.login && user.user_url) { + const loginAr = user.user_url.split('/') + user.login = loginAr[loginAr.length - 1] + } + axios.post(url, { + content: commentContent, + // TODO + "container_id": match.params.shixunId, + "container_type": "Shixun", + }, + { + // withCredentials: true + } + ).then((response) => { + if (response.data.discuss) { + let newDiscuss = response.data.discuss; + let { comments } = this.state; + var commentIndex = this._findCommentById(id); + let comment = comments[commentIndex] + comment = Object.assign({}, comment) + if (!comment.children ) { + comment.children = [] + } else { + comment.children = comment.children.slice(0); + } + // TODO userName iamge_url + comment.children.push( { + "can_delete": true, + "content": commentContent, + + "image_url": user.image_url, + "username": user.username, + "user_login": user.login, + "id": newDiscuss.id, + "position": newDiscuss.position, + "time": "1分钟前", + "praise_count": newDiscuss.praise_count, + + "user_id": newDiscuss.user_id, + + }) + + comments = comments.slice(0) + comments[commentIndex] = comment + + // ke + editor.html && editor.html('') + // md + if (editor.setValue) { + editor.setValue('') + const $ = window.$ + var view_selector = `.commentItemMDEditorView_${id}` + $(view_selector).hide(); + } + + + this.setState({ + // runTesting: false, + comments: comments + }, ()=>{ + // keditor代码美化 + editor.html && window.prettyPrint() + }) + } + console.log(response) + }).catch((error) => { + console.log(error) + }) + } + hiddenComment(item, childCommentId) { + const id = item.id + const { challenge, shixun, user, showSnackbar, match } = this.props; + // const url = `/api/v1/discusses/${id}/hidden` + const url = `/discusses/${id}/hidden.json` + + const commentIndex = this._findCommentById(id); + const { comments } = this.state; + const comment = Object.assign({}, comments[commentIndex]); + axios.post(url, { + hidden: !comment.hidden ? "1" : "0", + container_identifier: match.params.shixunId || shixun.identifier + }, + { + // withCredentials: true + } + ).then((response) => { + if (response.data.status === -1) { + showSnackbar(response.data.message) + return; + } + if (response.data.status === 1) { + + if (!childCommentId) { + comment.hidden = !comment.hidden; + const commentsCopy = this.state.comments.slice(0) + commentsCopy[commentIndex] = comment + this.setState({ + comments: commentsCopy + }) + } else { // TODO 目前子回复没hidden字段 + let childCommentIndex = this._findCommentById(childCommentId, comments[commentIndex].children); + const childComment = comments[commentIndex].children[childCommentIndex] + childComment.hidden = !childComment.hidden; + this.setState({ comments }) + } + + } + // {"message":"Couldn't find Discuss with id=911","status":-1} + console.log(response) + }).catch((error) => { + console.log(error) + }) + } + deleteComment(parrentComment, childCommentId) { + const { challenge, shixun } = this.props; + let deleteCommentId = parrentComment.id + if (childCommentId) { + deleteCommentId = childCommentId; + } + // const url = `/api/v1/discusses/${deleteCommentId}` + const url = `/discusses/${deleteCommentId}.json` + + axios.delete(url, + { + // withCredentials: true + } + ).then((response) => { + // TODO 删除成功或失败 + if (response.data && response.data.status === 1) { + const commentIndex = this._findCommentById(parrentComment.id); + + // https://stackoverflow.com/questions/29527385/removing-element-from-array-in-component-state + if (!childCommentId) { + this.setState((prevState) => ({ + comments: update(prevState.comments, {$splice: [[commentIndex, 1]]}) + })) + + if (this.state.comments.length <= 5) { + this.fetchComment() + } + } else { + let comments = this.state.comments; + let newComments = Object.assign({}, comments) + let childCommentIndex = this._findCommentById(childCommentId, newComments[commentIndex].children); + newComments[commentIndex].children = update(newComments[commentIndex].children, {$splice: [[childCommentIndex, 1]]}) + this.setState({ newComments }) + } + } + console.log(response) + }).catch((error) => { + console.log(error) + }) + } + + rewardCode(parrentComment, childComment, amount) { + const { challenge, shixun, showSnackbar } = this.props; + let handleComment = parrentComment + if (childComment) { + handleComment = childComment; + } + let handleCommentId = handleComment.id; + // const url = `/api/v1/discusses/${handleCommentId}/reward_code` + const url = `/discusses/${handleCommentId}/reward_code.json` + + axios.post(url, { + // id: handleCommentId, + + // container_id: shixun.id, + container_type: 'Discusses', + score: amount, + user_id: handleComment.user_id + }, + { + // withCredentials: true + } + ).then((response) => { + if (response.data && response.data.code) { + const commentIndex = this._findCommentById(parrentComment.id); + let { comments } = this.state; + const newComments = comments.slice(0) + + if (childComment) { + const childCommentIndex = this._findCommentById(handleComment.id, parrentComment.children); + const newChildComment = Object.assign({}, childComment); + newChildComment.reward = response.data.code + parrentComment = Object.assign({}, parrentComment) + parrentComment.children = parrentComment.children.slice(0) + parrentComment.children[childCommentIndex] = newChildComment + + newComments[commentIndex] = parrentComment; + + + } else { + const newComment = Object.assign({}, newComments[commentIndex]); + newComment.reward = response.data.code; + newComments[commentIndex] = newComment; + } + this.setState({ + comments: newComments + }) + } + }).catch((error) => { + console.log(error) + showSnackbar('奖励失败,请联系系统管理员!') + }) + } + + // 评论点赞 + commentPraise(discussId) { + const commentIndex = this._findCommentById(discussId); + const { comments } = this.state; + + const { challenge } = this.props; + // const url = `/api/v1/discusses/${discussId}/plus` + const url = `/discusses/${discussId}/plus.json` + axios.post(url, { + // id: discussId, + // container_id: challenge.id, + container_type: 'Discuss', //Discuss + type: comments[commentIndex].user_praise === true ? 0 : 1, // "踩0;赞1" + }, + { + // withCredentials: true + } + ).then((response) => { + if (response.data.praise_count === 0 || response.data.praise_count) { + const newComments = comments.slice(0) + const comment = Object.assign({}, newComments[commentIndex]) + comment.user_praise = !comment.user_praise; + comment.praise_count = response.data.praise_count; + newComments[commentIndex] = comment; + this.setState({ + comments: newComments + }) + } + console.log(response) + }).catch((error) => { + console.log(error) + }) + } + + newMessage() { + return; // newMessage 暂时不用了 + const { shixun, myshixun } = this.props; + const url = `/api/v1/shixuns/${shixun.id}/new_message?container_type=Shixun&myshixun_id=${myshixun.id}` + // this.setState({ + // gotNewReply: true + // }) + axios.get(url, + { + // withCredentials: true + } + ).then((response) => { + const new_message = response.data.new_message; + if (response.data.new_message) { + this.setState({ + gotNewReply: new_message + }) + } + // console.log(response) + }).catch((error) => { + console.log(error) + }) + } + + showNewReply() { + const { shixun, myshixun } = this.props; + const commentId = 929 // TODO + const url = `/api/v1/shixuns/${shixun.id}/anchor?container_type=Shixun&myshixun_id=${myshixun.id}&discuss_id=${commentId}` + + this.setState({ + loadingComments: true, + gotNewReply: false, + + }); + axios.get(url, + { + // withCredentials: true + } + ).then((response) => { + const data = response.data; + const new_message = data.new_message; + + this.setState({ + comments: data.children_list, + comment_count_without_reply: data.disscuss_count, + + currentPage: data.page, + loadingComments: false, + + }, () => { + if (response.data.find_status) { // 没找到评论的话,默认会返回第一页的评论 + const comment_J = window.$(`#reply_content_${commentId}`); + if (comment_J.length) { + comment_J[0].scrollIntoView() + comment_J.parents('.comment_item_cont').css('border', '1px solid #4CACFF') + } + } + }) + console.log(response) + }).catch((error) => { + console.log(error) + }) + } + + // ----------------------------------------------------------------------------------------------评论 End + + // ----------------------------------------------------------------------------------------------评论 End + + componentDidMount() { + // commentsDelegateParent #game_left_contents #tab_con_4 + $(".commentsDelegateParent") + .delegate(".J_Comment_Reply .comment_content img, .J_Comment_Reply .childrenCommentsView img","click", (event) => { + + const imageSrc = event.target.src + // 非回复里的头像图片; 非emoticons + if (imageSrc.indexOf('/images/avatars/User') === -1 && + imageSrc.indexOf('kindeditor/plugins/emoticons') === -1 ) { + this.setState({ + showImage: true, + imageSrc, + }) + } + }); + } + onImageLayerClose = () => { + this.setState({ + showImage: false, + imageSrc: '', + }) + } + + showNotification = (description, message = "提示", icon) => { + const data = { + message, + description + } + if (icon) { + data.icon = icon; + } + notification.open(data); + } + render() { + return ( + + + + + + + ) + } + } +} +/* +

+

+ HOC Debugger Component +

+

+ Props +

+
{stringify(this.props)}
+

+ State +

+
{stringify(this.state)}
+ {super.render()} +
+ */ \ No newline at end of file diff --git a/public/react/src/modules/courses/coursesPublic/Addcourses.js b/public/react/src/modules/courses/coursesPublic/Addcourses.js index 097d55053..c3e579872 100644 --- a/public/react/src/modules/courses/coursesPublic/Addcourses.js +++ b/public/react/src/modules/courses/coursesPublic/Addcourses.js @@ -1,5 +1,5 @@ import React,{ Component } from "react"; -import { Modal,Checkbox,Input, Spin, Icon } from "antd"; +import { Modal,Checkbox,Input, Spin, Icon,notification } from "antd"; import axios from 'axios'; import Modals from '../../modals/Modals'; const CheckboxGroup = Checkbox.Group; @@ -187,15 +187,26 @@ class Addcourses extends Component{ if(response.data.course_id!=undefined){ this.submitasyn(response.data.course_id) } + notification.open({ + message:"提示", + description:response.data.message + }); this.props.hideAddcoursestype(); - this.props.showNotification(response.data.message); + // this.props.showNotification(response.data.message); + }else{ - this.setState({ - Addcoursestype:false - }) + + notification.open({ + message:"提示", + description:response.data.message + }); + this.setState({ + Addcoursestype:false + }) this.props.hideAddcoursestype(); - this.props.showNotification(response.data.message); + + // this.setState({ // loadtype:true, // modalsType:true, diff --git a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js index 5ba33032c..0dfbed1ab 100644 --- a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js +++ b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js @@ -222,6 +222,8 @@ class Testpapersettinghomepage extends Component{ : 答题列表 + {Commonheadofthetestpaper&&Commonheadofthetestpaper.show_statistic===true? + 统计结果:""} 设置 } diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js index 3c9202921..660ef1c71 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js @@ -33,7 +33,7 @@ class GraduationTasksedit extends Component{ componentDidMount(){ - + let {title_num}=this.state; let tasksid=this.props.match.params.category_id; let url ="/graduation_tasks/"+tasksid+"/edit.json" @@ -52,15 +52,18 @@ class GraduationTasksedit extends Component{ } } - + let namelength=result.data.task_name.length; + let sixlength=title_num-namelength this.setState({ fileList:newfilelist, description:result.data.description, tasktype:result.data.task_type, name:result.data.task_name, data:result.data, + title_num:sixlength }) + this.props.form.setFieldsValue({ tasktype:result.data.task_type, name:result.data.task_name, diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js index b5c34e975..6b5930bc2 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js @@ -1168,7 +1168,8 @@ class GraduationTaskssettingapp extends Component{ value={end_time===null||end_time===""?"":moment(end_time, dateFormat)} onChange={this.onChangeTimeend} disabledTime={disabledDateTime} - disabled={this.props.isSuperAdmin()===true?flagPageEdit===true?false:true:this.props.isAdmin()===true?endtimetype===true?true:flagPageEdit===true?false:true:true} + // disabled={this.props.isSuperAdmin()===true?flagPageEdit===true?false:true:this.props.isAdmin()===true?endtimetype===true?true:flagPageEdit===true?false:true:true} + disabled={this.props.isAdmin()===true?endtimetype===true?true:flagPageEdit===true?false:true:true} className={this.state.endTimetypes===true||end_timetype===true?"noticeTip":""} /> @@ -1251,7 +1252,8 @@ class GraduationTaskssettingapp extends Component{
评分设置
最终成绩组成 (取各教师最终评分的平均分)
- 启用交叉评阅 (给老师分配其他指导老师的学生作品) + 启用交叉评阅 (给老师分配其他指导老师的学生作品) {crosscomment===true?
diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js index 1433319b3..2d205001e 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js @@ -800,55 +800,62 @@ class GraduationTaskssettinglist extends Component{ let category_id=this.props.match.params.category_id; let task_Id = this.props.match.params.task_Id; + if(this.props.isStudent()===true){ + + columns.some((item,key)=> { + if (item.title === "学号") { + columns.splice(key, 1) + return true + } + } + ) + + } if(taskslistdata&&taskslistdata.course_group_count<=0){ - //分班有显示 - columns.map((item,key)=>{ - if(item.title==="分班"){ - columns.splice(key,1) + columns.some((item,key)=> { + if (item.title === "分班") { + columns.splice(key, 1) + return true + } } - }) + ) } if(taskslistdata&&taskslistdata.cross_comment===false){ - columns.map((item,key)=>{ - if(item.title==="交叉评分"){ - columns.splice(key,1) + columns.some((item,key)=> { + if (item.title === "交叉评分") { + columns.splice(key, 1) + return true + } + } + ) + + } + + if(taskslistdata&&taskslistdata.have_grouping===false){ + + columns.some((item,key)=> { + if (item.title === "关联项目") { + columns.splice(key, 1) + return true } - }) + } + ) - if(taskslistdata&&taskslistdata.have_grouping===false){ - columns.map((item,key)=>{ - if(item.title==="关联项目"){ - columns.splice(key,1) - } - }) - columns.map((item,key)=>{ - if(item.title==="分组"){ - columns.splice(key,1) - } - }) - } - - }else{ - if(taskslistdata&&taskslistdata.have_grouping===false){ - columns.map((item,key)=>{ - if(item.title==="关联项目"){ - columns.splice(key,1) - } - }) + columns.some((item,key)=> { + if (item.title === "分组") { + columns.splice(key, 1) + return true + } + } + ) - columns.map((item,key)=>{ - if(item.title==="分组"){ - columns.splice(key,1) - } - }) - } - } + } return( @@ -1018,8 +1025,8 @@ class GraduationTaskssettinglist extends Component{ {this.props.isAdmin()?
  • 导出
  • :""} diff --git a/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js b/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js index ea368d478..c7ae7292d 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js @@ -3,6 +3,7 @@ import CoursesListType from '../coursesPublic/CoursesListType'; import {WordsBtn,ActionBtn} from 'educoder'; import ShixunWorkModal from './Shixunworkdetails/ShixunWorkModal'; import HomeworkModal from "../coursesPublic/HomeworkModal"; +import NoneData from '../coursesPublic/NoneData' import { Form, Select, @@ -93,23 +94,27 @@ class ShixunStudentWork extends Component { let url = "/homework_commons/" + homeworkid + "/code_review_results.json"; axios.get(url).then((response) => { + debugger if (response.data.status === undefined || response.data.status === 0) { if(response.data!=undefined){ - let datas=[]; - let list=response.data.users_reviews; - for(var i=0; i { if (response.data.status === undefined || response.data.status === 0) { if(response.data!=undefined){ - let datas=[]; - let list=response.data.users_reviews; - for(var i=0; i { + if (item.title === "学号") { + columns.splice(key, 1) + return true + } + } + ) + + } + return (
    {this.state.showmodel===true? - {data&&data?

    @@ -554,10 +573,10 @@ class ShixunStudentWork extends Component {

    - {data.homework_name} + {data&&data.homework_name}

    返回 @@ -593,10 +612,10 @@ class ShixunStudentWork extends Component { href={`/api/homework_commons/${this.props.match.params.coursesId}/works_list.xlsx`} >导出 : ""} {this.props.isAdmin()? - data.end_immediately===true? + data&&data.end_immediately===true? 立即截止 : "" : ""} {this.props.isAdmin()? - data.publish_immediately===true? + data&&data.publish_immediately===true? 立即发布 : "" : ""} {/*{this.props.isAdmin()?*/} @@ -623,10 +642,11 @@ class ShixunStudentWork extends Component { `} -
  • +
  • 正在执行查重,请稍后刷新页面查看结果 温馨提示:执行时间因查重作品数以及作品的代码量而异 +
  • + {data&&data? +
    • @@ -742,9 +764,9 @@ class ShixunStudentWork extends Component { />}
    -
    +
    :""} -
    :""} +
    diff --git a/public/react/src/modules/tpm/SiderBar.js b/public/react/src/modules/tpm/SiderBar.js index b0b029b45..f8af121e1 100644 --- a/public/react/src/modules/tpm/SiderBar.js +++ b/public/react/src/modules/tpm/SiderBar.js @@ -95,7 +95,7 @@ class SiderBar extends Component {
    From 9832ae4c4c747946a763c3f0c9a10a5737b29225 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 16:14:40 +0800 Subject: [PATCH 15/20] =?UTF-8?q?=E5=85=A8=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/members/teacherList.js | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 10e646590..35ef28bca 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -89,10 +89,20 @@ function buildColumns(that) {

    ): '' } + {course_groups && course_groups.length > 1 &&
  • + {/* 防止被外面group包裹 */} + + that.onCheckAllChange(e, item, index)} onChange={() => {}} + >全选 + +
  • } that.joinCourseGroup(checkedValues, item, index)} value={arg_course_groups.map(item => item.id)} disabled={!isAdminOrCreator} > + { course_groups && course_groups.filter((item) => { return (!that.state.groupSearchValue || item.name.indexOf(that.state.groupSearchValue) != -1) @@ -165,7 +175,7 @@ function buildColumns(that) { dataIndex: 'course_member_id', key: 'course_member_id', render: (content, item, index) => { - return + return content ? : '' } }) } @@ -190,7 +200,20 @@ class studentsList extends Component{ teachers: [], checkBoxValues: [], isSpin:false, - application_list: [] + application_list: [], + checkAllArray: [] + } + } + onCheckAllChange = (e, item, index) => { + const that = this; + debugger; + const checkAllArray = that.state.checkAllArray.slice(0) + checkAllArray[index] = !checkAllArray[index] + that.setState({checkAllArray}) + if (checkAllArray[index]) { + that.joinCourseGroup(that.state.course_groups.map((item) => item.id), item, index) + } else { + that.joinCourseGroup([], item, index) } } inputSearch=(e)=>{ From 5f1d34b1ff06b39943a8e5889243791c70f2ab64 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 16:20:25 +0800 Subject: [PATCH 16/20] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/members/teacherList.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 35ef28bca..c5422b96f 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -117,6 +117,11 @@ function buildColumns(that) { ) }) } +

    + trigger('groupAdd', that.props.coursesids)} + >添加分班... +

    } } From 2ab6e4d874a86bde1fc2c316a65618c0b0e24384 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 16:28:00 +0800 Subject: [PATCH 17/20] =?UTF-8?q?=E5=B7=B2=E5=8A=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/members/modal/AddStudentModal.js | 6 ++++-- .../src/modules/courses/members/modal/AddTeacherModal.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/members/modal/AddStudentModal.js b/public/react/src/modules/courses/members/modal/AddStudentModal.js index 0b747171d..cb40c1983 100644 --- a/public/react/src/modules/courses/members/modal/AddStudentModal.js +++ b/public/react/src/modules/courses/members/modal/AddStudentModal.js @@ -221,7 +221,8 @@ class AddStudentModal extends Component{ - + +

    @@ -252,7 +253,8 @@ class AddStudentModal extends Component{ - + +

    ) diff --git a/public/react/src/modules/courses/members/modal/AddTeacherModal.js b/public/react/src/modules/courses/members/modal/AddTeacherModal.js index 21bfdbc8c..268238d98 100644 --- a/public/react/src/modules/courses/members/modal/AddTeacherModal.js +++ b/public/react/src/modules/courses/members/modal/AddTeacherModal.js @@ -292,7 +292,8 @@ class AddTeacherModal extends Component{ - + +

    { candidates && candidates.length ?
    @@ -322,7 +323,8 @@ class AddTeacherModal extends Component{ - + +

    ) From 193c9a2576223567622d953c90bd32f97bd52ef9 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 16:31:01 +0800 Subject: [PATCH 18/20] isAdminOrStudent --- public/react/src/modules/courses/busyWork/CommonWorkList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 46d06e300..30bc37d88 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -93,7 +93,7 @@ function buildColumns(that, student_works) {
    ), }] - if (!niPingAndIsStudent) { + if (!niPingAndIsStudent && isAdminOrStudent) { columns.push({ width: 88, title: '学号', From 7f57b5339788b6f4b8359dca2474ef21c5f29e89 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 29 Jun 2019 16:34:49 +0800 Subject: [PATCH 19/20] =?UTF-8?q?=E5=AD=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/members/studentsList.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js index 669d8a65d..63ae5683a 100644 --- a/public/react/src/modules/courses/members/studentsList.js +++ b/public/react/src/modules/courses/members/studentsList.js @@ -80,6 +80,15 @@ const buildColumns = (that) => { width:"50%", className:"color-grey-6" }]; + const isAdminOrStudent = that.props.isAdminOrStudent() + if (!isAdminOrStudent) { + columns.some((item,key)=> { + if (item.title === "学号") { + columns.splice(key, 1) + return true + } + }) + } const isAdmin = that.props.isAdmin() if (isAdmin) { columns.unshift({ From d48804e94015d57db0639b01029f8235336fdb1f Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Sat, 29 Jun 2019 16:51:47 +0800 Subject: [PATCH 20/20] =?UTF-8?q?=E5=AF=B9=E9=9D=9E=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E6=88=90=E5=91=98=E9=9A=90=E8=97=8F=E5=AD=A6=E5=8F=B7=E5=88=97?= =?UTF-8?q?=EF=BC=88=E9=97=AE=E5=8D=B7=E3=80=81=E6=AF=95=E8=AE=BE=E9=80=89?= =?UTF-8?q?=E9=A2=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/exercise/question/shixunAnswer.js | 36 ++++++++++++------- .../graduation/topics/GraduateTopicDetail.js | 8 ++--- .../topics/GraduateTopicDetailTable.js | 8 +++-- .../graduation/topics/GraduateTopicItem.js | 6 ++-- .../courses/poll/PollDetailTabFirst.js | 33 ++++++++++++++--- 5 files changed, 65 insertions(+), 26 deletions(-) diff --git a/public/react/src/modules/courses/exercise/question/shixunAnswer.js b/public/react/src/modules/courses/exercise/question/shixunAnswer.js index 0ce4b3084..a1c4ff44b 100644 --- a/public/react/src/modules/courses/exercise/question/shixunAnswer.js +++ b/public/react/src/modules/courses/exercise/question/shixunAnswer.js @@ -200,7 +200,7 @@ class shixunAnswer extends Component{ className:"edu-txt-center", render:(testCount,item,index)=>{ return( - { item.testCount ? item.testCount : "--" } + { item.testCount ? item.testCount : -- } ) } }, { @@ -210,7 +210,7 @@ class shixunAnswer extends Component{ className:"edu-txt-center", render:(endTime,item,index)=>{ return( - { item.endTime ? item.endTime : "--" } + { item.endTime ? item.endTime : -- } ) } }, { @@ -220,7 +220,7 @@ class shixunAnswer extends Component{ className:"edu-txt-center", render:(needTime,item,index)=>{ return( - { item.needTime ? item.needTime : "--" } + { item.needTime ? item.needTime : -- } ) } }, { @@ -259,7 +259,7 @@ class shixunAnswer extends Component{ step={0.1} precision={1} value={item.input_score} - style={{width:"60px",marginRight:"5px"}} + style={{width:"60px",marginLeft:"5px"}} placeholder="请输入分数" onChange={(value)=>{this.changeThis(value,index)}} onBlur={(value)=>this.changeThisScore(value,item.id,index)} @@ -269,9 +269,9 @@ class shixunAnswer extends Component{ } { item.operation ? - this.scrollToAnchor(`${questionType.question_id}${index+1}`)}>查看 + this.scrollToAnchor(`${questionType.question_id}${index+1}`)}>查看 : - -- + -- } ) @@ -279,28 +279,38 @@ class shixunAnswer extends Component{ }]; return(
    + { exercise && ((exercise.student_commit_status && exercise.student_commit_status != 0) || (exercise.user_exercise_status && exercise.user_exercise_status !=0) ) ?

    阶段成绩

    -
    +
    0 ? "pl30 pr30 resetTableStyle":"pl30 pr30 resetTableStyle stageTable"}> { data && data.length>0 ?
    : "" }
    { challenge && challenge.length > 0 &&
    -

    实训详情

    +

    实训详情

    { challenge.map((item,key)=>{ return( -
    +

    - + 第{item[0].position}关 - {item[0].name} + {item[0].name}

    @@ -308,7 +318,7 @@ class shixunAnswer extends Component{ {...this.props} {...this.state} challenge={item[0].outputs} > - { item[0].st===0 ?
    + { item[0].st===0 ?

    最近通过的代码 @@ -316,7 +326,7 @@ class shixunAnswer extends Component{

    -
  • +
  • -

    +

    {tableData && tableData.course_name} > {tableData.graduation_name} @@ -111,9 +111,9 @@ class GraduateTopicDetail extends Component{ 选题详情

    - {tableData && tableData.graduation_topic_name} - - this.props.history.goBack()}>返回 + {tableData && tableData.graduation_topic_name} + + this.props.history.goBack()}>返回

    diff --git a/public/react/src/modules/courses/graduation/topics/GraduateTopicDetailTable.js b/public/react/src/modules/courses/graduation/topics/GraduateTopicDetailTable.js index 4e92f75ee..c9bd3f496 100644 --- a/public/react/src/modules/courses/graduation/topics/GraduateTopicDetailTable.js +++ b/public/react/src/modules/courses/graduation/topics/GraduateTopicDetailTable.js @@ -169,6 +169,7 @@ class GraduateTopicDetailTable extends Component{ } = this.state const isAdmin =this.props.isAdmin(); const isStudent =this.props.isStudent(); + const isNotMember=this.props.isNotMember(); console.log(un_addClass_notice) return(
    @@ -176,7 +177,7 @@ class GraduateTopicDetailTable extends Component{
    序号 姓名 - 学号 + {isNotMember ?"" :学号} 分班 选题时间 操作 @@ -260,7 +261,7 @@ class GraduateTopicDetailTable extends Component{
  • {parseInt(key+1)+(parseInt(page-1)*15)} {item.student_name} - {item.student_id} + {isNotMember ?"" :{item.student_id}} {item.class_group_name || "--"} {item.selected_time} { @@ -288,6 +289,9 @@ class GraduateTopicDetailTable extends Component{ isAdmin && {item.result=== "待确认"?"--":item.result} } + { + isNotMember && -- + }
  • ) diff --git a/public/react/src/modules/courses/graduation/topics/GraduateTopicItem.js b/public/react/src/modules/courses/graduation/topics/GraduateTopicItem.js index 17a1b070e..7ccfae974 100644 --- a/public/react/src/modules/courses/graduation/topics/GraduateTopicItem.js +++ b/public/react/src/modules/courses/graduation/topics/GraduateTopicItem.js @@ -70,9 +70,9 @@ class GraduateTopicItem extends Component{ `}
    { - isNotMember?discussMessage.private_icon===true? - {discussMessage.name}: this.toDetailPage(`${discussMessage.id}`)} - className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.name}:"" + isNotMember && discussMessage.private_icon===true ? + {discussMessage.name}: + this.toDetailPage(`${discussMessage.id}`)} className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.name} } { diff --git a/public/react/src/modules/courses/poll/PollDetailTabFirst.js b/public/react/src/modules/courses/poll/PollDetailTabFirst.js index ceca9b291..f8846d751 100644 --- a/public/react/src/modules/courses/poll/PollDetailTabFirst.js +++ b/public/react/src/modules/courses/poll/PollDetailTabFirst.js @@ -192,7 +192,12 @@ class PollDetailTabFirst extends Component{ key: 'classes', dataIndex: 'classes', width:160, - className:poll_types && poll_types.groups_count > 0 ? "edu-txt-center":"edu-txt-center none" + className:poll_types && poll_types.groups_count > 0 ? "edu-txt-center":"edu-txt-center none", + render:(classes,item,index)=>{ + return( + item.classes ? {item.classes} : -- + ) + } }, { title: '提交状态', dataIndex: 'status', @@ -212,22 +217,42 @@ class PollDetailTabFirst extends Component{ width:160, render:(time,item,index)=>{ return( - item.time == null ? "--" : moment(item.time).format('YYYY-MM-DD HH:mm') + item.time == null ? -- : moment(item.time).format('YYYY-MM-DD HH:mm') ) } },{ title: '操作', dataIndex: 'operation', key: 'operation', - className:poll_types && poll_types.un_anonymous ? "edu-txt-center":"edu-txt-center none", + className:"edu-txt-center", width:120, render:(operation,item,index)=>{ return( - item.status == 1 ? 查看:-- + item.status == 1 ? 查看:-- ) } }]; + // 非课堂成员不显示学号列 + let isNotMember =this.props.isNotMember(); + if(isNotMember){ + columns.some((item,key)=> { + if (item.title === "学号") { + columns.splice(key, 1) + return true + } + } + ) + } // un_anonymous true为实名问卷,显示操作列,否则隐藏 + if(poll_types && (isNotMember || poll_types.un_anonymous == false)){ + columns.some((item,key)=> { + if (item.title === "操作") { + columns.splice(key, 1) + return true + } + } + ) + } return(
    {