diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index dd9b1bda..df1fdcd6 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -7,7 +7,7 @@ class StudentWorkController < ApplicationController require "base64" helper :attachments helper :files - before_filter :find_homework, :only => [:new, :index, :create, :homework_discuss, :homework_setting, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex, + before_filter :find_homework, :only => [:new, :index, :sonar, :create, :homework_discuss, :homework_setting, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex, :set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project, :search_course_students,:work_canrepeat,:change_project,:relate_myshixun,:shixun_work_export,:import_score,:code_review_results] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :adjust_score, :add_ultimate_score, :praise_student_work, :retry_work, :revise_attachment, :hide_score_detail, :destroy_score, @@ -15,7 +15,7 @@ class StudentWorkController < ApplicationController before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work, :commit_summary, :view_summary] 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, :forbidden_anonymous_comment, :adjust_score, :add_ultimate_score] - before_filter :require_login, :only => [:index, :show] + before_filter :require_login, :only => [:index, :sonar, :show] if RUBY_PLATFORM =~ /linux/ require 'roo-xls' @@ -493,7 +493,7 @@ class StudentWorkController < ApplicationController render :json => resultObj end - def index + def _index # REDO:分班信息提前查出来,然后循环中根据匹配去取 @is_teacher = User.current.logged? ? (User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) : false @@ -608,6 +608,12 @@ class StudentWorkController < ApplicationController @page = (params['page'] || 1).to_i @student_work_pages = Paginator.new @student_work_count, @limit, @page @offset ||= @student_work_pages.offset + end + + + def index + _index + @stundet_works = paginateHelper @stundet_works, @limit respond_to do |format| format.js @@ -620,6 +626,35 @@ class StudentWorkController < ApplicationController end end + + def sonar + _index + logger.debug "@stundet_works #{@stundet_works}" + + person_list = @stundet_works.map do |work| + o = { + name: "#{work.user.show_real_name}", + uid: "#{work.user.user_extensions.student_id}", + downloadUrl: '' + } + attachment = work.attachments.first + if attachment + o[:downloadUrl] = "https://#{Setting.host_name}/"+download_named_attachment_path(attachment.id, attachment.filename) + end + + o + end + + respond_to do |format| + format.json { + render json: { + homeworkId: @homework.id, + personList: person_list + } + } + end + end + # 查重详情页面的调分 def adjust_review_score if params[:score] && params[:challenge_id] @@ -1842,6 +1877,7 @@ class StudentWorkController < ApplicationController end end + private def hsd_committed_work?(user, homework) diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index f48bf0b2..d4352309 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -15,36 +15,37 @@

- <%= link_to @homework.course.name, course_path(@homework.course),:class => "color-grey-9" %> - > <% if @homework.course_homework_category.present? %> - <%= link_to @homework.course_homework_category.name, homework_common_index_path(:course => @homework.course_id, :homework_type => @homework.homework_type, :category => @homework.course_homework_category_id), :class => "color-grey-9" %> - <% else %> - <%= link_to "#{@homework.homework_type_ch}作业", homework_common_index_path(:course => @homework.course_id, :homework_type => @homework.homework_type),:class => "color-grey-9" %> - <% end %> + <%= link_to @homework.course.name, course_path(@homework.course), :class => "color-grey-9" %> + > + <% if @homework.course_homework_category.present? %> + <%= link_to @homework.course_homework_category.name, homework_common_index_path(:course => @homework.course_id, :homework_type => @homework.homework_type, :category => @homework.course_homework_category_id), :class => "color-grey-9" %> + <% else %> + <%= link_to "#{@homework.homework_type_ch}作业", homework_common_index_path(:course => @homework.course_id, :homework_type => @homework.homework_type), :class => "color-grey-9" %> + <% end %> > #<%= get_hw_index(@homework, @is_teacher, @homework.homework_type) + 1 %>

@@ -72,11 +73,11 @@ <% end %> <% if @is_teacher && @homework.homework_type == 4 && @homework.homework_group_reviews.count > 0 %> -

  • - - 查重结果 - -
  • +
  • + + 查重结果 + +
  • <% end %>
  • @@ -153,7 +154,7 @@ <% student_works = @homework.student_works.where("work_status != 0") %> <% if @group_teacher %> <% groups = @course.course_groups.where(:id => @member.teacher_course_groups.pluck(:course_group_id)) %> - <% group_students = @course.members.where(:course_group_id => @member.teacher_course_groups.pluck(:course_group_id)).select{|m| m.roles.to_s.include?("Student")} %> + <% group_students = @course.members.where(:course_group_id => @member.teacher_course_groups.pluck(:course_group_id)).select {|m| m.roles.to_s.include?("Student")} %> <% student_works = student_works.where(:user_id => group_students.map(&:user_id)) %> <% else %> <% groups = @course.course_groups %> @@ -198,11 +199,14 @@ 不限 > - + > - + > - +
  • 分班情况: @@ -212,7 +216,8 @@

    <% groups.each do |group| %> > - + <% end %> <% if !@group_teacher %> @@ -241,6 +246,10 @@ <% end %> <% end %> + <% if User.current.admin? %> + 质量检测 + <% end %> +

    @@ -362,8 +371,7 @@ if (!event) { event = window.event; //针对ie浏览器 code = event.keyCode; - } - else { + } else { code = event.keyCode; } if (code == 13) { @@ -416,4 +424,28 @@ pop_box_new(htmlvalue, 452, 163); $("#submit_url").val('<%= import_score_student_work_index_path(:homework => @homework.id) %>'); } + + function sonar() { + $.ajax({ + url: '/student_work/sonar?homework=' + $("#homework_id").val(), + type: 'get', + data: $("#student_work_search_form").serialize(), + success: function (data) { + console.log(data); + //调用sonar + + $.ajax({ + url: 'http://127.0.0.1:8080/api/sonar', + contentType: "application/json; charset=utf-8", + dataType: "json", + type: 'post', + data: JSON.stringify(data), + success: function (data1) { + console.log(data1); + alert('调用完成,请等待处理完成'); + } + }) + } + }) + } diff --git a/config/routes.rb b/config/routes.rb index 082a1d99..d02c1e4e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1247,6 +1247,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 get 'relate_myshixun' get 'shixun_work_export' post 'import_score' + get 'sonar' end end