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.
data/.travis.yml CHANGED
@@ -2,3 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 2.3.0
4
4
  before_install: gem install bundler -v 1.11.2
5
+
6
+ addons:
7
+ code_climate:
8
+ repo_token: 0d6a42692e201f67d8a80f194ed70179d696ed5aaec5f16e6d4c356a2e807428
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in corepathing.gemspec
4
4
  gemspec
5
+ gem "codeclimate-test-reporter", group: :test, require: nil
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/mdubbs/corepathing.svg?branch=master)](https://travis-ci.org/mdubbs/corepathing) [![Code Climate](https://codeclimate.com/github/mdubbs/corepathing/badges/gpa.svg)](https://codeclimate.com/github/mdubbs/corepathing)
1
+ [![Build Status](https://travis-ci.org/mdubbs/corepathing.svg?branch=master)](https://travis-ci.org/mdubbs/corepathing) [![Code Climate](https://codeclimate.com/github/mdubbs/corepathing/badges/gpa.svg)](https://codeclimate.com/github/mdubbs/corepathing) [![Test Coverage](https://codeclimate.com/github/mdubbs/corepathing/badges/coverage.svg)](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/student_tests.csv", "spec/data/domain_order.csv")
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/[USERNAME]/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.
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
- class Pathing
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(student_row, limit)
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
- name = student_row[0]
51
+ current_student_name = student_test_score_row[0]
34
52
  # init some data structures
35
- current_levels = {}
36
- path = []
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
- student_row.to_a[1..-1].each do |domain, level|
62
+ student_test_score_row.to_a[1..-1].each do |domain, grade_level|
40
63
  # set the max levels for each domain
41
- current_levels[domain] = level
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 |r|
46
- # get the current level we are on
47
- r_level = r[0]
48
- # iterate through the level's ordering (R -> L)
49
- r[1..-1].each do |r_domain|
50
- # grab the max level for the given domain (RF, RI, etc)
51
- max_level = current_levels[r_domain]
52
-
53
- if r_level == "K" && max_level != "K" #if the current level is K and max isn't, ignore it
54
- elsif r_level == max_level
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
- path.push("#{r_level}.#{r_domain}")
85
+ student_path.push({domain_row_grade_level => commone_core_domain })
57
86
  else
58
- if max_level < r_level
59
- path.push("#{r_level}.#{r_domain}")
60
- elsif max_level == "K"
61
- path.push("#{r_level}.#{r_domain}")
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
- # return formatted pathing string based on passed limit
67
- return "#{name},#{path[0, limit].join(",")}"
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
@@ -1,3 +1,3 @@
1
1
  module Corepathing
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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-03 00:00:00.000000000 Z
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