Skip to content

Commit

Permalink
Merge PR/5
Browse files Browse the repository at this point in the history
  • Loading branch information
mgtlake committed Aug 22, 2016
2 parents 35a96bd + d414d23 commit 85c56af
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions src/Juliet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ end
"""
Get user input in a environment agnostic manner
"""
macro getInput()
function getInput()
if isdefined(Main, :Atom)
return :(Main.Atom.input())
return Main.Atom.input()
else
return :(readline())
return readline()
end
end

courses = Vector{Types.Course}()
courses = Types.Course[]

help = Dict(
"select" => """
Expand Down Expand Up @@ -83,8 +83,8 @@ function choose_lesson(courses::Vector{Types.Course})

print_options(courses, "Courses:")

input = AbstractString{}
while (print("> "); input = @getInput;
input = ""
while (print("> "); input = getInput();
!isa(parse(input), Number) ||
!(0 < parse(Int, input) <= length(courses)))
@match strip(input) begin
Expand All @@ -109,8 +109,8 @@ function choose_lesson(course::Types.Course)
print_options(course.lessons,
"Lessons in $(course.name) (type `!back` to return to the total list):")

input = AbstractString{}
while (print("> "); input = @getInput;
input = ""
while (print("> "); input = getInput();
!isa(parse(input), Number) ||
!(0 < parse(Int, input) <= length(course.lessons)))
@match strip(input) begin
Expand All @@ -125,7 +125,7 @@ function choose_lesson(course::Types.Course)
complete_lesson(selection)
if selection != last(course.lessons)
println("Continue to next lesson in course? y/n")
while (input = strip(lowercase(@getInput));
while (input = strip(lowercase(getInput()));
!(input in ["yes", "y", "no", "n"]))
println("Invalid selection")
end
Expand Down Expand Up @@ -195,14 +195,14 @@ Get input for a question
"""
function get_input(question)
print("> ")
input = @getInput
input = getInput()
# Remove ansii codes
return replace(input, r"\e\[([A-Z]|[0-9])", "")
end

function get_input(question::Types.InfoQuestion)
print("...")
input = @getInput
print("[Press Enter to continue]")
input = getInput()
# Remove ansii codes
return replace(input, r"\e\[([A-Z]|[0-9])", "")
end
Expand Down
22 changes: 11 additions & 11 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ type Lesson
name::AbstractString
description::AbstractString
version::VersionNumber
authors::Array{AbstractString, 1}
keywords::Array{AbstractString, 1}
questions::Array{AbstractQuestion, 1}
authors::Vector{AbstractString}
keywords::Vector{AbstractString}
questions::Vector{AbstractQuestion}
end

immutable InfoQuestion <: AbstractQuestion
Expand All @@ -19,33 +19,33 @@ end

immutable SyntaxQuestion <: AbstractQuestion
text::AbstractString
hints::Array{AbstractString, 1}
hints::Vector{AbstractString}
answer::Expr
end

immutable FunctionQuestion <: AbstractQuestion
text::AbstractString
hints::Array{AbstractString, 1}
hints::Vector{AbstractString}
# I'd like to use a tuple, but most formats don't support it so I'll
# use an array for now
tests::Array{Array{AbstractString, 1}, 1}
tests::Vector{Vector{AbstractString}}
template::AbstractString
end

immutable MultiQuestion <: AbstractQuestion
text::AbstractString
hints::Array{AbstractString, 1}
options::Array{AbstractString, 1}
hints::Vector{AbstractString}
options::Vector{AbstractString}
answer::Int
end

type Course
name::AbstractString
description::AbstractString
version::VersionNumber
authors::Array{AbstractString, 1}
keywords::Array{AbstractString, 1}
lessons::Array{Lesson, 1}
authors::Vector{AbstractString}
keywords::Vector{AbstractString}
lessons::Vector{Lesson}
end

end # module
2 changes: 1 addition & 1 deletion test/out/1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Selct a lesson or course to get started, or type `!help` for information.

Starting Basic syntax
1 / 4: This lesson will teach you about basic Julia syntax
...2 / 4: Set `a` to be 1
[Press Enter to continue]2 / 4: Set `a` to be 1
> Keep up the great work!
3 / 4: Assign `b` to be twice `a`
> Keep up the great work!
Expand Down
2 changes: 1 addition & 1 deletion test/out/2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Selct a lesson or course to get started, or type `!help` for information.

Starting Basic syntax
1 / 4: This lesson will teach you about basic Julia syntax
...2 / 4: Set `a` to be 1
[Press Enter to continue]2 / 4: Set `a` to be 1
> One more try
> Keep up the great work!
3 / 4: Assign `b` to be twice `a`
Expand Down

0 comments on commit 85c56af

Please sign in to comment.