File size: 4,179 Bytes
3929396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
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
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
117
118
119
120
121
122
123
124
125
126
127
export interface ChecklistItem {
  label: string;
  required: boolean;
  details: string;
}

interface ChecklistCourse {
  courseLevel?: string | null;
  courseType?: string | null;
  language?: string | null;
  admissionRequirements?: string | null;
  scholarshipInfo?: string | null;
}

const CONDITIONAL: Array<{ pattern: RegExp; label: string; details: string }> = [
  {
    pattern: /ielts|toefl|pte|duolingo|english proficiency|language test/i,
    label: "English proficiency test",
    details: "IELTS, TOEFL, PTE, or the test named by the university.",
  },
  {
    pattern: /\bgre\b|\bgmat\b|\bsat\b|\bact\b|bitsat|jee|entrance test|entrance exam/i,
    label: "Entrance or standardized test score",
    details: "The score report for the test this course requires.",
  },
  {
    pattern: /portfolio|design samples|work samples/i,
    label: "Portfolio",
    details: "Work samples in the format the course page describes.",
  },
  {
    pattern: /research proposal|statement of research/i,
    label: "Research proposal",
    details: "Proposal requested for research degrees.",
  },
  {
    pattern: /medical|fitness certificate|health/i,
    label: "Medical or fitness certificate",
    details: "Only if the university asks for one.",
  },
  {
    pattern: /experience letter|work experience|resume|curriculum vitae|\bcv\b/i,
    label: "CV and work-experience letters",
    details: "CV plus proof of experience when the course asks for it.",
  },
];

/**
 * Documents an applicant should prepare. The baseline set is always included;
 * extra rows are added only when the course text names them.
 */
export function buildDocumentChecklist(course: ChecklistCourse): ChecklistItem[] {
  const text = `${course.admissionRequirements ?? ""} ${course.scholarshipInfo ?? ""} ${course.language ?? ""} ${course.courseType ?? ""} ${course.courseLevel ?? ""}`;
  const postgraduate = /master|postgrad|mba|doctor|ph\.?d|postdoc/i.test(course.courseLevel ?? "");
  const items: ChecklistItem[] = [
    {
      label: "Application form",
      required: true,
      details: "The university's own online or PDF application.",
    },
    {
      label: "Academic transcripts",
      required: true,
      details: "Official marksheets or transcripts for the qualification you are applying with.",
    },
    {
      label: postgraduate ? "Degree certificate" : "School leaving or predicted grades",
      required: true,
      details: postgraduate
        ? "Provisional or final degree certificate."
        : "Leaving certificate, predicted grades, or the equivalent.",
    },
    {
      label: "Passport or government ID",
      required: true,
      details: "A current photo identity page.",
    },
    {
      label: "Passport photograph",
      required: true,
      details: "A recent photo that matches the university's size rules.",
    },
    {
      label: "Statement of purpose",
      required: true,
      details: "Personal statement written for this course.",
    },
    {
      label: "Letters of recommendation",
      required: true,
      details: "Usually two academic or professional referees.",
    },
    {
      label: "CV",
      required: !/undergrad|bachelor|diploma/i.test(course.courseLevel ?? ""),
      details: "Education, projects, and activities.",
    },
    {
      label: "Proof of funds",
      required: true,
      details: "Bank statement or sponsor letter covering tuition and living costs.",
    },
  ];

  if (/english/i.test(course.language ?? "") || /ielts|toefl|english/i.test(text)) {
    items.push({
      label: "English proficiency test",
      required: /ielts|toefl|pte|duolingo|english proficiency/i.test(text),
      details: "Required when the university names an English test. Optional when the course is taught in English but no test is listed.",
    });
  }

  for (const rule of CONDITIONAL) {
    if (rule.pattern.test(text)) {
      items.push({ label: rule.label, required: true, details: rule.details });
    }
  }

  const seen = new Set<string>();
  return items.filter((item) => {
    const key = item.label.toLowerCase();
    if (seen.has(key)) return false;
    seen.add(key);
    return true;
  });
}