Skip to content

Commit

Permalink
Fixing conflicts alaashafaee#210
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Fadel authored and Mohamed Fadel committed Apr 25, 2014
2 parents c5c6c6e + 54ca827 commit e4e6f67
Show file tree
Hide file tree
Showing 39 changed files with 692 additions and 306 deletions.
Binary file removed coolsoft.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions tutor/app/assets/javascripts/helper.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# [Design - Story Design]
# Checks if an element exists in the document
# Parameters:
# element_id: The id of the element to be checked
# Returns: True if the element exist and false if not
# Author: Mussab ElDash
@element_exists = (element_id) ->
$("##{element_id}").length > 0
13 changes: 13 additions & 0 deletions tutor/app/assets/javascripts/hints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//[View hints and tips-story 4.22]
//Toggle to view previous hints.
//Parameters:
// id: Element that will be toggled.
//Returns: none.
//Author: Nadine Adel
function toggle_visibility(id) {
var element = document.getElementById(id);
if(element.style.display == 'block')
element.style.display = 'none';
else
element.style.display = 'block';
}
8 changes: 7 additions & 1 deletion tutor/app/assets/javascripts/problems.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ activate = ->
time = setInterval(timer, 1000)
timer

# [Design - Story Design]
# Start counter if the two labels with ids "mins" and "secs" exists
# Parameters: none
# Returns: none
# Author: Mussab ElDash
jQuery ->
activate()
if element_exists("mins") and element_exists("secs")
activate()
return
209 changes: 161 additions & 48 deletions tutor/app/assets/javascripts/solutions.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,139 @@ index_number = 0
return
test = $('#solution_input').val()
start_spin()
toggle_code_area()
$.ajax
type: "POST"
url: '/debuggers/' + problem_id
data: {code : input , case : test}
datatype: 'json'
success: (data) ->
clear_console()
variables = data
stop_spin()
if !data["success"]
compilation_error data["data"]["errors"]
return
variables = data["data"]
toggleDebug()
toggleDebug(1)
debug_console()
jump_state 0
error: ->
clear_console()
stop_spin()
toggle_code_area()
return
return

# [Compiler: Test - Story 3.15]
# Sends the code to the server to be compiled
# Parameters:
# problem_id: The id of the problem being solved
# Returns:
# none
# Author: Ahmed Akram
@compile = (problem_id) ->
input = $('#solution_code').val()
if input.length is 0
alert "You didn't write any code"
return
start_spin()
toggle_code_area()
$.ajax
type: "POST"
url: '/solutions/compile_solution'
data: {code : input, problem_id : problem_id}
datatype: 'json'
success: (unique) ->
clear_console()
stop_spin()
toggle_code_area()
if !unique["success"]
compilation_error unique["errors"]
return
$('.compilation_succeeded').html("Compilation Succeeded!")
error: ->
clear_console()
stop_spin()
toggle_code_area()
return
return

# [Compiler: Test - Story 3.15]
# Sends the code and the test case to the server to be tested
# Parameters:
# problem_id: The id of the problem being solved
# Returns:
# none
# Author: Ahmed Akram
@run_input = (problem_id) ->
code = $('#solution_code').val()
if code.length is 0
alert "You didn't write any code"
return
test = $('#solution_input').val()
start_spin()
toggle_code_area()
$.ajax
type: "POST"
url: '/solutions/execute'
data: {code : code, problem_id : problem_id, input : test}
datatype: 'json'
success: (data) ->
clear_console()
stop_spin()
toggle_code_area()
if data["compiler_error"]
compilation_error data["compiler_output"]
return
else if data["executer_feedback"]
input_test_output data["executer_output"]
return
else
runtime_error data["executer_output"]
return
error: ->
clear_console()
stop_spin()
toggle_code_area()
return
return

# [Compiler: Test - Story 3.15]
# Fills the console with the runtime errors
# Parameters:
# data: The hash containing the response
# Returns:
# none
# Author: Ahmed Akram
input_test_output = (data) ->
$('#output_section').html(data["message"])
return

# [Compiler: Test - Story 3.15]
# Disables the code and input area while debugging, compiling or running test case
# Parameters:
# none
# Returns:
# none
# Author: Ahmed Akram
toggle_code_area = ->
$('#solution_code').prop 'disabled', !$('#solution_code').prop 'disabled'
$('#solution_input').prop 'disabled', !$('#solution_input').prop 'disabled'

# [Compiler: Test - Story 3.15]
# Fills the console with the runtime errors
# Parameters:
# data: The hash containing the response
# Returns:
# none
# Author: Ahmed Akram
runtime_error = (data) ->
$('#runtime_error').toggle(true)
$('#error_section').html(if data["errors"] then data["errors"] else data)
$('#explanation_section').html(data["explanation"])
return

# [Debugger: Debug - Story 3.6]
# Fills the console with the compilation errors
# Parameters: none
Expand All @@ -50,7 +164,11 @@ compilation_error = (data) ->
# Parameters: none
# Returns: none
# Author: Mussab ElDash
clear_console = ->
clear_console = () ->
$('#runtime_error').toggle(false)
$('#validate_case').html("")
$('#output_section').html("")
$('.compilation_succeeded').html("")
$('.compilation_failed').html("")
$('.compilation_feedback').html("")
return
Expand Down Expand Up @@ -90,45 +208,29 @@ debug_console = ->
@toggle_spin = ->
$('#spinner').toggleClass "spinner"

# [Execute Line By Line - Story 3.8]
# [Compiler: Test - Story 3.15]
# Toggles debugging mode by changing the available buttons.
# Parameters: none
# Returns: none
# Author: Rami Khalil (Temporary)
@toggleDebug = ->
$('#debugButton').prop 'hidden', !$('#debugButton').prop 'hidden'
$('#compileButton').prop 'hidden', !$('#compileButton').prop 'hidden'
$('#testButton').prop 'hidden', !$('#testButton').prop 'hidden'
# Parameters:
# none
# Returns:
# none
# Author: Ahmed Akram + Rami Khalil
@toggleDebug = (state) ->
$('#debugButton').toggle(!state)
$('#compileButton').toggle(!state)
$('#testButton').toggle(!state)
$('#nextButton').toggle(state)
$('#previousButton').toggle(state)
$('#stopButton').toggle(state)
editor = ace.edit("editor")
editor.setReadOnly !editor.getReadOnly()

editor.setReadOnly(state)
normal_theme = "ace/theme/twilight"
debug_theme = normal_theme + "-debug"

if editor.getTheme() == normal_theme
editor.setTheme debug_theme
else
editor.setTheme normal_theme

$('#nextButton').prop 'hidden', !$('#nextButton').prop 'hidden'
$('#previousButton').prop 'hidden', !$('#previousButton').prop 'hidden'
$('#stopButton').prop 'hidden', !$('#stopButton').prop 'hidden'

# [Compile - Story 3.4]
# Sends the code to the server to be compiled.
# Parameters: none
# Returns: none
# Author: Rami Khalil (Temporary)
@compile = () ->
alert "Compiling"

# [Test - Story 3.15]
# Sends the code and the input to be processed on the server.
# Parameters: none
# Returns: none
# Author: Rami Khalil (Temporary)
@test = () ->
alert "Testing"

# [Execute Line By Line - Story 3.8]
# Moves to the next state of execution.
Expand Down Expand Up @@ -204,11 +306,12 @@ debug_console = ->
# Returns: none
# Author: Rami Khalil (Temporary)
@stop = () ->
toggleDebug()
toggleDebug(0)
index_number = 0;
toggle_code_area()
variables = null;

# To be Used when changing to ajax in order not to refresh page

# [Compiler: Validate - Story 3.5]
# submits a solution in the form without refreshing
# using ajax showing an alert box for success and failure scenarios
Expand All @@ -221,29 +324,39 @@ debug_console = ->
code = $('#solution_code').val()
mins = parseInt($('#mins').text())
secs = parseInt($('#secs').text())
time = mins*60 + secs
start_spin()
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: '/solutions'
data: {problem_id: problem_id, code: code, time: time}
datatype: 'json'
success: (data) ->
clear_console()
stop_spin()
success = $('#validate_success')
errors = $('#validate_error')
success.html("")
for i in data["success"]
success.append("#{i}<br>")
errors.html("")
for i in data["failure"]
errors.append("#{i}<br>")
if code.length isnt 0
alert 'Solution has been submitted successfully'
else
alert 'Blank submissions are not allowed'
toggle_code_area()
if data['compiler_error']
compilation_error(data['compiler_output'])
return
out = $('#validate_case')
out.html("")
content = ""
for i in data
if data["success"]
content += "<p style='color:green'>#{i['test_case']}, \
#{i['response']}</p>"
else
content += "<p style='color:red'>#{i['test_case']}, \
#{i['response']}</p>"
out.html(content)
return
error: (data) ->
clear_console()
stop_spin()
toggle_code_area()
return
return
13 changes: 13 additions & 0 deletions tutor/app/assets/javascripts/tips.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//[View hints and tips-story 4.22]
//Toggle to view previous tips
//Parameters:
// id: Element that will be toggled.
//Returns: none.
//Author: Nadine Adel
function toggle_visibility(id) {
var element = document.getElementById(id);
if(element.style.display == 'block')
element.style.display = 'none';
else
element.style.display = 'block';
}
7 changes: 7 additions & 0 deletions tutor/app/assets/stylesheets/hints.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.hidden {
display: none;
}

a.Lst {
font-size: 30px;
line-height: 0px;
padding-left: 0px;
font-weight: normal;
}
3 changes: 3 additions & 0 deletions tutor/app/assets/stylesheets/hints.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Hints controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
6 changes: 5 additions & 1 deletion tutor/app/assets/stylesheets/solutions.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ textarea {
border-width: thin;
max-height: 150px;
min-height: 150px;
background: #3d1451;
background: white;
overflow: scroll;
overflow-y: scroll;
overflow-x: scroll;
Expand Down Expand Up @@ -114,4 +114,8 @@ textarea {
border-style: solid;
border-width: 3px;
font-family: monospace;
}

.hidden {
visibility: false;
}
6 changes: 6 additions & 0 deletions tutor/app/assets/stylesheets/tips.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
a.Lst {
font-size: 30px;
line-height: 0px;
padding-left: 0px;
font-weight: normal;
}
Loading

0 comments on commit e4e6f67

Please sign in to comment.