Skip to content

Commit

Permalink
Issue #491, modifying scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhagii committed May 13, 2014
1 parent 2b66585 commit 85c438a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
57 changes: 55 additions & 2 deletions tutor/app/assets/javascripts/solutions.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ index_number = 0
# Author: Ahmed Akram
@compile = (problem_id) ->
input = $('#solution_code').val()
alert(input)
if input.length is 0
alert "You didn't write any code"
return
Expand All @@ -59,6 +60,7 @@ index_number = 0
url: '/solutions/compile_solution'
data: {code : input, problem_id : problem_id}
datatype: 'json'

success: (unique) ->
clear_console()
stop_spin()
Expand Down Expand Up @@ -353,6 +355,57 @@ debug_console = ->
content = ""
content = '<table class="table table-striped table-bordered
table-condensed table-hover" border="3">'
@var = "xxxx"
content += "<tr class='info'><th>TestCase</th><th>Status</th></tr>"
for i in data
if i['success']
content += "<tr><td>" + "<font color ='green'>#{i['test_case']}</font>" +
"</td>"
content += "<td>" + "<font color ='green'>#{i['response']}</font>" +
"</td></tr>"
else
content += "<tr><td>" + "<font color ='red'>#{i['test_case']}</font>" +
"</td>"
content += "<td>" + "<font color ='red'>#{i['response']}</font>"+
"</td></tr>"
out.html(content)
return
error: (data) ->
clear_console()
stop_spin()
toggle_code_area()
return
return


@validate_contest_code = (problem_id) ->
code = $('#solution_code').val()
mins = parseInt($('#mins').text())
secs = parseInt($('#secs').text())
time = (mins * 60) + secs
if code.length is 0
alert 'Blank submissions are not allowed'
return
toggle_code_area()
start_spin()
$.ajax
type: "POST"
url: '/cproblem/' + problem_id
data: {problem_id: problem_id, code: code, time: time}
datatype: 'json'
success: (data) ->
clear_console()
stop_spin()
toggle_code_area()
if data['compiler_error']
compilation_error(data['compiler_output'])
return
out = $('#validate_case')
out.html("")
content = ""
content = '<table class="table table-striped table-bordered
table-condensed table-hover" border="3">'
@var = "xxxx"
content += "<tr class='info'><th>TestCase</th><th>Status</th></tr>"
for i in data
if i['success']
Expand All @@ -365,7 +418,7 @@ debug_console = ->
"</td>"
content += "<td>" + "<font color ='red'>#{i['response']}</font>"+
"</td></tr>"
out.html(content)
out.html(content)
return
error: (data) ->
clear_console()
Expand All @@ -382,7 +435,7 @@ debug_console = ->
@reload_template = () ->
editor = ace.edit("editor");
edit_session = editor.getSession();
template = "public class CoolSoft {\n"
template = "\npublic class CoolSoft {\n"
template += "\tpublic static void main(String [] args) {\n\t\t\n\t}\n}"
edit_session.setValue(template);
return
6 changes: 2 additions & 4 deletions tutor/app/assets/stylesheets/solutions.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ textarea {
border: #999999;
border-style: solid;
border-width: thin;
max-height: 150px;
min-height: 150px;
max-height: 100px;
min-height: 100px;
background: white;
overflow: scroll;
overflow-y: scroll;
overflow-x: scroll;
max-width: 750px;
min-width: 750px;
}

.compilation_succeeded {
Expand Down

0 comments on commit 85c438a

Please sign in to comment.