Exemplo n.º 1
0
    function definition_after_data() {
        global $DB, $CFG;
        $hierarchy = new hierarchy();
        $mform = $this->_form;
        $sid = $mform->getElementValue('schoolid');

        if (isset($sid) && !empty($sid) && $sid[0] > 0) {
            $resource = cobalt_resources::get_instance();
            $building = $hierarchy->get_records_cobaltselect_menu('local_building', "schoolid=$sid[0] AND visible=1", null, '', 'id,fullname', get_string('select', 'local_classroomresources'));
            $one = $mform->createElement('select', 'buildingid', get_string('buildingid', 'local_classroomresources'), $building);
            $mform->insertElementBefore($one, 'beforefloor');
            $mform->addRule('buildingid', get_string('required'), 'required', null, 'client');
        }
        if (isset($one)) {
            $bid = $mform->getElementValue('buildingid');

            if (isset($bid) && !empty($bid) && $bid[0] > 0) {
                $resource = cobalt_resources::get_instance();
                $floor = $hierarchy->get_records_cobaltselect_menu('local_floor', "buildingid=$bid[0] AND visible=1", null, '', 'id,fullname', get_string('select', 'local_classroomresources'));
                $two = $mform->createElement('select', 'floorid', get_string('floorname', 'local_classroomresources'), $floor);
                $mform->insertElementBefore($two, 'beforeclass');
                $mform->addRule('floorid', get_string('required'), 'required', null, 'client');
            }
        }
        if (isset($two)) {
            $sid = $mform->getElementValue('schoolid');
            $fid = $mform->getElementValue('floorid');
            if (isset($fid) && !empty($fid) && $fid[0] > 0) {
                $resource = cobalt_resources::get_instance();
                $classroom = $hierarchy->get_records_cobaltselect_menu('local_classroom', "floorid=$fid[0] AND visible=1", null, '', 'id,fullname', get_string('select', 'local_classroomresources'));
                /*
                 * ###Bugreport #  classroom management
                 * @hemalatha c arun<*****@*****.**>
                 * (Resolved) adding proper addrule method for form field classroomid.
                 */
                $three = $mform->createElement('select', 'classroomid', get_string('classroomid', 'local_classroomresources'), $classroom);
                $mform->insertElementBefore($three, 'beforeresource');
                $mform->addRule('classroomid', get_string('required'), 'required', null, 'client');



                $resourcelist = $hierarchy->get_records_cobaltselect_menu('local_resource', "schoolid=$sid[0] AND visible=1", null, '', 'id,fullname', get_string('select', 'local_classroomresources'));
                $a = $mform->createElement('select', 'resourceid', get_string('resourceid', 'local_classroomresources'), $resourcelist);
                $mform->insertElementBefore($a, 'beforer');
                $b = $mform->getElement('resourceid')->setMultiple(true);
                $mform->addRule('resourceid', get_string('required'), 'required', null, 'client');
            }
        }
    }
Exemplo n.º 2
0
$PAGE->set_url('/local/classroomresources/view.php');
$PAGE->set_pagelayout('admin');
require_login();
if (!has_capability('local/classroomresources:view', $systemcontext)) {
    print_error('You dont have permissions');
}
$PAGE->set_context($systemcontext);
$PAGE->set_heading(get_string('pluginname', 'local_classroomresources'));
$PAGE->navbar->add(get_string('pluginname', 'local_classroomresources'), new moodle_url('/local/classroomresources/view.php'));
$PAGE->navbar->add(get_string('rview', 'local_classroomresources'));
echo $OUTPUT->header();

echo $OUTPUT->heading(get_string('manage', 'local_classroomresources'));
$hierarchy = new hierarchy();
$currenttab = 'viewr';
$resource = cobalt_resources::get_instance();

$resource->resource_tabs($currenttab, $id = -1);
if (isset($CFG->allowframembedding) and ! $CFG->allowframembedding) {
    echo $OUTPUT->box(get_string('assign', 'local_classroomresources'));
}
$list = $resource->assignedresourcelist();
if (empty($list)) {
    echo get_string('resounotassinanysch', 'local_classroomresources');
} else {
    $data = array();
    foreach ($list as $resour) {
        $result = array();
        $result[] = $DB->get_field('local_school', 'fullname', array('id' => $resour->schoolid));
        $result[] = $DB->get_field('local_building', 'fullname', array('id' => $resour->buildingid));
        $result[] = $DB->get_field('local_floor', 'fullname', array('id' => $resour->floorid));
Exemplo n.º 3
0
 /**
  * We are using singleton for this class 
  * @method get_instance
  * @todo get object for cobalt_resources class
  * @return object of this class
  * */
 public static function get_instance() {
     if (!self :: $resource) {
         self :: $resource = new cobalt_resources();
     }
     return self :: $resource;
 }