Linear mode now has tracking of the current quiz item index and allows skipping to the desired item.
closes #1
This commit is contained in:
parent
45d6e6f30d
commit
cf5852794b
@ -1,13 +1,16 @@
|
|||||||
linearMode = false
|
linearMode = false
|
||||||
linearCount = 0
|
linearCount = 0
|
||||||
selection = null
|
selection = null
|
||||||
|
itemMax = 1
|
||||||
|
|
||||||
refreshQuestion = () ->
|
refreshQuestion = () ->
|
||||||
if(sessionStorage.getItem('user_items'))
|
if(sessionStorage.getItem('user_items'))
|
||||||
items = JSON.parse(sessionStorage.getItem('user_items'))
|
items = JSON.parse(sessionStorage.getItem('user_items'))
|
||||||
|
itemMax = items.length
|
||||||
if linearMode
|
if linearMode
|
||||||
selection = items[linearCount]
|
selection = items[linearCount]
|
||||||
linearCount++
|
linearCount++
|
||||||
|
refreshQuizCounter()
|
||||||
if linearCount >= items.length # Wrap around
|
if linearCount >= items.length # Wrap around
|
||||||
linearCount = 0
|
linearCount = 0
|
||||||
else
|
else
|
||||||
@ -91,12 +94,18 @@ $('#filter-form').submit( (e) ->
|
|||||||
toggleQuizMode = () ->
|
toggleQuizMode = () ->
|
||||||
linearMode = !linearMode
|
linearMode = !linearMode
|
||||||
if linearMode
|
if linearMode
|
||||||
|
document.getElementById('quiz-counter').style.visibility = "visible"
|
||||||
$('#mode-toggle').text("Linear Mode")
|
$('#mode-toggle').text("Linear Mode")
|
||||||
else
|
else
|
||||||
linearCount = 0
|
linearCount = 0
|
||||||
|
document.getElementById('quiz-counter').style.visibility = "hidden"
|
||||||
$('#mode-toggle').text("Random Mode")
|
$('#mode-toggle').text("Random Mode")
|
||||||
refreshQuestion()
|
refreshQuestion()
|
||||||
|
|
||||||
|
refreshQuizCounter = () ->
|
||||||
|
document.getElementById('current-quiz').value = linearCount
|
||||||
|
document.getElementById('total-quiz').textContent = "/" + itemMax
|
||||||
|
|
||||||
$(document).keypress (e) ->
|
$(document).keypress (e) ->
|
||||||
if(e.which == 13)
|
if(e.which == 13)
|
||||||
$("#submit-answer").click();
|
$("#submit-answer").click();
|
||||||
@ -141,6 +150,15 @@ $('#error-area').find('button').click () ->
|
|||||||
$('#success-area').find('button').click () ->
|
$('#success-area').find('button').click () ->
|
||||||
$('#success-area').hide()
|
$('#success-area').hide()
|
||||||
|
|
||||||
|
$('#skip-to-item').click (e) ->
|
||||||
|
e.preventDefault()
|
||||||
|
targetValue = document.getElementById('current-quiz').value - 1
|
||||||
|
if(targetValue >= 0 && targetValue < itemMax)
|
||||||
|
linearCount = targetValue
|
||||||
|
refreshQuestion()
|
||||||
|
else
|
||||||
|
refreshQuizCounter()
|
||||||
|
|
||||||
$ ->
|
$ ->
|
||||||
$(document).ready ->
|
$(document).ready ->
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript 1.10.0
|
// Generated by CoffeeScript 1.10.0
|
||||||
(function() {
|
(function() {
|
||||||
var filterQuestions, getItemTypeFilters, getSrsTypeFilters, linearCount, linearMode, refreshQuestion, selection, toggleQuizMode, updateQuizItemStats;
|
var filterQuestions, getItemTypeFilters, getSrsTypeFilters, itemMax, linearCount, linearMode, refreshQuestion, refreshQuizCounter, selection, toggleQuizMode, updateQuizItemStats;
|
||||||
|
|
||||||
linearMode = false;
|
linearMode = false;
|
||||||
|
|
||||||
@ -8,13 +8,17 @@
|
|||||||
|
|
||||||
selection = null;
|
selection = null;
|
||||||
|
|
||||||
|
itemMax = 1;
|
||||||
|
|
||||||
refreshQuestion = function() {
|
refreshQuestion = function() {
|
||||||
var input_element, items;
|
var input_element, items;
|
||||||
if (sessionStorage.getItem('user_items')) {
|
if (sessionStorage.getItem('user_items')) {
|
||||||
items = JSON.parse(sessionStorage.getItem('user_items'));
|
items = JSON.parse(sessionStorage.getItem('user_items'));
|
||||||
|
itemMax = items.length;
|
||||||
if (linearMode) {
|
if (linearMode) {
|
||||||
selection = items[linearCount];
|
selection = items[linearCount];
|
||||||
linearCount++;
|
linearCount++;
|
||||||
|
refreshQuizCounter();
|
||||||
if (linearCount >= items.length) {
|
if (linearCount >= items.length) {
|
||||||
linearCount = 0;
|
linearCount = 0;
|
||||||
}
|
}
|
||||||
@ -136,14 +140,21 @@
|
|||||||
toggleQuizMode = function() {
|
toggleQuizMode = function() {
|
||||||
linearMode = !linearMode;
|
linearMode = !linearMode;
|
||||||
if (linearMode) {
|
if (linearMode) {
|
||||||
|
document.getElementById('quiz-counter').style.visibility = "visible";
|
||||||
$('#mode-toggle').text("Linear Mode");
|
$('#mode-toggle').text("Linear Mode");
|
||||||
} else {
|
} else {
|
||||||
linearCount = 0;
|
linearCount = 0;
|
||||||
|
document.getElementById('quiz-counter').style.visibility = "hidden";
|
||||||
$('#mode-toggle').text("Random Mode");
|
$('#mode-toggle').text("Random Mode");
|
||||||
}
|
}
|
||||||
return refreshQuestion();
|
return refreshQuestion();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
refreshQuizCounter = function() {
|
||||||
|
document.getElementById('current-quiz').value = linearCount;
|
||||||
|
return document.getElementById('total-quiz').textContent = "/" + itemMax;
|
||||||
|
};
|
||||||
|
|
||||||
$(document).keypress(function(e) {
|
$(document).keypress(function(e) {
|
||||||
if (e.which === 13) {
|
if (e.which === 13) {
|
||||||
return $("#submit-answer").click();
|
return $("#submit-answer").click();
|
||||||
@ -204,6 +215,18 @@
|
|||||||
return $('#success-area').hide();
|
return $('#success-area').hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#skip-to-item').click(function(e) {
|
||||||
|
var targetValue;
|
||||||
|
e.preventDefault();
|
||||||
|
targetValue = document.getElementById('current-quiz').value - 1;
|
||||||
|
if (targetValue >= 0 && targetValue < itemMax) {
|
||||||
|
linearCount = targetValue;
|
||||||
|
return refreshQuestion();
|
||||||
|
} else {
|
||||||
|
return refreshQuizCounter();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
return $(document).ready(function() {
|
return $(document).ready(function() {
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
@ -65,6 +65,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-2 col-md-offset-10">
|
||||||
|
<div id="quiz-counter" class="input-group" style="visibility: hidden">
|
||||||
|
<input id="current-quiz" type="number" class="form-control">
|
||||||
|
<span id="total-quiz" class="input-group-addon">/0</span>
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button class="btn btn-default" id="skip-to-item" type="button">Go!</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 text-center">
|
<div class="col-md-12 text-center">
|
||||||
<div id="error-area" class="alert alert-danger alert-dismissible collapse" role="alert">
|
<div id="error-area" class="alert alert-danger alert-dismissible collapse" role="alert">
|
||||||
|
Loading…
Reference in New Issue
Block a user