Пример #1
0
function blended_get_available_items($blended)
{
    global $DB;
    $selecteditems = $DB->get_records('blended_items', array('id_blended' => $blended->id));
    $items = blended_get_calificable_items($blended->course);
    if ($selecteditems) {
        // blended has restricted items
        $filtereditems = array();
        foreach ($selecteditems as $itemrecord) {
            $filtereditems[$itemrecord->id_item] = $items[$itemrecord->id_item];
        }
        return $filtereditems;
    } else {
        // all items activated
        return $items;
    }
}
Пример #2
-1
 function definition()
 {
     global $CFG, $DB, $COURSE;
     $mform =& $this->_form;
     $key = mt_rand(0xfff, 0x7fffffff);
     $mform->addElement('hidden', 'randomkey', $key);
     $mform->setType('randomkey', PARAM_INT);
     $mform->setDefault('randomkey', $key);
     $strrequired = get_string('required', 'blended');
     // Cabecera --------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Nombre ----------------------------------------------------------------
     $mform->addElement('text', 'name', get_string('name', 'blended'), array('size' => '64'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', $strrequired, 'required', null, 'client');
     // Descripción -----------------------------------------------------------
     $this->add_intro_editor(true, get_string('description', 'blended'));
     //Metodo de identificación ----------------------------------------------
     $idmethodoptions = array(0 => get_string('coded', 'blended'), 1 => get_string('plain', 'blended'));
     $mform->addElement('select', 'idmethod', get_string("idmethod", "blended"), $idmethodoptions);
     $mform->addHelpButton('idmethod', 'idmethod', 'blended');
     $mform->setDefault('idmethod', 0);
     // Tipo Codigo de barras  ----------------------------------------------
     $idcodeoptions = array('QRCode,Q' => 'QR 2D', 'DATAMATRIX' => 'DATAMATRIX ISO/IEC 16022', 'PDF417' => 'PDF417 ISO/IEC 15438:2006', 'EAN13' => 'EAN13');
     $mform->addElement('select', 'codebartype', get_string("codebartype", "blended"), $idcodeoptions);
     $mform->addHelpButton('codebartype', 'codebartype', 'blended');
     $mform->setDefault('codebartype', 'QRCode,Q');
     // enable/disable OMR part
     $mform->addElement('checkbox', 'omrenabled', get_string('OMRenable', 'blended'), get_string('OMRenableLabel', 'blended'));
     // Número de columnas del cuestionario --------------------------------------
     $numbercols = array_combine(range(1, 4), range(1, 4));
     $mform->addElement('select', 'numcols', get_string("numbercols", "blended"), $numbercols);
     $mform->addHelpButton('numcols', 'numbercols', 'blended');
     $mform->setDefault('numcols', 2);
     // Identificador ---------------------------------------------------------
     $options1 = array('userid' => get_string('userid', 'blended'), 'idnumber' => get_string('idnumber', 'blended'));
     $options2 = array();
     if (!($options = $DB->get_records_menu("user_info_field", null, "name", "id, name"))) {
         //print('No info user fields found!');
     } else {
         foreach ($options as $id => $name) {
             //$fieldid = $DB->get_field("user_info_field","id",array("name"=>$name));
             $options2["2" . $id] = get_string("userinfo", "blended") . $name;
         }
     }
     $idtypeoptions = $options1 + $options2;
     //$idtypeoptions = array_merge($options1, $options2);
     $mform->addElement('select', 'idtype', get_string("idtype", "blended"), $idtypeoptions);
     $mform->addHelpButton('idtype', 'idtype', 'blended');
     //$mform->setDefault('idtype', "0");
     // Longitud de identificacion de usuario ----------------------------------------
     $lengthuserinfooptions = array_combine(range(2, 12), range(2, 12));
     $mform->addElement('select', 'lengthuserinfo', get_string("lengthuserinfo", "blended"), $lengthuserinfooptions);
     $mform->addHelpButton('lengthuserinfo', 'lengthuserinfo', 'blended');
     $mform->setDefault('lengthuserinfo', 8);
     // Creación de los equipos -----------------------------------------------
     $teammethodoptions = array(0 => get_string('byteacher', 'blended'), 1 => get_string('bystudents', 'blended'), 2 => get_string('bystudentswithleaders', 'blended'));
     $mform->addElement('select', 'teammethod', get_string("teammethod", "blended"), $teammethodoptions);
     $mform->addHelpButton('teammethod', 'teammethod', 'blended');
     $mform->setDefault('teammethod', 0);
     // Select items
     //
     $items = blended_get_calificable_items($COURSE);
     $selected_items = blended_get_available_items($this->current);
     if (count($items) == count($selected_items)) {
         // this is represented as no filtering
         $selected_items = array();
     }
     $optionsitems = array();
     foreach ($items as $id => $item) {
         $optionsitems[$id] = blended_get_item_name($item);
     }
     $selectitemsform = $mform->addElement('select', 'selecteditems', get_string('selectitems', 'blended'), $optionsitems);
     $mform->addHelpButton('selecteditems', 'selectitems', 'blended');
     $selectitemsform->setMultiple(true);
     $selectitemsform->setSelected(array_keys($selected_items));
     // Numero de equipos por defecto ----------------------------------------
     $teamsoptions = array_combine(range(1, TEAMS_MAX_ENTRIES), range(1, TEAMS_MAX_ENTRIES));
     $mform->addElement('select', 'numteams', get_string("defaultnumteams", "blended"), $teamsoptions);
     $mform->setDefault('numteams', 10);
     // Numero de miembros por defecto ----------------------------------------
     $nummembersoptions = array_combine(range(1, MEMBERS_MAX_ENTRIES), range(1, MEMBERS_MAX_ENTRIES));
     $mform->addElement('select', 'nummembers', get_string("defaultnummembers", "blended"), $nummembersoptions);
     $mform->addHelpButton('nummembers', 'defaultnummembers', 'blended');
     $mform->setDefault('nummembers', 4);
     // Otras caracteristicas -------------------------------------------------
     $features = new stdClass();
     $features->groups = false;
     $features->groupings = true;
     $features->groupmembersonly = true;
     $this->standard_coursemodule_elements($features);
     // buttons
     $this->add_action_buttons();
 }