Ejemplo n.º 1
0
 /**
  * Override this method to return the main pulldown option
  * @return array List of options keyed on id
  */
 function get_main_options()
 {
     global $USER;
     $courses_array = array('0' => get_string('selectacourse', 'block_curr_admin'));
     // Fetch array of allowed classes
     $contexts = get_contexts_by_capability_for_user('class', 'block/php_report:view', $USER->id);
     if ($records = cmclass_get_listing('crsname', 'ASC', 0, 0, '', '', 0, false, $contexts)) {
         $allowed_courses = array();
         foreach ($records as $record) {
             if (!in_array($record->courseid, $allowed_courses)) {
                 $allowed_courses[] = $record->courseid;
             }
         }
         sort($allowed_courses);
         // Fetch array of all courses
         $course_list = course_get_listing('name', 'ASC', 0, 0, '', '');
         foreach ($course_list as $course_obj) {
             // Only show courses that are associated with an allowed class
             if (in_array($course_obj->id, $allowed_courses)) {
                 $courses_array[$course_obj->id] = strlen($course_obj->name) > 80 ? substr($course_obj->name, 0, 80) . '...' : $course_obj->name;
             }
         }
     }
     return $courses_array;
 }
Ejemplo n.º 2
0
 /**
  * Test course search.
  */
 public function test_coursesearch()
 {
     $this->load_csv_data();
     $namesearch = 'Test';
     $alpha = 'T';
     $courses = course_get_listing('crs.name', 'ASC', 0, 20, $namesearch, $alpha);
     $this->assertInternalType('array', $courses);
     $this->assertArrayHasKey(100, $courses);
     $this->assertInternalType('object', $courses[100]);
     $expected = array('id' => 100, 'name' => 'Test Course', 'code' => '__test_course_code__', 'idnumber' => '__test__course__', 'syllabus' => 'Syllabus', 'documents' => 'Documents', 'lengthdescription' => 'Length Description', 'length' => '5', 'credits' => '1', 'environmentid' => '1', 'cost' => '100', 'version' => '1');
     foreach ($expected as $key => $val) {
         $this->assertObjectHasAttribute($key, $courses[100]);
         $this->assertEquals($val, $courses[100]->{$key});
     }
 }
Ejemplo n.º 3
0
 function action_default()
 {
     // Get parameters
     $sort = optional_param('sort', 'name', PARAM_ALPHA);
     $dir = optional_param('dir', 'ASC', PARAM_ALPHA);
     $page = optional_param('page', 0, PARAM_INT);
     $perpage = optional_param('perpage', 30, PARAM_INT);
     // how many per page
     $namesearch = trim(optional_param('search', '', PARAM_TEXT));
     $alpha = optional_param('alpha', '', PARAM_ALPHA);
     // Define columns
     $columns = array('name' => get_string('course_name', 'block_curr_admin'), 'code' => get_string('course_code', 'block_curr_admin'), 'envname' => get_string('environment', 'block_curr_admin'), 'version' => get_string('course_version', 'block_curr_admin'), 'curricula' => get_string('course_curricula', 'block_curr_admin'));
     $items = course_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, coursepage::get_contexts('block/curr_admin:course:view'));
     $numitems = course_count_records($namesearch, $alpha, coursepage::get_contexts('block/curr_admin:course:view'));
     coursepage::get_contexts('block/curr_admin:course:edit');
     coursepage::get_contexts('block/curr_admin:course:delete');
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
 }
 /**
  * Specifies available report filters
  * (empty by default but can be implemented by child class)
  *
  * @param   boolean  $init_data  If true, signal the report to load the
  *                               actual content of the filter objects
  *
  * @return  array                The list of available filters
  */
 function get_filters($init_data = true)
 {
     $courses = array();
     $contexts = get_contexts_by_capability_for_user('course', $this->access_capability, $this->userid);
     $course_list = course_get_listing('name', 'ASC', 0, 0, '', '', $contexts);
     foreach ($course_list as $course_obj) {
         $courses[$course_obj->id] = $course_obj->name;
     }
     $optcol1_choices = array('1' => get_string('yes', $this->lang_file), '0' => get_string('no', $this->lang_file));
     $optcol2_choices = array('1' => get_string('yes', $this->lang_file), '0' => get_string('no', $this->lang_file));
     return array(new generalized_filter_entry('sccc', 'crs', 'id', get_string('filter_courses', $this->lang_file), false, 'simpleselect', array('choices' => $courses, 'numeric' => true, 'anyvalue' => get_string('allcourses', $this->lang_file), 'help' => array('sitewide_course_completion_course_help', get_string('filter_courses', $this->lang_file), 'block_php_report'))), new generalized_filter_entry('sccts', '', '', '', false, 'radiobuttons', array('choices' => $optcol1_choices, 'checked' => '0', 'heading' => get_string('filter_users_time_spent', $this->lang_file), 'help' => array('sitewide_course_completion_time_help', get_string('filter_users_time_spent', $this->lang_file), 'block_php_report'))), new generalized_filter_entry('sccg', '', '', '', false, 'radiobuttons', array('choices' => $optcol2_choices, 'checked' => '0', 'heading' => get_string('filter_users_grade', $this->lang_file), 'help' => array('sitewide_course_completion_grade_help', get_string('filter_users_grade', $this->lang_file), 'block_php_report'))), new generalized_filter_entry('sccdr', 'clsenr', 'completetime', get_string('filter_date_range', $this->lang_file), false, 'date', array('help' => array('sitewide_course_completion_date_help', get_string('filter_date_range', $this->lang_file), 'block_php_report'))));
 }
Ejemplo n.º 5
0
    } else {
        $ids[] = clean_param($dirtyids, PARAM_INT);
    }
} else {
    $ids[] = 0;
}
// Must have blank value as the default here (instead of zero) or it breaks the gas guage report
$choices_array = array(array('', get_string('anyvalue', 'filters')));
if (sizeof($ids) > 0) {
    $contexts = get_contexts_by_capability_for_user('course', 'block/php_report:view', $USER->id);
    foreach ($ids as $id) {
        $records = false;
        if ($id > 0) {
            $records = curriculumcourse_get_listing($id, 'crs.name');
            $idfield = 'courseid';
            $namefield = 'coursename';
        } else {
            if ($id == 0) {
                $records = course_get_listing();
                $idfield = 'id';
                $namefield = 'name';
            }
        }
        if (is_array($records)) {
            foreach ($records as $record) {
                $choices_array[] = array($record->id, $record->{$namefield});
            }
        }
    }
}
echo json_encode($choices_array);
Ejemplo n.º 6
0
 function definition()
 {
     global $USER, $CFG, $COURSE, $CURMAN;
     parent::definition();
     if (!empty($this->_customdata['obj'])) {
         $obj = $this->_customdata['obj'];
         if (empty($obj->startdate) || $obj->startdate == 0) {
             $this->set_data(array('disablestart' => '1'));
         }
         if (empty($obj->enddate) || $obj->enddate == 0) {
             $this->set_data(array('disableend' => '1'));
         }
         if (isset($obj->starttimeminute) && isset($obj->starttimehour)) {
             $this->set_data(array('starttime' => array('minute' => $obj->starttimeminute, 'hour' => $obj->starttimehour)));
         }
         if (isset($obj->endtimeminute) && isset($obj->endtimehour)) {
             $this->set_data(array('endtime' => array('minute' => $obj->endtimeminute, 'hour' => $obj->endtimehour)));
         }
     }
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     // If there is no custom data for the course, create some
     if (empty($this->_customdata['obj']->course->name) || empty($this->_customdata['obj']->id)) {
         $courses = array();
         if (!empty($USER->id)) {
             $contexts = get_contexts_by_capability_for_user('course', 'block/curr_admin:class:create', $USER->id);
             // get listing of available ELIS courses
             $courses = course_get_listing('name', 'ASC', 0, 0, '', '', $contexts);
         }
         // Add course select
         $attributes = array('onchange' => 'update_trk_multiselect(); ');
         $selections = array();
         if (!empty($courses)) {
             foreach ($courses as $course) {
                 $selections[$course->id] = '(' . $course->idnumber . ')' . $course->name;
             }
         }
         $mform->addElement('select', 'courseid', get_string('course', 'block_curr_admin') . ':', $selections, $attributes);
         $mform->setHelpButton('courseid', array('cmclassform/course', get_string('course', 'block_curr_admin'), 'block_curr_admin'));
         $firstcourse = reset($courses);
         $this->firstcourse = $firstcourse;
         if (false !== $firstcourse && empty($this->_customdata['obj']->id)) {
             $this->add_track_multi_select($firstcourse->id);
         } elseif (!empty($courses)) {
             $this->add_track_multi_select($this->_customdata['obj']->courseid);
         }
     } else {
         $extra_params = array();
         $mform->addElement('static', 'courseid', get_string('course', 'block_curr_admin') . ':');
         // Get current action and set param accordingly
         $current_action = optional_param('action', 'view', PARAM_ALPHA);
         $extra_params['action'] = $current_action;
         $extra_params['s'] = 'crs';
         // Want to set the url for the course
         $extra_params['id'] = $this->_customdata['obj']->courseid;
         // Course id
         $course_url = $this->get_moodle_url($extra_params);
         $course_name = '(' . $this->_customdata['obj']->course->idnumber . ')' . '<a href="' . $course_url . '" >' . $this->_customdata['obj']->course->name . '</a>';
         $this->set_data(array('courseid' => $course_name));
         $mform->setHelpButton('courseid', array('cmclassform/course', get_string('course', 'block_curr_admin'), 'block_curr_admin'));
         $this->add_track_multi_select($this->_customdata['obj']->courseid);
     }
     if (!empty($this->_customdata['obj']->courseid)) {
         $mform->freeze('courseid');
     } else {
         $mform->addRule('courseid', get_string('required'), 'required', NULL, 'client');
     }
     // Done adding course select
     //get_string('general');
     $mform->addElement('text', 'idnumber', get_string('class_idnumber', 'block_curr_admin') . ':');
     $mform->addRule('idnumber', get_string('required'), 'required', NULL, 'client');
     $mform->setType('idnumber', PARAM_TEXT);
     $mform->setHelpButton('idnumber', array('cmclassform/idnumber', get_string('class_idnumber', 'block_curr_admin'), 'block_curr_admin'));
     $mform->addElement('date_selector', 'startdate', get_string('class_startdate', 'block_curr_admin') . ':', array('optional' => true, 'disabled' => 'disabled'));
     $mform->setHelpButton('startdate', array('cmclassform/startdate', get_string('class_startdate', 'block_curr_admin'), 'block_curr_admin'));
     $mform->addElement('date_selector', 'enddate', get_string('class_enddate', 'block_curr_admin') . ':', array('optional' => true));
     // They may very likely be a much better way of checking for this...
     if (empty($obj->starttimehour) and empty($obj->starttimeminute)) {
         $mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => $CURMAN->config->time_format_12h));
     } else {
         $mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => $CURMAN->config->time_format_12h));
     }
     $mform->setHelpButton('starttime', array('cmclassform/starttime', get_string('class_starttime', 'block_curr_admin'), 'block_curr_admin'));
     // Do the same thing for the endtime
     if (empty($obj->endtimehour) and empty($obj->endtimeminute)) {
         $mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => $CURMAN->config->time_format_12h));
     } else {
         $mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => $CURMAN->config->time_format_12h));
     }
     $mform->addElement('text', 'maxstudents', get_string('class_maxstudents', 'block_curr_admin') . ':');
     $mform->setType('maxstudents', PARAM_INT);
     $mform->setHelpButton('maxstudents', array('cmclassform/maxstudents', get_string('class_maxstudents', 'block_curr_admin'), 'block_curr_admin'));
     // Environment selector
     $envs = environment_get_listing();
     $envs = $envs ? $envs : array();
     $o_envs = array(get_string('none', 'block_curr_admin'));
     foreach ($envs as $env) {
         $o_envs[$env->id] = $env->name;
     }
     $mform->addElement('select', 'environmentid', get_string('environment', 'block_curr_admin') . ':', $o_envs);
     $mform->setHelpButton('environmentid', array('cmclassform/environment', get_string('environment', 'block_curr_admin'), 'block_curr_admin'));
     // Course selector
     if (empty($this->_customdata['obj']->moodlecourseid)) {
         $this->add_moodle_course_select();
     } else {
         global $CURMAN;
         $coursename = $CURMAN->db->get_field('course', 'fullname', 'id', $this->_customdata['obj']->moodlecourseid);
         $mform->addElement('static', 'class_attached_course', get_string('class_attached_course', 'block_curr_admin') . ':', "<a href=\"{$CFG->wwwroot}/course/view.php?id={$this->_customdata['obj']->moodlecourseid}\">{$coursename}</a>");
         $mform->setHelpButton('class_attached_course', array('cmclassform/moodlecourseid', get_string('moodlecourse', 'block_curr_admin'), 'block_curr_admin'));
         $mform->addElement('hidden', 'moodlecourseid');
     }
     $mform->addElement('checkbox', 'enrol_from_waitlist', get_string('waitlistenrol', 'block_curr_admin') . ':');
     $mform->setHelpButton('enrol_from_waitlist', array('cmclassform/waitlistenrol', get_string('waitlistenrol', 'block_curr_admin'), 'block_curr_admin'));
     // custom fields
     $fields = field::get_for_context_level('class');
     $fields = $fields ? $fields : array();
     $lastcat = null;
     $context = isset($this->_customdata['obj']) && isset($this->_customdata['obj']->id) ? get_context_instance(context_level_base::get_custom_context_level('class', 'block_curr_admin'), $this->_customdata['obj']->id) : get_context_instance(CONTEXT_SYSTEM);
     require_once CURMAN_DIRLOCATION . '/plugins/manual/custom_fields.php';
     foreach ($fields as $rec) {
         $field = new field($rec);
         if (!isset($field->owners['manual'])) {
             continue;
         }
         if ($lastcat != $rec->categoryid) {
             $lastcat = $rec->categoryid;
             $mform->addElement('header', "category_{$lastcat}", htmlspecialchars($rec->categoryname));
         }
         manual_field_add_form_element($this, $context, $field);
     }
     $this->add_action_buttons();
 }
Ejemplo n.º 7
0
        $ids[] = clean_param($dirtyids, PARAM_INT);
    }
} else {
    $ids[] = 0;
}
// Must have blank value as the default here (instead of zero) or it breaks the gas guage report
$choices_array = array(array('', get_string('anyvalue', 'filters')));
if (!empty($ids)) {
    $contexts = get_contexts_by_capability_for_user('course', 'local/elisreports:view', $USER->id);
    foreach ($ids as $id) {
        $records = false;
        if ($id > 0) {
            $records = curriculumcourse_get_listing($id, 'crs.name', 'ASC', 0, 0, '', '', array('contexts' => $contexts));
            $idfield = 'courseid';
            $namefield = 'coursename';
        } else {
            if ($id == 0) {
                $records = course_get_listing('crs.name', 'ASC', 0, 0, '', '', $contexts);
                $idfield = 'id';
                $namefield = 'name';
            }
        }
        if (is_array($records) && !empty($records) || $records instanceof Iterator && $records->valid() === true) {
            foreach ($records as $record) {
                $choices_array[] = array($record->{$idfield}, $record->{$namefield});
            }
        }
        unset($records);
    }
}
echo json_encode($choices_array);
Ejemplo n.º 8
0
 /**
  * Adds fields to this form which are relevant to the course, either
  * new or old, that a class is being requested for, including any associated
  * validation rules
  */
 protected function add_course_info()
 {
     global $PAGE, $USER;
     $PAGE->requires->js('/blocks/courserequest/forms.js');
     $mform =& $this->_form;
     $mform->addElement('header', 'courseheader', get_string('createcourseheader', 'block_courserequest'));
     $courses = array(0 => get_string('newcourse', 'block_courserequest'));
     /*
      * Get all courses the current user has access to:
      * Access is allowed if you have the correct capability at the system, curriculum, or course level
      */
     $course_contexts = get_contexts_by_capability_for_user('course', 'block/courserequest:request', $USER->id);
     // this will actually handle all cases because it handles curricula explicitly
     $eliscourses = course_get_listing('crs.name', 'ASC', 0, 0, '', '', $course_contexts);
     $eliscourses = $eliscourses ? $eliscourses : array();
     foreach ($eliscourses as $course) {
         $courses[$course->id] = '(' . $course->idnumber . ') ' . $course->name;
     }
     $mform->addElement('select', 'courseid', get_string('course', 'block_courserequest'), $courses, array('onchange' => 'handle_course_change()'));
     // If this user has approval permission then let's give them the class id field so we can skip the approval page
     $syscontext = context_system::instance();
     if (has_capability('block/courserequest:approve', $syscontext)) {
         // indicate that course idnumber is required
         $label = '<span class="required">' . get_string('courseidnumber', 'block_courserequest') . '*</span>';
         $mform->addElement('text', 'crsidnumber', $label);
         $mform->addRule('crsidnumber', null, 'maxlength', 100);
         $mform->setType('crsidnumber', PARAM_TEXT);
         $mform->disabledIf('crsidnumber', 'courseid', 'gt', '0');
     }
     // indicate that course name is required
     $label = '<span class="required">' . get_string('title', 'block_courserequest') . '*</span>';
     $mform->addElement('text', 'title', $label);
     $mform->setType('title', PARAM_RAW);
     // only needed for new courses
     $mform->disabledIf('title', 'courseid', 'gt', '0');
     $usecoursefields = get_config('block_courserequest', 'use_course_fields');
     if (!empty($usecoursefields)) {
         // add course-level custom fields to the interface
         $this->add_custom_fields('course', true);
     }
 }
Ejemplo n.º 9
0
 function definition()
 {
     global $USER, $CFG, $DB, $PAGE;
     parent::definition();
     if (!empty($this->_customdata['obj'])) {
         $obj = $this->_customdata['obj'];
         if (empty($obj->startdate) || $obj->startdate == 0) {
             $this->set_data(array('disablestart' => '1'));
         }
         if (empty($obj->enddate) || $obj->enddate == 0) {
             $this->set_data(array('disableend' => '1'));
         }
         if (isset($obj->starttimeminute) && isset($obj->starttimehour) && $obj->starttimeminute < 61 && $obj->starttimehour < 25) {
             $this->set_data(array('starttime' => array('minute' => $obj->starttimeminute, 'hour' => $obj->starttimehour)));
         }
         if (isset($obj->endtimeminute) && isset($obj->endtimehour) && $obj->endtimeminute < 61 && $obj->endtimehour < 25) {
             $this->set_data(array('endtime' => array('minute' => $obj->endtimeminute, 'hour' => $obj->endtimehour)));
         }
     }
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     // If there is no custom data for the course, create some
     if (empty($this->_customdata['obj']->course->name) || empty($this->_customdata['obj']->id)) {
         $courses = array();
         if (!empty($USER->id)) {
             // This is necessary for creating a new class instance but will prevent a parent course from appearing
             // when the user has class edit permissions but not class creation permission -- ELIS-5954
             $contexts = get_contexts_by_capability_for_user('course', 'local/elisprogram:class_create', $USER->id);
             // get listing of available ELIS courses
             $courses = course_get_listing('name', 'ASC', 0, 0, '', '', $contexts);
             // Detect if we are editing an existing class instance by checking for an value in the 'id' element
             $elm = $mform->_elements[$mform->_elementIndex['id']];
             $id = $elm->getValue();
             if (!empty($id)) {
                 // Make sure that the parent course for this class is always included otherwise the display is messed up
                 // and hitting the form Cancel button causes a DB error -- ELIS-5954
                 $pmclass = new pmclass($id);
                 $courses = array_merge($courses, course_get_listing('name', 'ASC', 0, 0, $pmclass->course->idnumber));
             }
         }
         // Add course select
         $attributes = array('onchange' => 'update_trk_multiselect(); update_crs_template();');
         $selections = array();
         if (!empty($courses)) {
             foreach ($courses as $course) {
                 $selections[$course->id] = '(' . $course->idnumber . ')' . $course->name;
             }
         }
         $mform->addElement('select', 'courseid', get_string('course', 'local_elisprogram') . ':', $selections, $attributes);
         $mform->addHelpButton('courseid', 'pmclassform:course', 'local_elisprogram');
         $firstcourse = reset($courses);
         $this->firstcourse = $firstcourse;
         if (false !== $firstcourse && empty($this->_customdata['obj']->id)) {
             $this->add_track_multi_select($firstcourse->id);
         } elseif (!empty($courses)) {
             $this->add_track_multi_select($this->_customdata['obj']->courseid);
         }
     } else {
         $extra_params = array();
         $mform->addElement('static', 'courseid', get_string('course', 'local_elisprogram') . ':');
         // Get current action and set param accordingly
         $current_action = optional_param('action', 'view', PARAM_ALPHA);
         $extra_params['action'] = $current_action;
         $extra_params['s'] = 'crs';
         // Want to set the url for the course
         $extra_params['id'] = $this->_customdata['obj']->courseid;
         // Course id
         $course_url = $this->get_moodle_url($extra_params);
         $course_name = '(' . $this->_customdata['obj']->course->idnumber . ')' . '<a href="' . $course_url . '" >' . $this->_customdata['obj']->course->name . '</a>';
         $this->set_data(array('courseid' => $course_name));
         $mform->addHelpButton('courseid', 'pmclassform:course', 'local_elisprogram');
         $this->add_track_multi_select($this->_customdata['obj']->courseid);
     }
     if (!empty($this->_customdata['obj']->courseid)) {
         $mform->freeze('courseid');
     } else {
         $mform->addRule('courseid', get_string('required'), 'required', NULL, 'client');
     }
     // Done adding course select
     // Set any associated Moodle course for this class instance
     if (empty($this->_customdata['obj']->moodlecourseid) && !empty($this->_customdata['obj']->id)) {
         $this->_customdata['obj']->moodlecourseid = moodle_get_course($this->_customdata['obj']->id);
     }
     $mform->addElement('text', 'idnumber', get_string('class_idnumber', 'local_elisprogram') . ':');
     $mform->setType('idnumber', PARAM_TEXT);
     $mform->addRule('idnumber', get_string('required'), 'required', NULL, 'client');
     $mform->addRule('idnumber', null, 'maxlength', 100, 'client');
     $mform->addHelpButton('idnumber', 'pmclassform:class_idnumber', 'local_elisprogram');
     $mform->addElement('date_selector', 'startdate', get_string('class_startdate', 'local_elisprogram') . ':', array('optional' => true, 'disabled' => 'disabled'));
     $mform->addHelpButton('startdate', 'pmclassform:class_startdate', 'local_elisprogram');
     $mform->addElement('date_selector', 'enddate', get_string('class_enddate', 'local_elisprogram') . ':', array('optional' => true));
     if (!isset($obj->starttimehour) || $obj->starttimehour >= 25 || !isset($obj->starttimeminute) || $obj->starttimeminute >= 61) {
         $mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'local_elisprogram') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => elis::$config->local_elisprogram->time_format_12h));
     } else {
         $mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'local_elisprogram') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => elis::$config->local_elisprogram->time_format_12h));
     }
     $mform->addHelpButton('starttime', 'pmclassform:class_starttime', 'local_elisprogram');
     // Do the same thing for the endtime
     if (!isset($obj->endtimehour) || $obj->endtimehour >= 25 || !isset($obj->endtimeminute) || $obj->endtimeminute >= 61) {
         $mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'local_elisprogram') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => elis::$config->local_elisprogram->time_format_12h));
     } else {
         $mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'local_elisprogram') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => elis::$config->local_elisprogram->time_format_12h));
     }
     $mform->addElement('text', 'maxstudents', get_string('class_maxstudents', 'local_elisprogram') . ':');
     $mform->setType('maxstudents', PARAM_INT);
     $mform->addHelpButton('maxstudents', 'pmclassform:class_maxstudents', 'local_elisprogram');
     // Course selector
     if (empty($this->_customdata['obj']->moodlecourseid)) {
         $this->add_moodle_course_select();
     } else {
         $PAGE->requires->js('/local/elisprogram/js/classform.js');
         $courseSelected = array();
         $coursename = $DB->get_field('course', 'fullname', array('id' => $this->_customdata['obj']->moodlecourseid));
         $courseSelected[] = $mform->createElement('static', 'class_attached_course', get_string('class_attached_course', 'local_elisprogram') . ':', "<a href=\"{$CFG->wwwroot}/course/view.php?id={$this->_customdata['obj']->moodlecourseid}\">{$coursename}</a>");
         //only show checkbox if current action is edit
         $current_action = optional_param('action', 'view', PARAM_ALPHA);
         if ($current_action == 'edit') {
             $options = array();
             //set group to null
             $options['group'] = null;
             $options['onclick'] = "return class_confirm_unlink(this,'" . get_string('class_unlink_confirm', 'local_elisprogram') . "')";
             $courseSelected[] = $mform->createElement('advcheckbox', 'unlink_attached_course', get_string('class_unlink_attached_course', 'local_elisprogram') . ':', get_string('class_unlink_attached_course', 'local_elisprogram'), $options);
         }
         $mform->addGroup($courseSelected, 'courseSelected', get_string('class_attached_course', 'local_elisprogram') . ':');
         $mform->addHelpButton('courseSelected', 'pmclassform:moodlecourse', 'local_elisprogram');
         $mform->addElement('hidden', 'moodlecourseid');
         $mform->setType('moodlecourseid', PARAM_INT);
     }
     $mform->addElement('advcheckbox', 'enrol_from_waitlist', get_string('waitlistenrol', 'local_elisprogram') . ':');
     $mform->addHelpButton('enrol_from_waitlist', 'pmclassform:waitlistenrol', 'local_elisprogram');
     // custom fields
     $this->add_custom_fields('class', 'local/elisprogram:class_edit', 'local/elisprogram:class_view', 'course');
     $this->add_action_buttons();
 }
 /**
  * Specifies available report filters for the page value
  *
  * @return  generalized_filter_entry array  The list of available filters
  */
 function get_page_value_filters()
 {
     //filter by CM course the current user has access to
     $this->require_dependencies();
     $contexts = get_contexts_by_capability_for_user('course', $this->access_capability, $this->userid);
     $course_choices = array();
     if ($listing = course_get_listing('crs.name', 'ASC', 0, 0, '', '', $contexts)) {
         foreach ($listing as $element) {
             $course_choices[$element->id] = $element->name;
         }
     }
     $course_options = array('choices' => $course_choices, 'numeric' => true);
     $course_label = get_string('filter_course', 'rlreport_course_completion_gas_gauge');
     return array(new generalized_filter_entry('course', '', 'id', $course_label, false, 'simpleselect', $course_options));
 }
Ejemplo n.º 11
0
 public function create_corequisite_form($formid = '', $extraclass = '', $rows = '2', $cols = '40')
 {
     require_once elispm::file('coursepage.class.php');
     $config_data = array();
     $config_data['formid'] = $formid;
     $config_data['rows'] = $rows;
     $config_data['cols'] = $cols;
     $courseListing = course_get_listing();
     unset($courseListing[$this->courseid]);
     if (!empty($courseListing)) {
         $existingCorequisites = array();
         foreach ($courseListing as $crsid => $crs) {
             if ($this->is_corequisite($crsid)) {
                 $existingCorequisites[$crsid] = '(' . $crs->idnumber . ')' . $crs->name;
             }
         }
         $config_data['existingCorequisites'] = $existingCorequisites;
     }
     $contexts = coursepage::get_contexts('local/elisprogram:course_view');
     $courseListing = course_get_listing('crs.name', 'ASC', 0, 0, '', '', $contexts);
     unset($courseListing[$this->courseid]);
     if (!empty($courseListing)) {
         $availableCorequisites = array();
         foreach ($courseListing as $crsid => $crs) {
             if (!$this->is_prerequisite($crsid) && !$this->is_corequisite($crsid)) {
                 $availableCorequisites[$crsid] = '(' . $crs->idnumber . ')' . $crs->name;
             }
         }
         $config_data['availableCorequisites'] = $availableCorequisites;
     }
     $config_data['association_id'] = $this->id;
     $config_data['courseid'] = $this->courseid;
     $config_data['curriculumid'] = $this->curriculumid;
     return new corequisiteform($this->form_url, $config_data);
 }
Ejemplo n.º 12
0
 function display_default()
 {
     global $DB, $USER;
     // Get parameters
     $sort = optional_param('sort', 'name', PARAM_ALPHA);
     $dir = optional_param('dir', 'ASC', PARAM_ALPHA);
     $page = optional_param('page', 0, PARAM_INT);
     $perpage = optional_param('perpage', 30, PARAM_INT);
     // how many per page
     $namesearch = trim(optional_param('search', '', PARAM_TEXT));
     $alpha = optional_param('alpha', '', PARAM_ALPHA);
     // Define columns
     $columns = array('name' => array('header' => get_string('course_name', 'local_elisprogram')), 'code' => array('header' => get_string('course_code', 'local_elisprogram')), 'version' => array('header' => get_string('course_version', 'local_elisprogram')), 'curricula' => array('header' => get_string('course_curricula', 'local_elisprogram'), 'display_function' => 'count_curricula'));
     // Set sorting
     if ($dir !== 'DESC') {
         $dir = 'ASC';
     }
     if (isset($columns[$sort])) {
         $columns[$sort]['sortable'] = $dir;
     }
     // TBD: get context set ...
     $contextset = coursepage::get_contexts('local/elisprogram:course_view');
     //$contextset = pm_context_set::for_user_with_capability('course','local/elisprogram:course_view', $USER->id);
     // Get list of courses
     $items = course_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, $contextset);
     $numitems = course_count_records($namesearch, $alpha, $contextset);
     // Cache the context capabilities
     coursepage::get_contexts('local/elisprogram:course_edit');
     coursepage::get_contexts('local/elisprogram:course_delete');
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
 }