diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 82c827b48..0463e08e8 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -62,6 +62,7 @@ class AdminController < ApplicationController course = Course.where("id = #{params[:course_id].to_i}").first unless course.nil? course.update_column('syllabus_id', params[:syllabus_id].to_i) + Rails.logger.error "update_syllabus_id: admin_controller/select_scourse_syllabus" @flag = true end end @@ -83,6 +84,7 @@ class AdminController < ApplicationController syllabus.description = Message.where("id = 19412").first.nil? ? nil : Message.where("id = 19412").first.content if syllabus.save course.update_column('syllabus_id', syllabus.id) + Rails.logger.error "update_syllabus_id: admin_controller/create_syllabus" @flag = params[:flag].to_i @course = course respond_to do |format| diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 2020915f8..2f50c8105 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -58,9 +58,10 @@ class HomeworkCommonController < ApplicationController def edit @user = User.current - @is_in_course = params[:is_in_course].to_i + @is_in_course = params[:is_in_course] + @is_manage = params[:is_manage] @course_activity = params[:course_activity].to_i - if @is_in_course == 1 || @course_activity == 1 + if @is_in_course.to_i == 1 || @course_activity == 1 @left_nav_type = 3 respond_to do |format| format.html{render :layout => 'base_courses'} @@ -144,7 +145,11 @@ class HomeworkCommonController < ApplicationController @homework_detail_programing.save if @homework_detail_programing @homework_detail_group.save if @homework_detail_group - if params[:is_in_course] == "1" + if params[:is_manage] == "1" + redirect_to manage_or_receive_homeworks_user_path(User.current.id) + elsif params[:is_manage] == "2" + redirect_to my_homeworks_user_path(User.current.id) + elsif params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => @course.id) elsif params[:is_in_course] == "0" redirect_to user_homeworks_user_path(User.current.id) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 7db6e592e..58d1cb3b2 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -98,7 +98,7 @@ class PullRequestsController < ApplicationController # @return [Gitlab::ObjectifiedHash] def accept_pull_request begin - status = @g.accept_merge_rquest(@project.gpid, params[:id]) + status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid) respond_to do |format| format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)} end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 3d87b007d..adfcd6263 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -775,30 +775,33 @@ class StudentWorkController < ApplicationController end def retry_work - if @work.destroy - if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 - pros = @work.student_work_projects.where("is_leader = 0") - pros.each do |pro| - pro.destroy - end - project = @work.student_work_projects.where("is_leader = 1").first - project.update_attributes(:student_work_id => nil) - elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 - @work.student_work_projects.each do |pro2| - pro2.destroy + if @homework.homework_type == 3 + if @work.destroy + if @homework.homework_detail_group.base_on_project == 1 + pros = @work.student_work_projects.where("is_leader = 0") + pros.each do |pro| + pro.destroy + end + project = @work.student_work_projects.where("is_leader = 1").first + project.update_attributes(:student_work_id => nil) + elsif @homework.homework_detail_group.base_on_project == 0 + @work.student_work_projects.each do |pro2| + pro2.destroy + end end end - @student_work = StudentWork.new - respond_to do |format| - format.js - end + elsif @homework.homework_type == 1 + @work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0) + end + @student_work = StudentWork.new + respond_to do |format| + format.js end end #添加评分,已评分则为修改评分 def add_score @is_last = params[:is_last] == "true" - render_403 and return if User.current == @work.user #不可以匿评自己的作品 @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? #老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分 render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 932617671..c9cea575e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -599,7 +599,7 @@ class UsersController < ApplicationController if(params[:type].blank? || params[:type] == "1") #我的题库 courses = @user.courses.where("is_delete = 1") course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}") + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}") elsif params[:type] == "2" #公共题库 visible_course = Course.where("is_delete = 0") visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" @@ -1460,6 +1460,7 @@ class UsersController < ApplicationController def user_projects4show @page = params[:page].to_i + 1 @projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10).offset(@page * 10) + @all_count = @user.projects.visible.count end def user_course_activities diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 3fcc9fb8a..3ba3ee2b2 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -1,6 +1,6 @@ #学生提交作品表 class StudentWork < ActiveRecord::Base - attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test, :simi_id, :simi_value + attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test, :simi_id, :simi_value, :work_status belongs_to :homework_common belongs_to :user diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index c6854f3dd..e9253ff90 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -353,6 +353,7 @@ class CoursesService #@course.password = params[:course][:password] @course.tea_id = current_user.id @course.syllabus_id = params[:syllabus_id].to_i + Rails.logger.error "update_syllabus_id: courses_service/create_course" @course.term = params[:term] @course.time = params[:time] @course.end_term = params[:end_term] @@ -412,6 +413,7 @@ class CoursesService #course.safe_attributes = params[:course] #course.password = params[:course][:password] course.syllabus_id = params[:syllabus_id].to_i + Rails.logger.error "update_syllabus_id: courses_service/edit_course" course.time = params[:time] course.term = params[:term] course.end_time = params[:end_time] diff --git a/app/services/syllabuses_service.rb b/app/services/syllabuses_service.rb index fcb70653b..4681917fc 100644 --- a/app/services/syllabuses_service.rb +++ b/app/services/syllabuses_service.rb @@ -86,12 +86,14 @@ class SyllabusesService courses.each do |course| if ::Course === course course.syllabus_id = sy.id + Rails.logger.error "update_syllabus_id: syllabus_service/create" course.save! send_wechat_create_class_notice user,course elsif Hash === course c = ::Course.new(course) c.tea_id = user.id c.syllabus_id = sy.id + Rails.logger.error "update_syllabus_id: syllabus_service/create" c.update_default_value c.is_public = 0 c.save! @@ -136,6 +138,7 @@ class SyllabusesService course.name = c course.tea_id = user.id course.syllabus_id = sy.id + Rails.logger.error "update_syllabus_id: syllabus_service/edit" course.update_default_value course.is_public = 0 course.save! diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index d4d9d7c16..1bd71e7a9 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -1,5 +1,5 @@