Skip to content

Commit

Permalink
Merge branch 'MDL-66587-master' of git://github.com/bmbrands/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Sep 24, 2020
2 parents c43dac4 + d910726 commit 1d7781b
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 80 deletions.
1 change: 0 additions & 1 deletion mod/quiz/attemptlib.php
Expand Up @@ -2795,7 +2795,6 @@ public function render_end_bits(mod_quiz_renderer $output) {
}
return html_writer::link($this->attemptobj->summary_url(),
get_string('endtest', 'quiz'), array('class' => 'endtestlink aalink')) .
$output->countdown_timer($this->attemptobj, time()) .
$this->render_restart_preview_link($output);
}
}
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/module.js
Expand Up @@ -71,7 +71,7 @@ M.mod_quiz.timer = {
M.mod_quiz.timer.endtime = M.pageloadstarttime.getTime() + start*1000;
M.mod_quiz.timer.preview = preview;
M.mod_quiz.timer.update();
Y.one('#quiz-timer').setStyle('display', 'block');
Y.one('#quiz-timer-wrapper').setStyle('display', 'flex');
},

/**
Expand Down
7 changes: 3 additions & 4 deletions mod/quiz/renderer.php
Expand Up @@ -294,10 +294,8 @@ public function countdown_timer(quiz_attempt $attemptobj, $timenow) {
$this->initialise_timer($timerstartvalue, $ispreview);
}

return html_writer::tag('div', get_string('timeleft', 'quiz') . ' ' .
html_writer::tag('span', '', array('id' => 'quiz-time-left')),
array('id' => 'quiz-timer', 'role' => 'timer',
'aria-atomic' => 'true', 'aria-relevant' => 'text'));

return $this->output->render_from_template('mod_quiz/timer', (object)[]);
}

/**
Expand Down Expand Up @@ -447,6 +445,7 @@ public function attempt_page($attemptobj, $page, $accessmanager, $messages, $slo
$output = '';
$output .= $this->header();
$output .= $this->quiz_notices($messages);
$output .= $this->countdown_timer($attemptobj, time());
$output .= $this->attempt_form($attemptobj, $page, $slots, $id, $nextpage);
$output .= $this->footer();
return $output;
Expand Down
74 changes: 0 additions & 74 deletions mod/quiz/styles.css
Expand Up @@ -196,80 +196,6 @@
margin: 0.5em 0;
}

/* Countdown timer. */
#quiz-timer {
display: none;
margin-top: 1em;
}

#quiz-time-left {
font-weight: bold;
}

#quiz-timer.timeleft15 {
background: #fff;
}

#quiz-timer.timeleft14 {
background: #fee;
}

#quiz-timer.timeleft13 {
background: #fdd;
}

#quiz-timer.timeleft12 {
background: #fcc;
}

#quiz-timer.timeleft11 {
background: #fbb;
}

#quiz-timer.timeleft10 {
background: #faa;
}

#quiz-timer.timeleft9 {
background: #f99;
}

#quiz-timer.timeleft8 {
background: #f88;
}

#quiz-timer.timeleft7 {
background: #f77;
}

#quiz-timer.timeleft6 {
background: #f66;
}

#quiz-timer.timeleft5 {
background: #f55;
}

#quiz-timer.timeleft4 {
background: #f44;
}

#quiz-timer.timeleft3 {
background: #f33;
}

#quiz-timer.timeleft2 {
background: #f22;
}

#quiz-timer.timeleft1 {
background: #f11;
}

#quiz-timer.timeleft0 {
background: #f00;
}

/** mod quiz mod **/
#page-mod-quiz-mod #id_reviewoptionshdr .fitem {
width: 23%;
Expand Down
31 changes: 31 additions & 0 deletions mod/quiz/templates/timer.mustache
@@ -0,0 +1,31 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_quiz/timer
Login page template
Example context (json):
{
}
}}
<div id="quiz-timer-wrapper" class="mb-2">
<div id="quiz-timer" class="quiz-timer-inner py-1 px-2 ml-auto" role="timer" aria-atomic="true" aria-relevant="text">
{{#str}} timeleft, quiz {{/str}}
<span id="quiz-time-left"></span>
</div>
</div>
28 changes: 28 additions & 0 deletions theme/boost/scss/moodle/modules.scss
Expand Up @@ -1265,6 +1265,34 @@ div#dock {
margin: 0 0.4em;
}

/* Countdown timer. */
#page-mod-quiz-attempt #region-main {
overflow-x: inherit;
}

#quiz-timer-wrapper {
display: none;
position: sticky;
justify-content: end;
top: $navbar-height + 5px;
z-index: $zindex-modal;
#quiz-timer {
border: $border-width solid $red;
background-color: $white;
}
}
.pagelayout-embedded #quiz-timer-wrapper {
top: 5px;
}

@for $i from 0 through 16 {
#quiz-timer-wrapper #quiz-timer.timeleft#{$i} {
$bg: lighten($red, ($i * 3%));
background-color: $bg;
color: color-yiq($bg);
}
}

// Assign.
.path-mod-assign [data-region="grade-actions-panel"] [data-region="grade-actions"] .collapse-buttons {
top: auto;
Expand Down
85 changes: 85 additions & 0 deletions theme/boost/style/moodle.css
Expand Up @@ -17524,6 +17524,91 @@ div#dock {
padding: 0;
margin: 0 0.4em; }

/* Countdown timer. */
#page-mod-quiz-attempt #region-main {
overflow-x: inherit; }

#quiz-timer-wrapper {
display: none;
position: sticky;
justify-content: end;
top: 55px;
z-index: 1050; }
#quiz-timer-wrapper #quiz-timer {
border: 1px solid #d43f3a;
background-color: #fff; }

.pagelayout-embedded #quiz-timer-wrapper {
top: 5px; }

#quiz-timer-wrapper #quiz-timer.timeleft0 {
background-color: #d43f3a;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft1 {
background-color: #d74b47;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft2 {
background-color: #d95753;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft3 {
background-color: #dc6460;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft4 {
background-color: #df706c;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft5 {
background-color: #e27c79;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft6 {
background-color: #e48885;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft7 {
background-color: #e79592;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft8 {
background-color: #eaa19e;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft9 {
background-color: #edadab;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft10 {
background-color: #efb9b8;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft11 {
background-color: #f2c6c4;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft12 {
background-color: #f5d2d1;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft13 {
background-color: #f8dedd;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft14 {
background-color: #faeaea;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft15 {
background-color: #fdf7f6;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft16 {
background-color: white;
color: #212529; }

.path-mod-assign [data-region="grade-actions-panel"] [data-region="grade-actions"] .collapse-buttons {
top: auto; }

Expand Down
85 changes: 85 additions & 0 deletions theme/classic/style/moodle.css
Expand Up @@ -17751,6 +17751,91 @@ div#dock {
padding: 0;
margin: 0 0.4em; }

/* Countdown timer. */
#page-mod-quiz-attempt #region-main {
overflow-x: inherit; }

#quiz-timer-wrapper {
display: none;
position: sticky;
justify-content: end;
top: 55px;
z-index: 1050; }
#quiz-timer-wrapper #quiz-timer {
border: 1px solid #d43f3a;
background-color: #fff; }

.pagelayout-embedded #quiz-timer-wrapper {
top: 5px; }

#quiz-timer-wrapper #quiz-timer.timeleft0 {
background-color: #d43f3a;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft1 {
background-color: #d74b47;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft2 {
background-color: #d95753;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft3 {
background-color: #dc6460;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft4 {
background-color: #df706c;
color: #fff; }

#quiz-timer-wrapper #quiz-timer.timeleft5 {
background-color: #e27c79;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft6 {
background-color: #e48885;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft7 {
background-color: #e79592;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft8 {
background-color: #eaa19e;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft9 {
background-color: #edadab;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft10 {
background-color: #efb9b8;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft11 {
background-color: #f2c6c4;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft12 {
background-color: #f5d2d1;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft13 {
background-color: #f8dedd;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft14 {
background-color: #faeaea;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft15 {
background-color: #fdf7f6;
color: #212529; }

#quiz-timer-wrapper #quiz-timer.timeleft16 {
background-color: white;
color: #212529; }

.path-mod-assign [data-region="grade-actions-panel"] [data-region="grade-actions"] .collapse-buttons {
top: auto; }

Expand Down

0 comments on commit 1d7781b

Please sign in to comment.