Select Git revision
Amrita Deb authored
Update action.php, card_form.php, controller.php, index.php, lib.php, locallib.php, mod_form.php, README.md, renderer.php, styles.css, review_form.php, view.php, version.php, backup/moodle2/backup_cardbox_activity_task.class.php, backup/moodle2/backup_cardbox_stepslib.php, backup/moodle2/restore_cardbox_stepslib.php, backup/moodle2/restore_cardbox_activity_task.class.php, classes/output/card.php, classes/output/start.php, classes/output/statistics.php, classes/output/review.php, classes/output/overview.php, classes/output/practice.php, classes/task/remind.php, db/access.php, db/install.xml, db/install.php, db/tasks.php, db/upgrade.php, db/messages.php, js/Chart.bundle.js, js/review2.js, js/overview.js, js/statistics.js, js/review.js, js/start.js, js/practice.js, model/card_selection_algorithm.php, model/cardcollection.class.php, model/card_selection_interface.php, model/card_sorting_interface.php, model/cardbox.class.php, model/card_sorting_algorithm.php, pix/icon.png, pix/icon_19.png, pix/icon_19.svg, pix/icon.svg, pix/icon_21.png, pix/icon_21.svg, pix/icon_25.png, pix/icon_25.svg, templates/card.mustache, templates/cardside.mustache, templates/options.mustache, templates/overview.mustache, templates/practice.mustache, templates/practice_answer_autocheck.mustache, templates/practice_answer_selfcheck.mustache, templates/practice_question_autocheck.mustache, templates/practice_question_selfcheck.mustache, templates/practice_start.mustache, templates/review.mustache, templates/review2.mustache, templates/statistics.mustache, lang/de/cardbox.php, lang/en/cardbox.php files
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
action.php 5.40 KiB
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* In this file, incoming AJAX request from practice.js are handled.
*
* @package mod_cardbox
* @copyright 2019 RWTH Aachen (see README.md)
* @author Anna Heynkes
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once($CFG->dirroot . '/mod/cardbox/locallib.php');
$cmid = required_param('id', PARAM_INT);
list ($course, $cm) = get_course_and_cm_from_cmid($cmid, 'cardbox');
$cardbox = $DB->get_record('cardbox', array('id'=> $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm);
require_sesskey();
$context = context_module::instance($cmid);
$action = required_param('action', PARAM_ALPHA); // ...'$action' determines what is to be done; see below.
if ($action === 'review') {
require_once($CFG->dirroot . '/mod/cardbox/classes/output/review.php');
$cardid = required_param('cardid', PARAM_INT);
$newstatus = required_param('status', PARAM_TEXT);
$nextcard = optional_param('nextcard', 0, PARAM_INT);
$dataobject = new stdClass();
$dataobject->id = $cardid;
switch($newstatus) {
case 'approve':
$dataobject->approved = '1';
$dataobject->approvedby = $USER->id;
$success = $DB->update_record('cardbox_cards', $dataobject, false);
break;
case 'reject':
$success = cardbox_delete_card($cardid);
break;
case 'skip':
$success = 1;
break;
}
if (empty($success)) {
echo json_encode(['status' => 'error', 'reason' => get_string('error:updateafterreview', 'cardbox')]); // XXX check double string entries.