Show More
Commit Description:
moved to ror 2.0.2, add user rel to model submission...
Commit Description:
moved to ror 2.0.2, add user rel to model submission
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@3 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
app/controllers/user_admin_controller.rb
| 73 lines
| 1.5 KiB
| text/x-ruby
| RubyLexer
|
|
r0 | class UserAdminController < ApplicationController | ||
before_filter :authenticate, :authorization | ||||
def index | ||||
list | ||||
render :action => 'list' | ||||
end | ||||
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) | ||||
verify :method => :post, :only => [ :destroy, :create, :update ], | ||||
:redirect_to => { :action => :list } | ||||
def list | ||||
|
r1 | @users = User.find(:all) | ||
|
r0 | end | ||
def show | ||||
@user = User.find(params[:id]) | ||||
end | ||||
def new | ||||
@user = User.new | ||||
end | ||||
def create | ||||
@user = User.new(params[:user]) | ||||
if @user.save | ||||
flash[:notice] = 'User was successfully created.' | ||||
redirect_to :action => 'list' | ||||
else | ||||
render :action => 'new' | ||||
end | ||||
end | ||||
def edit | ||||
@user = User.find(params[:id]) | ||||
end | ||||
def update | ||||
@user = User.find(params[:id]) | ||||
if @user.update_attributes(params[:user]) | ||||
flash[:notice] = 'User was successfully updated.' | ||||
redirect_to :action => 'show', :id => @user | ||||
else | ||||
render :action => 'edit' | ||||
end | ||||
end | ||||
def destroy | ||||
User.find(params[:id]).destroy | ||||
redirect_to :action => 'list' | ||||
end | ||||
def user_stat | ||||
@problems = Problem.find_available_problems | ||||
@users = User.find(:all) | ||||
@scorearray = Array.new | ||||
@users.each do |u| | ||||
ustat = Array.new | ||||
ustat[0] = u.login | ||||
@problems.each do |p| | ||||
c, sub = Submission.find_by_user_and_problem(u.id,p.id) | ||||
if c!=0 | ||||
ustat << sub.points | ||||
else | ||||
ustat << 0 | ||||
end | ||||
end | ||||
@scorearray << ustat | ||||
end | ||||
end | ||||
end | ||||