'mform1'));
*
* @author Patricia Alves Rodrigues
* @author Leônidas O. Brandão
* @version v 1.5 2013/09/19
* @package mod_iassign
* @since 2010/09/27
* @copyright iMatica (iMath) - Computer Science Dep. of IME-USP (Brazil)
*
* License
* - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Moodle core defines constant MOODLE_INTERNAL which shall be used to make sure that the script is included and not called directly.
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot . '/course/moodleform_mod.php');
require_once($CFG->dirroot . '/mod/iassign/lib.php');
/// This class create form based moodleform.
// @see /lib/formslib.php: __construct($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true, $ajaxformdata=null)
class mod_iassign_form extends moodleform {
/// Add elements to form
function definition () {
global $CFG, $COURSE, $USER, $DB, $OUTPUT; // $OUTPUT only used to get '$OUTPUT->help_icon(...)'
$mform = $this->_form;
$instance = $this->_customdata;
//D echo "
iassign_form.php: this->_customdata="; print_r($this->_customdata); echo " ";
// iGeom has special parameter 'script'
$params = array('name' => '%iGeom%', 'parent' => 0);
$igeom = $DB->get_records_sql(
"SELECT s.id, s.name, s.parent FROM {iassign_ilm} s
WHERE s.name LIKE :name AND s.parent = :parent", $params);
$id = $COURSE->cm;
foreach ($igeom as $item)
$idigeom = $item->id; // get the last id of iGeom
// Get recently used ilm id: @igor
$params = array('curso' => $COURSE->id);
$result_recent = $DB->get_record_sql(
"SELECT stm.iassign_ilmid FROM {iassign_statement} stm, {iassign} ias
WHERE stm.iassignid = ias.id AND ias.course=:curso ORDER BY stm.id DESC LIMIT 1", $params);
$all_ilm = $DB->get_records('iassign_ilm', array('enable' => 1)); // or use ./lib.php function: $all_ilm = search_iLM(1);
$iassigns = $DB->get_records('iassign_statement', array('iassignid' => $COURSE->iassignid));
if ($all_ilm) {
$ids = "";
$names = "";
$evaluates = "";
foreach ($all_ilm as $one_ilm) {
$ids .= "'" . $one_ilm->id . "',";
$names .= "'" . $one_ilm->name . "',";
$evaluates .= "'" . $one_ilm->evaluate . "',";
}
$ids .= "'0'";
$evaluates .= "'0'";
}
$name_iassigns = "";
if ($iassigns) {
foreach ($iassigns as $iassign) {
$name_iassigns .= "'" . addslashes($iassign->name) . "',"; // if the name has ' it implies close JavaScript string => error!
}
}
$name_iassigns .= "''";
$error_name = get_string('error_iassign_name', 'iassign');
// @todo Código Javascript, verificar alternativa.
$code_javascript = "
";
//-------------------------------------------------------------------------------
// Adding the "title_type_iassign" fieldset, where all the common settings are showed
// Data is insert through 'locallib.php ! action() -> new_iassign($param) : 3433/6441'
$mform->addElement('header', 'title_type_iassign', get_string('type_iassign', 'iassign'));
$type_iassign = array();
$type_iassign[1] = get_string('example', 'iassign');
$type_iassign[2] = get_string('test', 'iassign');
$type_iassign[3] = get_string('exercise', 'iassign');
$mform->addElement('select', 'type_iassign', get_string('choose_type_activity', 'iassign'), $type_iassign, array('onChange' => 'config_type(this.value);'));
$mform->setDefault('type_iassign', 3); // default type_iassign = 3
$mform->addHelpButton('type_iassign', 'helptypeiassign', 'iassign');
//-------------------------------------------------------------------------------
// Adding the "data_activity" fieldset, where all the common settings are showed
$mform->addElement('header', 'data_activity', get_string('data_activity', 'iassign'));
$mform->addElement('static', 'author', get_string('author_id', 'iassign'));
$mform->addElement('static', 'author_modified', get_string('author_id_modified', 'iassign'));
// Adding the standard "name" field
$mform->addElement('text', 'name', get_string('iassigntitle', 'iassign'), array('size' => '55', 'onChange' => 'confirm_name(this.value);'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', get_string('required', 'iassign'), 'required');
// Adding the standard "proposition" field
//moodle2: $mform->addElement('htmleditor', 'proposition', get_string('proposition', 'iassign'));
$mform->addElement('editor', 'proposition', get_string('proposition', 'iassign')); //moodle 3
$mform->setType('proposition', PARAM_RAW);
$mform->addRule('proposition', get_string('required', 'iassign'), 'required');
//-----------------------------------------------------------------------------
// Adding the "interactivy_learning_module" fieldset, where all the common settings are showed
$mform->addElement('header', 'interactivy_learning_module', get_string('interactivy_learning_module', 'iassign'));
$mform->setExpanded('interactivy_learning_module');
// Search iLM registered in the database
// Field : 'iassign_ilmid'
// $ilms = search_iLM(1);
$ilms = $all_ilm;
//TODO Trick: was difficult to use 'mform->addGroup(...)', then I made by hand