Select Git revision
BlobController.cs
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
controller.php 49.41 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/>.
/**
*
* @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
*/
defined('MOODLE_INTERNAL') || die();
define ('ENABLE_AUTOCORRECT', 0);
define ('DISABLE_AUTOCORRECT', 1);
require_once($CFG->dirroot.'/mod/cardbox/locallib.php');
if (!isset($action)) {
$action = required_param('action', PARAM_ALPHA);
}
/* *********************************************** Add a new flashcard *********************************************** */
if ($action === 'addflashcard') {
require_capability('mod/cardbox:submitcard', $context);
require_once('card_form.php');
$PAGE->set_url('/mod/cardbox/view.php', array('id' => $cm->id, 'action' => 'addflashcard'));
$returnurl = new moodle_url('/mod/cardbox/view.php', array('id' => $cmid, 'action' => 'practice'));
$actionurl = new moodle_url('/mod/cardbox/view.php', array('id' => $cmid, 'action' => 'addflashcard'));
$stringman = get_string_manager();
$strings = $stringman->load_component_strings('cardbox', 'en'); // Method gets the strings of the language files.
$PAGE->requires->strings_for_js(array_keys($strings), 'cardbox'); // Method to use the language-strings in javascript.
$PAGE->requires->js(new moodle_url("/mod/cardbox/js/addcard.js?ver=00001"));
$params = array($cmid, 1, null); // true means: the user checks their own results.
$PAGE->requires->js_init_call('addCard', $params, true);
// Contextual data to pass on to the card form.
if (empty($entry)) {
$entry = new stdClass();
$entry->id = $cmid;
$entry->course = $cm->course;
$entry->action = $action;
}
$options = array('subdirs' => 0, 'maxbytes' => 0, 'areamaxbytes' => 10485760, 'maxfiles' => 3,
'accepted_types' => array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'svg'), 'return_types' => 1 | 2);
$component = 'mod_cardbox';
$filearea = 'content';
$customdata = array('cardboxid' => $cardbox->id, 'cmid' => $cmid, 'allowautocorrection' => $cardbox->autocorrection);
$mform = new mod_cardbox_card_form(null, $customdata);
$mform->set_data($entry);
if ($mform->is_cancelled()) {