diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 3db7ada2b..1e68ed2ed 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -6,8 +6,8 @@ class HomeworkCommonController < ApplicationController include StudentWorkHelper before_filter :find_course, :only => [:index,:new,:create] - before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set] - before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set] + before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] + before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] before_filter :member_of_course, :only => [:index] def index @@ -38,6 +38,7 @@ class HomeworkCommonController < ApplicationController def edit @user = User.current @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i respond_to do |format| format.html{render :layout => 'new_base_user'} end @@ -88,8 +89,12 @@ class HomeworkCommonController < ApplicationController @homework_detail_programing.save if @homework_detail_programing if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => @course.id) - else + elsif params[:is_in_course] == "0" redirect_to user_homeworks_user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" + redirect_to user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" + redirect_to course_path(@course.id) end end end @@ -101,8 +106,12 @@ class HomeworkCommonController < ApplicationController format.html { if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => @course.id) - else + elsif params[:is_in_course] == "0" redirect_to user_homeworks_user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" + redirect_to user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" + redirect_to course_path(@course.id) end } end @@ -184,6 +193,19 @@ class HomeworkCommonController < ApplicationController end end + def alert_forbidden_anonymous_comment + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] if params[:is_in_course] + @course_activity = params[:course_activity] if params[:course_Activity] + respond_to do |format| + format.js + end + end + def programing_test test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]} @index = params[:index] diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 25782ec4b..38b953732 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,11 +3,11 @@ class StudentWorkController < ApplicationController include StudentWorkHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] - before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule] + before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment] ### def program_test @@ -469,6 +469,25 @@ class StudentWorkController < ApplicationController end end + def forbidden_anonymous_comment + @homework.update_column('anonymous_comment', 1) + homework_detail_manual = @homework.homework_detail_manual + homework_detail_programing = @homework.homework_detail_programing + if homework_detail_programing + homework_detail_manual.update_column('ta_proportion', 0.4) + homework_detail_programing.update_column('ta_proportion', 0.6) + else + homework_detail_manual.update_column('ta_proportion', 1.0) + end + @homework.student_works.each do |student_work| + set_final_score @homework,student_work + student_work.save + end + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + end + private #获取作业 def find_homework 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/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb index f8ed4bb24..1cb64b2b5 100644 --- a/app/views/blog_comments/reply.js.erb +++ b/app/views/blog_comments/reply.js.erb @@ -2,6 +2,6 @@ $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); <% else%> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); <% end %> \ No newline at end of file diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index 7892ed773..ea904a63f 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,3 +1,3 @@ -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); init_activity_KindEditor_data('<%= @user_activity_id%>',"","87%"); diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index 4a7cb900d..a54e0667e 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -92,7 +92,7 @@ <% act = activity.course_act %> <% case activity.course_act_type.to_s %> <% when 'HomeworkCommon' %> - <%= render :partial => 'users/course_homework', :locals => {:activity => act, :user_activity_id => activity.id} %> + <%= render :partial => 'users/course_homework', :locals => {:activity => act, :user_activity_id => activity.id, :course_activity => 1} %> <% when 'News' %> <%= render :partial => 'users/course_news', :locals => {:activity => act, :user_activity_id => activity.id} %> <% when 'Message' %> 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/homework_common/alert_forbidden_anonymous_comment.js.erb b/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb new file mode 100644 index 000000000..5177f4d92 --- /dev/null +++ b/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb @@ -0,0 +1,6 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/alert_forbidden_anonymous', :locals => {:user_activity_id => @user_activity_id,:is_in_course => @is_in_course,:course_activity => @course_activity}) %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed"); \ No newline at end of file diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index 79692207f..ac772171d 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -8,6 +8,17 @@ homework_description_editor.html(""); $("#homework_editor").toggle(); } + function cancel_edit(){ + <% if @is_in_course == 1 %> + window.location.href='<%=homework_common_index_path(:course => @course.id) %>'; + <% elsif @is_in_course == 0 %> + window.location.href='<%=user_homeworks_user_path(User.current.id) %>'; + <% elsif @is_in_course == -1 && @course_activity == 0 %> + window.location.href='<%=user_path(User.current.id) %>'; + <% elsif @is_in_course == -1 && @course_activity == 1 %> + window.location.href='<%=course_path(@course.id) %>'; + <% end %> + }