. /** * Handles AJAX requests for the customcert module. * * @package mod_customcert * @copyright 2013 Mark Nelson * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once(__DIR__ . '/../../config.php'); if (!defined('AJAX_SCRIPT')) { define('AJAX_SCRIPT', true); } $tid = required_param('tid', PARAM_INT); $values = required_param('values', PARAM_RAW); $values = json_decode($values); // Make sure the template exists. $template = $DB->get_record('customcert_templates', array('id' => $tid), '*', MUST_EXIST); // Set the template. $template = new \mod_customcert\template($template); // Perform checks. if ($cm = $template->get_cm()) { $courseid = $cm->course; require_login($courseid, false, $cm); } else { require_login(); } // Make sure the user has the required capabilities. $template->require_manage(); // Loop through the data. foreach ($values as $value) { $element = new stdClass(); $element->id = $value->id; $element->posx = $value->posx; $element->posy = $value->posy; $DB->update_record('customcert_elements', $element); }