$answerFromBank = 'jtest'; $questionID = getQuizWordID($userID, $vstyle); $answerID = $questionID; $element = 'reading'; $answerChoices = getRandomWords($choiceQ, $answerFromBank, $answerID, $userID, $element); //get random words in HIRAGANA; need to get hiragana, not kanji //Prepare for Display in kanjiRE.php $rand = rand(0, $choiceQ - 1); $answer = $vstyle == 'audioR' || $vstyle == 'kanjiH' ? getReading($answerID, $answerFromBank) : getWord($answerID, $answerFromBank); $answerChoices[$rand]['id'] = $answerID; $answerChoices[$rand][$element] = $answer; //print_r($answerChoices); //Finalized Variables Used in kanjiRE.php $question = $vstyle == 'audioR' || $vstyle == 'audioK' ? getWordInfo('audio_filename', $questionID, $questionFromBank) : getWord($questionID, $questionFromBank); if (isSentencesDeck(getVocStat('cvset', $userID)) == '1') { $sentences = getSentences($questionID); } else { $sentences = False; } } elseif (getSkill('vStyle', $userID) == 'engK' || getSkill('vStyle', $userID) == 'engKR') { //*************************************************************************************************** //*************************************English<-->Kanji+Hiragana; Hiragana*************************** //*************************************************************************************************** //$choiceQ = 5; $questionFromBank = 'etest'; $answerFromBank = 'jtest'; //get word $questionID = getQuizWordID($userID, getSkill('vStyle', $userID)); //echo "newQuesID is: $questionID <br />"; $question = getWord($questionID, $questionFromBank); $answerID = getAnswerIDVocab($questionID, $questionFromBank);
query occurs. ****************************************************************************/ include 'dbsetup.php'; include 'util.php'; if ($_GET['words']) { $words = mysql_real_escape_string($_GET['words']); $context = array(); $matches = getConcordance($words); $context["concordance"] = array(); $context["concordance"]["num"] = $matches['numMatches']; $context["concordance"]["docs"] = $matches['numNarratives']; $context["concordance"]["matches"] = $matches['matches']; $context["grammatical"] = getGrammaticalContext($words); if ($_GET['type'] == "tree") { $context['concordance']['lefts'] = getSentences($context['concordance']['matches'], "left"); $context['concordance']['rights'] = getSentences($context['concordance']['matches'], "right"); } echo json_encode($context); } //Part 1: concordance function getConcordance($words) { $query = "SELECT * FROM sentence WHERE match sentence against('" . $words . "' IN BOOLEAN MODE);"; $results = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.\n\t\t<br/> Query: " . $query . "\n\t\t<br/> Error: (" . mysql_errno() . ") " . mysql_error()); $pattern = "/" . str_replace('"', "", $_GET['words']) . "/"; $matched = array(); $matched['numMatches'] = mysql_num_rows($results); $matched['numNarratives']; $matched['matches'] = array(); while ($row = mysql_fetch_array($results)) { $split = array();