Show More
Commit Description:
group enable
Commit Description:
group enable
References:
File last commit:
Show/Diff file:
Action:
app/helpers/application_helper.rb | 225 lines | 7.0 KiB | text/x-ruby | RubyLexer |
pramook
initial commit...
r0 # Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
jittat
added user settings...
r13
- change user_admin default action from list to index...
r588 #new bootstrap header
bootstrap navbar
r553 def navbar_user_header
left_menu = ''
right_menu = ''
user = User.find(session[:user_id])
if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list')
left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission')
left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index')
end
if GraderConfiguration['right.user_hall_of_fame']
left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof')
end
use jquery by default
r554 right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}})
bootstrap navbar
r553 if GraderConfiguration['system.user_setting_enabled']
use jquery by default
r554 right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}})
bootstrap navbar
r553 end
use jquery by default
r554 right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}})
bootstrap navbar
r553
result = content_tag(:ul,left_menu.html_safe,class: 'nav navbar-nav') + content_tag(:ul,right_menu.html_safe,class: 'nav navbar-nav navbar-right')
end
reorder submission and remove duplicate code for submission
r644 def add_menu(title, controller, action, html_option = {})
bootstrap navbar
r553 link_option = {controller: controller, action: action}
html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option)
content_tag(:li, link_to(title,link_option),html_option)
end
jittat
small changes, layouts...
r22 def user_header
jittat
test interface upload...
r36 menu_items = ''
jittat
added user settings...
r13 user = User.find(session[:user_id])
jittat
clean up layouts...
r25
jittat
[web] improved log-in & roles efficiency...
r104 if (user!=nil) and (session[:admin])
jittat
[web] small styling, split out admin's menu, put config into table.info...
r77 # admin menu
menu_items << "<b>Administrative task:</b> "
jittat
[web] added announcement...
r97 append_to menu_items, '[Announcements]', 'announcements', 'index'
jittat
[web] added message feature...
r102 append_to menu_items, '[Msg console]', 'messages', 'console'
Jittat Fakcharoenphol
added individual contest mode
r217 append_to menu_items, '[Problems]', 'problems', 'index'
append_to menu_items, '[Users]', 'user_admin', 'index'
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, '[Results]', 'user_admin', 'user_stat'
grafted from 2b2663ff0e59
r501 append_to menu_items, '[Report]', 'report', 'multiple_login'
jittat
[web] updated grader monitoring...
r105 append_to menu_items, '[Graders]', 'graders', 'list'
Jittat Fakcharoenphol
added contest model
r266 append_to menu_items, '[Contests]', 'contest_management', 'index'
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, '[Sites]', 'sites', 'index'
append_to menu_items, '[System config]', 'configurations', 'index'
jittat
[web] small styling, split out admin's menu, put config into table.info...
r77 menu_items << "<br/>"
end
jittat
clean up layouts...
r25 # main page
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
jittat
[web] added mode + access control, when sites started/finished...
r122
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
jittat
[web] added mode + access control, when sites started/finished...
r122 end
add options to allow hall of fame viewing by any user...
r424
prepare for better hall of fame
r425 if GraderConfiguration['right.user_hall_of_fame']
add options to allow hall of fame viewing by any user...
r424 append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof'
end
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
jittat
added 'user_setting_enabled' option...
r156
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if GraderConfiguration['system.user_setting_enabled']
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
jittat
added 'user_setting_enabled' option...
r156 end
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
jittat
test interface upload...
r36
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 menu_items.html_safe
jittat
test interface upload...
r36 end
def append_to(option,label, controller, action)
option << ' ' if option!=''
option << link_to_unless_current(label,
:controller => controller,
:action => action)
jittat
added user settings...
r13 end
jittat
[web] fixing ticket #10...
r65 def format_short_time(time)
- after submission, redirecto to edit_submission_path...
r696 now = Time.zone.now
jittat
[web] fixing ticket #10...
r65 st = ''
- after submission, redirecto to edit_submission_path...
r696 if (time.yday != now.yday) or (time.year != now.year)
st = time.strftime("%d/%m/%y ")
jittat
[web] fixing ticket #10...
r65 end
st + time.strftime("%X")
end
Jittat Fakcharoenphol
added individual contest mode
r217 def format_short_duration(duration)
return '' if duration==nil
d = duration.to_f
return Time.at(d).gmtime.strftime("%X")
end
- after submission, redirecto to edit_submission_path...
r696 def format_full_time_ago(time)
st = time_ago_in_words(time) + ' ago (' + format_short_time(time) + ')'
end
jittat
[web] added mode + access control, when sites started/finished...
r122 def read_textfile(fname,max_size=2048)
begin
File.open(fname).read(max_size)
rescue
nil
end
end
jittat
more styling...
r78
* add button size option to toggle_button helper
r563 def toggle_button(on,toggle_url,id, option={})
btn_size = option[:size] || 'btn-xs'
group enable
r795 btn_block = option[:block] || 'btn-block'
* add button size option to toggle_button helper
r563 link_to (on ? "Yes" : "No"), toggle_url,
group enable
r795 {class: "btn #{btn_block} #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle",
* add button size option to toggle_button helper
r563 id: id,
data: {remote: true, method: 'get'}}
* add forgotten toggle file...
r559 end
use ace editor for submission viewing
r566 def get_ace_mode(language)
# return ace mode string from Language
case language.pretty_name
when 'Pascal'
'ace/mode/pascal'
when 'C++','C'
'ace/mode/c_cpp'
when 'Ruby'
'ace/mode/ruby'
when 'Python'
'ace/mode/python'
when 'Java'
'ace/mode/java'
else
'ace/mode/c_cpp'
end
end
- countdown timer
r572
jittat
more styling...
r78 def user_title_bar(user)
jittat
[web] added mode + access control, when sites started/finished...
r122 header = ''
jittat
[web] site start/stop supports...
r123 time_left = ''
jittat
[web] added mode + access control, when sites started/finished...
r122
#
# if the contest is over
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if GraderConfiguration.time_limit_mode?
Jittat Fakcharoenphol
added individual contest mode
r217 if user.contest_finished?
jittat
[web] site start/stop supports...
r123 header = <<CONTEST_OVER
jittat
[web] added site and time out basic functionality...
r85 <tr><td colspan="2" align="center">
<span class="contest-over-msg">THE CONTEST IS OVER</span>
</td></tr>
CONTEST_OVER
jittat
[web] site start/stop supports...
r123 end
Jittat Fakcharoenphol
added individual contest mode
r217 if !user.contest_started?
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 time_left = "&nbsp;&nbsp;" + (t 'title_bar.contest_not_started')
else
Jittat Fakcharoenphol
added individual contest mode
r217 time_left = "&nbsp;&nbsp;" + (t 'title_bar.remaining_time') +
" #{format_short_duration(user.contest_time_left)}"
jittat
[web] site start/stop supports...
r123 end
jittat
[web] added site and time out basic functionality...
r85 end
jittat
[web] added mode + access control, when sites started/finished...
r122
#
# if the contest is in the anaysis mode
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if GraderConfiguration.analysis_mode?
jittat
[web] added mode + access control, when sites started/finished...
r122 header = <<ANALYSISMODE
<tr><td colspan="2" align="center">
<span class="contest-over-msg">ANALYSIS MODE</span>
</td></tr>
ANALYSISMODE
end
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 contest_name = GraderConfiguration['contest.name']
jittat
added contest.name to settings...
r141
jittat
[web] added mode + access control, when sites started/finished...
r122 #
# build real title bar
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 result = <<TITLEBAR
jittat
more styling...
r78 <div class="title">
<table>
jittat
[web] added mode + access control, when sites started/finished...
r122 #{header}
jittat
more styling...
r78 <tr>
<td class="left-col">
#{user.full_name}<br/>
update Current time to properly use rails time
r351 #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)}
jittat
[web] site start/stop supports...
r123 #{time_left}
<br/>
jittat
more styling...
r78 </td>
jittat
added contest.name to settings...
r141 <td class="right-col">#{contest_name}</td>
jittat
more styling...
r78 </tr>
</table>
</div>
TITLEBAR
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 result.html_safe
jittat
more styling...
r78 end
Jittat Fakcharoenphol
fixed javascript/css assets, fixed link_to_remote in problems page
r322 def markdown(text)
markdown = RDiscount.new(text)
markdown.to_html.html_safe
end
- add view testcase toggle for each problem...
r632
BOOTSTRAP_FLASH_MSG = {
success: 'alert-success',
error: 'alert-danger',
make group_user and group_problem unique
r678 alert: 'alert-danger',
- add view testcase toggle for each problem...
r632 notice: 'alert-info'
}
def bootstrap_class_for(flash_type)
BOOTSTRAP_FLASH_MSG.fetch(flash_type.to_sym, flash_type.to_s)
end
def flash_messages
flash.each do |msg_type, message|
concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
concat message
end)
end
nil
end
pramook
initial commit...
r0 end