query($sql); if(mysqli_num_rows($result_articles)) { while ($articleDb = mysqli_fetch_object($result_articles)) { $voc = json_decode($articleDb->value, true); $id = $articleDb->id; if($selection_new[0] == 'true' && $voc[0]['progress'] == '5') { $value_new[0]['activeLearn'] = 'true'; $value_new[0]['learnStatus'] = 'pending'; $query_contains = 1; } else { $value_new[0]['activeLearn'] = '0'; $value_new[0]['learnStatus'] = '0'; if($selection_new[1] == 'true' && ($voc[0]['progress'] == '4' || $voc[0]['progress'] == '3')) { $value_new[0]['activeLearn'] = 'true'; $value_new[0]['learnStatus'] = 'pending'; $query_contains = 1; } else { $value_new[0]['activeLearn'] = '0'; $value_new[0]['learnStatus'] = '0'; if($selection_new[2] == 'true' && ($voc[0]['progress'] == '2' || $voc[0]['progress'] == '1' || $voc[0]['progress'] == '0')) { $value_new[0]['activeLearn'] = 'true'; $value_new[0]['learnStatus'] = 'pending'; $query_contains = 1; } else { $value_new[0]['activeLearn'] = '0'; $value_new[0]['learnStatus'] = '0'; } } } $value_new[0]['1'] = $voc[0]['1']; $value_new[0]['2'] = $voc[0]['2']; $value_new[0]['progress'] = $voc[0]['progress']; $value_new_new = json_encode($value_new); $conn->query("UPDATE `VokabelBox2Content`SET `value` = '$value_new_new' WHERE `path` = '$userid/lang/$list/' AND `id` = '$id'"); } } else { die(); } if($query_contains != 1) { print("noSelection"); die(); } print("true"); } else { if($_SESSION["difficulty"] == '1') { $active_voc = $_SESSION["active-voc"]; $sql = "SELECT `value` FROM `VokabelBox2Content` WHERE `type` = 'voc' AND `path` = '$userid/lang/$list/' AND `id` = '$active_voc'"; $result_articles = $conn->query($sql); if(mysqli_num_rows($result_articles)) { while ($articleDb = mysqli_fetch_object($result_articles)) { $voc = json_decode($articleDb->value, true); if($meta == 'true') { $value_new[0]['activeLearn'] = 'true'; $value_new[0]['learnStatus'] = 'true'; $value_new[0]['1'] = $voc[0]['1']; $value_new[0]['2'] = $voc[0]['2']; if($voc[0]['progress'] <= 4) { $value_new[0]['progress'] = $voc[0]['progress'] + 1; } else { $value_new[0]['progress'] = $voc[0]['progress']; } print("true,"); } else { $value_new[0]['activeLearn'] = 'true'; $value_new[0]['learnStatus'] = 'false'; $value_new[0]['1'] = $voc[0]['1']; $value_new[0]['2'] = $voc[0]['2']; if($voc[0]['progress'] >= 1) { $value_new[0]['progress'] = $voc[0]['progress'] - 1; } else { $value_new[0]['progress'] = $voc[0]['progress']; } print("false,"); } $value_new_new = json_encode($value_new); $conn->query("UPDATE `VokabelBox2Content` SET `value` = '$value_new_new' WHERE `path` = '$userid/lang/$list/' AND `id` = '$active_voc'"); } } $false = 0; $true = 0; $sql = "SELECT `value`,`id` FROM `VokabelBox2Content` WHERE `type` = 'voc' AND `path` = '$userid/lang/$list/'"; $result_articles = $conn->query($sql); if(mysqli_num_rows($result_articles)) { while ($articleDb = mysqli_fetch_object($result_articles)) { $voc = json_decode($articleDb->value, true); $id = $articleDb->id; if($voc[0]['activeLearn'] == 'true') { $number_main++; } if($voc[0]['learnStatus'] == 'true' || $voc[0]['learnStatus'] == 'false') { $number_completed++; } if($voc[0]['learnStatus'] == 'true') { $true++; } if($voc[0]['learnStatus'] == 'false') { $false++; } } } $n = '"learnStatus":"pending"'; $sql = "SELECT `value`,`id` FROM `VokabelBox2Content` WHERE `type` = 'voc' AND `path` = '$userid/lang/$list/' AND `value` LIKE '%$n%' ORDER BY RAND() LIMIT 1"; $result_articles = $conn->query($sql); if(mysqli_num_rows($result_articles)) { while ($articleDb = mysqli_fetch_object($result_articles)) { $voc = json_decode($articleDb->value, true); $_SESSION["active-voc"] = $articleDb->id; $question = $voc[0]['1']; $right_answer = $voc[0]['2']; } } $width = ($number_completed / $number_main) * 100; $difficulty = $_SESSION["difficulty"]; $number_completed++; $question = str_replace(",", ",", $question); $right_answer = str_replace(",", ",", $right_answer); if($number_main - $number_completed == -1) { print("$number_completed/$number_main,$false - $true,$question,true,$right_answer,$width,$difficulty"); } else { print("$number_completed/$number_main,$false - $true,$question,false,$right_answer,$width,$difficulty"); } } else { // Wenn Difficulty 2 oder 3 $active_voc = $_SESSION["active-voc"]; $suggestion = htmlentities(substr($_POST["suggestion"], 0, 30), ENT_QUOTES, 'UTF-8'); $sql = "SELECT `value` FROM `VokabelBox2Content` WHERE `type` = 'voc' AND `path` = '$userid/lang/$list/' AND `id` = '$active_voc'"; $result_articles = $conn->query($sql); if(mysqli_num_rows($result_articles)) { while ($articleDb = mysqli_fetch_object($result_articles)) { $voc = json_decode($articleDb->value, true); similar_text($voc[0]['2'], $suggestion, $return); $difficulty = $_SESSION["difficulty"]; if(($voc[0]['2'] == $suggestion && $_SESSION["difficulty"] == '3') ||($return >= 85 && $_SESSION["difficulty"] == '2')) { $value_new[0]['activeLearn'] = 'true'; $value_new[0]['learnStatus'] = 'true'; $value_new[0]['1'] = $voc[0]['1']; $value_new[0]['2'] = $voc[0]['2']; if($voc[0]['progress'] <= 4) { $value_new[0]['progress'] = $voc[0]['progress'] + 1; } else { $value_new[0]['progress'] = $voc[0]['progress']; } print("true,"); } else { $value_new[0]['activeLearn'] = 'true'; $value_new[0]['learnStatus'] = 'false'; $value_new[0]['1'] = $voc[0]['1']; $value_new[0]['2'] = $voc[0]['2']; if($voc[0]['progress'] >= 1) { $value_new[0]['progress'] = $voc[0]['progress'] - 1; } else { $value_new[0]['progress'] = $voc[0]['progress']; } print("false,"); } $right_answer = $voc[0]['2']; $value_new_new = json_encode($value_new); $conn->query("UPDATE `VokabelBox2Content` SET `value` = '$value_new_new' WHERE `path` = '$userid/lang/$list/' AND `id` = '$active_voc'"); } } $false = 0; $true = 0; $sql = "SELECT `value`,`id` FROM `VokabelBox2Content` WHERE `type` = 'voc' AND `path` = '$userid/lang/$list/'"; $result_articles = $conn->query($sql); if(mysqli_num_rows($result_articles)) { while ($articleDb = mysqli_fetch_object($result_articles)) { $voc = json_decode($articleDb->value, true); $id = $articleDb->id; if($voc[0]['activeLearn'] == 'true') { $number_main++; } if($voc[0]['learnStatus'] == 'true' || $voc[0]['learnStatus'] == 'false') { $number_completed++; } if($voc[0]['learnStatus'] == 'true') { $true++; } if($voc[0]['learnStatus'] == 'false') { $false++; } } } $n = '"learnStatus":"pending"'; $sql = "SELECT `value`,`id` FROM `VokabelBox2Content` WHERE `type` = 'voc' AND `path` = '$userid/lang/$list/' AND `value` LIKE '%$n%' ORDER BY RAND() LIMIT 1"; $result_articles = $conn->query($sql); if(mysqli_num_rows($result_articles)) { while ($articleDb = mysqli_fetch_object($result_articles)) { $voc = json_decode($articleDb->value, true); $_SESSION["active-voc"] = $articleDb->id; $question = $voc[0]['1']; } } $width = ($number_completed / $number_main) * 100; $difficulty = $_SESSION["difficulty"]; $number_completed++; $question = str_replace(",", ",", $question); $right_answer = str_replace(",", ",", $right_answer); if($number_main - $number_completed == -1) { print("$number_completed/$number_main,$false - $true,$question,true,$right_answer,$width,$difficulty"); } else { print("$number_completed/$number_main,$false - $true,$question,false,$right_answer,$width,$difficulty"); } } } ?>