Last active
August 29, 2015 14:06
-
-
Save fpereira1/41d23e8b283d20a79e93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SG(function() { | |
$('sg-question').removeClass('sg-hide'); | |
}); | |
$('.sg-question-title code').hide(); | |
randomRange = function(min, max) {console.log(min,max); return Math.floor(Math.random() * (max - min + 1)) + min; } | |
eval($('.sg-question-title code').text()); | |
$('.sg-question-title var').each(function(i, el) { | |
var text = $(el).text(); | |
$(el).text(eval(text)); | |
}); | |
var $sgOptions = $('.sg-question-options'); | |
$sgOptions.hide(); | |
// floor and display result to the user | |
var result = Math.floor(result); | |
$('body').prepend('Correct answer is ' + Math.floor(result)); | |
var answerTextField = $('<input name="answer">').keyup(function() { | |
var answerVal = Math.floor(parseInt($(this).val())); | |
if(result == answerVal){ | |
$sgOptions.find('input[title=correct]').click(); | |
} else { | |
$sgOptions.find('input[title="not correct"]').click(); | |
} | |
}).insertAfter($sgOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment