Version 2
This commit is contained in:
384
temporary/pagecontent/action-learn.php
Normal file
384
temporary/pagecontent/action-learn.php
Normal file
@@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
if($meta == 'start') {
|
||||
|
||||
$difficulty = $_POST["difficulty"];
|
||||
|
||||
if($difficulty != '1' && $difficulty != '2' && $difficulty != '3') {
|
||||
die();
|
||||
}
|
||||
$_SESSION["difficulty"] = $difficulty;
|
||||
|
||||
|
||||
$selection = $_POST["selection"];
|
||||
|
||||
|
||||
$path = $userid . "/lang/" . $list . "/";
|
||||
|
||||
$selection_new = explode(",",$selection);
|
||||
|
||||
$query_contains = 0; // Variable überprüft ob Auswahl Vokabeln enthält.
|
||||
|
||||
|
||||
$sql = "SELECT `value`,`id` FROM `VokabelBox2Content` WHERE `type` = 'voc' AND `path` = '$userid/lang/$list/'";
|
||||
$result_articles = mysql_query ($sql, $ezine_db);
|
||||
if(mysql_num_rows($result_articles))
|
||||
{
|
||||
|
||||
while ($articleDb = mysql_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);
|
||||
|
||||
mysql_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 = mysql_query ($sql, $ezine_db);
|
||||
if(mysql_num_rows($result_articles))
|
||||
{
|
||||
|
||||
while ($articleDb = mysql_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);
|
||||
|
||||
mysql_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 = mysql_query ($sql, $ezine_db);
|
||||
if(mysql_num_rows($result_articles))
|
||||
{
|
||||
|
||||
while ($articleDb = mysql_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 = mysql_query ($sql, $ezine_db);
|
||||
if(mysql_num_rows($result_articles))
|
||||
{
|
||||
|
||||
while ($articleDb = mysql_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,<span>$false</span> - <span>$true</span>,$question,true,$right_answer,$width,$difficulty");
|
||||
}
|
||||
else {
|
||||
print("$number_completed/$number_main,<span>$false</span> - <span>$true</span>,$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 = mysql_query ($sql, $ezine_db);
|
||||
if(mysql_num_rows($result_articles))
|
||||
{
|
||||
|
||||
while ($articleDb = mysql_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);
|
||||
|
||||
mysql_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 = mysql_query ($sql, $ezine_db);
|
||||
if(mysql_num_rows($result_articles))
|
||||
{
|
||||
|
||||
while ($articleDb = mysql_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 = mysql_query ($sql, $ezine_db);
|
||||
if(mysql_num_rows($result_articles))
|
||||
{
|
||||
|
||||
while ($articleDb = mysql_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,<span>$false</span> - <span>$true</span>,$question,true,$right_answer,$width,$difficulty");
|
||||
}
|
||||
else {
|
||||
print("$number_completed/$number_main,<span>$false</span> - <span>$true</span>,$question,false,$right_answer,$width,$difficulty");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user