Skip to content

Commit

Permalink
fix bug in create_graph!()
Browse files Browse the repository at this point in the history
  • Loading branch information
heileman committed Dec 6, 2023
1 parent ea0f06c commit 0aa2a67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/DataTypes/Course.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ mutable struct CourseCollection <: AbstractCourse
end
end

# create a unique course id for a couse by hashing on the course's prefix, num, name, institution.
function course_id(prefix::AbstractString, num::AbstractString, name::AbstractString, institution::AbstractString)
convert(Int, mod(hash(name * prefix * num * institution), UInt32))
end
Expand Down
8 changes: 4 additions & 4 deletions src/DataTypes/Curriculum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ mutable struct Curriculum
create_graph!(this)
this.learning_outcomes = learning_outcomes
this.learning_outcome_graph = SimpleDiGraph{Int}()
create_learning_outcome_graph!(this)
#create_learning_outcome_graph!(this)
this.course_learning_outcome_graph = MetaDiGraph()
create_course_learning_outcome_graph!(this)
#create_course_learning_outcome_graph!(this)
errors = IOBuffer()
if !(is_valid(this, errors))
printstyled("WARNING: Curriculum was created, but is invalid due to requisite cycle(s):", color = :yellow)
Expand Down Expand Up @@ -276,8 +276,8 @@ function create_graph!(curriculum::Curriculum)
mapped_vertex_ids = map_vertex_ids(curriculum)
for c in curriculum.courses
for r in collect(keys(c.requisites[curriculum.requisite_clauses[c.id]]))
if r mapped_vertex_ids
warning("requisite $(r.name), required by $(c.name), is not in curriculum $(c.name)")
if r keys(mapped_vertex_ids)
printstyled("WARNING: A requisite for course $(c.name) is not in curriculum $(curriculum.name)\n", color = :yellow)
else
if add_edge!(curriculum.graph, mapped_vertex_ids[r], c.vertex_id[curriculum.id])
else
Expand Down
6 changes: 6 additions & 0 deletions test/CurricularAnalytics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ errors = IOBuffer()
@test is_valid(curric, errors) == true
@test length(extraneous_requisites(curric)) == 0

# Test case where the requisite for a course in a curriculum is not itself in the curriculum
H = Course("H", 3)
add_requisite!(H,G,pre) # H is a prerequiste to G, but not in the curriculum
curric = Curriculum("Postmodern Basket Weaving", [A,B,C,D,E,F,G], sortby_ID=false)
# this should issue a warning

# Test analytics
@test delay_factor(curric) == (33.0, [5.0, 5.0, 5.0, 5.0, 3.0, 5.0, 5.0])
@test blocking_factor(curric) == (16, [6, 3, 4, 2, 0, 0, 1])
Expand Down

0 comments on commit 0aa2a67

Please sign in to comment.