From 63ee6d5f9407268a475c43479beba1f64ae81abf Mon Sep 17 00:00:00 2001 From: Hayden Free Date: Thu, 4 Jun 2020 10:45:28 -0400 Subject: [PATCH] Minor datatype changes --- src/datatypes/DataTypes.jl | 26 ++------------------------ src/datatypes/course.jl | 3 ++- src/datatypes/coursecatalog.jl | 11 ++++++----- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/datatypes/DataTypes.jl b/src/datatypes/DataTypes.jl index 0eec1fb6..ea0f13e7 100644 --- a/src/datatypes/DataTypes.jl +++ b/src/datatypes/DataTypes.jl @@ -3,7 +3,7 @@ # Enumerated types @enum Degree AA AS AAS BA BS @enum System semester quarter -@enum Requisite pre co strict_co +@enum Requisite pre co strict_co custom @enum EdgeClass tree_edge back_edge forward_edge cross_edge # fundamental data types for curricular analytics @@ -13,26 +13,4 @@ include("curriculum.jl") include("degreeplan.jl") # additional types -include("coursecatalog.jl") - -# Returns a requisite as a string -function requisite_to_string(req::Requisite) - if req == pre - return "CurriculumPrerequisite" - elseif req == co - return "CurriculumCorequisite" - else - return "CurriculumStrictCorequisite" - end -end - -# Returns a requisite (enumerated type) from a string -function string_to_requisite(req::String) - if (req == "prereq" || req == "CurriculumPrerequisite") - return pre - elseif (req == "coreq" || req == "CurriculumCorequisite") - return co - elseif (req == "strict-coreq" || req == "CurriculumStrictCorequisite") - return strict_co - end -end \ No newline at end of file +include("coursecatalog.jl") \ No newline at end of file diff --git a/src/datatypes/course.jl b/src/datatypes/course.jl index a29c5fc3..e490ca55 100644 --- a/src/datatypes/course.jl +++ b/src/datatypes/course.jl @@ -61,6 +61,7 @@ mutable struct Course this.cross_listed = cross_listed this.canonical_name = canonical_name this.requisites = Dict{Int, Requisite}() + #this.requisite_formula this.metrics = Dict{String, Any}() this.metadata = Dict{String, Any}() this.learning_outcomes = learning_outcomes @@ -70,7 +71,7 @@ mutable struct Course end function course_id(prefix::AbstractString, num::AbstractString, name::AbstractString, institution::AbstractString) - mod(hash(name * prefix * num * institution), UInt32) + convert(Int, mod(hash(name * prefix * num * institution), UInt32)) end """ diff --git a/src/datatypes/coursecatalog.jl b/src/datatypes/coursecatalog.jl index 965fe9dc..ecde46e8 100644 --- a/src/datatypes/coursecatalog.jl +++ b/src/datatypes/coursecatalog.jl @@ -6,17 +6,17 @@ mutable struct CourseCatalog name::AbstractString # Name of the course catalog institution::AbstractString # Institution offering the courses in the catalog date_range::Tuple # range of dates the catalog is applicable over - catalog::Dict{UInt32, Course} # dictionary of courses in (course_id, course) format + catalog::Dict{Int, Course} # dictionary of courses in (course_id, course) format # Constructor function CourseCatalog(name::AbstractString, institution::AbstractString; courses::Array{Course}=Array{Course,1}(), - catalog::Dict{UInt32,Course}=Dict{UInt32,Course}(), date_range::Tuple=(), id::Int=0) + catalog::Dict{Int,Course}=Dict{Int,Course}(), date_range::Tuple=(), id::Int=0) this = new() this.name = name this.institution = institution this.catalog = catalog this.date_range = date_range - this.id = id + this.id = mod(hash(this.name * this.institution), UInt32) length(courses) > 0 ? add_course!(this, courses) : nothing return this end @@ -37,8 +37,9 @@ function is_duplicate(cc::CourseCatalog, course::Course) course.id in keys(cc.catalog) ? true : false end -function course(cc::CourseCatalog, prefix::AbstractString, num::AbstractString, name::AbstractString, institution::AbstractString) - hash_val = mod(hash(name * prefix * num * institution), UInt32) +# Return a course in a course catalog +function course(cc::CourseCatalog, prefix::AbstractString, num::AbstractString, name::AbstractString) + hash_val = mod(hash(name * prefix * num * cc.institution), UInt32) if hash_val in keys(cc.catalog) return cc.catalog[hash_val] else