Module: Jekyll::IncludeTerms
- Defined in:
- jekyll/_plugins/include-terms.rb
Instance Method Summary collapse
- #_term2months(term) ⇒ Object
- #_termWithinTerms(test_term, earlier_term, later_term) ⇒ Object
- #debugFaculty(faculty) ⇒ Object
- #debugStudent(student) ⇒ Object
-
#facultyActiveWithinTerms(faculty, first_term, second_term) ⇒ Object
——————————————————————.
- #facultyIsInArea(faculty, area) ⇒ Object
- #facultyLeftWithinTerms(faculty, first_term, second_term) ⇒ Object
- #facultyStartedWithinTerms(faculty, first_term, second_term) ⇒ Object
- #listFacultyActiveWithinTerms(faculty_list, first_term, second_term) ⇒ Object
- #listFacultyInArea(faculty_list, area) ⇒ Object
- #listFacultyLeftWithinTerms(faculty_list, first_term, second_term) ⇒ Object
- #listFacultyStartedWithinTerms(faculty_list, first_term, second_term) ⇒ Object
- #listStudentsAdmittedInAcademicYear(student_list, academic_year) ⇒ Object
- #listStudentsAdmittedWithinTerms(student_list, first_term, second_term) ⇒ Object
- #listStudentsAwardedDegree(student_list, degree) ⇒ Object
- #listStudentsAwardedDegreeWithinTermsWithPlanCode(student_list, first_term, second_term, plan_code) ⇒ Object
- #listStudentsAwardedDegreeWithPlanCode(student_list, plan_code) ⇒ Object
- #listStudentsEnrolledWithinTerms(student_list, first_term, second_term) ⇒ Object
- #listStudentsEnrolledWithinTermsWithPlanCode(student_list, first_term, second_term, plan_code) ⇒ Object
- #listStudentsGraduatedInAcademicYear(student_list, academic_year) ⇒ Object
-
#listStudentsGraduatedWithinTerms(student_list, first_term, second_term) ⇒ Object
students with a last_term, outcome = graduated, ie.
- #listStudentsLeftInAcademicYear(student_list, academic_year) ⇒ Object
- #listStudentsLeftWithDegree(student_list, degree) ⇒ Object
-
#listStudentsLeftWithinTerms(student_list, first_term, second_term) ⇒ Object
students with a last_term, outcome = graduated or did not finish,.
- #listStudentsLeftWithoutDegree(student_list) ⇒ Object
- #listStudentsLeftWithoutDegreeInAcademicYear(student_list, academic_year) ⇒ Object
-
#listStudentsLeftWithoutDegreeWithinTerms(student_list, first_term, second_term) ⇒ Object
students with a last_term, outcome = “did not finish” (which is not the same as transferred or switched program within the department).
- #listStudentsWithInitialDegreeProgram(student_list, degree) ⇒ Object
- #listStudentsWithInitialPlanCode(student_list, plan_code) ⇒ Object
- #outcomeDidNotFinishOrGraduated(outcome) ⇒ Object
- #planIsWithinTerms(plan, first_term, second_term) ⇒ Object
- #studentAdmittedInAcademicYear(student, academic_year) ⇒ Object
- #studentAdmittedWithinTerms(student, first_term, second_term) ⇒ Object
- #studentAwardedDegree(student, degree) ⇒ Object
- #studentAwardedDegreeWithinTermsWithPlanCode(student, first_term, second_term, plan_code) ⇒ Object
- #studentAwardedDegreeWithPlanCode(student, plan_code) ⇒ Object
- #studentEnrolledWithinTerms(student, first_term, second_term) ⇒ Object
- #studentEnrolledWithinTermsWithPlanCode(student, first_term, second_term, plan_code) ⇒ Object
- #studentGraduatedInAcademicYear(student, academic_year) ⇒ Object
-
#studentGraduatedWithinTerms(student, first_term, second_term) ⇒ Object
NOTE: should this be graduated or left? add a separate studentLeftWithinTerms.
- #studentLeftWithDegree(student, degree) ⇒ Object
- #studentLeftWithoutDegree(student) ⇒ Object
- #studentLeftWithoutDegreeInAcademicYear(student, academic_year) ⇒ Object
- #studentLeftWithoutDegreeWithinTerms(student, first_term, second_term) ⇒ Object
- #studentWithInitialDegreeProgram(student, degree) ⇒ Object
- #studentWithInitialPlanCode(student, plan_code) ⇒ Object
- #timeToDegree(student, degree) ⇒ Object
Instance Method Details
#_term2months(term) ⇒ Object
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 |
# File 'jekyll/_plugins/include-terms.rb', line 41 def _term2months(term) raise ArgumentError.new("Invalid term is nil.") if term == nil # Jekyll.logger.warn "Warning: term argument #{"%s" % [term]}" months = 0 t = -36000 if term.include?("/") # Jekyll.logger.warn "Warning: term code #{"%s" %[term]}" values = term.split("/") months = 12 * values[0].to_i + values[1].to_i elsif term.include?("_") # Jekyll.logger.warn "Warning: term key #{"%s" %[term]}" values = term.split("_") if values[1] == "spring" t = 1 elsif values[1] == "summer" t = 6 elsif values[1] == "fall" t = 9 end months = 12 * values[0].to_i + t # Jekyll.logger.warn "Warning: term key month string and month num #{"%s => %d" %[values[1],t]}" end #Jekyll.logger.warn "Warning: months: #{"%s" % [months]}" return months end |
#_termWithinTerms(test_term, earlier_term, later_term) ⇒ Object
8 9 10 11 12 13 |
# File 'jekyll/_plugins/include-terms.rb', line 8 def _termWithinTerms(test_term,earlier_term,later_term) test_months = _term2months(test_term) lower_months = _term2months(earlier_term) upper_months = _term2months(later_term) return ((lower_months <= test_months) and (test_months <= upper_months)) end |
#debugFaculty(faculty) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'jekyll/_plugins/include-terms.rb', line 30 def debugFaculty(faculty) if (faculty.key?('area')) if (faculty['area'] == 'DEV') return true end end return false end |
#debugStudent(student) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'jekyll/_plugins/include-terms.rb', line 16 def debugStudent(student) if (student.key?('area')) if (student['area'] == 'DEV') return true end end return false end |
#facultyActiveWithinTerms(faculty, first_term, second_term) ⇒ Object
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
# File 'jekyll/_plugins/include-terms.rb', line 706 def facultyActiveWithinTerms(faculty, first_term, second_term) #return true if any of the faculty start and last terms overlap with the time between first and second terms raise ArgumentError.new("facultyActiveWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("facultyActiveWithinTerms second_term is nil.") if second_term == nil first_month = _term2months(first_term); second_month = _term2months(second_term); start_month = 0; last_month = 36000; if (faculty.key?('first_term') && faculty['first_term'] != nil) start_month = _term2months(faculty['first_term']); end if (faculty.key?('last_term') && faculty['last_term'] != nil) last_month = _term2months(faculty['last_term']); end if (start_month <= first_month && second_month <= last_month) return true end return false end |
#facultyIsInArea(faculty, area) ⇒ Object
814 815 816 817 818 819 820 821 |
# File 'jekyll/_plugins/include-terms.rb', line 814 def facultyIsInArea(faculty,area) if ( faculty['area'] != nil) if (nil != faculty['area'].index(area)) return true end return false end end |
#facultyLeftWithinTerms(faculty, first_term, second_term) ⇒ Object
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
# File 'jekyll/_plugins/include-terms.rb', line 754 def facultyLeftWithinTerms(faculty, first_term, second_term) #return true if any of the faculty start and last terms overlap with the time between first and second terms raise ArgumentError.new("facultyActiveWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("facultyActiveWithinTerms second_term is nil.") if second_term == nil first_month = _term2months(first_term); second_month = _term2months(second_term); last_month = 36000; if (faculty.key?('last_term') && faculty['last_term'] != nil) last_month = _term2months(faculty['last_term']); end if (first_month <= last_month && last_month <= second_month) return true end return false end |
#facultyStartedWithinTerms(faculty, first_term, second_term) ⇒ Object
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
# File 'jekyll/_plugins/include-terms.rb', line 733 def facultyStartedWithinTerms(faculty, first_term, second_term) #return true if any of the faculty start and last terms overlap with the time between first and second terms raise ArgumentError.new("facultyActiveWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("facultyActiveWithinTerms second_term is nil.") if second_term == nil first_month = _term2months(first_term); second_month = _term2months(second_term); start_month = 0; if (faculty.key?('first_term') && faculty['first_term'] != nil) start_month = _term2months(faculty['first_term']); end if (first_month <= start_month && start_month <= second_month) return true end return false end |
#listFacultyActiveWithinTerms(faculty_list, first_term, second_term) ⇒ Object
776 777 778 779 780 781 782 783 784 785 786 787 |
# File 'jekyll/_plugins/include-terms.rb', line 776 def listFacultyActiveWithinTerms(faculty_list, first_term,second_term) raise ArgumentError.new("listFacultyActiveWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("listFacultyActiveWithinTerms second_term is nil.") if second_term == nil array_flag = faculty_list.is_a?(Array) return nil unless faculty_list.is_a?(Array) faculty_list.select { |faculty| !debugFaculty(faculty) && facultyActiveWithinTerms(faculty, first_term, second_term) } end |
#listFacultyInArea(faculty_list, area) ⇒ Object
823 824 825 826 827 828 829 830 |
# File 'jekyll/_plugins/include-terms.rb', line 823 def listFacultyInArea(faculty_list,area) return nil unless faculty_list.is_a?(Array) faculty_list.select { |faculty| !debugFaculty(faculty) && facultyIsInArea(faculty, area) } end |
#listFacultyLeftWithinTerms(faculty_list, first_term, second_term) ⇒ Object
789 790 791 792 793 794 795 796 797 798 799 800 |
# File 'jekyll/_plugins/include-terms.rb', line 789 def listFacultyLeftWithinTerms(faculty_list, first_term,second_term) raise ArgumentError.new("listFacultyActiveWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("listFacultyActiveWithinTerms second_term is nil.") if second_term == nil array_flag = faculty_list.is_a?(Array) return nil unless faculty_list.is_a?(Array) faculty_list.select { |faculty| !debugFaculty(faculty) && facultyLeftWithinTerms(faculty, first_term, second_term) } end |
#listFacultyStartedWithinTerms(faculty_list, first_term, second_term) ⇒ Object
801 802 803 804 805 806 807 808 809 810 811 812 |
# File 'jekyll/_plugins/include-terms.rb', line 801 def listFacultyStartedWithinTerms(faculty_list, first_term,second_term) raise ArgumentError.new("listFacultyActiveWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("listFacultyActiveWithinTerms second_term is nil.") if second_term == nil array_flag = faculty_list.is_a?(Array) return nil unless faculty_list.is_a?(Array) faculty_list.select { |faculty| !debugFaculty(faculty) && facultyStartedWithinTerms(faculty, first_term, second_term) } end |
#listStudentsAdmittedInAcademicYear(student_list, academic_year) ⇒ Object
576 577 578 579 580 581 |
# File 'jekyll/_plugins/include-terms.rb', line 576 def listStudentsAdmittedInAcademicYear (student_list, academic_year) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentAdmittedInAcademicYear(student, academic_year) } end |
#listStudentsAdmittedWithinTerms(student_list, first_term, second_term) ⇒ Object
569 570 571 572 573 574 |
# File 'jekyll/_plugins/include-terms.rb', line 569 def listStudentsAdmittedWithinTerms(student_list, first_term, second_term) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentAdmittedWithinTerms(student, first_term, second_term) } end |
#listStudentsAwardedDegree(student_list, degree) ⇒ Object
668 669 670 671 672 673 |
# File 'jekyll/_plugins/include-terms.rb', line 668 def listStudentsAwardedDegree(student_list, degree) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentAwardedDegree(student, degree) } end |
#listStudentsAwardedDegreeWithinTermsWithPlanCode(student_list, first_term, second_term, plan_code) ⇒ Object
682 683 684 685 686 687 |
# File 'jekyll/_plugins/include-terms.rb', line 682 def listStudentsAwardedDegreeWithinTermsWithPlanCode(student_list, first_term, second_term, plan_code) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentAwardedDegreeWithinTermsWithPlanCode(student, first_term, second_term, plan_code) } end |
#listStudentsAwardedDegreeWithPlanCode(student_list, plan_code) ⇒ Object
675 676 677 678 679 680 |
# File 'jekyll/_plugins/include-terms.rb', line 675 def listStudentsAwardedDegreeWithPlanCode(student_list, plan_code) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentAwardedDegreeWithPlanCode(student, plan_code) } end |
#listStudentsEnrolledWithinTerms(student_list, first_term, second_term) ⇒ Object
548 549 550 551 552 553 554 555 556 |
# File 'jekyll/_plugins/include-terms.rb', line 548 def listStudentsEnrolledWithinTerms(student_list, first_term, second_term) raise ArgumentError.new("listStudentsEnrolledWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("listStudentsEnrolledWithinTerms second_term is nil.") if second_term == nil return nil unless student_list.is_a?(Array) student_list.select { |student| !debugStudent(student) && studentEnrolledWithinTerms(student, first_term, second_term) } end |
#listStudentsEnrolledWithinTermsWithPlanCode(student_list, first_term, second_term, plan_code) ⇒ Object
558 559 560 561 562 563 564 565 566 |
# File 'jekyll/_plugins/include-terms.rb', line 558 def listStudentsEnrolledWithinTermsWithPlanCode(student_list, first_term, second_term, plan_code) raise ArgumentError.new("listStudentsEnrolledWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("listStudentsEnrolledWithinTerms second_term is nil.") if second_term == nil return nil unless student_list.is_a?(Array) student_list.select { |student| !debugStudent(student) && studentEnrolledWithinTermsWithPlanCode(student, first_term, second_term, plan_code) } end |
#listStudentsGraduatedInAcademicYear(student_list, academic_year) ⇒ Object
592 593 594 595 596 597 |
# File 'jekyll/_plugins/include-terms.rb', line 592 def listStudentsGraduatedInAcademicYear (student_list, academic_year) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentGraduatedInAcademicYear(student, academic_year) } end |
#listStudentsGraduatedWithinTerms(student_list, first_term, second_term) ⇒ Object
students with a last_term, outcome = graduated, ie. compeleted a plan and were awarded a degree
618 619 620 621 622 623 |
# File 'jekyll/_plugins/include-terms.rb', line 618 def listStudentsGraduatedWithinTerms(student_list, first_term, second_term) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentGraduatedWithinTerms(student, first_term, second_term) } end |
#listStudentsLeftInAcademicYear(student_list, academic_year) ⇒ Object
608 609 610 611 612 613 |
# File 'jekyll/_plugins/include-terms.rb', line 608 def listStudentsLeftInAcademicYear (student_list, academic_year) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && (studentGraduatedInAcademicYear(student, academic_year) || studentLeftWithoutDegreeInAcademicYear(student, academic_year)) } end |
#listStudentsLeftWithDegree(student_list, degree) ⇒ Object
690 691 692 693 694 695 |
# File 'jekyll/_plugins/include-terms.rb', line 690 def listStudentsLeftWithDegree(student_list, degree) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentLeftWithDegree(student, degree) } end |
#listStudentsLeftWithinTerms(student_list, first_term, second_term) ⇒ Object
students with a last_term, outcome = graduated or did not finish,
600 601 602 603 604 605 |
# File 'jekyll/_plugins/include-terms.rb', line 600 def listStudentsLeftWithinTerms(student_list, first_term, second_term) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && (studentGraduatedWithinTerms(student, first_term, second_term) || studentLeftWithoutDegreeWithinTerms(student, first_term, second_term)) } end |
#listStudentsLeftWithoutDegree(student_list) ⇒ Object
697 698 699 700 701 702 |
# File 'jekyll/_plugins/include-terms.rb', line 697 def listStudentsLeftWithoutDegree(student_list) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentLeftWithoutDegree(student) } end |
#listStudentsLeftWithoutDegreeInAcademicYear(student_list, academic_year) ⇒ Object
645 646 647 648 649 650 |
# File 'jekyll/_plugins/include-terms.rb', line 645 def listStudentsLeftWithoutDegreeInAcademicYear (student_list, academic_year) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentLeftWithoutDegreeInAcademicYear(student, academic_year) } end |
#listStudentsLeftWithoutDegreeWithinTerms(student_list, first_term, second_term) ⇒ Object
students with a last_term, outcome = “did not finish” (which is not the same as transferred or switched program within the department)
638 639 640 641 642 643 |
# File 'jekyll/_plugins/include-terms.rb', line 638 def listStudentsLeftWithoutDegreeWithinTerms(student_list, first_term, second_term) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentLeftWithoutDegreeWithinTerms(student, first_term, second_term) } end |
#listStudentsWithInitialDegreeProgram(student_list, degree) ⇒ Object
653 654 655 656 657 658 |
# File 'jekyll/_plugins/include-terms.rb', line 653 def listStudentsWithInitialDegreeProgram(student_list, degree) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentWithInitialDegreeProgram(student, degree) } end |
#listStudentsWithInitialPlanCode(student_list, plan_code) ⇒ Object
660 661 662 663 664 665 |
# File 'jekyll/_plugins/include-terms.rb', line 660 def listStudentsWithInitialPlanCode(student_list, plan_code) return nil if !(student_list.is_a?(Array)) student_list.select { |student| !debugStudent(student) && studentWithInitialPlanCode(student, plan_code) } end |
#outcomeDidNotFinishOrGraduated(outcome) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'jekyll/_plugins/include-terms.rb', line 132 def outcomeDidNotFinishOrGraduated(outcome) # returns "graduated" if outcome is one of the gst graduated options #returns "left" if outcome is one of gst left options # "graduated" and ""did not finish" are legacy gradbeta outcomes = ["Completed Program", "graduated"] = ["Discontinued", "Dismissed", "Deceased","did not finish"] # note: Leave of Absence, Active in Program don't count as left if (.include?(outcome)) return "graduated" end if (.include?(outcome)) return "DNF" end # legacy values! if (outcome.include?("switch") || outcome.include?("transfer")) return "DNF" end # need to validate outcomes! return nil end |
#planIsWithinTerms(plan, first_term, second_term) ⇒ Object
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 |
# File 'jekyll/_plugins/include-terms.rb', line 73 def planIsWithinTerms(plan, first_term, second_term) # if either plan.admit_term or plan.last_term fall within first_term and second_term (inclusive of first and second term), returns true # (ie. plan extent overlaps with time between first and second terms) raise ArgumentError.new("planIsWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("planIsWithinTerms second_term is nil.") if second_term == nil lower_months = _term2months(first_term) upper_months = _term2months(second_term) # Jekyll.logger.warn "Warning: first_term to months: #{"%s to %d" %[first_term, lower_months]}" admit_term = plan['admit_term'] if admit_term == nil return false end admit_months = _term2months(admit_term) if admit_months > upper_months return false end last_term = plan['last_term'] if last_term == nil last_months = 10000 * 12 # if we haven't graduated, set last term to year 100000 else last_months = _term2months(last_term) end if last_months < lower_months return false end return true end |
#studentAdmittedInAcademicYear(student, academic_year) ⇒ Object
124 125 126 127 128 129 130 |
# File 'jekyll/_plugins/include-terms.rb', line 124 def studentAdmittedInAcademicYear(student, academic_year) end_year = academic_year+1 first_term = "#{academic_year}/9" second_term = "#{end_year}/6" studentAdmittedWithinTerms(student, first_term, second_term) end |
#studentAdmittedWithinTerms(student, first_term, second_term) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'jekyll/_plugins/include-terms.rb', line 106 def studentAdmittedWithinTerms(student, first_term, second_term) if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if plan['admit_term'] != nil return (_termWithinTerms(plan['admit_term'],first_term,second_term)) end end else # Jekyll.logger.warn "Warning: student missing academic_plans array in #{student['fsuid']}" end # NOTE: check admit_term for students without an academic plan? if (student.key?('admit_term')) return (_termWithinTerms(student['admit_term'],first_term,second_term)) end return false end |
#studentAwardedDegree(student, degree) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'jekyll/_plugins/include-terms.rb', line 260 def studentAwardedDegree(student, degree) site = @context.registers[:site] if (site.data['dept'].nil? || site.data['dept']['academic_plan_codes'].nil?) return nil end academic_plans = site.data['dept']['academic_plan_codes'] if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if (plan.key?('outcome') ) if (outcomeDidNotFinishOrGraduated(plan['outcome']) == 'graduated') final_plan = academic_plans[key] if (final_plan['degree'] == degree) return true end end end end end return false end |
#studentAwardedDegreeWithinTermsWithPlanCode(student, first_term, second_term, plan_code) ⇒ Object
299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'jekyll/_plugins/include-terms.rb', line 299 def studentAwardedDegreeWithinTermsWithPlanCode(student, first_term,second_term,plan_code) if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if (key == plan_code) if (plan.key?('outcome') ) if (outcomeDidNotFinishOrGraduated(plan['outcome']) == 'graduated') return _termWithinTerms(plan['last_term'],first_term,second_term) end end end end end return false end |
#studentAwardedDegreeWithPlanCode(student, plan_code) ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'jekyll/_plugins/include-terms.rb', line 284 def studentAwardedDegreeWithPlanCode(student, plan_code) if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if (key == plan_code) if (plan.key?('outcome') ) if (outcomeDidNotFinishOrGraduated(plan['outcome']) == 'graduated') return true end end end end end return false end |
#studentEnrolledWithinTerms(student, first_term, second_term) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'jekyll/_plugins/include-terms.rb', line 222 def studentEnrolledWithinTerms(student, first_term, second_term) #return true if any of the students plans overlap with the time between first and second terms raise ArgumentError.new("studentEnrolledWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("studentEnrolledWithinTerms second_term is nil.") if second_term == nil if (student.key?('academic_plans')) for plan in student['academic_plans'] if planIsWithinTerms(plan[1], first_term, second_term) return true end end else #Jekyll.logger.warn "Warning: Student missing academic_plans array in #{student['fsuid']}" end return false end |
#studentEnrolledWithinTermsWithPlanCode(student, first_term, second_term, plan_code) ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'jekyll/_plugins/include-terms.rb', line 240 def studentEnrolledWithinTermsWithPlanCode(student, first_term, second_term,plan_code) #return true if any of the students plans overlap with the time between first and second terms raise ArgumentError.new("studentEnrolledWithinTerms first_term is nil.") if first_term == nil raise ArgumentError.new("studentEnrolledWithinTerms second_term is nil.") if second_term == nil if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if (key == plan_code) if planIsWithinTerms(plan, first_term, second_term) return true end end end else #Jekyll.logger.warn "Warning: Student missing academic_plans array in #{student['fsuid']}" end return false end |
#studentGraduatedInAcademicYear(student, academic_year) ⇒ Object
203 204 205 206 207 208 209 210 |
# File 'jekyll/_plugins/include-terms.rb', line 203 def studentGraduatedInAcademicYear(student, academic_year) end_year = academic_year+1 first_term = "#{academic_year}/9" second_term = "#{end_year}/6" studentGraduatedWithinTerms(student, first_term, second_term) end |
#studentGraduatedWithinTerms(student, first_term, second_term) ⇒ Object
NOTE: should this be graduated or left? add a separate studentLeftWithinTerms
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'jekyll/_plugins/include-terms.rb', line 159 def studentGraduatedWithinTerms(student, first_term, second_term) if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if planIsWithinTerms(plan, first_term, second_term) if plan['last_term'] != nil if ( _termWithinTerms(plan['last_term'], first_term,second_term ) ) if (plan.key?('outcome') ) return (outcomeDidNotFinishOrGraduated(plan['outcome']) == 'graduated') end end else return false end end end else # Jekyll.logger.warn "Warning: student missing academic_plans array in #{student['fsuid']}" end return false end |
#studentLeftWithDegree(student, degree) ⇒ Object
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'jekyll/_plugins/include-terms.rb', line 400 def studentLeftWithDegree(student, degree) site = @context.registers[:site] if (site.data['dept'].nil? || site.data['dept']['academic_plan_codes'].nil?) return nil end academic_plans = site.data['dept']['academic_plan_codes'] if (!student.key?('last_term')) # current students haven't left yet return false elsif student['last_term'] == nil return false end if (student.key?('academic_plans')) max_last_term = 0 max_plan_key = 'none' student['academic_plans'].each do |key, plan| if (plan.key?('outcome') && plan.key?('last_term')) term = plan['last_term'] if (term != nil && outcomeDidNotFinishOrGraduated(plan['outcome']) == 'graduated') this_last_term = _term2months(term) if (this_last_term > max_last_term) max_plan_key = key max_last_term = this_last_term end end end end plan = academic_plans[max_plan_key] # if (student['fsuid'] == 'sj14j') # Jekyll.logger.warn "Warning: sj14j #{max_last_term} #{max_plan_key} #{plan['degree'] } }" # end if (plan) if (plan.key?('degree') ) if (plan['degree'] == degree) return true end end end end return false end |
#studentLeftWithoutDegree(student) ⇒ Object
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'jekyll/_plugins/include-terms.rb', line 450 def studentLeftWithoutDegree(student) # return false if student awarded a degree, or is still active (doesn't have a last term) # return true if last_term set but no degree awarded # return true if student left but no degree for last plan if (!student.key?('last_term')) # current students haven't left yet return false elsif student['last_term'] == nil return false end # check to see if DNF any plans # but also check if graduated from any plans (in which case DNF is false overall) dnf_flag = false grad_flag= false if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if (plan.key?('outcome')) if (outcomeDidNotFinishOrGraduated(plan['outcome']) == 'DNF' ) dnf_flag = true elsif (outcomeDidNotFinishOrGraduated(plan['outcome']) == 'graduated' ) grad_flag = true end end end end return (dnf_flag && !grad_flag) end |
#studentLeftWithoutDegreeInAcademicYear(student, academic_year) ⇒ Object
212 213 214 215 216 217 218 219 |
# File 'jekyll/_plugins/include-terms.rb', line 212 def studentLeftWithoutDegreeInAcademicYear(student, academic_year) end_year = academic_year+1 first_term = "#{academic_year}/9" second_term = "#{end_year}/6" studentLeftWithoutDegreeWithinTerms(student, first_term, second_term) end |
#studentLeftWithoutDegreeWithinTerms(student, first_term, second_term) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'jekyll/_plugins/include-terms.rb', line 180 def studentLeftWithoutDegreeWithinTerms(student, first_term, second_term) if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if planIsWithinTerms(plan, first_term, second_term) if plan['last_term'] != nil if ( _termWithinTerms(plan['last_term'], first_term,second_term ) ) if (plan.key?('outcome') ) return (outcomeDidNotFinishOrGraduated(plan['outcome']) == 'DNF') end end else return false end end end else # Jekyll.logger.warn "Warning: student missing academic_plans array in #{student['fsuid']}" end return false end |
#studentWithInitialDegreeProgram(student, degree) ⇒ Object
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'jekyll/_plugins/include-terms.rb', line 314 def studentWithInitialDegreeProgram(student, degree) site = @context.registers[:site] if (site.data['dept'].nil? || site.data['dept']['academic_plan_codes'].nil?) return nil end academic_plans = site.data['dept']['academic_plan_codes'] # if (student['fsuid'] == 'cc18t') # plan = academic_plans[student['initial_plan_code']] # Jekyll.logger.warn "Warning: cc18t #{student['initial_plan_code']} #{plan['degree'] } }" # end if (student.key?('initial_plan_code')) init_plan_code = student['initial_plan_code'] plan = academic_plans[init_plan_code] if (plan) if (plan.key?('degree') ) if (plan['degree'] == degree) return true end end end else if (student.key?('academic_plans')) min_admit_term = 100000 min_plan_key = 'none' student['academic_plans'].each do |key, plan| term = plan['admit_term'] if (term != nil) this_admit_term = _term2months(term) if (this_admit_term < min_admit_term) min_plan_key = key min_admit_term = this_admit_term end end end plan = academic_plans[min_plan_key] if (plan) if (plan.key?('degree') ) if (plan['degree'] == degree) return true end end end end end return false end |
#studentWithInitialPlanCode(student, plan_code) ⇒ Object
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'jekyll/_plugins/include-terms.rb', line 365 def studentWithInitialPlanCode(student, plan_code) site = @context.registers[:site] if (site.data['dept'].nil? || site.data['dept']['academic_plan_codes'].nil?) return nil end academic_plans = site.data['dept']['academic_plan_codes'] if (student.key?('initial_plan_code')) if (plan_code == student['initial_plan_code']) return true end else if (student.key?('academic_plans')) min_admit_term = 100000 min_plan_key = 'none' student['academic_plans'].each do |key, plan| term = plan['admit_term'] if (term != nil) this_admit_term = _term2months(term) if (this_admit_term < min_admit_term) min_plan_key = key min_admit_term = this_admit_term end end end if (min_plan_key = plan_code) return true end end end return false end |
#timeToDegree(student, degree) ⇒ Object
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File 'jekyll/_plugins/include-terms.rb', line 483 def timeToDegree(student, degree) # time in years to graduation with given degree, or zero if hasn't graduated site = @context.registers[:site] if (site.data['dept'].nil? || site.data['dept']['academic_plan_codes'].nil?) return nil end academic_plans = site.data['dept']['academic_plan_codes'] if (student.key?('academic_plans')) student['academic_plans'].each do |key, plan| if (plan.key?('outcome')) if (outcomeDidNotFinishOrGraduated(plan['outcome']) == 'graduated') the_plan = academic_plans[key]; if (plan && plan.key?('degree') && plan['degree'] == degree) admit_months = _term2months(plan['admit_term']) last_months = _term2months(plan['last_term']) if (nil == admit_months) Jekyll.logger.warn "Warning: Student has nil admit_term #{student['last_name']} #{student['fsuid']}" end if (nil == last_months) Jekyll.logger.warn "Warning: Student has nil last_term #{student['last_name']} #{student['fsuid']}" end values = plan['last_term'].split("/") last_term_start_month = values[1].to_i # we add length of last term to time it took to graduate # so if yyyy/1 -> graduated at end of April (+ 4 months from 1) # if yyyy/6 then graduated at end of August (+ 3 months from 6) # if yyyy/9 then graduated at end of December(+ 4 months from 9) #(Note that term_codes are 1 indexed, so e.g. start of spring 2016 is 2016/1 instead of 2016/0) offset = 0; if (last_term_start_month < 6) offset = 4 elsif (last_term_start_month < 9) # summer is only 3 months long offset = 3 else offset = 4 end time = (last_months + offset) - admit_months; time = time / 12.0 return time end # degree matches end # graduated end # has outcome end # next plan end # has plans return 0 end |