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

dev_course
jingquan huang 6 years ago
commit 7261f7ab04

@ -275,7 +275,7 @@ class CoursesController < ApplicationController
end
end
@is_admin = current_user.creator_of_course? @course
@is_admin = @user_course_identity < Course::PROFESSOR
@applications= CourseMessage.unhandled_join_course_requests_by_course(@course)
@ -898,8 +898,8 @@ class CoursesController < ApplicationController
def top_banner
@user = current_user
@is_teacher = @user.teacher_of_course?(@course)
@is_student = @course.course_members.where(user_id: @user.id, role: 4, is_active: 1).present?
@is_teacher = @user_course_identity < Course::STUDENT
@is_student = @user_course_identity == Course::STUDENT
@course.increment!(:visits)
end

@ -8,7 +8,7 @@ class ExerciseAnswersController < ApplicationController
q_type = @exercise_question.question_type #试卷的类型
choice_id = params[:exercise_choice_id].present? ? params[:exercise_choice_id] : ""
answer_text = params[:answer_text].present? ? params[:answer_text] : "" #为字符串
if q_type < 4 && choice_id.blank?
if q_type < 4 && (q_type != 1) && choice_id.blank?
normal_status(-1,"请选择序号")
else
ea = @exercise_question.exercise_answers.search_answer_users("user_id",current_user.id) #试卷的当前用户的答案

@ -436,7 +436,7 @@ class ExercisesController < ApplicationController
exercise_status = @exercise.get_exercise_status(current_user.id)
if exercise_status == 1 && (course_group_ids - [0]).count > 0 # 试卷未发布且老师的分班大于1 ,才可以修改统一设置,否则按试卷默认的来处理
if exercise_status == 1 && course_group_ids.size > 0 # 试卷未发布且老师的分班大于1 ,才可以修改统一设置,否则按试卷默认的来处理
unified_setting = params[:unified_setting]
else
unified_setting = @exercise.unified_setting
@ -450,7 +450,7 @@ class ExercisesController < ApplicationController
answer_open = params[:answer_open] ? true : false #答案是否公开
# 统一设置或者分班为0则更新试卷并删除试卷分组
if unified_setting || (course_group_ids.count == 0)
if unified_setting || (course_group_ids.size == 0)
params_publish_time = params[:publish_time].blank? ? nil : params[:publish_time].to_time
params_end_time = nil
if params[:end_time].blank?
@ -798,12 +798,13 @@ class ExercisesController < ApplicationController
if exercise_status == 2 #跳过已截止的或未发布的
g_course = params[:group_ids]
if g_course.present?
user_course_groups= @course.teacher_course_groups.get_user_groups(current_user.id)
if user_course_groups.present?
teacher_course_group_ids = user_course_groups.pluck(:course_group_id)
else
teacher_course_group_ids = @course.course_groups.pluck(:id)
end
# user_course_groups= @course.teacher_course_groups.get_user_groups(current_user.id)
# if user_course_groups.present?
# teacher_course_group_ids = user_course_groups.pluck(:course_group_id)
# else
# teacher_course_group_ids = @course.course_groups.pluck(:id)
# end
teacher_course_group_ids = @course.charge_group_ids(current_user)
if g_course.map(&:to_i).sort == teacher_course_group_ids.sort #开始为统一设置
exercise.exercise_group_settings.destroy_all
new_ex_status = set_exercise_status(exercise.publish_time,Time.now)

@ -66,7 +66,7 @@ class GraduationTasksController < ApplicationController
@course.teacher_group_user_ids(current_user.id)
else
course_group_id = @course.course_member(current_user.id).course_group_id
@course.course_members.where(course_group_id: course_group_id).pluck(:user_id)
@course.students.where(course_group_id: course_group_id).pluck(:user_id)
end
@work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension])
@ -89,7 +89,7 @@ class GraduationTasksController < ApplicationController
# 分班情况
unless params[:course_group].blank?
group_user_ids = @course.course_members.where(course_group_id: params[:course_group]).pluck(:user_id)
group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id)
# 有分组只可能是老师身份查看列表
@work_list = @work_list.where(user_id: group_user_ids)
end

@ -691,7 +691,7 @@ class PollsController < ApplicationController
course_group_ids = @course.charge_group_ids(current_user) #当前老师的班级id数组
poll_status = @poll.get_poll_status(current_user.id)
if poll_status == 1 && (course_group_ids - [0]).count > 0 # 问卷未发布且老师的分班大于1 才可以修改统一设置否则按poll默认的来处理
if poll_status == 1 && course_group_ids.size > 0 # 问卷未发布且老师的分班大于1 才可以修改统一设置否则按poll默认的来处理
unified_setting = params[:unified_setting]
else
unified_setting = @poll.unified_setting

@ -1,8 +1,12 @@
class SchoolsController < ApplicationController
def school_list
schools = School.all
search = params[:search].to_s.strip
if search.present?
schools = schools.where('name Like ?', "%#{search}%")
end
def school_list
q = params[:search] ? params[:search].strip : ""
@schools = School.where("name like ?", "%#{q}%").pluck(:name)
render_ok(school_names: schools.pluck(:name))
end
end

@ -121,7 +121,7 @@ class Course < ApplicationRecord
end
#当前老师的班级id
def teacher_course_group_ids(user_id)
def teacher_course_ids(user_id)
course_teacher_member = teacher_course_groups.get_user_groups(user_id) #获取当前老师的分班
if course_teacher_member.blank?
if none_group_count > 0 #有未分班的,则发布到未发布分班
@ -139,9 +139,9 @@ class Course < ApplicationRecord
def teacher_group_user_ids user_id
teachers = teacher_course_groups.where(user_id: user_id)
if teachers.exists?
course_members.where(course_group_id: teachers.pluck(:course_group_id)).pluck(:user_id)
students.where(course_group_id: teachers.pluck(:course_group_id)).pluck(:user_id)
else
course_members.where(role: 4).pluck(:user_id)
students.pluck(:user_id)
end
end

@ -66,7 +66,7 @@ class Exercise < ApplicationRecord
#当前用户已发布的班级id和试卷分组已发布的班级id的交集
def common_published_ids(user_id)
current_user_groups = course.teacher_course_group_ids(user_id)
current_user_groups = course.teacher_course_ids(user_id)
if unified_setting
if course.none_group_count > 0 #有未分班的,则发布到未发布分班
un_group_ids = [0]

@ -50,10 +50,10 @@ class GraduationTopic < ApplicationRecord
def student_graduation_topic_status
sgt = self.student_graduation_topics
status =
if sgt.is_accepting.count == 0
2
elsif sgt.is_refused.count == self.student_graduation_topics.size
if sgt.where(status: [0, 1]).count.zero?
0
elsif sgt.is_accepting.count.zero?
2
else
1
end

@ -62,7 +62,7 @@ class Poll < ApplicationRecord
#当前用户已发布的班级id和试卷分组已发布的班级id的交集
def poll_published_ids(user_id)
current_user_groups = course.teacher_course_group_ids(user_id)
current_user_groups = course.teacher_course_ids(user_id)
if unified_setting
if course.none_group_count > 0 #有未分班的,则发布到未发布
un_group_ids = [0]

@ -11,7 +11,7 @@ json.course_end @course.is_end
json.deadline course_end_date @course.end_date
json.educoder_teacher @user.is_teacher?
#json.is_student @is_student
json.is_admin @user.creator_of_course?(@course)
json.is_admin @user_course_identity < Course::PROFESSOR
json.is_public @course.is_public == 1
json.code_halt @course.invite_code_halt == 1
json.invite_code @course.invite_code_halt == 0 ? @course.generate_invite_code : ""
@ -20,7 +20,7 @@ json.switch_to_teacher switch_teacher_role(@is_student, @course, @user)
json.switch_to_assistant switch_assistant_role(@is_student, @course, @user)
#json.join_course !@user.member_of_course?(@course)
#json.copy_course !@user.member_of_course?(@course) && @user.is_teacher?
json.course_identity @user.course_identity(@course)
json.course_identity @user_course_identity
if @course.is_end == 0
json.days_remaining (@course.end_date.to_date - Time.now.to_date).to_i
end

@ -7,10 +7,10 @@ json.unpublished_count @all_count - @published_count
json.task_count @task_count
json.tasks @tasks.each do |task|
task_private = @identity > Course::STUDENT && !task.is_public
# task_private = @identity > Course::STUDENT && !task.is_public
json.task_id task.id
json.name task.name
json.private_icon task_private
json.private_icon !task.is_public
json.task_status task.status #6.12 -hs
json.status task_curr_status(task, @course)[:status]
json.status_time task_curr_status(task, @course)[:time]

@ -1,6 +1,6 @@
json.array! topics do |topic|
task_private = course_identity > Course::STUDENT && !topic.is_public
json.private_icon task_private
# task_private = course_identity > Course::STUDENT && !topic.is_public
json.private_icon !topic.is_public
json.(topic, :id, :name, :status)
json.author topic.teacher.full_name
json.user_topic_status topic.user_status(current_user)

@ -12,10 +12,10 @@ json.category_id @category.try(:id)
json.category_name @category.try(:name)
json.homeworks @homework_commons.each do |homework|
homework_private = (@user_course_identity > Course::STUDENT) && !homework.is_public
# homework_private = (@user_course_identity > Course::STUDENT) && !homework.is_public
json.homework_id homework.id
json.name homework.name
json.private_icon homework_private
json.private_icon !homework.is_public
json.status homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:status]
json.status_time homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:time]
json.time_status homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:time_status]

@ -1 +0,0 @@
json.shools_name @schools

@ -34,9 +34,9 @@ class SchoolSelect extends Component{
}
})
.then((response) => {
if (response.data.shools_name) {
if (response.data.school_names) {
if (currentValue === value) {
callback(response.data.shools_name);
callback(response.data.school_names);
}
}
})

@ -314,7 +314,7 @@ class CoursesNew extends Component {
}
}).then((result)=>{
this.setState({
searchlistscholl:result.data.shools_name,
searchlistscholl:result.data.school_names,
scholl:value
})
this.props.form.setFieldsValue({

Loading…
Cancel
Save