From 2366b4d590c3df2cea90d8c702e503b54eb60595 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Sep 2019 10:09:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A4=9A=E9=80=89=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise_questions_controller.rb | 39 ++++++++++++++++-- dump.rdb | Bin 2487 -> 2487 bytes 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 57116a9e5..27e3fa2f4 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -497,7 +497,38 @@ class ExerciseQuestionsController < ApplicationController ex_obj_score = @exercise_current_user.objective_score #全部客观题得分 ex_subj_score = @exercise_current_user.subjective_score < 0.0 ? 0.0 : @exercise_current_user.subjective_score #全部主观题得分 ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分 - if @exercise_question.question_type == Exercise::COMPLETION #当为填空题,更新问题的总分, + if @exercise_question.question_type == Exercise::MULTIPLE + if ex_answers.present? #学生有回答时 取学生的答题得分,否则0分 + answer_choice_array = [] + ex_answers.each do |a| + answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + end + user_answer_content = answer_choice_array.sort + standard_answer = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).sort + if standard_answer.size == 1 # 老数据需要判断学生答题是否正确, 正确取原题得分,否则是0分 + standard_answer = standard_answer.first.to_s.split("").map(&:to_i).sort + if user_answer_content == standard_answer + ex_answer_old = @exercise_question.question_score + else + ex_answer_old = 0 + end + else # 新多选题只需取第一条答题记录的得分 + ex_answer_old = ex_answers.first.score > 0 ? ex_answers.first.score : 0 + end + else + ex_answer_old = 0 + end + + new_obj_score = ex_obj_score - ex_answer_old + @c_score + total_scores = new_obj_score + ex_subj_score + ex_scores = { + :objective_score => new_obj_score, + :score => total_scores + } + @exercise_current_user.update_attributes(ex_scores) + ex_answers.update_all(:score => @c_score) #所有的正确选项需重新更新 + + elsif @exercise_question.question_type == Exercise::COMPLETION #当为填空题,更新问题的总分, ex_answer_old = ex_answers.score_reviewed.pluck(:score).sum #每一关的得分总和 each_right_score = (@c_score / ex_answers.count.to_f) #调分后,平均每关的分数 new_obj_score = ex_obj_score - ex_answer_old + @c_score @@ -579,7 +610,7 @@ class ExerciseQuestionsController < ApplicationController end rescue Exception => e uid_logger_error(e.message) - tip_exception("没有权限") + tip_exception(e.message) raise ActiveRecord::Rollback end end @@ -703,8 +734,8 @@ class ExerciseQuestionsController < ApplicationController normal_status(-1,"用户不存在!") elsif @c_score.blank? normal_status(-1,"分数不能为空!") - elsif @exercise_question.question_type <= Exercise::JUDGMENT - normal_status(-1,"选择题/判断题不能调分!") + elsif @exercise_question.question_type == Exercise::SINGLE || @exercise_question.question_type == Exercise::JUDGMENT + normal_status(-1,"单选题/判断题不能调分!") elsif params[:comment].present? && params[:comment].length > 100 normal_status(-1,"评语不能超过100个字符!") else diff --git a/dump.rdb b/dump.rdb index bcf064366d9465f66c11de3ea1199b9ada47f4bd..9f62f75c757e26158b26bb280d1712217a6aab58 100644 GIT binary patch delta 37 tcmdlkyj^&Lf#8~l6|uiKN{drdbaPX44}CD*=$OaJ5s~pdA?Vt*uK+ZL5lH|5 delta 37 tcmdlkyj^&Lfnbw(e(W!f(&E$<-Q3jNLl>$yI_7b5tlX>ZyL{oCtpFKi58nU) From b7aa0e34c33424df8917663fb4e23c324d6d8bbd Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Thu, 12 Sep 2019 10:16:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/tpm/TPMsettings/TPMsettings.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index f78d62637..b2767887d 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -220,6 +220,7 @@ export default class TPMsettings extends Component { can_copy: undefined, task_pass: undefined, test_set_permission: undefined, + code_edit_permission: undefined, hide_code: undefined, code_hidden: undefined, forbid_copy: undefined, @@ -352,6 +353,7 @@ export default class TPMsettings extends Component { task_pass: response.data.shixun.task_pass, test_set_permission: response.data.shixun.test_set_permission, hide_code: response.data.shixun.hide_code, + code_edit_permission: response.data.shixun.code_edit_permission, code_hidden: response.data.shixun.code_hidden, is_secret_repository: response.data.shixun.is_secret_repository, init_is_secret_repository: response.data.shixun.is_secret_repository, @@ -546,7 +548,11 @@ export default class TPMsettings extends Component { }); } - + code_edit_permission = (e) => { + this.setState({ + code_edit_permission: e.target.checked + }) + } code_hidden=(e)=>{ let sum = "" if (e.target.checked === false) { @@ -869,7 +875,7 @@ export default class TPMsettings extends Component { let { name, choice_main_type, choice_small_type, choice_standard_scripts, scope_partment, choice_standard_scriptssum, vnc_evaluate, evaluate_script, webssh, use_scope, trainee, can_copy, task_pass, test_set_permission, hide_code, code_hidden, forbid_copy, vnc,multi_webssh, - opening_time,shixunmemoMDvalue,shixun_service_configlist, is_secret_repository + opening_time,shixunmemoMDvalue,shixun_service_configlist, is_secret_repository, code_edit_permission } = this.state; let newshixun_service_configlist = shixun_service_configlist.map(v => { @@ -982,6 +988,7 @@ export default class TPMsettings extends Component { vnc_evaluate: vnc_evaluate===null?undefined:vnc_evaluate, test_set_permission: test_set_permission, code_hidden: code_hidden, + code_edit_permission: code_edit_permission, trainee: trainee, task_pass: task_pass, hide_code: hide_code, @@ -1563,6 +1570,7 @@ export default class TPMsettings extends Component { test_set_permission, hide_code, forbid_copy, + code_edit_permission, code_hidden, vnc, vnc_evaluate, @@ -2274,6 +2282,15 @@ export default class TPMsettings extends Component { + {!code_hidden && !hide_code &&
+ 代码开放修改: + + + + +
} +
隐藏代码窗口: From c1c3db88a854b9c67c320b2341470171f88a8863 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Sep 2019 10:22:46 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=80=89=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/shixun_list.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/shixun_list.json.jbuilder b/app/views/shixuns/shixun_list.json.jbuilder index 54ac65a0a..2f1d4905c 100644 --- a/app/views/shixuns/shixun_list.json.jbuilder +++ b/app/views/shixuns/shixun_list.json.jbuilder @@ -10,7 +10,7 @@ json.shixun_list do # json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('
') json.content highlights json.level level_to_s(obj.trainee) - json.subjects obj.subjects do |subject| + json.subjects obj.subjects.uniq do |subject| json.(subject, :id, :name) end end From dd939433b0998f476ab9da20b31953c47f850c21 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Thu, 12 Sep 2019 10:49:22 +0800 Subject: [PATCH 4/4] protocol --- public/react/src/App.js | 14 ++++++++++++++ public/react/src/common/util/ShareUtil.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/public/react/src/App.js b/public/react/src/App.js index 1a4aedc05..17ee34255 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -326,6 +326,20 @@ class App extends Component { }); wx.ready(function () { console.log('wx is ready') + // var shareData = { + // title: 'EduCoder - 首页', + // desc: 'Educoder是一个面向计算机类的互联网IT教育和实战平台,提供企业级工程实训,以实现工程化专业教学的自动化和智能化。高校和企业人员可以在此开展计算机实践性教学活动,将传统的知识传授和时兴的工程实战一体化。', + // link: currentUrl, + // imgUrl: window.__testImageUrl + // || (currentUrl.endsWith('/') ? currentUrl : currentUrl + '/') + 'react/build/images/share_logo_icon.jpg' + // }; + + // wx.onMenuShareAppMessage(shareData);//分享给好友 + // wx.onMenuShareTimeline(shareData);//分享到朋友圈 + // wx.onMenuShareQQ(shareData);//分享给手机QQ + // wx.onMenuShareWeibo(shareData);//分享腾讯微博 + // wx.onMenuShareQZone(shareData);//分享到QQ空间 + configShareForIndex('/') }); wx.error(function (res) { diff --git a/public/react/src/common/util/ShareUtil.js b/public/react/src/common/util/ShareUtil.js index 24fffbf15..c4ec8a62a 100644 --- a/public/react/src/common/util/ShareUtil.js +++ b/public/react/src/common/util/ShareUtil.js @@ -1,4 +1,4 @@ -const host = window.location.host +const host = window.location.protocol + '//' + window.location.host const wx = window.wx function share(shareData) { try {