Module: Jekyll::StudentsStatus

Defined in:
jekyll/_plugins/students-status.rb

Instance Method Summary collapse

Instance Method Details

#alumStudents(student_list) ⇒ Object



164
165
166
167
168
169
# File 'jekyll/_plugins/students-status.rb', line 164

def alumStudents(student_list)
      return nil if !(student_list.is_a?(Array))
      student_list.select {
                |student| studentIsAlum(student)
            }
end

#currentAndIncomingStudents(student_list) ⇒ Object



156
157
158
159
160
161
# File 'jekyll/_plugins/students-status.rb', line 156

def currentAndIncomingStudents(student_list)
  return nil if !(student_list.is_a?(Array))
  student_list.select {
                  |student| (studentIsCurrent(student) || studentIsIncoming(student))
  		}
end

#currentStudents(student_list) ⇒ Object




149
150
151
152
153
154
# File 'jekyll/_plugins/students-status.rb', line 149

def currentStudents(student_list)
  return nil if !(student_list.is_a?(Array))
  student_list.select {
                  |student| studentIsCurrent(student)
  		}
end

#didNotFinishStudents(student_list) ⇒ Object



178
179
180
181
182
183
# File 'jekyll/_plugins/students-status.rb', line 178

def didNotFinishStudents(student_list)
      return nil if !(student_list.is_a?(Array))
      student_list.select {
                |student| studentDidNotFinish(student)
            }
end

#incomingStudents(student_list) ⇒ Object



171
172
173
174
175
176
# File 'jekyll/_plugins/students-status.rb', line 171

def incomingStudents(student_list)
		  return nil if !(student_list.is_a?(Array))
		  student_list.select {
            |student| studentIsIncoming(student)
		  		}
end

#kAlumObject



13
# File 'jekyll/_plugins/students-status.rb', line 13

def kAlum ; 1  end

#kCurrentObject



14
# File 'jekyll/_plugins/students-status.rb', line 14

def kCurrent ; 2 end

#kDebugObject



12
# File 'jekyll/_plugins/students-status.rb', line 12

def kDebug ; 0 end

#kDiscontinuedObject



17
# File 'jekyll/_plugins/students-status.rb', line 17

def kDiscontinued ; 16 end

#kDNFObject



16
# File 'jekyll/_plugins/students-status.rb', line 16

def kDNF ; 8 end

#kIncomingObject



15
# File 'jekyll/_plugins/students-status.rb', line 15

def kIncoming ; 4 end

#studentDidNotFinish(student) ⇒ Object



139
140
141
142
# File 'jekyll/_plugins/students-status.rb', line 139

def studentDidNotFinish(student)
    status = studentStatus(student)
    status & kDNF == 0 ? false : true # bit 3 flag is DNF
end

#studentIsAlum(student) ⇒ Object



118
119
120
121
122
123
124
# File 'jekyll/_plugins/students-status.rb', line 118

def studentIsAlum(student)
    status = studentStatus(student)
 
 #     Jekyll.logger.warn "Student status #{student['fsuid']} :  #{status} : alum: #{status & 1 == 0 ? false : true}"
    
    status & kAlum == 0 ? false : true # bit 0 flag is current
end

#studentIsCurrent(student) ⇒ Object



126
127
128
129
130
131
132
# File 'jekyll/_plugins/students-status.rb', line 126

def studentIsCurrent(student)
    status = studentStatus(student)
    
#   Jekyll.logger.warn "Student status #{student['fsuid']} :  #{status} : current: #{status & 2== 0 ? false : true}"

    status & kCurrent == 0 ? false : true # bit 1 flag is current
end

#studentIsIncoming(student) ⇒ Object



134
135
136
137
# File 'jekyll/_plugins/students-status.rb', line 134

def studentIsIncoming(student)
    status = studentStatus(student)
   status & kIncoming == 0 ? false : true # bit 2 flag is current
end

#studentStatus(student) ⇒ Object




31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'jekyll/_plugins/students-status.rb', line 31

def studentStatus(student)
    # student can have multiple statuses
    # so return bit flag value
    # 0 = debug (area = DEV), 1 = 'alum', 2 = 'current', 4 = 'incoming', 8 = 'DNF', 16 = 'discontinued'

    statusFlags = 0
    site = @context.registers[:site]

    # run through academic plans, looking at admit_term, last_term, and degree_awarded (nb: refactor to use outcome = graduated)
    # if student has last_term, then must have graduated or DNF
    # if student has outcome = graduated, then is an alum; if no degree_awarded then DNF
    # if student doesn't have last_term, then must be current or incoming
    # if admit_term months > current_months, then must be incoming
    #
    # NOTE: should count as DNF if DNF in one plan, but alum in another?
    # maybe we should sort plans, so that DNF even if previous alum in another plan...

    if (student.key?('area'))
    
      if (student['area'] == 'DEV')
          return kDebug
      end
    
    end
    
 #   if (student['fsuid'] == 'ac12t')
#          Jekyll.logger.warn "current months #{ '%d' % [site.config['current_months']]}"
#    end
    
    if (student.key?('academic_plans'))
        student['academic_plans'].each do |key, plan|
        
        
       #     if (student['fsuid'] == 'ac12t')
       #               Jekyll.logger.warn "Student #{student['fsuid']} : plan code key  #{ '%s' %  [key]  } "
       #     end
        
        
           
            # check if student has finished (last_term exists and is less than current months)
            has_finished = false;  
            # if last_term is missing, or last_term == null, then we don't have a last term
            if (plan.key?('last_term'))
              if (plan['last_term'] != nil) 
                last_months = term2months(plan['last_term'])
                # current_months is derived from current term and year, not calendar month
                if (last_months < site.config['current_months'])
                        has_finished = true;  
                        if (plan.key?('outcome'))
                            if (plan['outcome'] != nil)
                                if (plan['outcome'] == 'graduated')
                                    statusFlags = statusFlags | kAlum # alum
                                else
                                    statusFlags = statusFlags | kDNF # DNF
                                end
                            end
                        end # has outcome key
                 # last_months < current months
                 elsif (plan.key?('discontinued') && plan['discontinued'] != nil)
                        statusFlags = statusFlags | kDiscontinued 
                        has_finished = true; 
                 end
                end # non-nil last term
              end # has last term key
            if (!has_finished)
                if (plan.key?('admit_term'))
                    admit_months = term2months(plan['admit_term'])
             #       if (student['fsuid'] == 'ac12t')
             #         Jekyll.logger.warn "Student #{student['fsuid']} : admit months #{ '%d' %  [admit_months]  } "
             #       end
                    if (admit_months > site.config['current_months'])
                      statusFlags = statusFlags | kIncoming # incoming                          
                    else
                      statusFlags = statusFlags | kCurrent # current
               #       if (student['fsuid'] == 'ac12t')
               #           Jekyll.logger.warn "Student status #{student['fsuid']} : current "
               #       end
                    end
                end
                
                
            end
        end
    end
    return statusFlags
end

#term2months(term) ⇒ Object


Raises:

  • (ArgumentError)


22
23
24
25
26
# File 'jekyll/_plugins/students-status.rb', line 22

def term2months(term)
		    raise ArgumentError.new("Invalid term is nil.") if term == nil
			values = term.split("/")
    months = 12 * values[0].to_i +  values[1].to_i
end