corepathing 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +25 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +4 -0
- data/Gemfile +1 -0
- data/README.md +15 -4
- data/lib/corepathing.rb +59 -28
- data/lib/corepathing/version.rb +1 -1
- metadata +4 -2
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://travis-ci.org/mdubbs/corepathing) [](https://codeclimate.com/github/mdubbs/corepathing)
|
|
1
|
+
[](https://travis-ci.org/mdubbs/corepathing) [](https://codeclimate.com/github/mdubbs/corepathing) [](https://codeclimate.com/github/mdubbs/corepathing/coverage)
|
|
2
2
|
|
|
3
3
|
# Corepathing
|
|
4
4
|
|
|
@@ -23,12 +23,23 @@ Or install it yourself as:
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
25
|
Setup the pathing object with your CSV files
|
|
26
|
-
```
|
|
26
|
+
```ruby
|
|
27
27
|
# setup
|
|
28
|
-
pathing = Corepathing::Pathing.new("spec/data/
|
|
28
|
+
pathing = Corepathing::Pathing.new("spec/data/stu.csv", "spec/data/ord.csv")
|
|
29
29
|
|
|
30
30
|
# the parameter is the limit for number of steps to return for each student
|
|
31
31
|
pathing.path_students(5)
|
|
32
|
+
|
|
33
|
+
# will return an array of strings, each string representing the student's path
|
|
34
|
+
[#<Corepathing::Student:0x007fe8ab8d0568 @name="Albin Stanton", @max_domain_levels={"RF"=>"2", "RL"=>"3", "RI"=>"K", "L"=>"3"}, @path=[{"K"=>"RI"}, {"1"=>"RI"}, {"2"=>"RF"}, {"2"=>"RI"}, {"3"=>"RF"}]>, #<Corepathing::Student:0x007fe8ab8ca550 @name="Erik Purdy", @max_domain_levels={"RF"=>"3", "RL"=>"1", "RI"=>"1", "L"=>"1"}, @path=[{"1"=>"RL"}, {"1"=>"RI"}, {"2"=>"RI"}, {"2"=>"RL"}, {"2"=>"L"}]>]
|
|
35
|
+
|
|
36
|
+
#if you just want to calculate one student, given their row you can do
|
|
37
|
+
student_obj = pathing.get_path(student_row)
|
|
38
|
+
#<Corepathing::Student:0x007fc92b4f3e30 @name="Albin Stanton", @max_domain_levels={"RF"=>"2", "RL"=>"3", "RI"=>"K", "L"=>"3"}, @path=[{"K"=>"RI"}, {"1"=>"RI"}, {"2"=>"RF"}, {"2"=>"RI"}, {"3"=>"RF"}]>
|
|
39
|
+
|
|
40
|
+
#to get the string representation of the student's education path
|
|
41
|
+
student_obj.to_s
|
|
42
|
+
# will return "Albin Stanton,K.RI,1.RI,2.RF,2.RI,3.RF"
|
|
32
43
|
```
|
|
33
44
|
|
|
34
45
|
## Development
|
|
@@ -39,7 +50,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
39
50
|
|
|
40
51
|
## Contributing
|
|
41
52
|
|
|
42
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mdubbs/corepathing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
43
54
|
|
|
44
55
|
|
|
45
56
|
## License
|
data/lib/corepathing.rb
CHANGED
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
require "corepathing/version"
|
|
2
2
|
require 'csv'
|
|
3
|
+
|
|
3
4
|
module Corepathing
|
|
4
|
-
|
|
5
|
+
# Class for Student object
|
|
6
|
+
class Student
|
|
7
|
+
attr_accessor :name
|
|
8
|
+
attr_accessor :max_domain_levels
|
|
9
|
+
attr_accessor :path
|
|
5
10
|
|
|
6
|
-
|
|
11
|
+
def initialize(name, max_domain_grade_levels, education_path)
|
|
12
|
+
@name = name
|
|
13
|
+
@max_domain_levels = max_domain_grade_levels
|
|
14
|
+
@path = education_path
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def to_s
|
|
18
|
+
z = @path.map{|p| p.map{|k,v| "#{k}.#{v}"} }.join(',')
|
|
19
|
+
return "#{@name},#{z}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class Pathing
|
|
7
24
|
# Creates a new learning path object from the given domain_ordering and
|
|
8
25
|
# student_tests CSV files
|
|
9
|
-
#
|
|
10
|
-
|
|
11
26
|
def initialize(student_tests, domain_order)
|
|
12
27
|
# load up the CSV files and parse
|
|
13
28
|
@STUDENT_TESTS = CSV.read(student_tests, headers: true)
|
|
14
29
|
@DOMAIN_ORDER = CSV.read(domain_order, headers: false)
|
|
15
30
|
end
|
|
16
31
|
|
|
17
|
-
def path_students(limit)
|
|
32
|
+
def path_students(limit = nil)
|
|
18
33
|
# generate each student's learning path and return an array of the
|
|
19
34
|
# students found in the student csv.
|
|
20
35
|
ret = []
|
|
36
|
+
if limit.nil?
|
|
37
|
+
limit = 5
|
|
38
|
+
end
|
|
21
39
|
# iterate through the students
|
|
22
40
|
@STUDENT_TESTS.each do |x|
|
|
23
41
|
ret.push(get_path(x, limit))
|
|
@@ -25,46 +43,59 @@ module Corepathing
|
|
|
25
43
|
ret
|
|
26
44
|
end
|
|
27
45
|
|
|
28
|
-
def get_path(
|
|
46
|
+
def get_path(student_test_score_row, limit = nil)
|
|
29
47
|
# calculate the path for a given student, and return the number of steps
|
|
30
48
|
# desired.
|
|
31
49
|
|
|
32
50
|
# grab the students name
|
|
33
|
-
|
|
51
|
+
current_student_name = student_test_score_row[0]
|
|
34
52
|
# init some data structures
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
student_max_grade_levels = {}
|
|
54
|
+
student_path = []
|
|
55
|
+
students = []
|
|
56
|
+
|
|
57
|
+
if limit.nil?
|
|
58
|
+
limit = 5
|
|
59
|
+
end
|
|
37
60
|
|
|
38
61
|
# iterate through the students excluding the header row
|
|
39
|
-
|
|
62
|
+
student_test_score_row.to_a[1..-1].each do |domain, grade_level|
|
|
40
63
|
# set the max levels for each domain
|
|
41
|
-
|
|
64
|
+
student_max_grade_levels[domain] = grade_level
|
|
42
65
|
end
|
|
43
66
|
|
|
44
67
|
# iterate through the domain ordering file
|
|
45
|
-
@DOMAIN_ORDER.each do |
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
@DOMAIN_ORDER.each do |domain_row|
|
|
69
|
+
path_obj = {}
|
|
70
|
+
|
|
71
|
+
# get the current row's level (grade) we are on
|
|
72
|
+
domain_row_grade_level = domain_row[0]
|
|
73
|
+
|
|
74
|
+
# iterate through the level's ordering (Right -> Left)
|
|
75
|
+
domain_row[1..-1].each do |commone_core_domain|
|
|
76
|
+
|
|
77
|
+
# grab the max grade level for the given cc domain (RF, RI, etc)
|
|
78
|
+
max_domain_grade_level = student_max_grade_levels[commone_core_domain]
|
|
79
|
+
|
|
80
|
+
#if the current level is K and max isn't, ignore it
|
|
81
|
+
if domain_row_grade_level == "K" && max_domain_grade_level != "K"
|
|
82
|
+
#don't add it
|
|
83
|
+
elsif domain_row_grade_level == max_domain_grade_level
|
|
55
84
|
#if the levels match add it
|
|
56
|
-
|
|
85
|
+
student_path.push({domain_row_grade_level => commone_core_domain })
|
|
57
86
|
else
|
|
58
|
-
if
|
|
59
|
-
|
|
60
|
-
elsif
|
|
61
|
-
|
|
87
|
+
if max_domain_grade_level < domain_row_grade_level
|
|
88
|
+
student_path.push({domain_row_grade_level => commone_core_domain })
|
|
89
|
+
elsif max_domain_grade_level == "K"
|
|
90
|
+
student_path.push({domain_row_grade_level => commone_core_domain })
|
|
62
91
|
end
|
|
63
92
|
end
|
|
64
93
|
end
|
|
94
|
+
|
|
65
95
|
end
|
|
66
|
-
|
|
67
|
-
|
|
96
|
+
student = Student.new(current_student_name, student_max_grade_levels, student_path[0...limit])
|
|
97
|
+
|
|
98
|
+
return student
|
|
68
99
|
end
|
|
69
100
|
end
|
|
70
101
|
end
|
data/lib/corepathing/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: corepathing
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-05-
|
|
11
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -60,8 +60,10 @@ executables: []
|
|
|
60
60
|
extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
|
62
62
|
files:
|
|
63
|
+
- ".codeclimate.yml"
|
|
63
64
|
- ".gitignore"
|
|
64
65
|
- ".rspec"
|
|
66
|
+
- ".rubocop.yml"
|
|
65
67
|
- ".travis.yml"
|
|
66
68
|
- CODE_OF_CONDUCT.md
|
|
67
69
|
- Gemfile
|