Matcher 1.0.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 +7 -0
- data/lib/MockDb.rb +158 -0
- data/lib/Student.rb +27 -0
- data/lib/matcher.rb +60 -0
- data/lib/testCases.rb +59 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c3b170469b6bb0fe730e24869a5fe3dac9f347ed
|
4
|
+
data.tar.gz: a091380e5c0dd4c700f405e49d3d8752051ef141
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 13d9d953c23070e3aa531a57a72a296f4e909e7cfc938a74905ca901491a8411e837b0f0df0b2d97b1e2e263253c3b89a884a426bb36417b51b6fd54d10f56a7
|
7
|
+
data.tar.gz: 870351ee9732190197e250f5f7daca34286048f70445d40043b0d8330c69b446155275e74d8812673037d56f1776d7d2af6c47d7fdb8dcc75e2365c8e655cc76
|
data/lib/MockDb.rb
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
require_relative 'Student'
|
2
|
+
|
3
|
+
|
4
|
+
module MockDb
|
5
|
+
def self.tutors
|
6
|
+
return [
|
7
|
+
{
|
8
|
+
"headline" => "I am a tutor",
|
9
|
+
"description" => "i am a professional Javascript instructor",
|
10
|
+
"years_teaching" => "3",
|
11
|
+
"teaching_style" => "Fast",
|
12
|
+
"work_experience" => [
|
13
|
+
{
|
14
|
+
"company" => "Apple",
|
15
|
+
"location" => "California",
|
16
|
+
"title" => "Product Designer",
|
17
|
+
"from" => "Tue, 05 Nov 2015",
|
18
|
+
"to" => "Wed, 10 Sept 2017"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"education" => [
|
22
|
+
{
|
23
|
+
"school" => "National College of Ireland",
|
24
|
+
"degree" => "MSc Cloud Computing",
|
25
|
+
"graduated" => "Fri, 12 Nov 2014"
|
26
|
+
}
|
27
|
+
|
28
|
+
],
|
29
|
+
"subjects" => [
|
30
|
+
"Javascript",
|
31
|
+
"Computing",
|
32
|
+
"Cloud Computing"
|
33
|
+
],
|
34
|
+
"badge" => "3"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"headline" => "I am another tutor",
|
38
|
+
"description" => "i am a professional Rails instructor",
|
39
|
+
"years_teaching" => "5",
|
40
|
+
"teaching_style" => "Medium",
|
41
|
+
"work_experience" => [
|
42
|
+
{
|
43
|
+
"company" => "Intel",
|
44
|
+
"location" => "Michigan",
|
45
|
+
"title" => "Backend Developer",
|
46
|
+
"from" => "Tue, 05 Nov 2012",
|
47
|
+
"to" => "Wed, 10 Sept 2014"
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"education" => [
|
51
|
+
{
|
52
|
+
"school" => "National College of Ireland",
|
53
|
+
"degree" => "MSc Data Analytics",
|
54
|
+
"graduated" => "Fri, 12 Nov 2014"
|
55
|
+
}
|
56
|
+
|
57
|
+
],
|
58
|
+
"subjects" => [
|
59
|
+
"Ruby",
|
60
|
+
"Computer Science",
|
61
|
+
"Data Analytics"
|
62
|
+
],
|
63
|
+
"badge" => "1"
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"headline" => "Looking to impact lives",
|
67
|
+
"description" => "i am a Physics instructor with over 5 years in experience",
|
68
|
+
"years_teaching" => "10",
|
69
|
+
"teaching_style" => "Slow",
|
70
|
+
"work_experience" => [
|
71
|
+
{
|
72
|
+
"company" => "Facebook",
|
73
|
+
"location" => "Palo Alto",
|
74
|
+
"title" => "Data Scientist",
|
75
|
+
"from" => "Tue, 05 Nov 2004",
|
76
|
+
"to" => "Wed, 10 Sept 2012"
|
77
|
+
}
|
78
|
+
],
|
79
|
+
"education" => [
|
80
|
+
{
|
81
|
+
"school" => "Harvard University",
|
82
|
+
"degree" => "MSc Physics",
|
83
|
+
"graduated" => "Fri, 15 Sept 2002"
|
84
|
+
}
|
85
|
+
|
86
|
+
],
|
87
|
+
"subjects" => [
|
88
|
+
"Physics",
|
89
|
+
"Mathematics",
|
90
|
+
"Computer Science"
|
91
|
+
],
|
92
|
+
"badge" => "5"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"headline" => "A professional Finance instructor",
|
96
|
+
"description" => "i am a Finance intructor with over 8 years in the finance industry",
|
97
|
+
"years_teaching" => "6",
|
98
|
+
"teaching_style" => "Fast",
|
99
|
+
"work_experience" => [
|
100
|
+
{
|
101
|
+
"company" => "JP Morgan",
|
102
|
+
"location" => "New York",
|
103
|
+
"title" => "Financial Analyst",
|
104
|
+
"from" => "Tue, 05 Nov 2006",
|
105
|
+
"to" => "Wed, 10 Sept 2012"
|
106
|
+
}
|
107
|
+
],
|
108
|
+
"education" => [
|
109
|
+
{
|
110
|
+
"school" => "National University of Ireland",
|
111
|
+
"degree" => "MSc Finance",
|
112
|
+
"graduated" => "Fri, 15 Sept 2005"
|
113
|
+
}
|
114
|
+
|
115
|
+
],
|
116
|
+
"subjects" => [
|
117
|
+
"Business Management",
|
118
|
+
"Finance",
|
119
|
+
"Accounting"
|
120
|
+
],
|
121
|
+
"badge" => nil
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"headline" => "Chemical Engineering tutor",
|
125
|
+
"description" => "i am a Chemical Engineer with a huge knowledge base in the subject",
|
126
|
+
"years_teaching" => "3",
|
127
|
+
"teaching_style" => "Medium",
|
128
|
+
"work_experience" => [
|
129
|
+
{
|
130
|
+
"company" => "Pfizer",
|
131
|
+
"location" => "New York",
|
132
|
+
"title" => "Chemical Engineer",
|
133
|
+
"from" => "Tue, 05 Nov 2006",
|
134
|
+
"to" => "Wed, 10 Sept 2012"
|
135
|
+
}
|
136
|
+
],
|
137
|
+
"education" => [
|
138
|
+
{
|
139
|
+
"school" => "National University of Ireland",
|
140
|
+
"degree" => "MSc Chemical Engineering",
|
141
|
+
"graduated" => "Fri, 15 Sept 2004"
|
142
|
+
}
|
143
|
+
|
144
|
+
],
|
145
|
+
"subjects" => [
|
146
|
+
"Biochemistry",
|
147
|
+
"Chemistry",
|
148
|
+
"Sciences"
|
149
|
+
],
|
150
|
+
"badge" => nil
|
151
|
+
},
|
152
|
+
]
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.student
|
156
|
+
return MyUser;
|
157
|
+
end
|
158
|
+
end
|
data/lib/Student.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module MyUser
|
2
|
+
def self.student_props
|
3
|
+
return {
|
4
|
+
"id" => "3",
|
5
|
+
"email" => "timbrewer@gmail.com",
|
6
|
+
"firstname" => "Tim",
|
7
|
+
"lastname" => "Brewer",
|
8
|
+
"role" => "Student",
|
9
|
+
"gender" => "Male",
|
10
|
+
"has_profile" => "true",
|
11
|
+
"location" => "Dublin"
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.student
|
16
|
+
return {
|
17
|
+
"education_level" => "University",
|
18
|
+
"description" => "A student ready to learn",
|
19
|
+
"subjects_of_interest" => [
|
20
|
+
{"subject" => "Mathematics", "competency" => "1"},
|
21
|
+
{"subject" => "Chemistry", "competency" => "2"},
|
22
|
+
{"subject" => "Finance" , "competency" => "3"}
|
23
|
+
],
|
24
|
+
"student_id" => "3"
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
data/lib/matcher.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'MockDb'
|
2
|
+
|
3
|
+
class Matcher
|
4
|
+
#before_action :set_student
|
5
|
+
|
6
|
+
def self.getRecommendation(student, tutors)
|
7
|
+
@profile = student.student()
|
8
|
+
#check subjects students are interested in and their competency level
|
9
|
+
@studentSubjects = @profile["subjects_of_interest"]
|
10
|
+
|
11
|
+
#initialize an empty array to store list of recommended tutors
|
12
|
+
@recommendedTutors = []
|
13
|
+
|
14
|
+
#loop tutors array
|
15
|
+
#match tutor subjects with student subjects
|
16
|
+
#create an array of all subjects that match
|
17
|
+
#create an array for every tutor that has at least one match
|
18
|
+
#store competency count to store the
|
19
|
+
tutors.each do |d|
|
20
|
+
tutorSubjects = d["subjects"]
|
21
|
+
tutorStyle = d["teaching_style"]
|
22
|
+
subject_match = false
|
23
|
+
subject_match_array = []
|
24
|
+
competency_match_array = []
|
25
|
+
tutorSubjects.each do |t|
|
26
|
+
for i in @studentSubjects do
|
27
|
+
|
28
|
+
case i["competency"]
|
29
|
+
when "1"
|
30
|
+
subject_competency = "Slow"
|
31
|
+
when "2"
|
32
|
+
subject_competency = "Average"
|
33
|
+
when "3"
|
34
|
+
subject_competency = "Fast"
|
35
|
+
end
|
36
|
+
if(t == i["subject"])
|
37
|
+
subject_match = true
|
38
|
+
subject_match_array.push(t)
|
39
|
+
if(tutorStyle == subject_competency)
|
40
|
+
competency_match_array.push(t)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
@recommendedTutors.push({"tutor" => d, "subjects_matched" => subject_match_array, "competency_match" => competency_match_array}) if subject_match == true
|
46
|
+
end
|
47
|
+
|
48
|
+
return @recommendedTutors
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.matchTutor(student, tutors)
|
52
|
+
return self.getRecommendation(student, tutors)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.matchCompetency(student, tutors)
|
56
|
+
@recommendedTutors = self.getRecommendation(student, tutors)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
data/lib/testCases.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative 'MockDb'
|
2
|
+
|
3
|
+
module TestCases
|
4
|
+
#before_action :set_student
|
5
|
+
@student = MockDb.student()
|
6
|
+
@tutors = MockDb.tutors()
|
7
|
+
@studentrole = @student.student_props()
|
8
|
+
@profile = @student.student()
|
9
|
+
|
10
|
+
|
11
|
+
#return true if there is a student logged in
|
12
|
+
def self.get_student
|
13
|
+
true if @student
|
14
|
+
end
|
15
|
+
|
16
|
+
#return true if student has a role i.e student or tutor
|
17
|
+
def self.get_student_role
|
18
|
+
true if @studentrole["role"]
|
19
|
+
end
|
20
|
+
|
21
|
+
#return true if student role is "Student"
|
22
|
+
def self.is_student
|
23
|
+
true if @studentrole["role"] == "Student"
|
24
|
+
end
|
25
|
+
|
26
|
+
#return true if student has subjects of interests
|
27
|
+
def self.student_has_subject
|
28
|
+
true if @profile["subjects_of_interest"].length > 0
|
29
|
+
end
|
30
|
+
|
31
|
+
#return true if student has set a competeny level for all subjects
|
32
|
+
def self.student_subject_competency
|
33
|
+
all_competency_set = true
|
34
|
+
@profile["subjects_of_interest"].each do |s|
|
35
|
+
if s["competency"] == nil
|
36
|
+
all_competency_set = false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
return all_competency_set
|
40
|
+
end
|
41
|
+
|
42
|
+
#check to see if tutor has set subjects
|
43
|
+
def self.tutor_subjects
|
44
|
+
all_subjects_set = true
|
45
|
+
@tutors.each do |t|
|
46
|
+
if t["subjects"].length <= 0
|
47
|
+
all_subjects_set = false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
return all_subjects_set
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
private
|
56
|
+
# def set_student
|
57
|
+
# @student = MockDb.student()
|
58
|
+
# end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Matcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Femi Abdul
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A library to match students with tutors on the bookatutor application
|
14
|
+
email: femi.abdul67@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/MockDb.rb
|
20
|
+
- lib/Student.rb
|
21
|
+
- lib/matcher.rb
|
22
|
+
- lib/testCases.rb
|
23
|
+
homepage: http://rubygems.org/gems/matcher
|
24
|
+
licenses: []
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.5.2
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Match students with tutors
|
46
|
+
test_files: []
|