dev_course
SylorHuang 6 years ago
parent 629e9461ea
commit 62bd057317

@ -1140,6 +1140,7 @@ class ExercisesController < ApplicationController
exercise_ids = [@exercise.id]
@exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students
@c_group_counts = @course.course_groups_count
question_types = @exercise.exercise_questions.pluck(:question_type)
@exercise_publish_count = get_user_permission_course(exercise_ids,2).count #判断是否有已发布的分班
@exercise_unpublish_count = get_user_permission_course(exercise_ids,1).count #判断是否有未发布的分班

@ -30,16 +30,25 @@ class PollVotesController < ApplicationController
#begin
if question_type == 1
if user_votes.present? #用户曾经回答过的,答案选择不一样,否则新建
logger.info("########___________user_votes.present1111____________________#######")
current_user_answer = user_votes.first
if current_user_answer.poll_answer_id != question_answer_id #如果说更换了答案,则以前的答案删除,并新建记录
if current_user_answer&.poll_answer_id != question_answer_id #如果说更换了答案,则以前的答案删除,并新建记录
logger.info("########___________user_votes.present22222____________________#######")
current_user_answer.destroy
PollVote.create(vote_answer_params)
else
logger.info("########___________user_votes.present33333____________________#######")
if question_answer_text.present?
logger.info("########___________user_votes.present4444444____________________#######")
current_user_answer.update_attribute("vote_text", question_answer_text)
end
end
else
logger.info("########___________user_votes.present555555____________________#######")
PollVote.create(vote_answer_params)
end
elsif question_type == 2 #多选题的话答案应该是1个以上

@ -956,6 +956,8 @@ class PollsController < ApplicationController
@poll_publish_count = get_user_permission_course(poll_ids,2).count
@poll_unpublish_count = get_user_permission_course(poll_ids,1).count
@course_all_members = @course.students
@poll_group_counts = @course.course_groups_count
if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的问卷
@poll_current_user_status = 0
@poll_users_list = @poll.all_poll_users(current_user.id).distinct #该老师分班的全部学生

@ -15,7 +15,7 @@ json.exercise_types do
json.exercise_id @exercise.id
json.subjective @subjective_type #是否包含主观题1为包括0为不包括
json.exercise_end_time ((@ex_user_end_time.nil? || @ex_user_end_time < Time.now) ? "--" : how_much_time(@ex_user_end_time))
json.groups_count @exercise_course_groups.size
json.groups_count @c_group_counts
end
if @exercise_current_user_status == 0 #当为老师的时候

@ -16,7 +16,7 @@ json.poll_types do
json.user_permission @poll_current_user_status #当前用户存在且为课堂教师/管理员/超级管理员时为0 其他否则为1
json.poll_id @poll.id
json.poll_end_time @poll.end_time
json.groups_count @poll_course_groups.size
json.groups_count @poll_group_counts
end
if @poll_current_user_status == 0

@ -245,6 +245,6 @@ namespace :exercise_publish do
end
end
end
logger.info("")
Rails.logger.info("log--------------------------------exercise_end completed")
end
end

Loading…
Cancel
Save