diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index c8af509f8..e566a8f46 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -320,15 +320,15 @@ class CoursesService #如果加入角色为学生 并且当前是学生 if params[:role] == "10" && roleName == "Student" @state = 3 - #如果加入的角色为老师,并且当前已经是老师 + #如果加入的角色为老师,并且当前已经是老师 elsif params[:role] == "9" && roleName == "Teacher" @state = 8 - #如果加入的角色教辅并且当前为教辅 + #如果加入的角色教辅并且当前为教辅 elsif params[:role] == "7" && roleName == "TeachingAsistant" @state = 9 elsif roleName == "Manager" @state = 10 - #如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求 + #如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求 elsif (params[:role] != "10" && roleName == "Student") || (params[:role] == "7" && roleName != "TeachingAsistant" ) || (params[:role] == "9" && roleName != "Teacher" ) #如果已经发送过消息了,那么就要给个提示 if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0 @@ -338,7 +338,7 @@ class CoursesService CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) @state = 6 end - #如果加入角色是学生,但是是当前课程的教师或者教辅 + #如果加入角色是学生,但是是当前课程的教师或者教辅 elsif params[:role] == "10" && roleName != "Student" member.role_ids = [params[:role]] member.save @@ -349,26 +349,26 @@ class CoursesService @state = 1 end else - if params[:course_password] == course.password - if params[:role] == "10" || params[:role] == nil - members = [] - members << Member.new(:role_ids => [10], :user_id => current_user.id) - course.members << members - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) - @state = 0 - else - #如果已经发送过消息了,那么就要给个提示 - if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0 - @state = 7 - else - Mailer.run.join_course_request(course, User.current, params[:role]) - CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) - @state = 6 - end - end + if params[:course_password] == course.password + if params[:role] == "10" || params[:role] == nil + members = [] + members << Member.new(:role_ids => [10], :user_id => current_user.id) + course.members << members + StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + @state = 0 else - @state = 1 + #如果已经发送过消息了,那么就要给个提示 + if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0 + @state = 7 + else + Mailer.run.join_course_request(course, User.current, params[:role]) + CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) + @state = 6 + end end + else + @state = 1 + end end end else diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 8314c3902..25a4fae46 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -58,15 +58,15 @@ if(!check_memo_name()){ return; } - if($("textarea[name='memo[subject]']").val().trim() != "" && memo_content.html().trim() != "" ){ + if($("textarea[name='memo[subject]']").val().trim() != "" && !memo_content.isEmpty() ){ memo_content.sync(); $("#new_memo").submit(); - }else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.html().trim() == ""){ + }else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.isEmpty()){ $("#error").html("主题和内容不能为空").show(); } - else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.html().trim() != "" ){ + else if($("textarea[name='memo[subject]']").val().trim() == "" && !memo_content.isEmpty() ){ $("#error").html("主题不能为空").show(); - }else if($("textarea[name='memo[subject]']").val().trim() != "" && memo_content.html().val().trim() == ""){ + }else if($("textarea[name='memo[subject]']").val().trim() != "" && memo_content.isEmpty()){ $("#error").html("内容不能为空").show(); } } diff --git a/app/views/memos/edit.html.erb b/app/views/memos/edit.html.erb index 7ab460555..d26ebdbf8 100644 --- a/app/views/memos/edit.html.erb +++ b/app/views/memos/edit.html.erb @@ -2,7 +2,7 @@