Merge remote-tracking branch 'origin/dev_chen' into dev_chen

dev_chen
杨树明 5 years ago
commit 862b97785a

@ -605,6 +605,33 @@ class ExerciseQuestionsController < ApplicationController
ExerciseShixunAnswer.create!(ex_shixun_option)
new_obj_score = ex_obj_score + @c_score
end
total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
elsif total_scores > ex_all_scores
total_scores = ex_all_scores
end
ex_scores = {
:objective_score => new_obj_score,
:score => total_scores
}
@exercise_current_user.update!(ex_scores)
elsif @exercise_question.question_type == Exercise::PROGRAM
if ex_answers.exists?
ex_pro_old_score = ex_answers.first.score > 0.0 ? ex_answers.first.score : 0.0
new_obj_score = ex_obj_score - ex_pro_old_score + @c_score
ex_answers.first.update_attribute("score", @c_score)
else #如果学生未答,则创建新的答题记录
answer_option = {
:user_id => @user_id,
:exercise_question_id => @exercise_question.id,
:score => @c_score,
:answer_text => ""
}
ExerciseAnswer.create!(answer_option)
new_obj_score = ex_obj_score + @c_score
end
total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0

@ -1623,7 +1623,7 @@ class ExercisesController < ApplicationController
ques_number = q.question_number
end
ques_status = 0
if q.question_type != Exercise::PRACTICAL
if q.question_type < Exercise::PRACTICAL
ques_vote = q.exercise_answers.select {|answer| answer.user_id == user_id}
if ques_vote.present?
@ -1642,11 +1642,16 @@ class ExercisesController < ApplicationController
end
end
end
else
elsif q.question_type == Exercise::PRACTICAL
if Myshixun.exists?(user_id: user_id, shixun_id: q.shixun_id)
ques_status = 1
question_answered += 1
end
else
if HackUserLastestCode.exists?(user_id: user_id, hack_id: q.hack_id)
ques_status = 1
question_answered += 1
end
end
question_status = {
:ques_id => q.id,

@ -14,10 +14,10 @@ module ExerciseQuestionsHelper
}
answered_content.push(u_answer)
end
elsif question.question_type == Exercise::SUBJECTIVE
elsif question.question_type == Exercise::SUBJECTIVE || question.question_type == Exercise::PROGRAM
answered_content = exercise_answers.pluck(:answer_text)
end
if question.question_type == Exercise::PRACTICAL && ex_user.present? && ex_user.commit_status == 1 #存在实训题,且用户已提交了的,如果实训题只做了一半就关闭,则相当于不要了
if (question.question_type == Exercise::PRACTICAL || question.question_type == Exercise::PROGRAM) && ex_user.present? && ex_user.commit_status == 1 #存在实训题,且用户已提交了的,如果实训题只做了一半就关闭,则相当于不要了
if exercise.exercise_status == 3 #如果试卷已截止,则可以看到分数,否则不能查看分数
shixun_type = 2
else

@ -15,7 +15,7 @@ module ExercisesHelper
answers_content = q.exercise_answers.select{|answer| answer.user_id == user_id}
end
if q_type <= Exercise::JUDGMENT
if q_type <= Exercise::JUDGMENT || q_type == Exercise::PROGRAM
if answers_content.present? #学生有回答时,分数已经全部存到exercise_answer 表,多选题直接取第一个值,单选题和判断题选最后一个值(考虑并发)
ques_score = q_type == Exercise::MULTIPLE ? answers_content.first.score : answers_content.last.score
ques_score = ques_score < 0 ? 0.0 : ques_score
@ -454,6 +454,7 @@ module ExercisesHelper
score1 = 0.0 #选择题/判断题
score2 = 0.0 #填空题
score5 = 0.0 #实训题
score6 = 0.0 #编程题
ques_stand = [] #问题是否正确
exercise_end_time = end_time || Time.now
exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers,:exercise_shixun_challenges)
@ -608,6 +609,34 @@ module ExercisesHelper
end
end
end
elsif q.question_type == 6 #编程题
if answers_content.present?
score6 += answers_content.first.score
else
hack = q.hack
hack_user = hack&.hack_user_lastest_codes&.find_by(user_id: user.id)
if hack_user.present?
last_passed_code = hack_user.hack_user_codes.where("status = 0 and created_at < '#{exercise_end_time}'").last
if last_passed_code.present?
pro_score = q.question_score
code_content = last_passed_code.code
else
pro_score = 0
code_content = hack_user.hack_user_codes.where("created_at < '#{exercise_end_time}'").last&.code
end
else
pro_score = 0
code_content = nil
end
pro_option = {
:exercise_question_id => q.id,
:user_id => user.id,
:score => pro_score.round(1),
:answer_text => code_content
}
ExerciseAnswer.create(pro_option)
score6 += pro_score
end
end
user_scores = answers_content.blank? ? 0.0 : answers_content.score_reviewed.pluck(:score).sum
if user_scores > 0.0
@ -629,7 +658,7 @@ module ExercisesHelper
end
end
total_score = score1 + score2 + score5
total_score = score1 + score2 + score5 + score6
{
"total_score":total_score.round(1),
"stand_status":ques_stand
@ -923,10 +952,10 @@ module ExercisesHelper
elsif ques_type == 4
answered_content = exercise_answers&.pluck(:answer_text)
end
if ques_type == 5 #存在实训题,及已经做了实训题的
if ques_type == 5 || ques_type == 6 #存在实训题,及已经做了实训题的
if ex_status == 3 || is_teacher_or == 1 #如果试卷已截止,则可以看到分数,否则不能查看分数
shixun_type = 2
elsif ex_status == 2 && q.exercise_shixun_answers.present? #试卷未截止,且用户已回答的,则能看到答题的状态
elsif ex_status == 2 && (q.exercise_shixun_answers.present? || q.exercise_answers.present?) #试卷未截止,且用户已回答的,则能看到答题的状态
shixun_type =1
end
end

@ -48,4 +48,8 @@ class ExerciseQuestion < ApplicationRecord
exercise_standard_answers.pluck(:answer_text)
end
def hack_user user_id
hack_user = hack&.hack_user_lastest_codes&.find_by(user_id: user_id)
end
end

@ -125,4 +125,18 @@ elsif question.question_type == 6
json.hack_identifier hack.identifier
json.description hack.description
json.hack_id hack.id
if exercise_type == 3 || exercise_type == 4
json.user_answer user_answer
end
if (exercise_type == 3 || exercise_type == 4) && (shixun_type.present? && shixun_type > 0 ) #教师评阅/试卷截止后,答案公开/试卷未截止,但学生已做了实训题
hack_user = question.hack_user(ex_answerer.id)
if hack_user.present?
evaluate_codes = hack_user.hack_user_codes.where("created_at < '#{@exercise_user_current&.end_at}'")
json.evaluate_codes evaluate_codes do |code|
json.(code, :status, :error_msg, :error_line, :expected_output, :input, :output, :execute_time, :execute_memory)
json.created_at code.created_at.strftime('%Y-%m-%d %H:%M:%S')
end
end
end
end

@ -1,3 +1,4 @@
json.is_md @exercise.is_md
if @exercise_course_groups.present? && @exercise_course_groups.count > 0
json.course_groups do
json.array! @exercise_course_groups do |group|

@ -209,12 +209,16 @@ function QuillForEditor({
if (value && value.hasOwnProperty('ops')) {
// console.log(value.ops);
const ops = value.ops || [];
ops.forEach((item, i) => {
if (item.insert['image']) {
item.insert['image'] = Object.assign({}, item.insert['image'], { style: { cursor: 'pointer' }, onclick: (url) => showUploadImage(url) });
}
});
try {
const ops = value.ops || [];
ops.forEach((item, i) => {
if (item.insert['image']) {
item.insert['image'] = Object.assign({}, item.insert['image'], { style: { cursor: 'pointer' }, onclick: (url) => showUploadImage(url) });
}
});
}catch (e) {
}
}
const current = value

@ -13,6 +13,7 @@ import CoursesListType from '../coursesPublic/CoursesListType';
import QuillForEditor from "../../../common/quillForEditor";
import Multiple from './question/multiple';
import Single from './question/single';
import Progques from './question/Progques';
import FillEmpty from './question/fillEmpty';
import SimpleAnswer from './question/simpleAnswer';
import ShixunAnswer from './question/shixunAnswer';
@ -1014,6 +1015,22 @@ class ExerciseReviewAndAnswer extends Component{
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></ShixunAnswer>
}
{
//编程题
item.question_type == 6 &&
<Progques
{...this.props}
{...this.state}
is_md={is_md}
exercise={exercise}
questionType={item}
user_exercise_status={user_exercise_status}
id={this.state.Id}
index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></Progques>
}
{
//调分理由部分

@ -0,0 +1,103 @@
import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd";
import {DMDEditor,markdownToHTML, MarkdownToHtml } from 'educoder'
import QuillForEditor from "../../../../common/quillForEditor";
import axios from 'axios'
const tagArray = [
// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
// 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
// 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
]
class Progques extends Component{
constructor(props){
super(props);
}
toMDMode = (that) => {
}
onOptionContentChange = (value, index) => {
}
onBlurEmpty=(index,number)=>{
}
render(){
let {
questionType ,
exercise ,
user_exercise_status,
is_md
}=this.props
let isAdmin = this.props.isAdmin();
let isStudent = this.props.isStudent();
let item=questionType;
let titename="";
if(item){
if(is_md===true){
titename=item.description;
}else{
try {
titename = JSON.parse(item.description);
}catch (e) {
titename={"ops":[{"insert":item.description}]};
}
// JSON.parse 有些异常数据是undefined
if(titename===undefined){
titename={"ops":[{"insert":item.description}]};
}
try {
// JSON.parse 转换的时候如果是数字字符串就转成整数了
if(titename>=0){
titename={"ops":[{"insert":item.description}]};
}
}catch (e) {
}
}
}
return(
<div className="pl30 pr30">
<style>{`
.emptyPanel div#content_editorMd_show{
width: 100%;
border-radius: 4px;
// height: 35px;
margin-top:0px;
background-color:#fafafa;
color:#999;
// line-height:25px;
}
.answerStyle{
background:#f5f5f5;
border-radius:4px;
border: 1px solid #eaeaea;
padding:5px;
min-height:35px;
box-sizing:border-box;
}
.emptyPanel .quill_editor_for_react_area{
width: 100% !important;
}
`}</style>
<li className="df mb10 emptyPanel">
<QuillForEditor
readOnly={true}
value={titename}
showUploadImage={this.props.handleShowUploadImage}
/>
</li>
</div>
)
}
}
export default Progques
Loading…
Cancel
Save