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

Commit 8897061

Browse files
author
constantinol
committed
functioning flag button with its own handler and listener
1 parent fbdedb3 commit 8897061

2 files changed

Lines changed: 43 additions & 4 deletions

File tree

runestone/timed/css/timed.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,19 @@ ul#pageNums li {
2323
display: inline-block;
2424
font-size: 15px;
2525
}
26-
/* adding to here DELETE THIS*/
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+
} */
2739

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

@@ -58,6 +70,12 @@ ul#pageNums li {
5870
color: #000;
5971
}
6072

73+
.pagination > .flagcolor > a,
74+
.pagination > .flagcolor > span {
75+
background-color: #fac989;
76+
color: #000;
77+
}
78+
6179
p.examwarning {
6280
width: 50%;
6381
margin-left: auto;

runestone/timed/js/timed.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ export default class Timed extends RunestoneBase {
262262
this.leftContainer.appendChild(this.leftNavButton);
263263
this.pagNavList.appendChild(this.leftContainer);
264264
//
265-
this.leftContainer = document.createElement("li");
265+
this.flaggingPlace = document.createElement("ul");
266+
$(this.flaggingPlace).addClass("pagination");
267+
this.flagContainer = document.createElement("li");
266268
this.flagButton = document.createElement("button");
267269
$(this.flagButton).addClass("class1");
268270
this.flagButton.innerHTML = "Flag";
@@ -271,8 +273,8 @@ export default class Timed extends RunestoneBase {
271273
$(this.flagButton).attr("role", "button");
272274
$(this.flagButton).attr("id", "flag");
273275
$(this.flagButton).css("cursor", "pointer");
274-
this.leftContainer.appendChild(this.flagButton);
275-
this.pagNavList.appendChild(this.leftContainer);
276+
this.flagContainer.appendChild(this.flagButton);
277+
this.flaggingPlace.appendChild(this.flagContainer);
276278
//
277279
this.rightContainer = document.createElement("li");
278280
this.rightNavButton = document.createElement("button");
@@ -286,6 +288,7 @@ export default class Timed extends RunestoneBase {
286288
this.pagNavList.appendChild(this.rightContainer);
287289
this.ensureButtonSafety();
288290
this.navDiv.appendChild(this.pagNavList);
291+
this.navDiv.appendChild(this.flaggingPlace);
289292
this.break = document.createElement("br");
290293
this.navDiv.appendChild(this.break);
291294
// render the question number jump buttons
@@ -308,6 +311,7 @@ export default class Timed extends RunestoneBase {
308311
this.qNumList.appendChild(this.qNumWrapperList);
309312
this.navDiv.appendChild(this.qNumList);
310313
this.navBtnListeners();
314+
this.flagBtnListener();
311315
}
312316

313317
// when moving off of a question in an active exam:
@@ -381,6 +385,14 @@ export default class Timed extends RunestoneBase {
381385
).addClass("active");
382386
}
383387

388+
async handleFlag(event) {
389+
var target = $(event.target).text()
390+
if (target.match(/Flag/)) {
391+
$("ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
392+
).addClass("flagcolor");
393+
}
394+
}
395+
384396
async handleNumberedNav(event) {
385397
if (!this.taken) {
386398
await this.navigateAway();
@@ -428,6 +440,15 @@ export default class Timed extends RunestoneBase {
428440
);
429441
}
430442

443+
// set up events for flag
444+
flagBtnListener() {
445+
this.flaggingPlace.addEventListener(
446+
"click",
447+
this.handleFlag.bind(this),
448+
false
449+
);
450+
}
451+
431452
renderSubmitButton() {
432453
this.buttonContainer = document.createElement("div");
433454
$(this.buttonContainer).attr({

0 commit comments

Comments
 (0)