diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -19,6 +19,12 @@
//= require select2
//= require custom
//= require ace-rails-ap
+//= require ace/mode-c_cpp
+//= require ace/mode-ruby
+//= require ace/mode-pascal
+//= require ace/mode-javascript
+//= require ace/mode-java
+//= require ace/theme-merbivore
// since this is after blank line, it is not downloaded
diff --git a/app/assets/javascripts/custom.js.coffee b/app/assets/javascripts/custom.js.coffee
--- a/app/assets/javascripts/custom.js.coffee
+++ b/app/assets/javascripts/custom.js.coffee
@@ -39,7 +39,7 @@
return
editor = ace.edit("editor")
- editor.setTheme("ace/theme/monokai")
+ editor.setTheme("ace/theme/merbivore")
editor.getSession().setMode("ace/mode/javascript")
return
diff --git a/app/assets/javascripts/sources.js.coffee b/app/assets/javascripts/sources.js.coffee
--- a/app/assets/javascripts/sources.js.coffee
+++ b/app/assets/javascripts/sources.js.coffee
@@ -8,3 +8,25 @@
h = $("#editor_text")
e = ace.edit("editor")
h.val(e.getValue())
+
+ $("#language_id").on "change", (event) ->
+ text = $("#language_id option:selected").text()
+ mode = 'ace/mode/c_cpp'
+ switch text
+ when 'Pascal' then mode = 'ace/mode/pascal'
+ when 'C++','C' then mode = 'ace/mode/c_cpp'
+ when 'Ruby' then mode = 'ace/mode/ruby'
+ when 'Python' then mode = 'ace/mode/python'
+ when 'Java' then mode = 'ace/mode/java'
+ editor = ace.edit('editor')
+ editor.getSession().setMode(mode)
+
+ e = ace.edit("editor")
+ e.setValue($("#text_haha").val())
+ e.gotoLine(1)
+ $("#language_id").trigger('change')
+
+
+
+
+ return
diff --git a/app/controllers/sources_controller.rb b/app/controllers/sources_controller.rb
--- a/app/controllers/sources_controller.rb
+++ b/app/controllers/sources_controller.rb
@@ -1,7 +1,17 @@
class SourcesController < ApplicationController
- before_filter :authenticate, :except => [:index, :login]
+ before_filter :authenticate
def direct_edit
- @problem = Problem.find_by_id(params[:pid])
+ @problem = Problem.find(params[:pid])
+ @source = ''
end
+
+ def direct_edit_submission
+ @submission = Submission.find(params[:sid])
+ @source = @submission.source.to_s
+ @problem = @submission.problem
+ @lang_id = @submission.language.id
+ render 'direct_edit'
+ end
+
end
diff --git a/app/views/main/_problem.html.erb b/app/views/main/_problem.html.erb
deleted file mode 100644
--- a/app/views/main/_problem.html.erb
+++ /dev/null
@@ -1,21 +0,0 @@
-
">
-
- <%= "#{problem_counter+1}" %>
- |
-
- <%= "#{problem.name}"%>
- |
-
- <%= "#{problem.full_name}" %>
- <%= link_to_description_if_any "[#{t 'main.problem_desc'}]", problem %>
- |
-
- <%= @prob_submissions[problem.id][:count] %>
- |
-
- <%= render :partial => 'submission_short',
- :locals => {
- :submission => @prob_submissions[problem.id][:submission],
- :problem_name => problem.name }%>
- |
-
diff --git a/app/views/main/_problem.html.haml b/app/views/main/_problem.html.haml
new file mode 100644
--- /dev/null
+++ b/app/views/main/_problem.html.haml
@@ -0,0 +1,11 @@
+%tr
+ %td
+ = "#{problem.name}"
+ %td
+ = "#{problem.full_name}"
+ = link_to_description_if_any "[#{t 'main.problem_desc'}] ".html_safe, problem
+ %td{:align => "center"}
+ = @prob_submissions[problem.id][:count]
+ %td
+ = render :partial => 'submission_short',
+ :locals => {:submission => @prob_submissions[problem.id][:submission], :problem_name => problem.name }
diff --git a/app/views/main/_submission.html.haml b/app/views/main/_submission.html.haml
--- a/app/views/main/_submission.html.haml
+++ b/app/views/main/_submission.html.haml
@@ -1,17 +1,17 @@
-%tr{:class => ((submission_counter%2==0) ? "info-even" : "info-odd")}
- %td.info{:align => "center"}
+%tr
+ %td{:align => "center"}
= submission_counter+1
- %td.info{:align => "center"}
+ %td{:align => "center"}
= link_to "##{submission.id}", controller: :graders, action: :submission, id: submission.id
- %td.info
+ %td
= l submission.submitted_at, format: :long
= "( #{time_ago_in_words(submission.submitted_at)} ago)"
- %td.info{:align => "center"}
+ %td
= submission.source_filename
= " (#{submission.language.pretty_name}) "
= link_to('[load]',{:action => 'source', :id => submission.id})
- %td.info
+ %td
- if submission.graded_at!=nil
= "Graded at #{format_short_time(submission.graded_at)}."
%br/
@@ -20,5 +20,7 @@
%tt
= submission.grader_comment
= "]"
- %td.info
+ %td
= render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message }
+ %td
+ = link_to 'Edit', direct_edit_submission_path(submission.id), class: 'btn btn-success'
diff --git a/app/views/main/_submission_short.html.haml b/app/views/main/_submission_short.html.haml
--- a/app/views/main/_submission_short.html.haml
+++ b/app/views/main/_submission_short.html.haml
@@ -23,4 +23,4 @@
= " | "
= link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
= " | "
- = link_to "[#{t 'main.submissions_link'}]", :action => 'submission', :id => submission.problem.id
+ = link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id)
diff --git a/app/views/main/list.html.haml b/app/views/main/list.html.haml
--- a/app/views/main/list.html.haml
+++ b/app/views/main/list.html.haml
@@ -24,8 +24,7 @@
%table.table.table-striped.table-condensed
%thead
%tr.info-head
- %th #
- %th Tasks name
+ %th Task name
%th Full name
%th # of sub(s)
%th Results
@@ -38,14 +37,12 @@
= "#{cp[:contest] ? cp[:contest].title : 'Public problems'}"
%table.info
%tr.info-head
- %th
- %th Tasks name
+ %th Task name
%th Full name
%th # of sub(s)
%th Results
= render :partial => 'problem', :collection => cp[:problems]
-
%hr/
%script{:type => 'text/javascript'}
diff --git a/app/views/main/submission.html.haml b/app/views/main/submission.html.haml
--- a/app/views/main/submission.html.haml
+++ b/app/views/main/submission.html.haml
@@ -17,15 +17,15 @@
- if @submissions!=nil
- if @submissions.length>0
- %table.info
- %tr.info-head
- %th.info No.
- %th.info #
- %th.info At
- %th.info Source
- %th.info Result
- %th.info{:width => "300px"}
- Compiler message
+ %table.table
+ %thead
+ %th No.
+ %th #
+ %th At
+ %th Source
+ %th Result
+ %th{:width => "300px"} Compiler message
+ %th
= render :partial => 'submission', :collection => @submissions
- else
No submission
diff --git a/app/views/sources/direct_edit.html.haml b/app/views/sources/direct_edit.html.haml
--- a/app/views/sources/direct_edit.html.haml
+++ b/app/views/sources/direct_edit.html.haml
@@ -1,21 +1,23 @@
-%h1 Live submit
-= form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form-inline') do
- = hidden_field_tag 'editor_text'
- = hidden_field_tag 'submission[problem_id]', @problem.id
- .form-group
- = label_tag "Task:"
- = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
-
- .form-group
- = label_tag 'Language'
- = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name',"C++"), class: 'form-control', style: "width: 100px"
- .form-group
- = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit'
-
+%h2 Live submit
%br
+%textarea#text_haha{style: "display:none"}~ @source
.container
.row
- .col-md-12
- %div#editor{style: 'height: 400px'}
- Hahaha
+ .col-md-7
+ %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
+ .col-md-5
+ = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
+
+ = hidden_field_tag 'editor_text', @source
+ = hidden_field_tag 'submission[problem_id]', @problem.id
+ .form-group
+ = label_tag "Task:"
+ = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
+
+ .form-group
+ = label_tag 'Language'
+ = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.first.id), class: 'form-control select', style: "width: 100px"
+ .form-group
+ = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
+ data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
diff --git a/config/routes.rb b/config/routes.rb
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -40,6 +40,7 @@
# end
#end
get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit'
+ get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission'
match 'tasks/view/:file.:ext' => 'tasks#view'