package Ġcom . and b . apps . as pen . response Ċ Ċ import Ġcom . and b . apps . as pen . models . Subject Ċ import Ġcom . and b . apps . as pen . models . Subject Grade Ċ import Ġcom . and b . apps . as pen . models . Term Ċ import Ġkotlinx . serialization . Serializable Ċ Ċ @ Serializable Ċ data Ġclass ĠCourse ListResponse ( ĊĠĠĠ Ġval Ġerrors : ĠError Response , ĊĠĠĠ Ġval Ġconfig : ĠResponse Config Ġ= ĠResponse Config (" dc ps ", Ġ" 1 "), ĊĠĠĠ Ġval Ġdata : ĠList < Course Response >, ĊĠĠĠ Ġval Ġas Of : ĠInt Ċ ) Ċ Ċ fun ĠCourse ListResponse . to Subject List ( saved Configs : ĠList < Subject . Config >, Ġterm : ĠInt Ġ= Ġconfig . term . toInt ()): ĠList < Subject > Ġ{ ĊĠĠĠ Ġreturn Ġdata . map Ġ{ Ġcourse Response Ġ-> ĊĠĠĠĠĠĠĠ Ġval Ġ( last , Ġfirst ) Ġ= Ġif Ġ( course Response . teacher . contains ("," )) Ġcourse Response . teacher . split ("," ). map Ġ{ Ġit . trim () Ġ} Ġelse ĠlistOf ("", Ġcourse Response . teacher ) ĊĠĠĠĠĠĠĠ Ġval Ġconfig Ġ= Ġsaved Configs . find Ġ{ Ġit . id Ġ== Ġcourse Response . id Ġ} Ġ?: ĠSubject . Config ( course Response . id , Ġcourse Response . name . to Icon (), Ġ 0 xFF 4 CA F 5 0 . toInt (), Ġfalse ) ĊĠĠĠĠĠĠĠ ĠSubject ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= Ġcourse Response . id , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġcourse Response . name , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġteacher Ġ= Ġ"$ first Ġ$ last ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfig Ġ= Ġconfig , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġterms Ġ= ĠlistOf ( Term . Loading ( 1 ), ĠTerm . Loading ( 2 ), ĠTerm . Loading ( 3 ), ĠTerm . Loading ( 4 )). map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġwhen ( it . term ){ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġterm Ġ-> Ġcourse Response . to Term Gr ades ( it . term ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġit ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun ĠCourse Response . to Term Gr ades ( term : ĠInt ): ĠTerm . With Gr ades { ĊĠĠĠ Ġreturn ĠTerm . With Gr ades ( ĊĠĠĠĠĠĠĠ Ġterm Ġ= Ġterm , ĊĠĠĠĠĠĠĠ Ġassignments Ġ= Ġassignments . map Ġ{ Ġit . to Assignment ( name ) Ġ}, ĊĠĠĠĠĠĠĠ Ġgrade Ġ= Ġcurrent Term Grade . to Subject Grade (), ĊĠĠĠĠĠĠĠ Ġcategories Ġ= Ġcategory Table [ term . toString ()] Ġ?: Ġthrow ĠError (" Category Ġtable Ġdid Ġnot Ġexist Ġfor ĠCourse Response Ġ= Ġ$ this ") ĊĠĠĠ Ġ) Ċ } Ċ Ċ fun ĠString . to Subject Grade (): ĠSubject Grade Ġ{ ĊĠĠĠ Ġval Ġnumber Grade Ġ= Ġtake While Ġ{ Ġit Ġ!= Ġ' Ġ' Ġ}. toDouble OrNull () ĊĠĠĠ Ġval Ġletter Ġ= Ġtake Last While Ġ{ Ġit Ġ!= Ġ' Ġ' Ġ&& Ġit Ġ! in Ġ' 0 ' .. ' 9 ' Ġ} ĊĠĠĠ Ġreturn Ġwhen Ġ{ ĊĠĠĠĠĠĠĠ Ġnumber Grade Ġ!= Ġnull Ġ-> ĠSubject Grade . Letter ( number Grade , Ġletter ) ĊĠĠĠĠĠĠĠ Ġelse Ġ-> ĠSubject Grade . Un graded ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġfun ĠString . to Icon (): ĠSubject . Icon Ġ{ ĊĠĠĠ Ġval Ġcheck Ġ= Ġthis . toLowerCase () ĊĠĠĠ Ġreturn Ġicon Strings . find Ġ{ Ġpair Ġ-> Ġpair . second . any Ġ{ Ġit Ġin Ġcheck Ġ} Ġ} ?. first Ġ?: ĠSubject . Icon . S CHO OL Ċ } Ċ Ċ private Ġval Ġicon Strings : ĠList < Pair < Subject . Icon , ĠList < String >>> Ġ= ĠlistOf ( ĊĠĠĠ ĠSubject . Icon . ART Ġto ĠlistOf (" art ", Ġ" draw ", Ġ" paint ", Ġ" print ", Ġ" sc ul pt ", Ġ" cer am ic "), ĊĠĠĠ ĠSubject . Icon . ATOM Ġto ĠlistOf (" chem ", Ġ" physics "), ĊĠĠĠ ĠSubject . Icon . BIO LOG Y Ġto ĠlistOf (" bio "), ĊĠĠĠ ĠSubject . Icon . BOOK Ġto ĠlistOf (" english ", Ġ" l iter ature "), ĊĠĠĠ ĠSubject . Icon . CAL C UL US Ġto ĠlistOf (" calc "), ĊĠĠĠ ĠSubject . Icon . CAMERA Ġto ĠlistOf (" photo ", Ġ" imag ", Ġ" camera "), ĊĠĠĠ ĠSubject . Icon . COMP ASS Ġto ĠlistOf (" geom "), ĊĠĠĠ ĠSubject . Icon . COMP UT ER Ġto ĠlistOf (" computer "), ĊĠĠĠ ĠSubject . Icon . E CON OM ICS Ġto ĠlistOf (" e con "), ĊĠĠĠ ĠSubject . Icon . ENGINE ER ING Ġto ĠlistOf (" engine er ", Ġ" me ch ", Ġ" robot "), ĊĠĠĠ ĠSubject . Icon . FIL M Ġto ĠlistOf (" film ", Ġ" movie "), ĊĠĠĠ ĠSubject . Icon . FIN ANCE Ġto ĠlistOf (" fin anc "), ĊĠĠĠ ĠSubject . Icon . FL ASK Ġto ĠlistOf (" lab "), ĊĠĠĠ ĠSubject . Icon . G LO BE Ġto ĠlistOf (" geo ", Ġ" env iro ", Ġ" world "), ĊĠĠĠ ĠSubject . Icon . GO VER N MENT Ġto ĠlistOf (" gov "), ĊĠĠĠ ĠSubject . Icon . HE ALTH Ġto ĠlistOf (" health ", Ġ" med ", Ġ" safe "), ĊĠĠĠ ĠSubject . Icon . HISTORY Ġto ĠlistOf (" history "), ĊĠĠĠ ĠSubject . Icon . LA W Ġto ĠlistOf (" law "), ĊĠĠĠ ĠSubject . Icon . M US IC Ġto ĠlistOf (" music ", Ġ" band ", Ġ" orche stra "), ĊĠĠĠ ĠSubject . Icon . NE WS Ġto ĠlistOf (" news ", Ġ" journal "), ĊĠĠĠ ĠSubject . Icon . PE Ġto ĠlistOf (" physical "), ĊĠĠĠ ĠSubject . Icon . P SY CHO LOG Y Ġto ĠlistOf (" ps ych "), ĊĠĠĠ ĠSubject . Icon . SOC IO LOG Y Ġto ĠlistOf (" s oci "), ĊĠĠĠ ĠSubject . Icon . SPE AK ING Ġto ĠlistOf (" speak ", Ġ" speech ", Ġ" deb ate "), ĊĠĠĠ ĠSubject . Icon . STAT ISTICS Ġto ĠlistOf (" stat ", Ġ" prob "), ĊĠĠĠ ĠSubject . Icon . THE ATER Ġto ĠlistOf (" the ater ", Ġ" dr ama ", Ġ" stage "), ĊĠĠĠ ĠSubject . Icon . TRANSL ATE Ġto ĠlistOf (" language ", Ġ" f rench ", Ġ" span ish ", Ġ" chinese ", Ġ" ger man ", Ġ" latin ", Ġ" arab ic ", Ġ" ital ian ", Ġ" r ussian "), ĊĠĠĠ ĠSubject . Icon . WR IT ING Ġto ĠlistOf (" writ ", Ġ" po et ") Ċ )