Page 1 of 1

UQM Configuration

Posted: Mon May 01, 2006 7:05 pm
by webmaster609
It would appear that the UQM marks an answer incorrect if it is not typed in exactly as per the submitted answer...i.e: correct spelling, capitalization etc..... is there any way to relax the settings so it will ignore capitalization etc?

Posted: Tue May 02, 2006 12:06 am
by battye
In future versions, I will relax the settings on capital letters, but there's not a lot I can do for correct spelling etc.

Here is a quick fix (it is untested though, so if you experience any problems, remove it immediately).

Open quiz.php, FIND

Code: Select all

			if($user_answer == $actual_answer)
			{
				$correct[$i] = 1;
				$incorrect[$i] = 0;
				
				// The message consists of Question: Your Answer: Actual Answer
				$status = sprintf($lang['Quiz_answer_status'], $user_answer, '<font color="green">' . $actual_answer . '</font>');
			}
			
			else if($user_answer != $actual_answer)
			{
				$correct[$i] = 0;
				$incorrect[$i] = 1;
				$status = sprintf($lang['Quiz_answer_status'], $user_answer, '<font color="red">' . $actual_answer . '</font>');
			}
REPLACE THAT ENTIRE SECTION WITH

Code: Select all

			if(strtoupper($user_answer) == strtoupper($actual_answer))
			{
				$correct[$i] = 1;
				$incorrect[$i] = 0;
				
				// The message consists of Question: Your Answer: Actual Answer
				$status = sprintf($lang['Quiz_answer_status'], $user_answer, '<font color="green">' . $actual_answer . '</font>');
			}
			
			else if(strtoupper($user_answer) != strtoupper($actual_answer))
			{
				$correct[$i] = 0;
				$incorrect[$i] = 1;
				$status = sprintf($lang['Quiz_answer_status'], $user_answer, '<font color="red">' . $actual_answer . '</font>');
			}
The modifications that are being made are changing the 'if' and 'else if' lines, so that it sees all answers in the database as entirely in caps, and all the answers submitted by the user, entirely in caps, so that there won't be any conflict with capital letters :)

For example, before, it might say in the database that the answer was 'Gift', and the user typed in 'gift', and result in a 'no match'. This change will alter the database answer to GIFT (all caps) and the user answer to GIFT also, meaning there is a match now :)

Posted: Tue May 02, 2006 4:11 pm
by webmaster609
Battye,

Thanks for that quick fix mate...seems to be working fine..will let u know if any probs arise with it :0