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

dev_local
cxt 6 years ago
commit 0468c13017

@ -728,6 +728,7 @@ class ExerciseController < ApplicationController
ExerciseShixunAnswer.where(:exercise_question_id => @exercise.exercise_questions.pluck(:id)).destroy_all
@exercise.update_attributes(:exercise_status => 1, :publish_time => nil, :end_time => nil, :unified_setting => 1)
@exercise.exercise_group_settings.destroy_all
@exercise.exercise_user_questions.destroy_all
@exercise.course_acts.destroy_all
@exercise.tidings.destroy_all
create_exercises_list @exercise

@ -30,6 +30,7 @@ class Exercise < ActiveRecord::Base
end
def create_user_question_list exercise_user_id
self.exercise_user_questions.where(exercise_user_id: exercise_user_id).destroy_all
self.exercise_questions.where("question_type != 5").each do |question|
ExerciseUserQuestion.create(exercise_id: self.id, exercise_user_id: exercise_user_id, exercise_question_id: question.id)
end

@ -191,7 +191,7 @@
<label class="panel-form-label fl">系统评分占比:</label>
<span class="fl mr20 ml10">
<input type="radio" name="Proportion" value="Equal_proportion" id="Equal_proportion" class="ml5 mr5 magic-radio" onchange="startSystem_score_percentage()" />
<input type="radio" name="Proportion" value="Equal_proportion" id="Equal_proportion" class="ml5 mr5 magic-radio" onchange="startSystem_score_percentage() " />
<label class="mt3" for="Equal_proportion">均分比例</label>
</span>
@ -330,7 +330,9 @@
function startSystem_score_percentage(){
getpercentage()
}
// function customSystem_score_percentage(){
//
// }
$(function(){
//填写百分比初始化
//$("#All_tests").attr('checked', 'checked');
@ -422,15 +424,12 @@
var maxnum=0;
var percentagelist = document.getElementsByName("test_set[score][]");
if($("#Partial_test").is(":checked")) {
if ($("#Custom_ratio").is(":checked")) {
for (var i = 0; i < percentagelist.length; i++) {
maxnum = maxnum+parseInt($(percentagelist[i]).val());
}
if ($("#Partial_test").is(":checked")) {
for (var i = 0; i < percentagelist.length; i++) {
maxnum = maxnum + parseInt($(percentagelist[i]).val());
}
}
console.log("######"+maxnum);
if(maxnum != 100){
$("#occupy_type").show()
return

@ -0,0 +1,30 @@
class MigrateExerciseUserQuestions < ActiveRecord::Migration
def up
exercise = Exercise.where(:id => 1031).first
if exercise.present?
exercise.exercise_users.each do |exercise_user|
# 分配的实训题数量多于6个的撤销发布过的学生会有12个题则删除前六个题
if exercise_user.exercise_user_questions.where(:exercise_id => exercise.id).count > 6
exercise_user.exercise_user_questions[0..5].each do |question|
question.destroy
end
end
# 分数超过一百分的需要重新计算得分
if exercise_user.objective_score > 100.0
score = 0
ExerciseUserQuestion.where(exercise_user_id: exercise_user.id, exercise_id: exercise.id).each do |question|
question.exercise_shixun_challenges.each do |exercise_cha|
score += exercise_cha.exercise_shixun_answers.where(user_id => exercise_user.user_id).try(:score).to_f
end
end
exercise_user.update_attributes(score: score, objective_score: score)
end
end
end
end
def down
end
end
Loading…
Cancel
Save