diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index bc764d034..52e1f5fd0 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -61,7 +61,7 @@ class AdminController < ApplicationController if params[:syllabus_id] && params[:course_id] course = Course.where("id = #{params[:course_id].to_i}").first unless course.nil? - course.update_attribute('syllabus_id', params[:syllabus_id].to_i) + course.update_column('syllabus_id', params[:syllabus_id].to_i) @flag = true end end @@ -112,10 +112,10 @@ class AdminController < ApplicationController def non_syllabus_courses @name = params[:name].to_s.strip.downcase if @name && @name != "" - @courses = Course.where("syllabus_id is null").select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)} + @courses = Course.where("syllabus_id is null and is_delete = 0").select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)} @courses = @courses.sort{|x, y| y.created_at <=> x.created_at} else - @courses = Course.where("syllabus_id is null").order('created_at desc') + @courses = Course.where("syllabus_id is null and is_delete = 0").order('created_at desc') end @courses = paginateHelper @courses,30 @page = (params['page'] || 1).to_i - 1 @@ -124,11 +124,11 @@ class AdminController < ApplicationController end end - #修改课程名称 + #修改班级名称 def update_course_name @course = Course.where("id = #{params[:course_id].to_i}").first unless @course.nil? - @course.update_attribute("name", params[:name]) + @course.update_column("name", params[:name]) respond_to do |format| format.js end diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 73672d11a..03ed7945a 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -114,7 +114,7 @@ class QualityAnalysisController < ApplicationController end end rescue => e - puts e + @message = e.message end respond_to do |format| if @current_build_status == "success" @@ -227,9 +227,6 @@ class QualityAnalysisController < ApplicationController end @ha.store(key,value) end - - issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read - @sonar_issues = JSON.parse(issue_date).first end rescue => e puts e diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3f23d94dc..83a794cd9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2023,7 +2023,7 @@ class UsersController < ApplicationController @flag = true if params[:send_id].present? rs = ResourcesService.new - @ori, @flag, @save_message = rs.send_resource_to_course(params) + @ori, @flag, @save_message = rs.send_resource_to_course(User.current, params) elsif params[:send_ids].present? send_ids = params[:send_ids].split(",") course_ids = params[:course_ids] diff --git a/app/helpers/quality_analysis_helper.rb b/app/helpers/quality_analysis_helper.rb index 2a7d350e7..5940dd255 100644 --- a/app/helpers/quality_analysis_helper.rb +++ b/app/helpers/quality_analysis_helper.rb @@ -3,16 +3,16 @@ module QualityAnalysisHelper def sqale_rating_status val arr = [] - if val < 5 + if val <= 5 arr << "很好" arr << "b_green2" - elsif val. > 5 && val < 10 + elsif val. > 5 && val <= 10 arr << "较好" arr << "b_slow_yellow" - elsif val > 10 && val < 20 + elsif val > 10 && val <= 20 arr << "中等" arr << "b_yellow" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 arr << "较差" arr << "b_slow_red" elsif val > 20 @@ -23,10 +23,10 @@ module QualityAnalysisHelper def complexity_status val arr = [] - if val < 10 + if val <= 10 arr << "良好" arr << "b_green2" - elsif val > 10 && val < 15 + elsif val > 10 && val <= 15 arr << "较高" arr << "b_yellow" elsif val > 15 @@ -37,10 +37,10 @@ module QualityAnalysisHelper def duplicated_lines_density_status val arr = [] - if val < 30 + if val <= 30 arr << "良好" arr << "b_green2" - elsif val > 30 && val < 50 + elsif val > 30 && val <= 50 arr << "较高" arr << "b_yellow" elsif val > 50 @@ -51,10 +51,10 @@ module QualityAnalysisHelper def comment_lines_density_status val arr = [] - if val < 20 + if val <= 20 arr << "较低" arr << "b_yellow" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 arr << "正常" arr << "b_green2" elsif val > 50 @@ -64,15 +64,15 @@ module QualityAnalysisHelper end def score_sqale_rating val - if val > 0 && val < 5 + if val >= 0 && val <= 5 "5" - elsif val > 5 && val < 10 + elsif val > 5 && val <= 10 "4" - elsif val > 10 && val < 20 + elsif val > 10 && val <= 20 "3" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 "2" - elsif val > 20 + elsif val > 50 "1" end end diff --git a/app/views/admin/_courselist_detail_tr.html.erb b/app/views/admin/_courselist_detail_tr.html.erb index 07486faa3..83b7904ce 100644 --- a/app/views/admin/_courselist_detail_tr.html.erb +++ b/app/views/admin/_courselist_detail_tr.html.erb @@ -7,7 +7,7 @@ - <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %> + <%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %> <%= course.class_period %> @@ -15,6 +15,9 @@ <%= checked_image course.is_public? %> + + <%= course.is_delete == 0 ? '正常' : '归档' %> + <%= format_date(course.created_at) %> diff --git a/app/views/admin/courses.html.erb b/app/views/admin/courses.html.erb index 11fb1973f..8695bc6b9 100644 --- a/app/views/admin/courses.html.erb +++ b/app/views/admin/courses.html.erb @@ -27,10 +27,10 @@ - - + @@ -58,9 +61,11 @@ <% @courses.each do |course| %> + <% unless course.teacher.nil? %> " id="course_<%=course.id %>"> <%=render :partial => 'courselist_detail_tr', :locals => {:course => course} %> + <% end %> <% end %>
+ 序号 + 班级 @@ -42,6 +42,9 @@ <%=l(:field_is_public)%> + 状态 + <%=l(:field_created_on)%>
diff --git a/app/views/admin/non_syllabus_courses.html.erb b/app/views/admin/non_syllabus_courses.html.erb index 6c3cbec10..1be979eeb 100644 --- a/app/views/admin/non_syllabus_courses.html.erb +++ b/app/views/admin/non_syllabus_courses.html.erb @@ -27,10 +27,10 @@ - - + @@ -58,17 +61,18 @@ <% @courses.each do |course| %> + <% unless course.teacher.nil? %> " id="course_<%=course.id %>"> - + @@ -90,6 +97,7 @@ <% end %> + <% end %>
+ 序号 + 班级 @@ -42,6 +42,9 @@ <%=l(:field_is_public)%> + 状态 + <%=l(:field_created_on)%>
<%= course.id %> + <%= course.name%> - <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %> + <%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %> <%= course.class_period %> @@ -76,6 +80,9 @@ <%= checked_image course.is_public? %> + <%= course.is_delete == 0 ? '正常' : '归档' %> + <%= format_date(course.created_at) %>
diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb index b0b8abafe..3e2a7d373 100644 --- a/app/views/quality_analysis/_result_list.html.erb +++ b/app/views/quality_analysis/_result_list.html.erb @@ -17,10 +17,10 @@ <% if @quality_analyses.count >0 %> <% @quality_analyses.each do |qa| %>