@@ -302,6 +302,16 @@ export default class Timed extends RunestoneBase {
302302 this . pagNavList . addEventListener (
303303 "click" ,
304304 function ( event ) {
305+ if (
306+ this . renderedQuestionArray [ this . currentQuestionIndex ]
307+ . state == "broken_exam"
308+ ) {
309+ $ (
310+ "ul#pageNums > ul > li:eq(" +
311+ this . currentQuestionIndex +
312+ ")"
313+ ) . addClass ( "broken" ) ;
314+ }
305315 if (
306316 this . renderedQuestionArray [ this . currentQuestionIndex ]
307317 . question . isAnswered
@@ -358,6 +368,16 @@ export default class Timed extends RunestoneBase {
358368 this . qNumList . addEventListener (
359369 "click" ,
360370 function ( event ) {
371+ if (
372+ this . renderedQuestionArray [ this . currentQuestionIndex ]
373+ . state == "broken_exam"
374+ ) {
375+ $ (
376+ "ul#pageNums > ul > li:eq(" +
377+ this . currentQuestionIndex +
378+ ")"
379+ ) . addClass ( "broken" ) ;
380+ }
361381 if (
362382 this . renderedQuestionArray [ this . currentQuestionIndex ]
363383 . question . isAnswered
@@ -538,13 +558,21 @@ export default class Timed extends RunestoneBase {
538558 this . renderedQuestionArray [ this . currentQuestionIndex ] = {
539559 question : newq ,
540560 } ;
541- await newq . initialize ( ) ;
561+ try {
562+ await newq . initialize ( ) ;
563+ } catch ( e ) {
564+ this . renderedQuestionArray [
565+ this . currentQuestionIndex
566+ ] . state = "broken_exam" ;
567+ }
542568 } else if ( $ ( tmpChild ) . is ( "[data-component]" ) ) {
543569 let componentKind = $ ( tmpChild ) . data ( "component" ) ;
544570 this . renderedQuestionArray [ this . currentQuestionIndex ] = {
545571 question : window . component_factory [ componentKind ] ( opts ) ,
546572 } ;
547573 }
574+ } else if ( opts . state === "broken_exam" ) {
575+ return ;
548576 }
549577
550578 currentQuestion = this . renderedQuestionArray [ this . currentQuestionIndex ]
@@ -562,8 +590,10 @@ export default class Timed extends RunestoneBase {
562590 }
563591 }
564592
565- $ ( this . switchDiv ) . replaceWith ( currentQuestion . containerDiv ) ;
566- this . switchDiv = currentQuestion . containerDiv ;
593+ if ( currentQuestion . containerDiv ) {
594+ $ ( this . switchDiv ) . replaceWith ( currentQuestion . containerDiv ) ;
595+ this . switchDiv = currentQuestion . containerDiv ;
596+ }
567597
568598 // If the timed component has listeners, those might need to be reinitialized
569599 // This flag will only be set in the elements that need it--it will be undefined in the others and thus evaluate to false
0 commit comments