# HG changeset patch # User Jittat Fakcharoenphol # Date 2010-02-16 15:03:56 # Node ID 0b01fdb623a84f92220f470239cd0ab003dfabfe # Parent 48430f9891a7287aaf8f9d8e7ca3f62e2092e946 CRUD for contests. combined new contest pages with old contest management. fixed styling. diff --git a/app/controllers/contest_management_controller.rb b/app/controllers/contest_management_controller.rb --- a/app/controllers/contest_management_controller.rb +++ b/app/controllers/contest_management_controller.rb @@ -3,6 +3,7 @@ before_filter :admin_authorization def index + @num_contests = Contest.count() end def user_stat @@ -35,4 +36,15 @@ redirect_to :action => 'index' end + def change_contest_mode + if ['standard', 'contest', 'indv-contest'].include? params[:id] + config = Configuration.find_by_key('system.mode') + config.value = params[:id] + config.save + else + flash[:notice] = 'Wrong contest mode value' + end + redirect_to :action => 'index' + end + end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -2,6 +2,9 @@ before_filter :admin_authorization + in_place_edit_for :contest, :title + in_place_edit_for :contest, :enabled + # GET /contests # GET /contests.xml def index diff --git a/app/views/contest_management/_indv_contest_mode_index.html.haml b/app/views/contest_management/_indv_contest_mode_index.html.haml --- a/app/views/contest_management/_indv_contest_mode_index.html.haml +++ b/app/views/contest_management/_indv_contest_mode_index.html.haml @@ -1,4 +1,9 @@ -.submitbox - %b Menu: +%h2 Individual contest mode + +In this mode, each individual user can log in and participate in the +contest at any time. The contest timer starts as soon as the user log +in. + +.infobox = link_to '[View user start time]', :action => 'user_stat' = link_to '[Clear all start times]', {:action => 'clear_all_stat'}, {:confirm => 'Do you really want to clear all start time statistics?'} diff --git a/app/views/contest_management/index.html.haml b/app/views/contest_management/index.html.haml --- a/app/views/contest_management/index.html.haml +++ b/app/views/contest_management/index.html.haml @@ -1,20 +1,30 @@ %h1 Contest management -.submitbox +.infobox - %b Multiple contests: - = "There are #{Contest.count} contests running." - = "[#{link_to 'Create/Update/Delete contests', :controller => 'contests', :action => 'index'}]" - + - if @num_contests>1 + %b Multiple contests: + = "There are #{@num_contests} contests running." + - else + %b Single contest: + = "[#{link_to 'Add/remove contests', :controller => 'contests', :action => 'index'}]" -%b Contest mode: +.infobox + %b Web interface mode: + - if (not Configuration.contest_mode?) and (not Configuration.indv_contest_mode?) + standard mode + - elsif Configuration.contest_mode? + normal contest mode. + - else + individual contest mode. -- if (not Configuration.contest_mode?) and (not Configuration.indv_contest_mode?) - Currently the system is not running in contest mode. -- elsif Configuration.contest_mode? - System running in normal contest mode. -- else - System running in individual contest mode. + %br/ + Change mode to: + = "[#{link_to 'standard', :action => 'change_contest_mode', :id => 'standard'}]" + = "[#{link_to 'contest', :action => 'change_contest_mode', :id => 'contest'}]" + = "[#{link_to 'individual contest', :action => 'change_contest_mode', :id => 'indv-contest'}]" + +- if Configuration.indv_contest_mode? = render :partial => 'indv_contest_mode_index' %br/ diff --git a/app/views/contests/edit.html.erb b/app/views/contests/edit.html.erb --- a/app/views/contests/edit.html.erb +++ b/app/views/contests/edit.html.erb @@ -3,18 +3,23 @@ <% form_for(@contest) do |f| %> <%= f.error_messages %> -

- <%= f.label :title %>
- <%= f.text_field :title %> -

-

- <%= f.label :enabled %>
- <%= f.check_box :enabled %> -

+ + + + + + + + + +
<%= f.label :title %><%= f.text_field :title %>
+ <%= f.check_box :enabled %> + <%= f.label :enabled %> +

<%= f.submit 'Update' %>

<% end %> <%= link_to 'Show', @contest %> | -<%= link_to 'Back', contests_path %> \ No newline at end of file +<%= link_to 'Back', contests_path %> diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb --- a/app/views/contests/index.html.erb +++ b/app/views/contests/index.html.erb @@ -1,19 +1,24 @@ +<% content_for :head do %> +<%= javascript_include_tag :defaults %> +<% end %> +

Listing contests

-
- Go back to [<%= link_to 'contest management', :controller => 'contest_management', :action => 'index' %>] +
+ Go back to: [<%= link_to 'contest management', :controller => 'contest_management', :action => 'index' %>]
- + <% @contests.each do |contest| %> + <% @contest = contest %> - - + + diff --git a/app/views/contests/show.html.erb b/app/views/contests/show.html.erb --- a/app/views/contests/show.html.erb +++ b/app/views/contests/show.html.erb @@ -1,7 +1,8 @@ -

- Title: - <%=h @contest.title %> -

+

Contest: <%=h @contest.title %>

+ +
+ Go back to: [<%= link_to 'contest management', :controller => 'contest_management', :action => 'index' %>] +

Enabled: @@ -10,4 +11,4 @@ <%= link_to 'Edit', edit_contest_path(@contest) %> | -<%= link_to 'Back', contests_path %> \ No newline at end of file +<%= link_to 'Back', contests_path %> diff --git a/app/views/user_admin/list.rhtml b/app/views/user_admin/list.rhtml --- a/app/views/user_admin/list.rhtml +++ b/app/views/user_admin/list.rhtml @@ -1,38 +1,38 @@

Listing users

-Quick add -<% form_tag :action => 'create' do %> -
TitleEnabledEnabled
<%=h contest.title %><%=h contest.enabled %><%= in_place_editor_field :contest, :title, {}, :rows => 1 %><%= in_place_editor_field :contest, :enabled, {}, :rows => 1 %> <%= link_to 'Show', contest %> <%= link_to 'Edit', edit_contest_path(contest) %> <%= link_to 'Destroy', contest, :confirm => 'Are you sure?', :method => :delete %>
- - - - - - - - - - - - - - -
<%= text_field 'user', 'login', :size => 10 %><%= text_field 'user', 'full_name', :size => 30 %><%= password_field 'user', 'password', :size => 10 %><%= password_field 'user', 'password_confirmation', :size => 10 %><%= text_field 'user', 'email', :size => 15 %><%= submit_tag "Create" %>
-<% end %> -
-Import from site management -<% form_tag({:action => 'import'}, :multipart => true) do %> - File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %> -<% end %> -
-What else: -<%= link_to '[New user]', :action => 'new' %> -<%= link_to '[New list of users]', :action => 'new_list' %> -<%= link_to '[View administrators]', :action => 'admin' %> -<%= link_to '[Random passwords]', :action => 'random_all_passwords' %> -<%= link_to '[View active users]', :action => 'active' %> - + Quick add + <% form_tag :action => 'create' do %> + + + + + + + + + + + + + + + + +
<%= text_field 'user', 'login', :size => 10 %><%= text_field 'user', 'full_name', :size => 30 %><%= password_field 'user', 'password', :size => 10 %><%= password_field 'user', 'password_confirmation', :size => 10 %><%= text_field 'user', 'email', :size => 15 %><%= submit_tag "Create" %>
+ <% end %> +
+ Import from site management + <% form_tag({:action => 'import'}, :multipart => true) do %> + File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %> + <% end %> +
+ What else: + <%= link_to '[New user]', :action => 'new' %> + <%= link_to '[New list of users]', :action => 'new_list' %> + <%= link_to '[View administrators]', :action => 'admin' %> + <%= link_to '[Random passwords]', :action => 'random_all_passwords' %> + <%= link_to '[View active users]', :action => 'active' %>
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1,342 +1,237 @@ -/* Main Default */ body { - background: white url(../images/topbg.jpg) repeat-x top center; - font-size: 13px; - font-family: Tahoma, "sans-serif"; - margin: 10px; - padding: 10px; -} + background: white url(../images/topbg.jpg) repeat-x top center; + font-size: 13px; + font-family: Tahoma, "sans-serif"; + margin: 10px; + padding: 10px; } -/* Form Font */ input { - font-family: Tahoma, "sans-serif"; -} + font-family: Tahoma, "sans-serif"; } -/* Heading 1&2 */ h1 { - font-size: 24px; - color: #334488; - line-height: 2em; -} + font-size: 24px; + color: #334488; + line-height: 2em; } h2 { - font-size: 18px; - color: #5566bb; - line-height: 1.5em; -} - -/* Bar Line Color and Thickness */ -hr { - border-top: 1px solid #dddddd; - border-bottom: 1px solid #eeeeee; -} + font-size: 18px; + color: #5566bb; + line-height: 1.5em; } -/* Link + Anchor Color */ -a, a:link, a:visited { - color: #6666cc; - text-decoration: none; -} - -a:hover, a:focus { - color: #111166; - text-decoration: none; -} +hr { + border-top: 1px solid #dddddd; + border-bottom: 1px solid #eeeeee; } -/* This is the main menu bad*/ -div.userbar { - line-height: 1.5em; - text-align: right; - font-size: 12px; -} +a { + color: #6666cc; + text-decoration: none; } + a:link, a:visited { + color: #6666cc; + text-decoration: none; } + a:hover, a:focus { + color: #111166; + text-decoration: none; } -/* This is the top bar, displaying user's full name */ +div.userbar { + line-height: 1.5em; + text-align: right; + font-size: 12px; } div.title { - // background: #ddddff; - // border: 1px dashed blue; - padding: 10px 0px; - line-height: 1.5em; - font-size: 13px; -} - -div.title span.contest-over-msg { + padding: 10px 0px; + line-height: 1.5em; + font-size: 13px; } + div.title span.contest-over-msg { font-size: 15px; - color: red; -} - -div.title table { + color: red; } + div.title table { width: 100%; - font-weight: bold; -} - -div.title td.left-col { + font-weight: bold; } + div.title td.left-col { text-align: left; vertical-align: top; - color: #444444; -} - -div.title td.right-col { + color: #444444; } + div.title td.right-col { text-align: right; vertical-align: top; font-size: 18px; - color: #116699; -} + color: #116699; } -/* Standard table with header and rows with alternating background */ table.info { - margin: 10px 0; - border: 1px solid #666666; - border-collapse: collapse; - font-size: 12px; -} - -table.info th { + margin: 10px 0; + border: 1px solid #666666; + border-collapse: collapse; + font-size: 12px; } + table.info th { border: 1px solid #666666; line-height: 1.5em; - padding: 0 0.5em; -} - -table.info td { + padding: 0 0.5em; } + table.info td { border-left: 1px solid #666666; border-right: 1px solid #666666; line-height: 1.5em; - padding: 0 0.5em; -} + padding: 0 0.5em; } tr.info-head { - background: #777777; - color: white; -} - + background: #777777; + color: white; } tr.info-odd { - background: #eeeeee; -} - + background: #eeeeee; } tr.info-even { - background: #f9f9f9; -} + background: #f9f9f9; } -/******************************* - [Main] -********************************/ -div.submitbox { - background: #eeeeff; - border: 1px dotted #99aaee; - padding: 5px; - margin: 10px 0px; - color: black; - font-size: 13px; -} +.infobox { + background: #eeeeff; + border: 1px dotted #99aaee; + padding: 5px; + margin: 10px 0px; + color: black; + font-size: 13px; } -div.errorExplanation { - border: 1px dotted gray; - color: #bb2222; - padding: 5px 15px 5px 15px; - margin-bottom: 5px; - background-color: white; - font-weight: normal; -} +.submitbox { + background: #eeeeff; + border: 1px dotted #99aaee; + padding: 5px; + margin: 10px 0px; + color: black; + font-size: 13px; } - -div.errorExplanation h2 { +.errorExplanation { + border: 1px dotted gray; + color: #bb2222; + padding: 5px 15px 5px 15px; + margin-bottom: 5px; + background-color: white; + font-weight: normal; } + .errorExplanation h2 { color: #cc1111; - font-weight: bold; -} + font-weight: bold; } -/******************************* - [Settings] -********************************/ table.uinfo { - border-collapse: collapse; - border: 1px solid black; - font-size: 13px; -} + border-collapse: collapse; + border: 1px solid black; + font-size: 13px; } td.uinfo { - vertical-align: top; - border: 1px solid black; - padding: 5px; -} + vertical-align: top; + border: 1px solid black; + padding: 5px; } th.uinfo { - background: lightgreen; - vertical-align: top; - text-align: right; - border: 1px solid black; - padding: 5px; -} + background: lightgreen; + vertical-align: top; + text-align: right; + border: 1px solid black; + padding: 5px; } -/******************************* - [Submission] -********************************/ div.compilermsgbody { - font-family: monospace; -} - + font-family: monospace; } div.task-menu { - text-align: center; - font-size: 13px; - line-height: 1.75em; - font-weight: bold; - border-top: 1px dashed gray; - border-bottom: 1px dashed gray; - margin-top: 2px; - margin-bottom: 4px; -} + text-align: center; + font-size: 13px; + line-height: 1.75em; + font-weight: bold; + border-top: 1px dashed gray; + border-bottom: 1px dashed gray; + margin-top: 2px; + margin-bottom: 4px; } -/******************************* - [Submission] -********************************/ table.taskdesc { - border: 2px solid #dddddd; - border-collapse: collapse; - margin: 10px auto; - width: 90%; - font-size: 13px; -} - -table.taskdesc p { - font-size: 13px; -} - -table.taskdesc tr.name { + border: 2px solid #dddddd; + border-collapse: collapse; + margin: 10px auto; + width: 90%; + font-size: 13px; } + table.taskdesc p { + font-size: 13px; } + table.taskdesc tr.name { border: 2px solid #dddddd; background: #dddddd; color: #333333; font-weight: bold; font-size: 14px; line-height: 1.5em; - text-align: center; -} - -table.taskdesc td.desc-odd { + text-align: center; } + table.taskdesc td.desc-odd { padding: 5px; padding-left: 20px; - background: #fefeee; -} - -table.taskdesc td.desc-even { + background: #fefeee; } + table.taskdesc td.desc-even { padding: 5px; padding-left: 20px; - background: #feeefe; -} - -/********************** - Announcement -***********************/ + background: #feeefe; } div.announcementbox { - margin: 10px 0px; - background: #bbddee; - padding: 1px; -} - -div.announcementbox span.title { + margin: 10px 0px; + background: #bbddee; + padding: 1px; } + div.announcementbox span.title { font-weight: bold; color: #224455; padding-left: 10px; - line-height: 1.6em; -} - + line-height: 1.6em; } div.announcement { - margin: 2px; - background: white; - padding: 1px; - padding-left: 10px; - padding-right: 10px; - padding-top: 5px; - padding-bottom: 5px; -} + margin: 2px; + background: white; + padding: 1px; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; } .announcement p { - font-size: 12px; - margin: 2px; -} + font-size: 12px; + margin: 2px; } -div.pub-info, div.pub-info p { +div.pub-info { + text-align: right; + font-style: italic; + font-size: 9px; } + div.pub-info p { text-align: right; font-style: italic; - font-size: 9px; -} + font-size: 9px; } .announcement .toggles { - font-weight: normal; - float: right; - font-size: 80%; -} - + font-weight: normal; + float: right; + font-size: 80%; } .announcement .announcement-title { - font-weight: bold; -} - -/****************** - Messages -******************/ + font-weight: bold; } div.message { - margin: 10px 0 0; -} - -div.message div.message { - margin: 0 0 0 30px; -} - -div.message div.body { + margin: 10px 0 0; } + div.message div.message { + margin: 0 0 0 30px; } + div.message div.body { border: 2px solid #dddddd; background: #fff8f8; - padding-left: 5px; -} - -div.message div.reply-body { + padding-left: 5px; } + div.message div.reply-body { border: 2px solid #bbbbbb; background: #fffff8; - padding-left: 5px; -} - -div.message div.stat { + padding-left: 5px; } + div.message div.stat { font-size: 10px; line-height: 1.75em; padding: 0 5px; color: #333333; background: #dddddd; - font-weight: bold; -} - -div.message div.message div.stat { + font-weight: bold; } + div.message div.message div.stat { font-size: 10px; line-height: 1.75em; padding: 0 5px; color: #444444; background: #bbbbbb; - font-weight: bold; -} - -/******************** - Registration -********************/ + font-weight: bold; } div.contest-title { - color: white; - text-align: center; - line-height: 2em; -} - -div.registration-desc { - border: 1px dotted gray; - background: #f5f5f5; - padding: 5px; - margin: 10px 0; - font-size: 12px; - line-height: 1.5em; -} - -/******************** - [Test Interface] -********************/ - -div.test-desc { - border: 1px dotted gray; - background: #f5f5f5; - padding: 5px; - margin: 10px 0; - font-size: 12px; - line-height: 1.5em; -} + color: white; + text-align: center; + line-height: 2em; } +div.registration-desc, div.test-desc { + border: 1px dotted gray; + background: #f5f5f5; + padding: 5px; + margin: 10px 0; + font-size: 12px; + line-height: 1.5em; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass new file mode 100644 --- /dev/null +++ b/public/stylesheets/sass/application.sass @@ -0,0 +1,290 @@ +body + background: white url(../images/topbg.jpg) repeat-x top center + font-size: 13px + font-family: Tahoma, "sans-serif" + margin: 10px + padding: 10px + + +input + font-family: Tahoma, "sans-serif" + + +h1 + font-size: 24px + color: #334488 + line-height: 2em + + +h2 + font-size: 18px + color: #5566bb + line-height: 1.5em + + +hr + border-top: 1px solid #dddddd + border-bottom: 1px solid #eeeeee + + +a + color: #6666cc + text-decoration: none + + &:link, &:visited + color: #6666cc + text-decoration: none + + &:hover, &:focus + color: #111166 + text-decoration: none + + +div + &.userbar + line-height: 1.5em + text-align: right + font-size: 12px + + &.title + padding: 10px 0px + line-height: 1.5em + font-size: 13px + + span.contest-over-msg + font-size: 15px + color: red + + table + width: 100% + font-weight: bold + + td + &.left-col + text-align: left + vertical-align: top + color: #444444 + + &.right-col + text-align: right + vertical-align: top + font-size: 18px + color: #116699 + + +table.info + margin: 10px 0 + border: 1px solid #666666 + border-collapse: collapse + font-size: 12px + + th + border: 1px solid #666666 + line-height: 1.5em + padding: 0 0.5em + + td + border-left: 1px solid #666666 + border-right: 1px solid #666666 + line-height: 1.5em + padding: 0 0.5em + + +tr + &.info-head + background: #777777 + color: white + + &.info-odd + background: #eeeeee + + &.info-even + background: #f9f9f9 + +=basicbox + background: #eeeeff + border: 1px dotted #99aaee + padding: 5px + margin: 10px 0px + color: black + font-size: 13px + +.infobox + +basicbox + +.submitbox + +basicbox + +.errorExplanation + border: 1px dotted gray + color: #bb2222 + padding: 5px 15px 5px 15px + margin-bottom: 5px + background-color: white + font-weight: normal + + h2 + color: #cc1111 + font-weight: bold + + +table.uinfo + border-collapse: collapse + border: 1px solid black + font-size: 13px + + +td.uinfo + vertical-align: top + border: 1px solid black + padding: 5px + + +th.uinfo + background: lightgreen + vertical-align: top + text-align: right + border: 1px solid black + padding: 5px + + +div + &.compilermsgbody + font-family: monospace + + &.task-menu + text-align: center + font-size: 13px + line-height: 1.75em + font-weight: bold + border-top: 1px dashed gray + border-bottom: 1px dashed gray + margin-top: 2px + margin-bottom: 4px + + +table.taskdesc + border: 2px solid #dddddd + border-collapse: collapse + margin: 10px auto + width: 90% + font-size: 13px + + p + font-size: 13px + + tr.name + border: 2px solid #dddddd + background: #dddddd + color: #333333 + font-weight: bold + font-size: 14px + line-height: 1.5em + text-align: center + + td + &.desc-odd + padding: 5px + padding-left: 20px + background: #fefeee + + &.desc-even + padding: 5px + padding-left: 20px + background: #feeefe + + +div + &.announcementbox + margin: 10px 0px + background: #bbddee + padding: 1px + + span.title + font-weight: bold + color: #224455 + padding-left: 10px + line-height: 1.6em + + &.announcement + margin: 2px + background: white + padding: 1px + padding-left: 10px + padding-right: 10px + padding-top: 5px + padding-bottom: 5px + + +.announcement p + font-size: 12px + margin: 2px + + +div.pub-info + text-align: right + font-style: italic + font-size: 9px + + p + text-align: right + font-style: italic + font-size: 9px + + +.announcement + .toggles + font-weight: normal + float: right + font-size: 80% + + .announcement-title + font-weight: bold + + +div + &.message + margin: 10px 0 0 + + div + &.message + margin: 0 0 0 30px + + &.body + border: 2px solid #dddddd + background: #fff8f8 + padding-left: 5px + + &.reply-body + border: 2px solid #bbbbbb + background: #fffff8 + padding-left: 5px + + &.stat + font-size: 10px + line-height: 1.75em + padding: 0 5px + color: #333333 + background: #dddddd + font-weight: bold + + &.message div.stat + font-size: 10px + line-height: 1.75em + padding: 0 5px + color: #444444 + background: #bbbbbb + font-weight: bold + + &.contest-title + color: white + text-align: center + line-height: 2em + + &.registration-desc, &.test-desc + border: 1px dotted gray + background: #f5f5f5 + padding: 5px + margin: 10px 0 + font-size: 12px + line-height: 1.5em