dev_trainings
jingquan huang 6 years ago
commit d27f6a1ba4

@ -297,7 +297,6 @@ class ShixunsController < ApplicationController
# 首页实训导航点击时type参数 # 首页实训导航点击时type参数
def index def index
logger.info("##########humen count : #{session[:user_id].count}")
@type = params[:type] @type = params[:type]
@status = [["全部状态", 0], ["已发布", 2], ["未发布", 1], ["已关闭", 3]] @status = [["全部状态", 0], ["已发布", 2], ["未发布", 1], ["已关闭", 3]]
@diff = ["全部难度", "初级学员", "中级学员", "高级学员", "顶级学员"] @diff = ["全部难度", "初级学员", "中级学员", "高级学员", "顶级学员"]

@ -7,7 +7,7 @@ class StudentWorkController < ApplicationController
require "base64" require "base64"
helper :attachments helper :attachments
helper :files 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, :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] :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, 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 :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 :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 :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/ if RUBY_PLATFORM =~ /linux/
require 'roo-xls' require 'roo-xls'
@ -493,7 +493,7 @@ class StudentWorkController < ApplicationController
render :json => resultObj render :json => resultObj
end end
def index def _index
# REDO:分班信息提前查出来,然后循环中根据匹配去取 # REDO:分班信息提前查出来,然后循环中根据匹配去取
@is_teacher = User.current.logged? ? (User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) : false @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 @page = (params['page'] || 1).to_i
@student_work_pages = Paginator.new @student_work_count, @limit, @page @student_work_pages = Paginator.new @student_work_count, @limit, @page
@offset ||= @student_work_pages.offset @offset ||= @student_work_pages.offset
end
def index
_index
@stundet_works = paginateHelper @stundet_works, @limit @stundet_works = paginateHelper @stundet_works, @limit
if @stundet_works.size != 0 if @stundet_works.size != 0
@stundet_works = if @homework.homework_type == 1 @stundet_works = if @homework.homework_type == 1
@ -630,6 +636,35 @@ class StudentWorkController < ApplicationController
end end
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 def adjust_review_score
if params[:score] && params[:challenge_id] if params[:score] && params[:challenge_id]
@ -1852,6 +1887,7 @@ class StudentWorkController < ApplicationController
end end
end end
private private
def hsd_committed_work?(user, homework) def hsd_committed_work?(user, homework)

@ -15,35 +15,36 @@
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function () {
$(".white-panel li").click(function(){ $(".white-panel li").click(function () {
$(".white-panel li").removeClass("active"); $(".white-panel li").removeClass("active");
$(this).addClass("active"); $(this).addClass("active");
var n=$(this).attr("index"); var n = $(this).attr("index");
if($(this).find("a").html().trim()=="作业问答"){ if ($(this).find("a").html().trim() == "作业问答") {
$.get("<%= homework_discuss_student_work_index_path(:homework => @homework.id) %>"); $.get("<%= homework_discuss_student_work_index_path(:homework => @homework.id) %>");
} }
if($(this).find("a").html().trim()=="设置"){ if ($(this).find("a").html().trim() == "设置") {
$.get("<%= homework_setting_student_work_index_path(:homework => @homework.id, :is_new => @is_new) %>"); $.get("<%= homework_setting_student_work_index_path(:homework => @homework.id, :is_new => @is_new) %>");
} }
if($(this).find("a").html().trim()=="查重结果"){ if ($(this).find("a").html().trim() == "查重结果") {
$.get("<%= code_review_results_student_work_index_path(:homework => @homework.id) %>"); $.get("<%= code_review_results_student_work_index_path(:homework => @homework.id) %>");
} }
$(".edu-tab-con").addClass("undis"); $(".edu-tab-con").addClass("undis");
$("#edu-tab-con-"+n).removeClass("undis"); $("#edu-tab-con-" + n).removeClass("undis");
}) })
}) })
</script> </script>
<div class="edu-class-container"> <div class="edu-class-container">
<p class="mb10"> <p class="mb10">
<%= link_to @homework.course.name, course_path(@homework.course),:class => "color-grey-9" %> <%= link_to @homework.course.name, course_path(@homework.course), :class => "color-grey-9" %>
> <% if @homework.course_homework_category.present? %> >
<% 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" %> <%= 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 %> <% else %>
<%= link_to "#{@homework.homework_type_ch}作业", homework_common_index_path(:course => @homework.course_id, :homework_type => @homework.homework_type),:class => "color-grey-9" %> <%= link_to "#{@homework.homework_type_ch}作业", homework_common_index_path(:course => @homework.course_id, :homework_type => @homework.homework_type), :class => "color-grey-9" %>
<% end %> <% end %>
> #<%= get_hw_index(@homework, @is_teacher, @homework.homework_type) + 1 %></p> > #<%= get_hw_index(@homework, @is_teacher, @homework.homework_type) + 1 %></p>
<div class="pt10 pb10 edu-back-white clearfix"> <div class="pt10 pb10 edu-back-white clearfix">
@ -71,7 +72,7 @@
<a href="javascript:void(0);" class="tab_type">参考答案</a> <a href="javascript:void(0);" class="tab_type">参考答案</a>
</li> </li>
<% end %> <% end %>
<% if @is_teacher && @homework.homework_type == 4 && @homework.homework_group_reviews.size > 0 %> <% if @is_teacher && @homework.homework_type == 4 && @homework.homework_group_reviews.count > 0 %>
<li id="edu-tab-nav-5" index="5"> <li id="edu-tab-nav-5" index="5">
<a href="javascript:void(0);" class="tab_type"> <a href="javascript:void(0);" class="tab_type">
查重结果 查重结果
@ -153,7 +154,7 @@
<% student_works = @homework.student_works.where("work_status != 0") %> <% student_works = @homework.student_works.where("work_status != 0") %>
<% if @group_teacher %> <% if @group_teacher %>
<% groups = @course.course_groups.where(:id => @member.teacher_course_groups.pluck(:course_group_id)) %> <% 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)) %> <% student_works = student_works.where(:user_id => group_students.map(&:user_id)) %>
<% else %> <% else %>
<% groups = @course.course_groups %> <% groups = @course.course_groups %>
@ -198,11 +199,15 @@
<a href="javascript:void(0);" id="status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl10 pr10">不限</a> <a href="javascript:void(0);" id="status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl10 pr10">不限</a>
</span> </span>
<input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>> <input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>>
<label for="work_status_1" class="fl mr25">未提交(<%= @all_student_works.where(:work_status => 0).size %>)</label> <label for="work_status_1" class="fl mr25">未提交(<%= @all_student_works.where(:work_status => 0).count %>
)</label>
<input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>> <input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>>
<label for="work_status_2" class="fl mr25">按时提交(<%= student_works.where(:work_status => 1).size %>)</label> <label for="work_status_2" class="fl mr25">按时提交(<%= student_works.where(:work_status => 1).count %>
)</label>
<input id="work_status_3" class="magic-checkbox fl" type="checkbox" value="2" name="status[]" <%= !@status.blank? && @status.include?('2') ? 'checked' : '' %>> <input id="work_status_3" class="magic-checkbox fl" type="checkbox" value="2" name="status[]" <%= !@status.blank? && @status.include?('2') ? 'checked' : '' %>>
<label for="work_status_3" class="fl mr25">延时提交(<%= student_works.where(:work_status => 2).size %>)</label> <label for="work_status_3" class="fl mr25">延时提交(<%= student_works.where(:work_status => 2).count %>
)</label>
</li> </li>
<li class="clearfix"> <li class="clearfix">
<span class="fl mr10 color-grey-8">分班情况:</span> <span class="fl mr10 color-grey-8">分班情况:</span>
@ -212,7 +217,8 @@
<p class="fl pb10" style="display: block;max-width: 995px;"> <p class="fl pb10" style="display: block;max-width: 995px;">
<% groups.includes(:members).each do |group| %> <% groups.includes(:members).each do |group| %>
<input id="group_<%= group.id %>" class="magic-checkbox fl" type="checkbox" value="<%= group.id %>" name="group[]" <%= !@group.blank? && @group.include?(group.id) ? 'checked' : '' %>> <input id="group_<%= group.id %>" class="magic-checkbox fl" type="checkbox" value="<%= group.id %>" name="group[]" <%= !@group.blank? && @group.include?(group.id) ? 'checked' : '' %>>
<label for="group_<%= group.id %>" class="fl mr25"><%= group.name %>(<%= group.members.size %>)</label> <label for="group_<%= group.id %>" class="fl mr25"><%= group.name %>
(<%= group.members.count %>)</label>
<% end %> <% end %>
<% if !@group_teacher %> <% if !@group_teacher %>
<input id="group_0" class="magic-checkbox fl" type="checkbox" value="0" name="group[]"> <input id="group_0" class="magic-checkbox fl" type="checkbox" value="0" name="group[]">
@ -241,6 +247,10 @@
<% end %> <% end %>
<% end %> <% end %>
<% if User.current.admin? %>
<a onclick="sonar()" data-tip-down="仅限振远使用" class="fl white-btn orange-btn mt10 ml25">质量检测</a>
<% end %>
<div class="edu-find fr mr20 with20 pr"> <div class="edu-find fr mr20 with20 pr">
<div class="edu-find-input"> <div class="edu-find-input">
<input type="text" class="task-form-100 panel-box-sizing" maxlength="20" placeholder="姓名、学号关键字检索" value="<%= @name %>" id="course_student_name"/> <input type="text" class="task-form-100 panel-box-sizing" maxlength="20" placeholder="姓名、学号关键字检索" value="<%= @name %>" id="course_student_name"/>
@ -362,8 +372,7 @@
if (!event) { if (!event) {
event = window.event; //针对ie浏览器 event = window.event; //针对ie浏览器
code = event.keyCode; code = event.keyCode;
} } else {
else {
code = event.keyCode; code = event.keyCode;
} }
if (code == 13) { if (code == 13) {
@ -416,4 +425,28 @@
pop_box_new(htmlvalue, 452, 163); pop_box_new(htmlvalue, 452, 163);
$("#submit_url").val('<%= import_score_student_work_index_path(:homework => @homework.id) %>'); $("#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('调用完成,请等待处理完成');
}
})
}
})
}
</script> </script>

@ -1248,6 +1248,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'relate_myshixun' get 'relate_myshixun'
get 'shixun_work_export' get 'shixun_work_export'
post 'import_score' post 'import_score'
get 'sonar'
end end
end end

Loading…
Cancel
Save