Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 123ece6

Browse files
author
constantinol
committed
adds documentation to all new code for flag button. also modifies flag button for accessibility
1 parent 39c963b commit 123ece6

2 files changed

Lines changed: 36 additions & 45 deletions

File tree

runestone/timed/css/timed.css

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,20 @@ ul#pageNums li {
1010
color: #000 !important;
1111
}
1212

13-
/* adding from here DELETE THIS*/
14-
.class1 {
15-
background-color: #FFFF99 !important;
13+
.flagBtn { /* documentation */
14+
background-color: #ED9C59 !important;
1615
border: none;
16+
outline-style: solid;
17+
outline-color: #CE5718 ;
1718
color: #030201 !important;
1819
cursor: pointer;
1920
width: 150;
2021
height: 115;
2122
text-align: center;
2223
text-decoration: none;
23-
display: inline-block;
24+
display: ruby;
2425
font-size: 15px;
2526
}
26-
/*
27-
.flagBtn {
28-
background-color: #FFFF99 !important;
29-
border: none;
30-
color: #030201 !important;
31-
cursor: pointer;
32-
width: 150;
33-
height: 115;
34-
text-align: center;
35-
text-decoration: none;
36-
display: inline-block;
37-
font-size: 15px;
38-
} */
3927

4028
/* The following override styles in Bootstrap distribution file (bootstrap.min.css) */
4129

@@ -72,7 +60,7 @@ ul#pageNums li {
7260

7361
.pagination > .flagcolor > a,
7462
.pagination > .flagcolor > span {
75-
background-color: #fac989;
63+
background-color: #ED9C59;
7664
color: #000;
7765
}
7866

runestone/timed/js/timed.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/Next/)) {
365+
if (target.match(/Next/)) { // checks given text to match "Next"
360366
if ($(this.rightContainer).hasClass("disabled")) {
361367
return;
362368
}
363369
this.currentQuestionIndex++;
364-
} else if (target.match(/Prev/)) {
370+
} else if (target.match(/Prev/)) { // 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(/Come Back/)) {
404+
if (target.match(/Flag Question/)) {
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

Comments
 (0)