123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?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/>.
- /**
- * The main colab configuration form.
- *
- * @package colab
- * @copyright 2020 Your Name <you@example.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
- defined('MOODLE_INTERNAL') || die();
- require_once($CFG->dirroot.'/course/moodleform_mod.php');
- /**
- * Module instance settings form.
- *
- * @package colab
- * @copyright 2020 Your Name <you@example.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
- class mod_colab_mod_form extends moodleform_mod {
- /**
- * Defines forms elements
- */
- public function definition() {
- global $CFG;
- $mform = $this->_form;
- // Adding the "general" fieldset, where all the common settings are showed.
- $mform->addElement('header', 'general', get_string('general', 'form'));
- // Adding the standard "name" field.
- $mform->addElement('text', 'name', get_string('colabname', 'colab'), array('size' => '64'));
- if (!empty($CFG->formatstringstriptags)) {
- $mform->setType('name', PARAM_TEXT);
- } else {
- $mform->setType('name', PARAM_CLEANHTML);
- }
- $mform->addRule('name', null, 'required', null, 'client');
- $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
- $mform->addHelpButton('name', 'colabname', 'colab');
- // Adding the standard "intro" and "introformat" fields.
- if ($CFG->branch >= 29) {
- $this->standard_intro_elements();
- } else {
- $this->add_intro_editor();
- }
- // Adding the rest of colab settings, spreading all them into this fieldset
- // ... or adding more fieldsets ('header' elements) if needed for better logic.
- $mform->addElement('static', 'label1', 'colabsettings', get_string('colabsettings', 'colab'));
- $mform->addElement('header', 'colabfieldset', get_string('colabfieldset', 'colab'));
- // Add standard grading elements.
- $this->standard_grading_coursemodule_elements();
- // Add standard elements.
- $this->standard_coursemodule_elements();
- // Add standard buttons.
- $this->add_action_buttons();
- }
- function validation($data, $files) {
- global $COURSE, $DB, $CFG;
- echo 'entrada pós_criação';
- print_r($data);
- echo 'entrada files <br>';
- print_r($files);
- //encontra a ultma atividade
- $params = array('course' => $data->modulename);
- $records = $DB->get_record_sql('select max(id)+1 as ultima_ativ from {course}',$params);
- echo 'ultima atividade <br>';
- echo '1- <br>';
- echo $records -> ultima_ativ ;
- // deleta caso tenha algum registro anterior
- try {
-
- $DB->delete_records("colab_duplas", array('atividade'=>$records -> ultima_ativ));
-
- } catch (Exception $e) {
- echo 'Caught exception não foi possivel deletar duplas: ', $e->getMessage(), "\n";
- }
- //grava as duplas (teste fixo)
- try {
-
- $value-> id = 1;
- $value-> atividade = $records -> ultima_ativ ;
- $value-> par1 = 'user_test_1';
- $value-> par2 = 'user_test_2';
- $value-> obs = '';
- $DB->insert_record("colab_duplas", $value);
- } catch (Exception $e) {
- echo 'Caught exception não foi possivel gravar registo de dupla: ', $e->getMessage(), "\n";
- }
- // exit;
- return array();
- }
- }
|