Skip to content

Instantly share code, notes, and snippets.

@fpereira1
Last active August 29, 2015 14:06
Show Gist options
  • Save fpereira1/41d23e8b283d20a79e93 to your computer and use it in GitHub Desktop.
Save fpereira1/41d23e8b283d20a79e93 to your computer and use it in GitHub Desktop.
$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