Class: Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/matcher.rb

Class Method Summary collapse

Class Method Details

.getRecommendation(student, tutors) ⇒ Object

before_action :set_student



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/matcher.rb', line 6

def self.getRecommendation(student, tutors)
    @profile = student.student()
    #check subjects students are interested in and their competency level
    @studentSubjects = @profile["subjects_of_interest"] 

    #initialize an empty array to store list of recommended tutors
    @recommendedTutors = []
    
    #loop tutors array
    #match tutor subjects with student subjects
    #create an array of all subjects that match
    #create an array for every tutor that has at least one match
    #store competency count to store the 
    tutors.each do |d|
        tutorSubjects = d["subjects"]
        tutorStyle = d["teaching_style"]
        subject_match = false
        subject_match_array = []
        competency_match_array = []
        tutorSubjects.each do |t|
            for i in @studentSubjects do
            
                case i["competency"]
                when "1"
                    subject_competency = "Slow"
                when "2"
                    subject_competency = "Average"
                when "3"
                    subject_competency = "Fast"
                end
                if(t == i["subject"])
                    subject_match = true
                    subject_match_array.push(t)
                    if(tutorStyle == subject_competency)
                        competency_match_array.push(t)   
                    end
                end
            end
        end
        @recommendedTutors.push({"tutor" => d, "subjects_matched" => subject_match_array, "competency_match" => competency_match_array}) if subject_match == true
    end

    return @recommendedTutors
end

.matchCompetency(student, tutors) ⇒ Object



55
56
57
# File 'lib/matcher.rb', line 55

def self.matchCompetency(student, tutors)
    @recommendedTutors = self.getRecommendation(student, tutors)
end

.matchTutor(student, tutors) ⇒ Object



51
52
53
# File 'lib/matcher.rb', line 51

def self.matchTutor(student, tutors)
    return self.getRecommendation(student, tutors)    
end