fsf18.html 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  7. <link href="https://rsms.me/inter/inter.css" rel="stylesheet" />
  8. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
  9. <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.full.js"></script>
  10. <link
  11. href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.css"
  12. rel="stylesheet"
  13. />
  14. <link href="/2u/style" rel="stylesheet"/>
  15. <title>Module 18 NoSQL Challenge Rubric</title>
  16. <style>
  17. *,
  18. *::before,
  19. *::after {
  20. box-sizing: border-box;
  21. }
  22. html,
  23. body {
  24. margin: 0;
  25. padding: 0;
  26. line-height: 1.15;
  27. font-size: 100%;
  28. color: #fefefe;
  29. transition: all 0.4s;
  30. }
  31. body {
  32. background-color: #fbfcfd;
  33. font-family: 'Inter', sans-serif;
  34. color: #4a4a4a;
  35. }
  36. #app.dark {
  37. background-color: #121212;
  38. color: #e2e2e2;
  39. }
  40. h1 {
  41. font-size: 1.9rem;
  42. }
  43. h2 {
  44. font-size: 1.6rem;
  45. }
  46. h3 {
  47. font-size: 1.2rem;
  48. }
  49. h4 {
  50. font-size: 0.9rem;
  51. }
  52. p,
  53. legend {
  54. font-size: 1.2rem;
  55. }
  56. label {
  57. font-size: 0.9rem;
  58. line-height: 2;
  59. }
  60. fieldset {
  61. border: none;
  62. padding: 0;
  63. margin-top: 0.9rem;
  64. }
  65. input[type='radio'],
  66. input[type='checkbox'] {
  67. position: absolute !important;
  68. height: 1px;
  69. width: 1px;
  70. overflow: hidden;
  71. clip: rect(1px 1px 1px 1px);
  72. clip: rect(1px, 1px, 1px, 1px);
  73. white-space: nowrap;
  74. }
  75. .select-lg,
  76. .select-lg option {
  77. font-family: 'Inter', sans-serif;
  78. padding: 10px;
  79. }
  80. .narrow {
  81. width: 800px;
  82. }
  83. #app {
  84. padding: 3%;
  85. transition: all 0.4s;
  86. }
  87. #app h1 {
  88. font-size: 1.9rem;
  89. font-weight: 700;
  90. line-height: 1.3;
  91. }
  92. header {
  93. display: flex;
  94. justify-content: space-between;
  95. align-items: center;
  96. }
  97. .switch-group {
  98. display: flex;
  99. align-items: center;
  100. height: 2.25rem;
  101. width: 4.5rem;
  102. }
  103. input[type='checkbox'] + .toggle {
  104. height: 100%;
  105. width: 100%;
  106. background-color: #77a1db;
  107. border-radius: 1.9rem;
  108. cursor: pointer;
  109. display: flex;
  110. align-items: center;
  111. padding: 0.35rem;
  112. cursor: pointer;
  113. overflow: hidden;
  114. background-position: 25% 125%;
  115. transition: all 0.5s;
  116. }
  117. input[type='checkbox']:focus + .toggle {
  118. outline: rgb(59, 153, 252) auto 5px;
  119. }
  120. input[type='checkbox']:checked + .toggle {
  121. background-color: rgb(85, 89, 204);
  122. background-size: 1rem;
  123. background-repeat: no-repeat;
  124. background-position: 25%;
  125. background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQiIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAxNCAxNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMSIgY3k9IjgiIHI9IjEiIGZpbGw9IndoaXRlIi8+CjxjaXJjbGUgY3g9IjgiIGN5PSI3IiByPSIxIiBmaWxsPSJ3aGl0ZSIvPgo8Y2lyY2xlIGN4PSI1IiBjeT0iMTMiIHI9IjEiIGZpbGw9IndoaXRlIi8+CjxjaXJjbGUgY3g9IjUiIGN5PSIyIiByPSIyIiBmaWxsPSJ3aGl0ZSIvPgo8Y2lyY2xlIGN4PSIxMyIgY3k9IjMiIHI9IjEiIGZpbGw9IndoaXRlIi8+CjxjaXJjbGUgY3g9IjEyLjUiIGN5PSI5LjUiIHI9IjEuNSIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==');
  126. transition: all 0.5s;
  127. }
  128. input[type='checkbox'] + .toggle::after {
  129. content: '';
  130. display: block;
  131. height: 1.7rem;
  132. width: 1.7rem;
  133. border-radius: 50%;
  134. cursor: pointer;
  135. border: 4px solid #e1be64;
  136. background-color: #fddf74;
  137. transform: translateX(0rem);
  138. transition: all 0.5s;
  139. background-position: center bottom;
  140. }
  141. input[type='checkbox']:hover + .toggle::after {
  142. transform: translateX(0rem) scale(1.1);
  143. }
  144. input[type='checkbox']:checked + .toggle::after {
  145. border: 4px solid #ffffff;
  146. background-color: rgba(255, 255, 255, 0.4);
  147. transform: translateX(2.1rem);
  148. transition: all 0.5s;
  149. background-position: center;
  150. background-size: 60%;
  151. background-repeat: no-repeat;
  152. background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTkiIGhlaWdodD0iMTkiIHZpZXdCb3g9IjAgMCAxOSAxOSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE4LjUgMTAuMjlDMTguMzQyNyAxMS45OTIyIDE3LjcwMzkgMTMuNjE0NCAxNi42NTgyIDE0Ljk2NjhDMTUuNjEyNiAxNi4zMTkyIDE0LjIwMzUgMTcuMzQ1OCAxMi41OTU3IDE3LjkyNjVDMTAuOTg3OSAxOC41MDczIDkuMjQ3OTggMTguNjE4MSA3LjU3OTUgMTguMjQ2MUM1LjkxMTAyIDE3Ljg3NDEgNC4zODI5OSAxNy4wMzQ1IDMuMTc0MjMgMTUuODI1OEMxLjk2NTQ2IDE0LjYxNyAxLjEyNTk0IDEzLjA4OSAwLjc1MzkwNyAxMS40MjA1QzAuMzgxODc1IDkuNzUyMDIgMC40OTI3MTYgOC4wMTIwOCAxLjA3MzQ2IDYuNDA0M0MxLjY1NDIgNC43OTY1MSAyLjY4MDgzIDMuMzg3MzcgNC4wMzMyMSAyLjM0MTc1QzUuMzg1NTkgMS4yOTYxNCA3LjAwNzggMC42NTczMDUgOC43MSAwLjVDNy43MTM0MSAxLjg0ODI3IDcuMjMzODUgMy41MDk0NSA3LjM1ODUzIDUuMTgxNDFDNy40ODMyMSA2Ljg1MzM4IDguMjAzODYgOC40MjUwNiA5LjM4OTQgOS42MTA2QzEwLjU3NDkgMTAuNzk2MSAxMi4xNDY2IDExLjUxNjggMTMuODE4NiAxMS42NDE1QzE1LjQ5MDYgMTEuNzY2MiAxNy4xNTE3IDExLjI4NjYgMTguNSAxMC4yOVYxMC4yOVoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo=');
  153. }
  154. input[type='checkbox']:checked:hover + .toggle::after {
  155. transform: translateX(2.1rem) scale(1.075);
  156. }
  157. .card {
  158. background-color: #fff;
  159. border-radius: 6px;
  160. border-width: 0;
  161. box-shadow: rgba(155, 155, 155, 0.45) 0 0 30px -5px;
  162. font-size: 1.1rem;
  163. height: 100%;
  164. line-height: 1.8rem;
  165. padding: 1.5rem 2rem;
  166. width: 100%;
  167. margin-bottom: 1.9rem;
  168. }
  169. .dark .card {
  170. background-color: #333333;
  171. box-shadow: none;
  172. }
  173. .card h1,
  174. .card h2,
  175. .card h3,
  176. .card h4,
  177. .card h5,
  178. .card h6 {
  179. color: #4a4a4a;
  180. }
  181. .dark .card h1,
  182. .dark .card h2,
  183. .dark .card h3,
  184. .dark .card h4,
  185. .dark .card h5,
  186. .dark .card h6 {
  187. color: #e2e2e2;
  188. }
  189. .card-header h2 {
  190. display: inline-block;
  191. }
  192. .card .cat-score {
  193. margin-left: 20px;
  194. font-size: smaller;
  195. }
  196. .card h3 {
  197. font-size: 1.2rem;
  198. font-weight: 700;
  199. line-height: 1.8em;
  200. margin: 0;
  201. padding: 0;
  202. }
  203. .card p,
  204. .card label,
  205. .card legend {
  206. color: #7a869c;
  207. border-width: 0;
  208. display: block;
  209. font-size: 1.1rem;
  210. font-weight: 300;
  211. line-height: 1.8em;
  212. margin: 0;
  213. padding: 0;
  214. }
  215. .card legend {
  216. display: flex;
  217. justify-content: flex-start;
  218. align-items: center;
  219. }
  220. .card legend .score {
  221. font-size: smaller;
  222. margin-left: 20px;
  223. font-weight: 100;
  224. min-width: 5%;
  225. }
  226. .dark .card p,
  227. .dark .card label,
  228. .dark .card legend {
  229. color: #e2e2e2;
  230. }
  231. .card label {
  232. display: inline-block;
  233. }
  234. .card input[type='radio'] + label::before {
  235. content: '';
  236. height: 0.9rem;
  237. width: 0.9rem;
  238. margin-right: 0.7rem;
  239. border-radius: 50%;
  240. border: 1px solid rgb(74, 74, 74);
  241. background-color: #ffffff;
  242. display: inline-block;
  243. cursor: pointer;
  244. position: relative;
  245. top: 0.09rem;
  246. }
  247. .dark .card input[type='radio'] + label::before {
  248. border: 1px solid #e2e2e2;
  249. background-color: inherit;
  250. }
  251. .card input[type='radio']:checked + label::before {
  252. background-color: rgb(47, 106, 189);
  253. border-color: rgb(47, 106, 189);
  254. }
  255. .dark .card input[type='radio']:checked + label::before {
  256. background-color: #d9d9d9;
  257. border-color: #d9d9d9;
  258. }
  259. .card input[type='radio']:checked + label {
  260. font-weight: bold;
  261. color: #4a4a4a;
  262. }
  263. .dark input[type='radio']:checked + label {
  264. color: #e2e2e2;
  265. }
  266. .card input[type='radio']:focus + label::before {
  267. outline: rgb(59, 153, 252) auto 5px;
  268. }
  269. .card legend {
  270. margin-bottom: 0.4rem;
  271. }
  272. .totals {
  273. font-size: 1.6rem;
  274. }
  275. .totals + h2 {
  276. font-size: 1.9rem;
  277. margin-top: 0;
  278. }
  279. .grade {
  280. font-size: 1.9rem;
  281. }
  282. button {
  283. background-color: #fff;
  284. border: 1px solid #4a4a4a;
  285. border-radius: 6px;
  286. box-shadow: rgba(155, 155, 155, 0.5) 1px 2px 3px 0;
  287. color: #4a4a4a;
  288. cursor: pointer;
  289. display: inline-block;
  290. font-size: 1rem;
  291. font-weight: 500;
  292. letter-spacing: 0.04em;
  293. line-height: 1.8em;
  294. margin: 0.75rem 1.1rem 1.1rem 0;
  295. outline: none;
  296. padding: 0.5rem 1.4rem;
  297. text-transform: uppercase;
  298. transition-delay: 0s;
  299. transition-duration: 0.25s;
  300. transition-property: all;
  301. transition-timing-function: ease-out;
  302. width: fit-content;
  303. }
  304. .dark button {
  305. background: #d9d9d9;
  306. color: #121212;
  307. box-shadow: none;
  308. }
  309. button:hover {
  310. border-color: #dbdbdb;
  311. color: #dbdbdb;
  312. }
  313. .dark button:hover {
  314. color: #121212;
  315. }
  316. button.copy {
  317. margin-left: 0.4rem;
  318. font-size: 0.8rem;
  319. }
  320. button:focus {
  321. border-color: rgb(56, 56, 56);
  322. box-shadow: rgb(219, 219, 219) 0px 0px 0px 3px;
  323. color: rgb(56, 56, 56);
  324. }
  325. div[role='alert'] {
  326. color: #4a4a4a;
  327. font-size: 1.2rem;
  328. margin-bottom: 1.2rem;
  329. }
  330. .dark div[role='alert'] {
  331. color: #e2e2e2;
  332. }
  333. .summary {
  334. font-size: 1.2rem;
  335. border: none;
  336. font-family: monospace;
  337. background-color: #d5d9de;
  338. padding: 0.9rem;
  339. border-radius: 6px;
  340. line-height: 1.5;
  341. width: 100%;
  342. }
  343. .summary h2,
  344. .dark .summary h2 {
  345. font-size: 1.2rem;
  346. font-family: 'Inter', sans-serif;
  347. margin-top: 35px;
  348. margin-bottom: 5px;
  349. }
  350. .summary h2:first-of-type,
  351. .dark .summary h2:first-of-type {
  352. margin-top: 15px;
  353. }
  354. .dark .summary {
  355. background: #6b6a6a;
  356. color: #e2e2e2;
  357. }
  358. .summary pre,
  359. .dark .summary pre {
  360. white-space: pre-wrap;
  361. border-radius: 5px;
  362. padding: 15px;
  363. border: solid 2px rgba(0, 0, 0, 0.4);
  364. }
  365. .summary pre:empty {
  366. display: none;
  367. }
  368. .summary pre:empty + button {
  369. display: none;
  370. }
  371. .d-none {
  372. display: none;
  373. }
  374. @media (max-width: 450px) {
  375. .btn-container {
  376. text-align: center;
  377. }
  378. button {
  379. width: 100%;
  380. margin: 0.5rem;
  381. }
  382. input[type='checkbox']:checked + .toggle::after {
  383. transform: translateX(1.3rem);
  384. background-size: 50%;
  385. }
  386. input[type='checkbox']:checked:hover + .toggle::after {
  387. transform: translateX(1.3rem) scale(1.1);
  388. background-size: 50%;
  389. }
  390. }
  391. @media (max-width: 515px) {
  392. input[type='checkbox']:checked + .toggle::after {
  393. transform: translateX(1.7rem);
  394. }
  395. input[type='checkbox']:checked:hover + .toggle::after {
  396. transform: translateX(1.7rem) scale(1.1);
  397. }
  398. }
  399. @media (max-width: 460px) {
  400. input[type='checkbox']:checked + .toggle::after {
  401. transform: translateX(1.4rem);
  402. }
  403. input[type='checkbox']:checked:hover + .toggle::after {
  404. transform: translateX(1.4rem) scale(1.1);
  405. }
  406. }
  407. @media (max-width: 400px) {
  408. #app h1 {
  409. font-size: 1.6rem;
  410. }
  411. input[type='checkbox']:checked + .toggle::after {
  412. transform: translateX(1.3rem);
  413. }
  414. input[type='checkbox']:checked:hover + .toggle::after {
  415. transform: translateX(1.3rem) scale(1.1);
  416. }
  417. }
  418. @media (max-width: 340px) {
  419. input[type='checkbox']:checked + .toggle::after {
  420. transform: translateX(0.9rem);
  421. }
  422. input[type='checkbox']:checked:hover + .toggle::after {
  423. transform: translateX(0.9rem) scale(1.075);
  424. }
  425. }
  426. </style>
  427. <script>
  428. $(function () {
  429. let $select2 = $('.select2').select2({
  430. containerCssClass: 'wrap',
  431. });
  432. function triggerEvent(name, val) {
  433. let selected = $("select[name='" + name + "']");
  434. let change = new Event('change', { bubbles: true });
  435. selected[0].dispatchEvent(change);
  436. }
  437. $('.select2').on('select2:select', function (e) {
  438. triggerEvent(e.target.name, e.target.value);
  439. });
  440. });
  441. </script>
  442. </head>
  443. <body>
  444. <div id="app"></div>
  445. <script>
  446. (function (window) {
  447. 'use strict';
  448. function Model() {
  449. this.title = `Module 18 NoSQL Challenge Rubric (Coding)`;
  450. this.categories = [
  451. {
  452. title: 'Deliverables',
  453. subtitle: null,
  454. score: 0,
  455. questions: [
  456. {
  457. title:
  458. 'Student submitted GitHub Repo containing application code',
  459. score: 10,
  460. type: 'true false',
  461. message: 'GitHub repo is empty',
  462. status: false,
  463. },
  464. ],
  465. },
  466. {
  467. title: 'Walkthrough Video',
  468. subtitle: null,
  469. score: 0,
  470. questions: [
  471. {
  472. title: 'Student includes link to walkthrough video in README',
  473. score: 5,
  474. type: 'true false',
  475. message:
  476. 'Student does not include link to walkthrough video in README',
  477. status: false,
  478. },
  479. {
  480. title:
  481. 'Walkthrough video shows all of the technical acceptance criteria being met',
  482. score: 5,
  483. type: 'true false',
  484. message:
  485. "Walkthrough video doesn't show all of the technical acceptance criteria being met",
  486. status: false,
  487. },
  488. {
  489. title:
  490. 'Walkthrough video demonstrates how to start the server',
  491. score: 2,
  492. type: 'true false',
  493. message:
  494. 'Walkthrough video does not demonstrate how to start the server',
  495. status: false,
  496. },
  497. {
  498. title:
  499. 'Walkthrough video demonstrates GET routes for all users and all thoughts being tested in Insomnia',
  500. score: 5,
  501. type: 'likert',
  502. options: [
  503. {
  504. message:
  505. 'Walkthrough video does not demonstrate GET routes for all users and all thoughts being tested in Insomnia',
  506. score: 0,
  507. },
  508. {
  509. message:
  510. 'Walkthrough video demonstrates GET routes for 1 of the 2 following being tested in Insomnia: all users or all thoughts',
  511. score: 2,
  512. },
  513. {
  514. message:
  515. 'Walkthrough video demonstrates GET routes for all users and all thoughts being tested in Insomnia',
  516. score: 5,
  517. },
  518. ],
  519. message: '',
  520. status: false,
  521. },
  522. {
  523. title:
  524. 'Walkthrough video demonstrates GET routes for a single user and a single thought being tested in Insomnia',
  525. score: 5,
  526. type: 'likert',
  527. options: [
  528. {
  529. message:
  530. 'Walkthrough video does not demonstrate GET routes for a single user and a single thought being tested in Insomnia',
  531. score: 0,
  532. },
  533. {
  534. message:
  535. 'Walkthrough video demonstrates GET routes for 1 of the 2 following being tested in Insomnia: a single user or a single thought',
  536. score: 2,
  537. },
  538. {
  539. message:
  540. 'Walkthrough video demonstrates GET routes for a single user and a single thought being tested in Insomnia',
  541. score: 5,
  542. },
  543. ],
  544. message: '',
  545. status: false,
  546. },
  547. {
  548. title:
  549. 'Walkthrough video demonstrates POST, PUT, and DELETE routes for users and thoughts being tested in Insomnia',
  550. score: 5,
  551. type: 'likert',
  552. options: [
  553. {
  554. message:
  555. 'Walkthrough video does not demonstrate POST, PUT, and DELETE routes for users and thoughts being tested in Insomnia',
  556. score: 0,
  557. },
  558. {
  559. message:
  560. 'Walkthrough video demonstrates POST, PUT, and DELETE routes for 1 of the 2 following being tested in Insomnia: users or thoughts',
  561. score: 2,
  562. },
  563. {
  564. message:
  565. 'Walkthrough video demonstrates POST, PUT, and DELETE routes for users and thoughts being tested in Insomnia',
  566. score: 5,
  567. },
  568. ],
  569. message: '',
  570. status: false,
  571. },
  572. {
  573. title:
  574. 'Walkthrough video demonstrates POST and DELETE routes for a user’s friend list being tested in Insomnia',
  575. score: 5,
  576. type: 'likert',
  577. options: [
  578. {
  579. message:
  580. 'Walkthrough video does not demonstrate POST and DELETE routes for a user’s friend list being tested in Insomnia',
  581. score: 0,
  582. },
  583. {
  584. message:
  585. 'Walkthrough video demonstrates 1 of the 2 following being tested in Insomnia: POST or DELETE routes for a user’s friend list',
  586. score: 2,
  587. },
  588. {
  589. message:
  590. 'Walkthrough video demonstrates POST and DELETE routes for a user’s friend list being tested in Insomnia',
  591. score: 5,
  592. },
  593. ],
  594. message: '',
  595. status: false,
  596. },
  597. {
  598. title:
  599. 'Walkthrough video demonstrates POST and DELETE routes for reactions to thoughts being tested in Insomnia',
  600. score: 5,
  601. type: 'likert',
  602. options: [
  603. {
  604. message:
  605. 'Walkthrough video does not demonstrate POST and DELETE routes for reactions to thoughts being tested in Insomnia',
  606. score: 0,
  607. },
  608. {
  609. message:
  610. 'Walkthrough video demonstrates 1 of the 2 following being tested in Insomnia: POST or DELETE routes for reactions to thoughts',
  611. score: 2,
  612. },
  613. {
  614. message:
  615. 'Walkthrough video demonstrates POST and DELETE routes for reactions to thoughts being tested in Insomnia',
  616. score: 5,
  617. },
  618. ],
  619. message: '',
  620. status: false,
  621. },
  622. ],
  623. },
  624. {
  625. title: 'Technical Acceptance Criteria',
  626. subtitle:
  627. 'Watch out for errors in the console from this point forward.',
  628. score: 0,
  629. questions: [
  630. {
  631. title:
  632. 'Application includes User and Thought models that match Challenge instructions',
  633. score: 5,
  634. type: 'likert',
  635. options: [
  636. {
  637. message:
  638. "Application doesn't include User and Thought models that match Challenge instructions",
  639. score: 0,
  640. },
  641. {
  642. message:
  643. 'Application includes 1 of the 2 following: User or Thought models that match Challenge instructions',
  644. score: 2,
  645. },
  646. {
  647. message:
  648. 'Application includes User and Thought models that match Challenge instructions',
  649. score: 5,
  650. },
  651. ],
  652. message: '',
  653. status: false,
  654. },
  655. {
  656. title:
  657. 'Application includes schema settings for User and Thought models as outlined in the Challenge instructions',
  658. score: 5,
  659. type: 'likert',
  660. options: [
  661. {
  662. message:
  663. "Application doesn't include schema settings for User and Thought models as outlined in the Challenge instructions",
  664. score: 0,
  665. },
  666. {
  667. message:
  668. 'Application includes schema settings as outlined in the Challenge instructions for 1 of the 2 following: User or Thought models',
  669. score: 2,
  670. },
  671. {
  672. message:
  673. 'Application includes schema settings for User and Thought models as outlined in the Challenge instructions',
  674. score: 5,
  675. },
  676. ],
  677. message: '',
  678. status: false,
  679. },
  680. {
  681. title:
  682. "Application includes Reactions as the reaction field's subdocument schema in the Thought model",
  683. score: 5,
  684. type: 'true false',
  685. message:
  686. "Application doesn't include Reactions as the reaction field's subdocument schema in the Thought model",
  687. status: false,
  688. },
  689. {
  690. title:
  691. 'Application includes GET routes that return all users and all thoughts',
  692. score: 5,
  693. type: 'likert',
  694. options: [
  695. {
  696. message:
  697. "Application doesn't include GET routes that return all users and all thoughts",
  698. score: 0,
  699. },
  700. {
  701. message:
  702. 'Application includes GET routes that return 1 of the 2 following: all users or all thoughts',
  703. score: 2,
  704. },
  705. {
  706. message:
  707. 'Application includes GET routes that return all users and all thoughts',
  708. score: 5,
  709. },
  710. ],
  711. message: '',
  712. status: false,
  713. },
  714. {
  715. title:
  716. 'Application includes GET routes that return a single user and a single thought',
  717. score: 5,
  718. type: 'likert',
  719. options: [
  720. {
  721. message:
  722. "Application doesn't include GET routes that return a single user and a single thought",
  723. score: 0,
  724. },
  725. {
  726. message:
  727. 'Application includes GET routes that return 1 of the 2 following: a single user or a single thought',
  728. score: 2,
  729. },
  730. {
  731. message:
  732. 'Application includes GET routes that return a single user and a single thought',
  733. score: 5,
  734. },
  735. ],
  736. message: '',
  737. status: false,
  738. },
  739. {
  740. title:
  741. "Application includes POST routes that can create a new user, a new thought, a reaction to a thought, and add a friend to a user's friend list",
  742. score: 5,
  743. type: 'likert',
  744. options: [
  745. {
  746. message:
  747. "Application doesn't include POST routes that can create a new user, a new thought, a reaction to a thought, or add a friend to a user's friend list",
  748. score: 0,
  749. },
  750. {
  751. message:
  752. "Application includes POST routes that can do 1 of the 4 following: create a new user, create a new thought, create a reaction to a thought, or add a friend to a user's friend list",
  753. score: 2,
  754. },
  755. {
  756. message:
  757. "Application includes POST routes that can do 2 of the 4 following: create a new user, create a new thought, create a reaction to a thought, or add a friend to a user's friend list",
  758. score: 3,
  759. },
  760. {
  761. message:
  762. "Application includes POST routes that can do 3 of the 4 following: create a new user, create a new thought, create a reaction to a thought, or add a friend to a user's friend list",
  763. score: 4,
  764. },
  765. {
  766. message:
  767. "Application includes POST routes that can create a new user, a new thought, a reaction to a thought, and add a friend to a user's friend list",
  768. score: 5,
  769. },
  770. ],
  771. message: '',
  772. status: false,
  773. },
  774. {
  775. title:
  776. 'Application includes PUT routes that can update a user or a thought',
  777. score: 5,
  778. type: 'likert',
  779. options: [
  780. {
  781. message:
  782. "Application doesn't include PUT routes that can update a user or a thought",
  783. score: 0,
  784. },
  785. {
  786. message:
  787. 'Application includes PUT routes that can update 1 of the 2 following: a user or a thought',
  788. score: 2,
  789. },
  790. {
  791. message:
  792. 'Application includes PUT routes that can update a user or a thought',
  793. score: 5,
  794. },
  795. ],
  796. message: '',
  797. status: false,
  798. },
  799. {
  800. title:
  801. "Application includes DELETE routes that can delete a user, a thought, a reaction to a thought, and remove a friend from a user's friend list",
  802. score: 5,
  803. type: 'likert',
  804. options: [
  805. {
  806. message:
  807. "Application doesn't include DELETE routes that can delete a user, a thought, a reaction to a thought, or a friend from a user's friend list",
  808. score: 0,
  809. },
  810. {
  811. message:
  812. "Application includes DELETE routes that can do 1 of the 4 following: delete a user, delete a thought, delete a reaction to a thought, or remove a friend from a user's friend list",
  813. score: 2,
  814. },
  815. {
  816. message:
  817. "Application includes DELETE routes that can do 2 of the 4 following: delete a user, delete a thought, delete a reaction to a thought, or remove a friend from a user's friend list",
  818. score: 3,
  819. },
  820. {
  821. message:
  822. "Application includes DELETE routes that can do 3 of the 4 following: delete a user, delete a thought, delete a reaction to a thought, or remove a friend from a user's friend list",
  823. score: 4,
  824. },
  825. {
  826. message:
  827. "Application includes DELETE routes that can delete a user, a thought, a reaction to a thought, and remove a friend from a user's friend list",
  828. score: 5,
  829. },
  830. ],
  831. message: '',
  832. status: false,
  833. },
  834. ],
  835. },
  836. {
  837. title: 'Repository Quality',
  838. subtitle: null,
  839. score: 0,
  840. questions: [
  841. {
  842. title: 'Repository has a unique name',
  843. score: 2,
  844. type: 'true false',
  845. message: "Repo doesn't have a unique name",
  846. status: false,
  847. },
  848. {
  849. title:
  850. 'Repository follows best practices for file structure and naming conventions',
  851. score: 2,
  852. type: 'true false',
  853. message:
  854. "Code doesn't follow recommended file/folder structure",
  855. status: false,
  856. },
  857. {
  858. title:
  859. 'Repository follows best practices for variable and function naming conventions, indentation, quality comments, etc.',
  860. score: 2,
  861. type: 'true false',
  862. message:
  863. "Code doesn't follow good practices for variable names, indentation, lacks quality comments",
  864. status: false,
  865. },
  866. {
  867. title:
  868. 'Repository contains multiple descriptive commit messages',
  869. score: 2,
  870. type: 'true false',
  871. message:
  872. "Repo doesn't contain multiple descriptive commit messages",
  873. status: false,
  874. },
  875. {
  876. title:
  877. 'Repository contains quality README with description and a link to walkthrough video',
  878. score: 5,
  879. type: 'likert',
  880. options: [
  881. {
  882. message:
  883. "Repo doesn't contain a quality README with description and a link to walkthrough video",
  884. score: 0,
  885. },
  886. {
  887. message:
  888. 'Repository README is missing either the description or the link to the walkthrough video',
  889. score: 2,
  890. },
  891. {
  892. message:
  893. 'Repository contains quality README with description and a link to walkthrough video',
  894. score: 5,
  895. },
  896. ],
  897. message: '',
  898. status: false,
  899. },
  900. ],
  901. },
  902. {
  903. title: 'Bonus',
  904. subtitle: null,
  905. score: 0,
  906. questions: [
  907. {
  908. title:
  909. "Application removes a user's associated thoughts when the user is deleted",
  910. score: 10,
  911. type: 'true false',
  912. message:
  913. "Application removes a user's associated thoughts when the user is deleted",
  914. status: false,
  915. },
  916. ],
  917. },
  918. {
  919. title: 'Academic Integrity',
  920. subtitle:
  921. 'If any of of the following are true, partner with your instructor to investigate plagiarism. Contact your SSM if you believe plagiarism has occurred.',
  922. score: 0,
  923. questions: [
  924. {
  925. title: 'Application contains a low number of commits',
  926. score: 0,
  927. type: 'true false',
  928. message: null,
  929. status: false,
  930. },
  931. {
  932. title:
  933. 'Application codebase appears advanced for the student, at this point in the course, or in general',
  934. score: 0,
  935. type: 'true false',
  936. message: null,
  937. status: false,
  938. },
  939. {
  940. title:
  941. 'Application package.json file references a different author and/or repository',
  942. score: 0,
  943. type: 'true false',
  944. message: null,
  945. status: false,
  946. },
  947. {
  948. title:
  949. 'Application package.json file references much older versions of npm packages',
  950. score: 0,
  951. type: 'true false',
  952. message: null,
  953. status: false,
  954. },
  955. ],
  956. },
  957. ];
  958. this.initStorage();
  959. }
  960. Model.prototype.initStorage = function () {
  961. this.score = 0;
  962. this.questions = [];
  963. this.messages = new Set();
  964. this.flagged = new Set();
  965. this.isDarkMode =
  966. JSON.parse(localStorage.getItem('isDarkMode')) || false;
  967. this.categories.forEach((category) => {
  968. category.score = 0;
  969. category.questions.forEach((question) => {
  970. question.category = category.title;
  971. question.status = false;
  972. question.id = this.questions.length;
  973. question.flagged = category.title === 'Academic Integrity';
  974. question.bonus = category.title === 'Bonus';
  975. if (question.type === 'likert') {
  976. question.message = question.options[0].message
  977. .split(' - ')
  978. .pop();
  979. }
  980. let messageObj = {
  981. message: question.message,
  982. category: question.category,
  983. };
  984. question.message &&
  985. !question.bonus &&
  986. this.messages.add(messageObj);
  987. this.questions.push(question);
  988. category.score += question.score;
  989. });
  990. });
  991. };
  992. Model.prototype.toggleDarkMode = function () {
  993. this.isDarkMode = !this.isDarkMode;
  994. localStorage.setItem('isDarkMode', this.isDarkMode);
  995. };
  996. Model.prototype.toggleRadio = function (radio) {
  997. const id = Number(radio.getAttribute('name'));
  998. const question = this.questions[id];
  999. const questionScore = document.querySelector(
  1000. "span[data-id='" + id + "']"
  1001. );
  1002. const category = question.category;
  1003. const categoryScore = document.querySelector(
  1004. "span[data-cat='" + category + "']"
  1005. );
  1006. const resultsCategoryScore = document.querySelector(
  1007. "span[data-res-cat='" + category + "']"
  1008. );
  1009. question.status = !question.status;
  1010. if (question.status === true) {
  1011. if (!question.bonus) {
  1012. this.messages.forEach((message) => {
  1013. if (message.message === question.message) {
  1014. this.messages.delete(message);
  1015. }
  1016. });
  1017. } else {
  1018. let messageObj = {
  1019. message: question.message,
  1020. category: category,
  1021. };
  1022. this.messages.add(messageObj);
  1023. }
  1024. this.score += question.score;
  1025. if (question.flagged) {
  1026. this.flagged.add(question.id);
  1027. }
  1028. } else {
  1029. if (question.flagged) {
  1030. this.flagged.delete(question.id);
  1031. }
  1032. if (!question.bonus) {
  1033. if (question.message) {
  1034. let messageObj = {
  1035. message: question.message,
  1036. category: category,
  1037. };
  1038. this.messages.add(messageObj);
  1039. }
  1040. } else {
  1041. this.messages.forEach((message) => {
  1042. if (message.message === question.message) {
  1043. this.messages.delete(message);
  1044. }
  1045. });
  1046. }
  1047. this.score -= question.score;
  1048. }
  1049. if (category !== 'Academic Integrity') {
  1050. if (question.status) {
  1051. questionScore.textContent = question.score;
  1052. } else {
  1053. questionScore.textContent = 0;
  1054. }
  1055. const catQuestions = this.categories.filter(
  1056. (cat) => cat.title === category
  1057. )[0].questions;
  1058. let categoryTotal = 0;
  1059. catQuestions.forEach((question) => {
  1060. if (question.type === 'true false') {
  1061. if (question.status) {
  1062. categoryTotal += question.score;
  1063. }
  1064. } else {
  1065. let score = document.querySelector(
  1066. "select[name='" + question.id + "']"
  1067. ).value;
  1068. categoryTotal += parseInt(score);
  1069. }
  1070. });
  1071. categoryScore.textContent = categoryTotal;
  1072. resultsCategoryScore.textContent = categoryTotal;
  1073. }
  1074. };
  1075. Model.prototype.handleSelect = function (select) {
  1076. const id = Number(select.getAttribute('name'));
  1077. const question = this.questions[id];
  1078. const questionScore = document.querySelector(
  1079. "span[data-id='" + id + "']"
  1080. );
  1081. const oldScore = questionScore.textContent;
  1082. const category = question.category;
  1083. const categoryScore = document.querySelector(
  1084. "span[data-cat='" + category + "']"
  1085. );
  1086. const resultsCategoryScore = document.querySelector(
  1087. "span[data-res-cat='" + category + "']"
  1088. );
  1089. let newMessage = select.selectedOptions[0].text.split(' - ').pop();
  1090. if (newMessage === 'Open this menu') {
  1091. newMessage = select[1].text.split(' - ').pop();
  1092. }
  1093. if (question.type === 'likert') {
  1094. this.messages.forEach((item) => {
  1095. if (item.message === question.message) {
  1096. this.messages.delete(item);
  1097. }
  1098. });
  1099. question.message = newMessage;
  1100. let messageObj = {
  1101. message: newMessage,
  1102. category: category,
  1103. };
  1104. this.messages.add(messageObj);
  1105. }
  1106. this.score -= parseInt(oldScore);
  1107. this.score += parseInt(select.value);
  1108. questionScore.textContent = select.value;
  1109. const catQuestions = this.categories.filter(
  1110. (cat) => cat.title === category
  1111. )[0].questions;
  1112. let categoryTotal = 0;
  1113. catQuestions.forEach((question) => {
  1114. if (question.type === 'true false') {
  1115. if (question.status) {
  1116. categoryTotal += question.score;
  1117. }
  1118. } else {
  1119. let score = document.querySelector(
  1120. "select[name='" + question.id + "']"
  1121. ).value;
  1122. categoryTotal += parseInt(score);
  1123. }
  1124. });
  1125. categoryScore.textContent = categoryTotal;
  1126. resultsCategoryScore.textContent = categoryTotal;
  1127. };
  1128. Model.prototype.calcGrade = function () {
  1129. const roundedScore = Math.min(100, Math.ceil(this.score));
  1130. let letterGrade = '';
  1131. if (roundedScore >= 97) {
  1132. letterGrade = 'A+';
  1133. } else if (roundedScore >= 93 && roundedScore <= 96) {
  1134. letterGrade = 'A';
  1135. } else if (roundedScore >= 90 && roundedScore <= 92) {
  1136. letterGrade = 'A-';
  1137. } else if (roundedScore >= 87 && roundedScore <= 89) {
  1138. letterGrade = 'B+';
  1139. } else if (roundedScore >= 83 && roundedScore <= 86) {
  1140. letterGrade = 'B';
  1141. } else if (roundedScore >= 80 && roundedScore <= 82) {
  1142. letterGrade = 'B-';
  1143. } else if (roundedScore >= 77 && roundedScore <= 79) {
  1144. letterGrade = 'C+';
  1145. } else if (roundedScore >= 73 && roundedScore <= 76) {
  1146. letterGrade = 'C';
  1147. } else if (roundedScore >= 70 && roundedScore <= 72) {
  1148. letterGrade = 'C-';
  1149. } else if (roundedScore >= 67 && roundedScore <= 69) {
  1150. letterGrade = 'D+';
  1151. } else if (roundedScore >= 63 && roundedScore <= 66) {
  1152. letterGrade = 'D';
  1153. } else if (roundedScore >= 60 && roundedScore <= 62) {
  1154. letterGrade = 'D-';
  1155. } else {
  1156. letterGrade = 'F';
  1157. }
  1158. return letterGrade;
  1159. };
  1160. Model.prototype.hasFlags = function () {
  1161. return this.flagged.size > 0;
  1162. };
  1163. function View(model) {
  1164. this.model = model;
  1165. this.generateHTML();
  1166. this.cacheDom();
  1167. }
  1168. View.prototype.cacheDom = function () {
  1169. this.darkModeToggle = document.querySelector('#dark-mode');
  1170. this.radios = Array.from(
  1171. document.querySelectorAll("input[type='radio']")
  1172. );
  1173. this.selects = Array.from(document.querySelectorAll('select'));
  1174. this.totals = document.querySelector('.totals');
  1175. this.grade = document.querySelector('.grade');
  1176. this.alert = document.querySelector("div[role='alert']");
  1177. this.summaryHeading = document.querySelector('.summary-heading');
  1178. this.summary = document.querySelector('.summary');
  1179. this.model.categories
  1180. .filter((category) => category.title !== 'Academic Integrity')
  1181. .map((category) => {
  1182. let summary = category.title.replace(/\s+/g, '-').toLowerCase();
  1183. let summaryName = summary + '-summary';
  1184. return (this[summaryName] = document.querySelector(
  1185. '.' + summary
  1186. ));
  1187. });
  1188. this.resetButton = document.querySelector('.reset');
  1189. this.model.categories
  1190. .filter((category) => category.title !== 'Academic Integrity')
  1191. .map((category) => {
  1192. let button = category.title.replace(/\s+/g, '-').toLowerCase();
  1193. let buttonName = 'copyButton-' + button;
  1194. return (this[buttonName] = document.querySelector(
  1195. '.copy-' + button
  1196. ));
  1197. });
  1198. };
  1199. View.prototype.createFieldset = function ({
  1200. title,
  1201. id,
  1202. score,
  1203. status,
  1204. category,
  1205. type,
  1206. options,
  1207. }) {
  1208. return `<fieldset class="input-group">
  1209. <legend>
  1210. <span class="title">${title}</span> ${
  1211. category === 'Academic Integrity'
  1212. ? ''
  1213. : "<span class='score'><span data-id='" +
  1214. id +
  1215. "' class='current-score'>0</span> / " +
  1216. score +
  1217. '</span>'
  1218. }
  1219. </legend>
  1220. ${
  1221. type === 'true false'
  1222. ? `<div class="radio-group">
  1223. <input type="radio" name="${id}" id="${id}-true" value="true">
  1224. <label for="${id}-true">True</label>
  1225. </div>
  1226. <div class="radio-group">
  1227. <input type="radio" name="${id}" id="${id}-false" value="false" checked>
  1228. <label for="${id}-false">False</label>
  1229. </div>`
  1230. : `<div class="select-group">
  1231. <select name="${id}" class="select-lg select2 narrow wrap">
  1232. <option value="0" selected>Open this menu</option>
  1233. ${options.map(
  1234. (option) =>
  1235. `<option value="${option.score}">${option.score} - ${option.message}</option>`
  1236. )}
  1237. </select>
  1238. </div>`
  1239. }
  1240. </fieldset>`;
  1241. };
  1242. View.prototype.createCard = function ({
  1243. title,
  1244. subtitle,
  1245. questions,
  1246. score,
  1247. }) {
  1248. return `<div class="card">
  1249. <div class="card-header"><h2>${title}</h2> ${
  1250. title !== 'Academic Integrity'
  1251. ? "<span class='cat-score'><span data-cat='" +
  1252. title +
  1253. "'>0</span> / " +
  1254. score +
  1255. '</span>'
  1256. : ''
  1257. }</div>
  1258. ${subtitle ? `<h3>${subtitle}</h3>` : ''}
  1259. ${questions.map((child) => this.createFieldset(child)).join('')}
  1260. </div>`;
  1261. };
  1262. View.prototype.createResults = function () {
  1263. return `<div class="card">
  1264. <h2>Recommended Grade: <span class="grade">F</span></h2>
  1265. <h2 class="totals">Total: (0/100)</h2>
  1266. <div class="d-none" role="alert">
  1267. You've selected <strong>True</strong> for one of more Academic
  1268. Integrity prompts and are advised to investigate plagiarism before
  1269. issuing a grade.
  1270. </div>
  1271. <div class="summary" aria-label="summary">
  1272. ${this.model.categories
  1273. .filter((category) => category.title !== 'Academic Integrity')
  1274. .map((category) => {
  1275. let score = category.score;
  1276. let title = category.title;
  1277. let catClass = title.replace(/\s+/g, '-').toLowerCase();
  1278. return (
  1279. '<h2>' +
  1280. title +
  1281. "<span class='cat-score'><span data-res-cat='" +
  1282. title +
  1283. "'>0</span> / " +
  1284. score +
  1285. "</span></h2><pre class='" +
  1286. catClass +
  1287. "'>" +
  1288. [...this.model.messages]
  1289. .filter((messageObj) => messageObj.category === category.title)
  1290. .map((messageObj) => `* ${messageObj.message}\n`)
  1291. .join('') +
  1292. "</pre><button class='copy copy-" +
  1293. catClass +
  1294. "'>Copy To Clipboard</button>"
  1295. );
  1296. })
  1297. .join('')}
  1298. </div>
  1299. <div class="btn-container">
  1300. <button class="reset">Reset Form</button>
  1301. </div>
  1302. </div>`;
  1303. };
  1304. View.prototype.createHeader = function (title, isDarkMode = false) {
  1305. return `<header>
  1306. <h1>${title}</h1>
  1307. <div class="switch-group">
  1308. <input type="checkbox" name="dark-mode" id="dark-mode" ${
  1309. isDarkMode ? 'checked' : ''
  1310. }>
  1311. <label aria-label="dark mode" for="dark-mode" class="toggle">
  1312. </label>
  1313. </div>
  1314. </header>`;
  1315. };
  1316. View.prototype.generateHTML = function () {
  1317. this.wrapper = document.querySelector('#app');
  1318. if (this.model.isDarkMode) {
  1319. this.wrapper.classList.add('dark');
  1320. }
  1321. const survey = this.model.categories.reduce((final, current) => {
  1322. final += this.createCard(current);
  1323. return final;
  1324. }, '');
  1325. const results = this.createResults();
  1326. const header = this.createHeader(
  1327. this.model.title,
  1328. this.model.isDarkMode
  1329. );
  1330. this.wrapper.innerHTML = header + survey + results;
  1331. };
  1332. View.prototype.update = function () {
  1333. const roundedScore = Math.min(100, Math.ceil(this.model.score));
  1334. this.totals.textContent = `Total: (${roundedScore}/ 100)`;
  1335. const letterGrade = this.model.calcGrade();
  1336. this.grade.textContent = letterGrade;
  1337. if (this.model.hasFlags()) {
  1338. this.alert.classList.remove('d-none');
  1339. } else {
  1340. this.alert.classList.add('d-none');
  1341. }
  1342. if (this.model.isDarkMode) {
  1343. this.wrapper.classList.add('dark');
  1344. } else {
  1345. this.wrapper.classList.remove('dark');
  1346. }
  1347. this.model.categories
  1348. .filter((category) => category.title !== 'Academic Integrity')
  1349. .forEach((category) => {
  1350. let catClass = category.title.replace(/\s+/g, '-').toLowerCase();
  1351. this[catClass + '-summary'].innerHTML = [...this.model.messages]
  1352. .filter((messageObj) => messageObj.category === category.title)
  1353. .map((messageObj) => `* ${messageObj.message}\n`)
  1354. .join('');
  1355. });
  1356. };
  1357. function Controller(model, view) {
  1358. this.model = model;
  1359. this.view = view;
  1360. this.addEventListeners();
  1361. }
  1362. Controller.prototype.addEventListeners = function () {
  1363. this.view.wrapper.addEventListener('change', (event) => {
  1364. const { target } = event;
  1365. if (target.name !== 'dark-mode') {
  1366. if (!target.matches("input[type='radio']")) {
  1367. this.model.handleSelect(target);
  1368. } else {
  1369. this.model.toggleRadio(target);
  1370. }
  1371. }
  1372. this.view.update();
  1373. });
  1374. this.view.resetButton.addEventListener('click', () => {
  1375. this.model.initStorage();
  1376. this.view.radios.forEach(
  1377. (radio) => (radio.checked = radio.hasAttribute('checked'))
  1378. );
  1379. this.view.selects.forEach(
  1380. (select) => (select.selectedIndex = null)
  1381. );
  1382. this.model.questions
  1383. .filter((question) => question.category !== 'Academic Integrity')
  1384. .forEach((question) => {
  1385. const id = question.id;
  1386. const questionScore = document.querySelector(
  1387. "span[data-id='" + id + "']"
  1388. );
  1389. questionScore.textContent = 0;
  1390. });
  1391. this.model.categories
  1392. .filter((category) => category.title !== 'Academic Integrity')
  1393. .forEach((category) => {
  1394. const title = category.title;
  1395. const categoryScore = document.querySelector(
  1396. "span[data-cat='" + title + "']"
  1397. );
  1398. const resultsCategoryScore = document.querySelector(
  1399. "span[data-res-cat='" + title + "']"
  1400. );
  1401. categoryScore.textContent = 0;
  1402. resultsCategoryScore.textContent = 0;
  1403. });
  1404. this.view.update();
  1405. window.scrollTo(0, 0);
  1406. });
  1407. this.model.categories
  1408. .filter((category) => category.title !== 'Academic Integrity')
  1409. .forEach((category) => {
  1410. let title = category.title.replace(/\s+/g, '-').toLowerCase();
  1411. let buttonName = 'copyButton-' + title;
  1412. let summaryName = title + '-summary';
  1413. this.view[buttonName].addEventListener('click', () => {
  1414. const selection = window.getSelection();
  1415. const range = document.createRange();
  1416. range.selectNodeContents(this.view[summaryName]);
  1417. selection.removeAllRanges();
  1418. selection.addRange(range);
  1419. document.execCommand('copy');
  1420. });
  1421. });
  1422. this.view.darkModeToggle.addEventListener('change', () => {
  1423. this.model.toggleDarkMode();
  1424. this.view.update();
  1425. });
  1426. };
  1427. function App(Model, View, Controller) {
  1428. this.model = new Model();
  1429. this.view = new View(this.model);
  1430. this.controller = new Controller(this.model, this.view);
  1431. }
  1432. return new App(Model, View, Controller);
  1433. })(window);
  1434. </script>
  1435. </body>
  1436. </html>