js/questions.js
/* Check the answer
 * @param {json} inputResult - the user input containing their sql output in json.stringify!
 * @return {bool} - correct or not?
 */
Check the answer
@param {json} inputResult - the user input containing their sql output in json.stringify.
Check the answer @param { json } inputResult - the user input containing their sql output in json . stringify .
function checkAnswer(inputResult) {
	var currQuestion = (typeof Cookies.get('CurrQuestion') !== 'undefined') ? Cookies.get('CurrQuestion') : 1
	var cache = Cookies.getJSON('Question-' + currQuestion)
	if(typeof cache === 'undefined') {
		return false
	}
	var answerResult = db.exec(cache.Answer)
	if(typeof answerResult[0] === 'undefined' && typeof inputResult[0] === 'undefined') {
		return true
	}
	for(var i = 0; i < inputResult[0].columns.length; i++) {
		inputResult[0].columns[i] = inputResult[0].columns[i].toUpperCase().replace(/\`/g, "")
	}
	for(var i = 0; i < answerResult[0].columns.length; i++) {
		answerResult[0].columns[i] = answerResult[0].columns[i].toUpperCase().replace(/\`/g, "")
	}
	var answer = JSON.stringify(answerResult)
	var input = JSON.stringify(inputResult)
	if(input === answer) {
		return true
	}
	return false
}
function checkAnswer ( inputResult ) { var currQuestion = ( typeof Cookies . get ( 'CurrQuestion' ) !== 'undefined' ) ? Cookies . get ( 'CurrQuestion' ) : 1 var cache = Cookies . getJSON ( 'Question-' + currQuestion ) if ( typeof cache === 'undefined' ) { return false } var answerResult = db . exec ( cache . Answer ) if ( typeof answerResult [ 0 ] === 'undefined' && typeof inputResult [ 0 ] === 'undefined' ) { return true } for ( var i = 0 ; i < inputResult [ 0 ] . columns . length ; i ++ ) { inputResult [ 0 ] . columns [ i ] = inputResult [ 0 ] . columns [ i ] . toUpperCase ( ) . replace ( / \` / g , "" ) } for ( var i = 0 ; i < answerResult [ 0 ] . columns . length ; i ++ ) { answerResult [ 0 ] . columns [ i ] = answerResult [ 0 ] . columns [ i ] . toUpperCase ( ) . replace ( / \` / g , "" ) } var answer = JSON . stringify ( answerResult ) var input = JSON . stringify ( inputResult ) if ( input === answer ) { return true } return false }
Check the answer
 @param {json} inputResult - the user input containing their sql output in json.stringify!
Check the answer @param { json } inputResult - the user input containing their sql output in json . stringify!
// get the current question from cookie
 // get the model answer from the cache (generated when a question was stored)
 // if the answer isn't in the cache, WTF happened?!?!
 /* BugFix
	 * If the question generated no longer returns values, then mark it as correct!
	 */ // make the input columns capitalised as it's valid whatever case!
 // make the answer columns capitalised as it's valid whatever case!
 // stringify strings
 // check if the input is the same as the answer
 // correct 
 // nope
