@@ -173,10 +173,15 @@ export default class Timed extends RunestoneBase {
173173 $ ( this . navDiv ) . attr ( {
174174 style : "text-align:center" ,
175175 } ) ;
176+ this . flagDiv = document . createElement ( "div" ) ; // div that will hold the "Flag Question" button
177+ $ ( this . flagDiv ) . attr ( {
178+ style : "text-align: center" ,
179+ } ) ;
176180 this . switchContainer = document . createElement ( "div" ) ;
177181 this . switchContainer . classList . add ( "switchcontainer" ) ;
178182 this . switchDiv = document . createElement ( "div" ) ; // is replaced by the questions
179183 this . timedDiv . appendChild ( this . navDiv ) ;
184+ this . timedDiv . appendChild ( this . flagDiv ) ; // add flagDiv to timedDiv, which holds components for navigation and questions for timed assessment
180185 this . timedDiv . appendChild ( this . switchContainer ) ;
181186 this . switchContainer . appendChild ( this . switchDiv ) ;
182187 $ ( this . timedDiv ) . attr ( {
@@ -249,6 +254,7 @@ export default class Timed extends RunestoneBase {
249254 }
250255
251256 renderNavControls ( ) {
257+ // making "Prev" button
252258 this . pagNavList = document . createElement ( "ul" ) ;
253259 $ ( this . pagNavList ) . addClass ( "pagination" ) ;
254260 this . leftContainer = document . createElement ( "li" ) ;
@@ -261,21 +267,21 @@ export default class Timed extends RunestoneBase {
261267 $ ( this . leftNavButton ) . css ( "cursor" , "pointer" ) ;
262268 this . leftContainer . appendChild ( this . leftNavButton ) ;
263269 this . pagNavList . appendChild ( this . leftContainer ) ;
264- //
270+ // making "Flag Question" button
265271 this . flaggingPlace = document . createElement ( "ul" ) ;
266272 $ ( this . flaggingPlace ) . addClass ( "pagination" ) ;
267273 this . flagContainer = document . createElement ( "li" ) ;
268274 this . flagButton = document . createElement ( "button" ) ;
269- $ ( this . flagButton ) . addClass ( "class1 " ) ;
270- this . flagButton . innerHTML = "Come Back" ;
275+ $ ( this . flagButton ) . addClass ( "flagBtn " ) ;
276+ this . flagButton . innerHTML = "Flag Question" ; // name on button
271277 $ ( this . flagButton ) . attr ( "aria-labelledby" , "Flag" ) ;
272278 $ ( this . flagButton ) . attr ( "tabindex" , "5" ) ;
273279 $ ( this . flagButton ) . attr ( "role" , "button" ) ;
274280 $ ( this . flagButton ) . attr ( "id" , "flag" ) ;
275281 $ ( this . flagButton ) . css ( "cursor" , "pointer" ) ;
276- this . flagContainer . appendChild ( this . flagButton ) ;
277- this . flaggingPlace . appendChild ( this . flagContainer ) ;
278- //
282+ this . flagContainer . appendChild ( this . flagButton ) ; // adding button to container
283+ this . flaggingPlace . appendChild ( this . flagContainer ) ; // adding container to flaggingPlace
284+ // making "Next" button
279285 this . rightContainer = document . createElement ( "li" ) ;
280286 this . rightNavButton = document . createElement ( "button" ) ;
281287 $ ( this . rightNavButton ) . attr ( "aria-label" , "Next" ) ;
@@ -288,7 +294,7 @@ export default class Timed extends RunestoneBase {
288294 this . pagNavList . appendChild ( this . rightContainer ) ;
289295 this . ensureButtonSafety ( ) ;
290296 this . navDiv . appendChild ( this . pagNavList ) ;
291- this . navDiv . appendChild ( this . flaggingPlace ) ;
297+ this . flagDiv . appendChild ( this . flaggingPlace ) ; // adds flaggingPlace to the flagDiv
292298 this . break = document . createElement ( "br" ) ;
293299 this . navDiv . appendChild ( this . break ) ;
294300 // render the question number jump buttons
@@ -311,7 +317,7 @@ export default class Timed extends RunestoneBase {
311317 this . qNumList . appendChild ( this . qNumWrapperList ) ;
312318 this . navDiv . appendChild ( this . qNumList ) ;
313319 this . navBtnListeners ( ) ;
314- this . flagBtnListener ( ) ;
320+ this . flagBtnListener ( ) ; // listens for click on flag button
315321 }
316322
317323 // when moving off of a question in an active exam:
@@ -356,12 +362,12 @@ export default class Timed extends RunestoneBase {
356362 await this . navigateAway ( ) ;
357363 }
358364 var target = $ ( event . target ) . text ( ) ;
359- if ( target . match ( / N e x t / ) ) {
365+ if ( target . match ( / N e x t / ) ) { // checks given text to match "Next"
360366 if ( $ ( this . rightContainer ) . hasClass ( "disabled" ) ) {
361367 return ;
362368 }
363369 this . currentQuestionIndex ++ ;
364- } else if ( target . match ( / P r e v / ) ) {
370+ } else if ( target . match ( / P r e v / ) ) { // checks given text to match "Prev"
365371 if ( $ ( this . leftContainer ) . hasClass ( "disabled" ) ) {
366372 return ;
367373 }
@@ -384,26 +390,25 @@ export default class Timed extends RunestoneBase {
384390 "ul#pageNums > ul > li:eq(" + this . currentQuestionIndex + ")"
385391 ) . addClass ( "active" ) ;
386392 if ( $ ( "ul#pageNums > ul > li:eq(" + this . currentQuestionIndex + ")"
387- ) . hasClass ( "flagcolor" ) ) {
388- this . flagButton . innerHTML = "Done" ;
389-
393+ ) . hasClass ( "flagcolor" ) ) { // checking for class
394+ this . flagButton . innerHTML = "Unflag Question" ; // changes text on button
390395 }
391396 else {
392- this . flagButton . innerHTML = "Come Back" ;
397+ this . flagButton . innerHTML = "Flag Question" ; // changes text on button
393398 }
394-
395399 }
396400
397401 async handleFlag ( event ) {
402+ // called when flag button is clicked
398403 var target = $ ( event . target ) . text ( )
399- if ( target . match ( / C o m e B a c k / ) ) {
404+ if ( target . match ( / F l a g Q u e s t i o n / ) ) {
400405 $ ( "ul#pageNums > ul > li:eq(" + this . currentQuestionIndex + ")"
401- ) . addClass ( "flagcolor" ) ;
402- this . flagButton . innerHTML = "Done " ;
406+ ) . addClass ( "flagcolor" ) ; // class will change color of question block
407+ this . flagButton . innerHTML = "Unflag Question " ;
403408 } else {
404409 $ ( "ul#pageNums > ul > li:eq(" + this . currentQuestionIndex + ")"
405- ) . removeClass ( "flagcolor" ) ;
406- this . flagButton . innerHTML = "Come Back" ;
410+ ) . removeClass ( "flagcolor" ) ; // will restore current color of question block
411+ this . flagButton . innerHTML = "Flag Question" ; // also sets name back
407412 }
408413 }
409414
@@ -412,7 +417,6 @@ export default class Timed extends RunestoneBase {
412417 await this . navigateAway ( ) ;
413418 }
414419 for ( var i = 0 ; i < this . qNumList . childNodes . length ; i ++ ) {
415- //this.flagButton.innerHTML = "Come Back";
416420 for (
417421 var j = 0 ;
418422 j < this . qNumList . childNodes [ i ] . childNodes . length ;
@@ -434,13 +438,12 @@ export default class Timed extends RunestoneBase {
434438 $ (
435439 "ul#pageNums > ul > li:eq(" + this . currentQuestionIndex + ")"
436440 ) . addClass ( "active" ) ;
437- if ( $ ( "ul#pageNums > ul > li:eq(" + this . currentQuestionIndex + ")"
441+ if ( $ ( "ul#pageNums > ul > li:eq(" + this . currentQuestionIndex + ")" // checking for flagcolor class
438442 ) . hasClass ( "flagcolor" ) ) {
439- this . flagButton . innerHTML = "Done" ;
440-
443+ this . flagButton . innerHTML = "Unflag Question" ;
441444 }
442445 else {
443- this . flagButton . innerHTML = "Come Back " ;
446+ this . flagButton . innerHTML = "Flag Question " ;
444447 }
445448 await this . renderTimedQuestion ( ) ;
446449 this . ensureButtonSafety ( ) ;
@@ -463,11 +466,11 @@ export default class Timed extends RunestoneBase {
463466 ) ;
464467 }
465468
466- // set up events for flag
469+ // set up event for flag
467470 flagBtnListener ( ) {
468471 this . flaggingPlace . addEventListener (
469472 "click" ,
470- this . handleFlag . bind ( this ) ,
473+ this . handleFlag . bind ( this ) , // calls this to take action
471474 false
472475 ) ;
473476 }
0 commit comments