添加《学生列表按作业评分排序》功能

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2014-12-18 18:24:37 +08:00
parent 6b2fb87b2c
commit 1965b75d92
6 changed files with 147 additions and 57 deletions

View File

@ -23,7 +23,7 @@ class CoursesController < ApplicationController
before_filter :require_login, :only => [:join, :unjoin]
#before_filter :allow_join, :only => [:join]
@@result = nil
def join
if User.current.logged?
course = Course.find_by_id params[:object_id]
@ -296,6 +296,7 @@ class CoursesController < ApplicationController
else
@results = searchStudent(@course)
end
@@result = @results
@members = searchStudent(@course)
@membercount = @members.count
@results = paginateHelper @results
@ -308,6 +309,7 @@ class CoursesController < ApplicationController
@members = searchStudent(@course)
@membercount = @members.count
@results = searchStudent_by_group(group, @course)
@@result = @results
@results = paginateHelper @results
end
def member
@ -326,13 +328,14 @@ class CoursesController < ApplicationController
when '2'
@subPage_title = l :label_student_list
@members = searchStudent(@course)
@members = searchStudent_sort(@course, 'desc')
@membercount = @members.count
else
@subPage_title = ''
@members = @course.member_principals.includes(:roles, :principal).all.sort
end
@@result = @members
@members = paginateHelper @members
render :layout => 'base_courses'
else
@ -340,6 +343,21 @@ class CoursesController < ApplicationController
end
end
def member_score_sort
@teachers= searchTeacherAndAssistant(@course)
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@role = params[:role]
@course_groups = @course.course_groups if @course.course_groups
@show_serch = params[:role] == '2'
@subPage_title = l :label_student_list
@render_file = 'member_list'
unless @@result.nil?
@results = @@result.reverse
@@result = @results
end
@results = paginateHelper @results
end
# 显示每个学生的作业评分详情
def show_member_score
@member_score = Member.find(params[:member_id]) if params[:member_id]

View File

@ -175,18 +175,24 @@ module CoursesHelper
end
members
end
def search_student_and_score project
def searchStudent_sort project, sort_by
#searchPeopleByRoles(project, StudentRoles)
members = []
scores = []
project.members.each do |m|
if m && m.user && m.user.allowed_to?(:as_student,project)
members << m
end
end
members.sort!{ |mem1, mem2| mem1.student_homework_score[1].to_f <=> mem2.student_homework_score[1].to_f}
if sort_by == "desc"
members.reverse!
end
members
end
def searchStudent_by_name project, name
#searchPeopleByRoles(project, StudentRoles)
members = []

View File

@ -1,3 +1,13 @@
<script type=" text/javascript" charset="utf-8">
function change_pic(id){
var classname = document.getElementById(id).className
if(classname == 'st_up') {
document.getElementById(id).className = 'st_down'
}
else
document.getElementById(id).className = 'st_up'
}
</script>
<div style="margin-left: 15px" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
<% if !@canShowCode %>
@ -30,13 +40,15 @@
<div class="st_box">
<ul class="st_box_top">
<% if @subPage_title == l(:label_student_list) %>
<li class="ml358"><a href="#" >作业积分</a><a href="#" class="st_down"></a></li>
<li class="ml358"><%= link_to '作业积分', member_score_sort_course_path ,method: 'get', remote: true, :onclick => "change_pic('pic')"%>
<a id="pic" href="#" class="st_down"></a></li>
<li class="ml50"><a href="#" >加入时间</a></li>
<% else %>
<li class="ml50" style="margin-left: 470px"><a href="#" >加入时间</a></li>
<li class="ml50" style="margin-left: 470px"><li class="ml50"><a href="#" >加入时间</a></li>
<% end %>
</ul>
<div id="list_detail">
<% members.each do |member| %>
<div class="cl"></div><!--st_box_top end-->
@ -86,6 +98,7 @@
</div>
<% end; reset_cycle %>
</div>
</div>
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
<% else %>
<p class="nodata">

View File

@ -0,0 +1,48 @@
<% members.each do |member| %>
<div class="cl"></div><!--st_box_top end-->
<div class="st_boxlist">
<% next if member.new_record? %>
<a href="#" class="st_img" style="float:left;"> <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %></a>
<ul style="margin-left: 15px">
<% if @canShowCode %>
<li>
<%= l(:label_bidding_user_studentname) %> :
<%= link_to member.user.show_name, user_path(member.user) %>
</li> </br>
<%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %>
<% else %>
<%= content_tag "li", link_to(member.user.name, user_path(member.user)) %>
<% end %>
<!--teacher's code disapeared moified by huang-->
<% if @canShowCode %>
<li>
<%= l(:label_bidding_user_studentcode) %> :
<%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
</li>
<%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %>
<% end %>
</ul>
<% if @subPage_title == l(:label_student_list) %>
<%= link_to member.student_homework_score[1].to_s, {
:action => 'show_member_score',
:member_id => member.id,
:remote => true},
:class => 'ml258 c_red', :style => "color:red;" %>
<% unless member.created_on.nil? %>
<%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey" %>
<% end %>
<% else %>
<% unless member.created_on.nil? %>
<%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey", :style=>"margin-left:195px" %>
<% end %>
<% end %>
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
</div>
<% end; reset_cycle %>

View File

@ -0,0 +1,4 @@
/**
* Created by Administrator on 2014/12/3.
*/
$("#list_detail").html("<%= escape_javascript( render :partial => 'member_list_detail', :locals => {:members => @results})%>");

View File

@ -646,6 +646,7 @@ RedmineApp::Application.routes.draw do
post 'restartcourse'
match "searchmembers", :controller => 'courses', :action => 'searchmembers', :via => [:post,:get]
match "searchgroupmembers", :via => [:post, :get]
match 'member_score_sort', :via => [:get]
match "updategroupname", :via => [:post, :get]
match "addgroups", :via => [:post, :get]
match 'deletegroup', :via => [:delete]