<?php session_start(); require_once '../models/database.php'; $db = new DatabaseConnector($_SESSION['user_id']); $plan = $_POST['plan'] == "true" ? true : false; $steps = json_decode($_POST['steps']); $direction = $_POST['direction']; //Store options to database $options = ["plan" => $plan, "direction" => $direction, "steps" => $steps]; $db->saveOptions($options); $_SESSION['count'] = $db->prepareLearnVocables($plan, $steps); $_SESSION['direction'] = $direction; $_SESSION['plan'] = $plan; //Reset result counts $_SESSION['right_c'] = 0; $_SESSION['wrong_c'] = 0; $_SESSION['mastered_c'] = 0; $db->setResultCount("right_c", 0); $db->setResultCount("wrong_c", 0); $db->setResultCount("mastered_c", 0);
<?php session_start(); require_once '../models/database.php'; require_once '../models/vocable.php'; require_once '../models/lesson.php'; # This script calculates the next_date field for right vocs and resets wrong ones. # It returns all information that is needed for the javascript to update the site with new vocs, # that is: own_/foreign_language, lesson, step, index $db = new DatabaseConnector($_SESSION['user_id']); if (isset($_POST['result'])) { $db->scheduleVoc($_SESSION['current_id'], $_POST['result'], $_SESSION['plan']); if ($_POST['result'] == "right") { $_SESSION['right_c']++; $db->setResultCount('right_c', $_SESSION['right_c']); if ($db->getVocById($_SESSION['current_id'])->getStep() == 6) { $_SESSION['mastered_c']++; $db->setResultCount('mastered_c', $_SESSION['mastered_c']); } } elseif ($_POST['result'] == "wrong") { $_SESSION['wrong_c']++; $db->setResultCount('wrong_c', $_SESSION['wrong_c']); } } # Now return the next vocable $new_voc = $db->getNextVocable(); if (!$new_voc) { die("end"); } $_SESSION['current_id'] = $new_voc->getId(); //shuffle based on direction setting