@@ -32,7 +32,8 @@ interface ExamStatus {
3232 | "InProgress"
3333 | "PendingModeration"
3434 | "RetakeLater"
35- | "Expired" ;
35+ | "Expired"
36+ | "UnmetPrerequisites" ;
3637 message ?: string ;
3738 alertStatus ?: "success" | "info" | "warning" | "error" ;
3839}
@@ -156,9 +157,18 @@ function getExamStatus(
156157 attempts : Attempts
157158) : ExamStatus {
158159 const latestAttempt = getLatestAttempt ( attempts ) ;
160+ const examStatus : ExamStatus = { status : "Available" } ;
159161
160162 if ( ! latestAttempt ) {
161- return { status : "Available" } ;
163+ if ( ! exam . canTake && exam . prerequisites . length > 0 ) {
164+ return {
165+ status : "UnmetPrerequisites" ,
166+ message :
167+ "You must complete the prerequisite courses to take this exam." ,
168+ alertStatus : "info" ,
169+ } ;
170+ }
171+ return examStatus ;
162172 }
163173
164174 switch ( latestAttempt . status ) {
@@ -186,7 +196,15 @@ function getExamStatus(
186196
187197 const now = new Date ( ) ;
188198 if ( now >= retakeAvailableAt ) {
189- return { status : "Available" } ;
199+ if ( ! exam . canTake && exam . prerequisites . length > 0 ) {
200+ return {
201+ status : "UnmetPrerequisites" ,
202+ message :
203+ "You must complete the prerequisite courses to take this exam." ,
204+ alertStatus : "info" ,
205+ } ;
206+ }
207+ return examStatus ;
190208 }
191209
192210 return {
@@ -196,7 +214,15 @@ function getExamStatus(
196214 } ;
197215
198216 default :
199- return { status : "Available" } ;
217+ if ( ! exam . canTake && exam . prerequisites . length > 0 ) {
218+ return {
219+ status : "UnmetPrerequisites" ,
220+ message :
221+ "You must complete the prerequisite courses to take this exam." ,
222+ alertStatus : "info" ,
223+ } ;
224+ }
225+ return examStatus ;
200226 }
201227}
202228
0 commit comments