<?php session_start(); $_SESSION['streak'] = 0; include 'stats.php'; $userId = getUserID($_SESSION['username']); $skillName = $_POST['skillName']; $value = $_POST['value']; echo "received {$skillName} and {$value}"; setSkill($skillName, $userId, $value); //echo "<p>ajskset: $skillName || $value || $userId</p>"; echo "<span style='color:#e2e5e9; font-size:0.9em;'>Updated!</span>"; //header("location: quiz.php"); //if($skillName == 'vStyle' && substr($value,0,5)=='kanji'){ //include 'display_mc.php'; include 'mc_get.php'; include 'include/kanjiRE.php'; ?>
//gold $changeLog[] = "<li><span class='label label-warning'>Gold Coins</span>:<b>+<span class='text-success'>{$gcRw}</span></b></li>"; for ($i = 0; $i < sizeof($skills); $i++) { setScore($skills[$i], $userID, getScore($skills[$i], $userID) + $scoreIncr); $changeLog[] = "<li>" . getStatInfo($skills[$i], 'display_name') . ":<b> +{$scoreIncr}</b> Confidence points</li>"; } //$changeLog[] = "<li>Overall Player Confidence:<b>+$confCorrGain</b> Confidence points</span></li>"; //$changeLog[] = "<li>Quiz Mode:<b> +$skillCorrGain</b> Confidence points</span></li>"; //$changeLog[] = "<li>Streak Bonus: <b>+$streakBonus</b> Confidence points</span></li>"; //------------------INCREMENT GENERAL SKILLS $result = "<span style='color:green;'>CORRECT!</span>"; } elseif ($wordIDGuess != $answerID) { $correct = false; setStat('conf', $userID, getStat('conf', $userID) - $confWrongPen); //overall conf stat setSkill($progressVoc, $userID, getSkill($progressVoc, $userID) - $skillWrongPen); //cvset prog skill setStat('gold', $userID, getStat('gold', $userID) - $gcPen); //gold incrUserDeckStat('stats_incorrect', $cvset, $vstyle, $userID); for ($i = 0; $i < sizeof($skills); $i++) { setStat($skills[$i], $userID, getScore($skills[$i], $userID) - $scoreDecr); $changeLog[] = "<li>" . getStatInfo($skills[$i], 'display_name') . ": <span class='text-danger'>-{$scoreDecr} Confidence points</span></li>"; } $_SESSION['streak'] = 0; } //Update Statistics //insertFlashcardResults($user_id,$deck_id,$word_id,$word_lv,$vstyle_id,$correct,$time_taken); //****************************************************** //****CHECK IF PLAYER LEVELED UP & PREPARE DISPLAY VARIABLES*** //******************************************** $lvUp = setLevelUp($userID, 'quiz');
$query = mysql_query($sql) or die(mysql_error()); $userID = mysql_insert_id($conn); require_once 'stats.php'; setStat('conf', $userID, '0'); setStat('maxconf', $userID, '150'); setStat('lv', $userID, '1'); setStat('gold', $userID, '0'); setStat('dmd', $userID, '0'); //Set Initial Deck //setOwnershipDeck('hirkat',$userID); //setOwnershipvStyle('hirkat','audioR',$userID); //setOwnershipDeck('minna',$userID);//sets ownership of deck(adds this deck to users' user_decks); initializesdeck_lv, deck_progress, deck_prog_max setOwnershipDeck('minna', $userID); //sets ownership of deck(adds this deck to users' user_decks); initializesdeck_lv, deck_progress, deck_prog_max setSkill('cvset', $userID, 'minna'); setSkill('vstyle', $userID, 'kanjiRE'); // CREATE THEIR SESSIONS AND COOKIES $_SESSION['username'] = $u; $_SESSION['prevID'] = 1; $_SESSION['guestInit'] = true; } /******************************************************************************************************************/ require_once 'words.php'; require_once 'stats.php'; require_once 'config.php'; $userID = getUserID($u); $cvset = getSkill('cvset', $userID); $userDeckIds = getUserDecks(getUserID($u)); $currentConf = getStat('conf', $userID); $maxconf = getStat('maxconf', $userID); $currConfPerc = $currentConf / $maxconf * 100;
function getQuizWordID($userID, $wType) { include 'config.php'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(error_log('Error connecting to mysql')); mysql_select_db($dbname); $cvset = getSkill('cvset', $userID); //error_log($wType); if ($cvset == 'hirkat' || $cvset == 'katakana') { if ($wType != 'audioK' && $wType != 'audioR' && $wType != 'audioE') { $wType == 'kanjiRE'; setSkill('vstyle', $userID, 'kanjiRE'); } } $j = 0; $lv = getRanLv($cvset, $userID); //works do { if ($wType == 'kanjiH') { $r = mysql_query("SELECT count(*) FROM jtest WHERE {$cvset} ={$lv} AND word != reading"); $d = mysql_fetch_row($r); $rand = mt_rand(0, $d[0] - 1); $query = sprintf("SELECT id,{$cvset} FROM jtest WHERE {$cvset} ='%s' AND word != reading LIMIT {$rand}, 1", mysql_real_escape_string($lv)); } else { if ($wType == 'kanjiRE' || $wType == 'kanjiE' || $wType == 'engK' || $wType == 'engKR' || $wType == 'audioR' || $wType == 'audioK' || $wType == 'audioE') { $query = sprintf("SELECT id,{$cvset} FROM jtest WHERE {$cvset} ='%s' ORDER BY RAND() LIMIT 1", mysql_real_escape_string($lv)); } } $result = mysql_query($query) or error_log("Query Error:<br />File: words.php<br />Function: getQuizWordID()<br />Line:200<br />Mysql Error:" . mysql_error()); $question = mysql_fetch_array($result); $_SESSION['wordLv'] = $question[$cvset]; $j++; //if($question['id'] !='' && $_SESSION['prevID'] != $question['id']){$lv++;} $lv++; } while ($question['id'] == '' || $_SESSION['prevID'] == $question['id']); //incr if kanjiH and first levels contain no kanji $_SESSION['prevID'] = $question['id']; return $question['id']; }
<?php session_start(); header('Content-Type: text/html; charset=utf-8'); include_once "../include/check_login.php"; //if($user_ok == false){header("location: ../logout.php");} include_once '../stats.php'; $userId = getUserID(preg_replace('#[^a-z0-9]#i', '', $_SESSION['username'])); setSkill('cvset', $userId, getDeckShortName($_POST['deckId'], '')); setSkill('vStyle', $userId, $_POST['vStyle']); if (getSkill('cvset', $userId) != getDeckInfoFromId($_POST['deckId'], 'short_name') || getSkill('vStyle', $userId) != $_POST['vStyle']) { echo "sent id " . $_POST['deckId'] . "</br>" . getDeckShortName($_POST['deckId'], ''); echo getSkill('cvset', $userId) . "</br>"; echo getSkill('vStyle', $userId) . "</br>"; } else { echo "change_success"; }
function setOwnershipvStyle($deckSN, $vStyle, $userId) { //find the id's of these in the skills table and insert into user_skills table $sProg = $deckSN . "_" . $vStyle . "_prog"; $sLevel = $deckSN . "_" . $vStyle . "_lv"; $sProgMax = $deckSN . "_" . $vStyle . "_prog_max"; setUDecksVStyle($deckSN, $userId, $vStyle); //updates user_decks ownership of vstyle setSkill($sProg, $userId, '1'); //skill needs to exist in skill table first setSkill($sLevel, $userId, '1'); setSkill($sProgMax, $userId, '100'); //later, create getInitSkillMax() to grab the deck/skill's lv 1 cap. }
<?php session_start(); include '../stats.php'; include '../words.php'; $userID = getUserID($_SESSION['username']); //echo "Before switch ".$_POST['vstyle']."<br />"; if ($_POST['vstyle'] == 'kanji') { $vstyle = 'kanjiRE'; setSkill('vstyle', $userID, 'kanjiRE'); } else { if ($_POST['vstyle'] == 'audio') { $vstyle = 'audioR'; setSkill('vstyle', $userID, 'audioR'); } else { //$vstyle = 'kanjiRE'; } } //echo "After switch $vstyle <br />"; //echo "getting skill just after setting it $userID".getSkill('vStyle',$userID) ."<br />"; //echo $vstyle; //$cvset = $_POST['cv']; //without this post, super dumb to get the uid through //$userID = $_POST['u']; include '../include/vstyle-menus.php'; include '../mc_get.php'; //echo "from mc_get into RE $userID".getSkill('vStyle',$userID) ."<br />"; include '../include/kanjiRE.php';