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);
 }
Exemple #2
0
/**
 * Dynamically loads child menu items for a curriculum entity
 *
 * @param   int             $id                    The entity id
 * @param   int             $parent_cluster_id     The last cluster passed going down the elisadmin tree, or 0 if none
 * @param   int             $parent_curriculum_id  The last curriculum passed going down the elisadmin tree, or 0 if none
 * @param   int             $num_block_icons       Max number of entries to display
 * @param   string          $parent_path           Path of parent curriculum elements in the tree
 * @return  menuitem array                         The appropriate child items
 */
function block_elisadmin_load_menu_children_curriculum($id, $parent_cluster_id, $parent_curriculum_id, $num_block_icons, $parent_path = '')
{
    global $CFG;
    //page dependencies
    require_once elispm::file('pmclasspage.class.php');
    $result_items = array();
    /*****************************************
     * Curriculum - Course Associations
     *****************************************/
    $course_css_class = block_elisadmin_get_item_css_class('course_instance');
    //permissions filter
    $course_filter = array('contexts' => coursepage::get_contexts('local/elisprogram:course_view'));
    $listing = curriculumcourse_get_listing($id, 'position', 'ASC', 0, $num_block_icons, '', '', $course_filter);
    foreach ($listing as $item) {
        $item->id = $item->courseid;
        $params = array('id' => $item->id, 'action' => 'view');
        //count associated classes
        $class_contexts = pmclasspage::get_contexts('local/elisprogram:class_view');
        $class_count = pmclass_count_records('', '', $item->id, false, $class_contexts, $parent_cluster_id);
        $isLeaf = empty($class_count);
        $result_items[] = block_elisadmin_get_menu_item('course', $item, 'root', $course_css_class, $parent_cluster_id, $parent_curriculum_id, $params, $isLeaf, $parent_path);
    }
    unset($listing);
    //summary item
    $num_records = curriculumcourse_count_records($id, '', '', $course_filter);
    if ($num_block_icons < $num_records) {
        $params = array('id' => $id);
        $result_items[] = block_elisadmin_get_menu_summary_item('curriculumcourse', $course_css_class, $num_records - $num_block_icons, $params, '', $parent_path);
    }
    /*****************************************
     * Curriculum - Track Associations
     *****************************************/
    $track_css_class = block_elisadmin_get_item_css_class('track_instance');
    //permissions filter
    $track_contexts = trackpage::get_contexts('local/elisprogram:track_view');
    if ($track_records = track_get_listing('name', 'ASC', 0, $num_block_icons, '', '', $id, $parent_cluster_id, $track_contexts)) {
        foreach ($track_records as $track_record) {
            $params = array('id' => $track_record->id, 'action' => 'view');
            //count associated classes
            $class_contexts = array('contexts' => pmclasspage::get_contexts('local/elisprogram:class_view'));
            $class_count = track_assignment_count_records($track_record->id, '', '', $class_contexts);
            //count associated clusters
            $cluster_filter = array('contexts' => usersetpage::get_contexts('local/elisprogram:userset_view'));
            $cluster_count = clustertrack::count_clusters($track_record->id, $parent_cluster_id, $cluster_filter);
            $isLeaf = empty($class_count) && empty($cluster_count);
            $result_items[] = block_elisadmin_get_menu_item('track', $track_record, 'root', $track_css_class, $parent_cluster_id, $parent_curriculum_id, $params, $isLeaf, $parent_path);
        }
    }
    //summary item
    $num_records = track_count_records('', '', $id, $parent_cluster_id, $track_contexts);
    if ($num_block_icons < $num_records) {
        $params = array('id' => $id);
        //add extra param if appropriate
        if (!empty($parent_cluster_id)) {
            $params['parent_clusterid'] = $parent_cluster_id;
        }
        $result_items[] = block_elisadmin_get_menu_summary_item('track', $track_css_class, $num_records - $num_block_icons, $params, '', $parent_path);
    }
    /*****************************************
     * Curriculum - Cluster Associations
     *****************************************/
    $cluster_css_class = block_elisadmin_get_item_css_class('cluster_instance');
    //permissions filter
    $cluster_filter = array('contexts' => usersetpage::get_contexts('local/elisprogram:userset_view'));
    $clusters = clustercurriculum::get_clusters($id, $parent_cluster_id, 'name', 'ASC', 0, $num_block_icons, $cluster_filter);
    //$clusters = clustercurriculum::get_clusters($id, $parent_cluster_id, 'priority, name', 'ASC', 0, $num_block_icons);
    if (!empty($clusters)) {
        foreach ($clusters as $cluster) {
            $cluster->id = $cluster->clusterid;
            $params = array('id' => $cluster->id, 'action' => 'view');
            $result_items[] = block_elisadmin_get_menu_item('userset', $cluster, 'root', $cluster_css_class, $cluster->id, $parent_curriculum_id, $params, false, $parent_path);
        }
    }
    //summary item
    $num_records = clustercurriculum::count_clusters($id, $parent_cluster_id, $cluster_filter);
    if ($num_block_icons < $num_records) {
        $params = array('id' => $id);
        //add extra param if appropriate
        if (!empty($parent_cluster_id)) {
            $params['parent_clusterid'] = $parent_cluster_id;
        }
        $result_items[] = block_elisadmin_get_menu_summary_item('curriculumcluster', $cluster_css_class, $num_records - $num_block_icons, $params, 'clustercurriculumpage.class.php', $parent_path);
    }
    return $result_items;
}
 public function body_definition()
 {
     $mform =& $this->_form;
     $parent_obj = $this->_customdata['parent_obj'];
     $curriculumid = $parent_obj->id;
     $coursecurriculum = new curriculumcourse();
     $coursecurriculum->curriculumid = $curriculumid;
     $mform->addElement('hidden', 'curriculumid', $curriculumid);
     $mform->setType('curriculumid', PARAM_INT);
     $mform->addElement('text', 'curriculumname', get_string('curriculum', 'block_curr_admin') . ':', 'readonly="readonly"');
     $mform->setType('curriculumname', PARAM_TEXT);
     $mform->setHelpButton('curriculumname', array('coursecurriculumform/curriculumname', get_string('curriculum', 'block_curr_admin'), 'block_curr_admin'));
     $contexts = coursepage::get_contexts('block/curr_admin:associate');
     $courses_avail = $coursecurriculum->get_courses_avail(array('contexts' => $contexts));
     $courses = array();
     if (isset($this->_customdata['obj'])) {
         $course = $this->_customdata['obj']->course;
         $curriculum = $this->_customdata['obj']->curriculum;
         $courses[$course->id] = $course->name;
     } else {
         if (is_array($courses_avail)) {
             foreach ($courses_avail as $crsid => $c) {
                 $courses[$crsid] = $c->name . ' (' . $c->idnumber . ')';
             }
             natcasesort($courses);
         }
     }
     $mform->addElement('select', 'courseid', get_string('course', 'block_curr_admin') . ':', $courses);
     $mform->addRule('courseid', null, 'required', null, 'client');
     $mform->setHelpButton('courseid', array('coursecurriculumform/coursename', get_string('course', 'block_curr_admin'), 'block_curr_admin'));
     $this->set_data(array('curriculumname' => $parent_obj->name));
 }
 function can_do_default()
 {
     $id = $this->required_param('id', PARAM_INT);
     return coursepage::_has_capability('block/curr_admin:course:edit', $id);
 }
 function action_savenew()
 {
     $courseid = $this->required_param('courseid', PARAM_INT);
     $target = $this->get_new_page(array('action' => 'add'));
     $form = new $this->form_class($target->get_moodle_url());
     if ($form->is_cancelled()) {
         $coursepage = new coursecurriculumpage();
         $target = $coursepage->get_new_page(array('id' => $courseid));
         redirect($target->get_url(), '', 0.1);
     }
     $data = $form->get_data();
     if ($data) {
         $obj = new $this->data_class();
         $obj->set_from_data($data);
         $obj->add();
         $course = new course($data->courseid);
         $course->add_course_to_curricula(array($obj->id));
         $coursepage = new coursepage();
         $target = $coursepage->get_new_page(array('action' => 'view', 'id' => $course->id));
         redirect($target->get_url(), ucwords($obj->get_verbose_name()) . ' ' . $obj->to_string() . ' saved.');
     } else {
         // Validation must have failed, redisplay form
         $form->display();
     }
 }
 function action_copycurr()
 {
     global $CFG;
     // TODO: replace print_object messages with notice messages
     $sesskey = required_param('sesskey', PARAM_TEXT);
     if (!confirm_sesskey($sesskey)) {
         print_error('invalidsesskey', 'error', 'index.php');
     }
     $data = (array) data_submitted();
     $clusterid = $this->required_param('id', PARAM_INT);
     if (empty($data)) {
         notify(get_string('nodatasubmit', 'block_curr_admin'), 'red');
     }
     $targetcluster = new cluster($clusterid);
     // Retrieve all of the curriculums that need to be copied and assigned
     $prefixlen = strlen(self::CPY_CURR_PREFIX);
     foreach ($data as $datakey => $datavalue) {
         if (0 === strncmp($datakey, self::CPY_CURR_PREFIX, $prefixlen)) {
             $currid = (int) substr($datakey, $prefixlen);
             if (!$currid) {
                 continue;
             }
             $curr = new curriculum($currid);
             $options = array('targetcluster' => $targetcluster);
             if ($this->optional_param(self::CPY_CURR_TRK_PREFIX . $currid, 0, PARAM_INT)) {
                 $options['tracks'] = true;
             }
             if ($this->optional_param(self::CPY_CURR_CRS_PREFIX . $currid, 0, PARAM_INT)) {
                 $options['courses'] = true;
             }
             if ($this->optional_param(self::CPY_CURR_CLS_PREFIX . $currid, 0, PARAM_INT)) {
                 $options['classes'] = true;
             }
             if ($this->optional_param(self::CPY_CURR_TRK_PREFIX . $currid, 0, PARAM_INT)) {
                 $options['tracks'] = true;
             }
             $options['moodlecourses'] = $this->optional_param(self::CPY_CURR_MDLCRS_PREFIX . $currid, 'copyalways', PARAM_ALPHA);
             $rv = $curr->duplicate($options);
             if (!empty($rv['errors'])) {
                 foreach ($rv['errors'] as $error) {
                     notify($error);
                 }
             }
             /**
              * The following block of code performs any necessary post-processing,
              * primarily used for copying role assignments
              */
             //we need to handle curricula first in case role assignments
             //at lower levels become redundant
             if (!empty($rv['curricula'])) {
                 $curriculum = new stdClass();
                 $curriculum->id = $rv['curricula'][$curr->id];
                 curriculumpage::after_cm_entity_add($curriculum);
             }
             if (!empty($rv['tracks'])) {
                 foreach ($rv['tracks'] as $trackid) {
                     $track = new stdClass();
                     $track->id = $trackid;
                     trackpage::after_cm_entity_add($track);
                 }
             }
             if (!empty($rv['courses'])) {
                 foreach ($rv['courses'] as $courseid) {
                     $course = new stdClass();
                     $course->id = $courseid;
                     coursepage::after_cm_entity_add($course);
                 }
             }
             if (!empty($rv['classes'])) {
                 foreach ($rv['classes'] as $classid) {
                     $class = new stdClass();
                     $class->id = $classid;
                     cmclasspage::after_cm_entity_add($class);
                 }
             }
             if (!empty($rv['curricula'])) {
                 $newcurr = new curriculum($rv['curricula'][$curr->id]);
                 $curr->newname = $newcurr->name;
                 notify(get_string('clustcpycurr', 'block_curr_admin', $curr), 'notifysuccess');
             }
         }
     }
     redirect($CFG->wwwroot . '/curriculum/index.php?id=' . $data['id'] . '&amp;s=clstcur', '', 2);
 }
 function get_content()
 {
     global $CFG, $ADMIN, $USER, $CURMAN, $HTTPSPAGEREQUIRED;
     require_once $CFG->libdir . '/adminlib.php';
     require_once $CFG->dirroot . '/my/pagelib.php';
     // dependencies on page classes
     require_once $CFG->dirroot . '/curriculum/clusterpage.class.php';
     require_once $CFG->dirroot . '/curriculum/curriculumpage.class.php';
     require_once $CFG->dirroot . '/curriculum/coursepage.class.php';
     require_once $CFG->dirroot . '/curriculum/trackpage.class.php';
     // ELIS-1251 - Don't display a useless message if in the center column
     //        if ($this->instance->position == BLOCK_POS_CENTRE) {
     //            $this->content = new stdClass;
     //            $output = "This is content to display if in the middle...";
     //            $this->content->text = $output;
     //            $this->content->footer = '';
     //            return $this->content;
     //        }
     /// Display a link to the admin interface if on the main site index page and the current user has
     /// admin or developer access.
     //        if ($this->instance->pageid == SITEID &&
     //            has_capability('block/curr_admin:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
     //
     //            $this->content = new stdClass;
     //            $this->content->text   = '<a href="' . $CFG->wwwroot . '/curriculum/index.php">' .
     //                                     get_string('accesscurriculumadmin', 'block_curr_admin') . '</a>';
     //            $this->content->footer = '';
     //        }
     /// Determine the users CM access level.
     $access = cm_determine_access($USER->id);
     $this->title = get_string("blocktitle{$access}", 'block_curr_admin');
     if (empty($access) || $this->content !== NULL) {
         return $this->content;
     }
     //if we are not on a CM "newpage", disable the expansion of
     //entities in the curr admin tree (logic in curriculum/index.php)
     if (!isset($CURMAN->page)) {
         unset($USER->currentitypath);
     }
     //include the necessary javascript libraries for the YUI TreeView
     require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_treeview'));
     //for converting tree representation
     require_js('yui_json');
     //for asynch request dynamic loading
     require_js('yui_connection');
     //include our custom code that handles the YUI Treeview menu
     if (!empty($HTTPSPAGEREQUIRED)) {
         $wwwroot = $CFG->httpswwwroot;
     } else {
         $wwwroot = $CFG->wwwroot;
     }
     require_js($wwwroot . '/curriculum/js/menuitem.js');
     //CM entities for placement at the top of the menu
     $cm_entity_pages = array();
     $cm_entity_pages[] = new menuitem('root');
     $num_block_icons = isset($CURMAN->config->num_block_icons) ? $CURMAN->config->num_block_icons : 5;
     /*****************************************
      * Clusters
      *****************************************/
     if (!isset($CURMAN->config->display_clusters_at_top_level) || !empty($CURMAN->config->display_clusters_at_top_level)) {
         $manageclusters_css_class = block_curr_admin_get_item_css_class('manageclusters');
         $cluster_css_class = block_curr_admin_get_item_css_class('cluster_instance');
         require_once CURMAN_DIRLOCATION . '/lib/contexts.php';
         $context_result = cm_context_set::for_user_with_capability('cluster', 'block/curr_admin:cluster:view', $USER->id);
         $extrafilters = array('contexts' => $context_result, 'parent' => 0);
         $num_records = cluster_count_records('', '', $extrafilters);
         if ($clusters = cluster_get_listing('priority, name', 'ASC', 0, $num_block_icons, '', '', $extrafilters)) {
             foreach ($clusters as $cluster) {
                 $params = array('id' => $cluster->id, 'action' => 'view');
                 // count sub-clusters
                 $cluster_filter = array('contexts' => clusterpage::get_contexts('block/curr_admin:cluster:view'), 'parent' => $cluster->id);
                 $cluster_count = cluster_count_records('', '', $cluster_filter);
                 // count associated curricula
                 $curriculum_filter = array('contexts' => curriculumpage::get_contexts('block/curr_admin:curriculum:view'));
                 $curriculum_count = clustercurriculum::count_curricula($cluster->id, $curriculum_filter);
                 $isLeaf = empty($cluster_count) && empty($curriculum_count);
                 $cm_entity_pages[] = block_curr_admin_get_menu_item('cluster', $cluster, 'root', $manageclusters_css_class, $cluster->id, 0, $params, $isLeaf);
             }
         }
         if ($num_block_icons < $num_records) {
             $cm_entity_pages[] = block_curr_admin_get_menu_summary_item('cluster', $cluster_css_class, $num_records - $num_block_icons);
         }
     }
     /*****************************************
      * Curricula
      *****************************************/
     if (!empty($CURMAN->config->display_curricula_at_top_level)) {
         $managecurricula_css_class = block_curr_admin_get_item_css_class('managecurricula');
         $curriculum_css_class = block_curr_admin_get_item_css_class('curriculum_instance');
         require_once CURMAN_DIRLOCATION . '/curriculumpage.class.php';
         $num_records = curriculum_count_records('', '', curriculumpage::get_contexts('block/curr_admin:curriculum:view'));
         if ($curricula = get_records(CURTABLE, '', '', 'priority ASC, name ASC', '*', 0, $num_block_icons)) {
             foreach ($curricula as $curriculum) {
                 $params = array('id' => $curriculum->id, 'action' => 'view');
                 // count associated courses
                 $course_filter = array('contexts' => coursepage::get_contexts('block/curr_admin:course:view'));
                 $course_count = curriculumcourse_count_records($curriculum->id, '', '', $course_filter);
                 // count associated tracks
                 $track_contexts = trackpage::get_contexts('block/curr_admin:track:view');
                 $track_count = track_count_records('', '', $curriculum->id, 0, $track_contexts);
                 // count associated clusters
                 $cluster_filter = array('contexts' => clusterpage::get_contexts('block/curr_admin:cluster:view'));
                 $cluster_count = clustercurriculum::count_clusters($curriculum->id, 0, $cluster_filter);
                 $isLeaf = empty($course_count) && empty($track_count) && empty($cluster_count);
                 $cm_entity_pages[] = block_curr_admin_get_menu_item('curriculum', $curriculum, 'root', $managecurricula_css_class, 0, $curriculum->id, $params, $isLeaf);
             }
         }
         if ($num_block_icons < $num_records) {
             $cm_entity_pages[] = block_curr_admin_get_menu_summary_item('curriculum', $curriculum_css_class, $num_records - $num_block_icons);
         }
     }
     global $SITE;
     //general cm pages
     $pages = array(new menuitem('dashboard', new menuitempage('dashboardpage'), 'root', '', block_curr_admin_get_item_css_class('dashboard')), new menuitem('admn', null, 'root', get_string('admin'), block_curr_admin_get_item_css_class('admn', true)), new menuitem('bulkuser', new menuitempage('bulkuserpage'), null, get_string('userbulk', 'admin'), block_curr_admin_get_item_css_class('bulkuser')));
     //show the Jasper report server link if applicable
     if (cm_jasper_link_enabled()) {
         //page action
         $jasper_link_params = array('action' => 'reportslist');
         //page instance
         $jasper_link_page = new menuitempage('jasperreportpage', '', $jasper_link_params);
         //styling for the link
         $jasper_link_css = block_curr_admin_get_item_css_class('reportslist');
         $pages[] = new menuitem('reportslist', $jasper_link_page, null, '', $jasper_link_css);
     }
     $pages = array_merge($pages, array(new menuitem('customfields', new menuitempage('customfieldpage', '', array('level' => 'user')), null, '', block_curr_admin_get_item_css_class('customfields')), new menuitem('clusterclassification', new menuitempage('clusterclassificationpage', 'plugins/cluster_classification/clusterclassificationpage.class.php'), null, get_string('cluster_classification', 'crlm_cluster_classification'), block_curr_admin_get_item_css_class('clusterclassification')), new menuitem('info', null, 'root', get_string('informationalelements', 'block_curr_admin'), block_curr_admin_get_item_css_class('info', true)), new menuitem('managetags', new menuitempage('tagpage'), null, '', block_curr_admin_get_item_css_class('managetags')), new menuitem('manageenvironments', new menuitempage('envpage'), null, '', block_curr_admin_get_item_css_class('manageenvironments')), new menuitem('users', null, 'root', '', block_curr_admin_get_item_css_class('users', true)), new menuitem('manageusers', new menuitempage('usermanagementpage'), null, '', block_curr_admin_get_item_css_class('manageusers')), new menuitem('manageclusters', new menuitempage('clusterpage'), null, '', block_curr_admin_get_item_css_class('manageclusters')), new menuitem('curr', null, 'root', get_string('curriculum', 'block_curr_admin'), block_curr_admin_get_item_css_class('curr', true)), new menuitem('certificatelist', new menuitempage('certificatelistpage'), null, '', block_curr_admin_get_item_css_class('certificatelist')), new menuitem('managecurricula', new menuitempage('curriculumpage'), null, '', block_curr_admin_get_item_css_class('managecurricula')), new menuitem('managecourses', new menuitempage('coursepage'), null, '', block_curr_admin_get_item_css_class('managecourses')), new menuitem('manageclasses', new menuitempage('cmclasspage'), null, '', block_curr_admin_get_item_css_class('manageclasses')), new menuitem('crscat', null, 'root', get_string('learningplan', 'block_curr_admin'), block_curr_admin_get_item_css_class('crscat', true)), new menuitem('currentcourses', new menuitempage('coursecatalogpage', '', array('action' => 'current')), null, '', block_curr_admin_get_item_css_class('currentcourses')), new menuitem('availablecourses', new menuitempage('coursecatalogpage', '', array('action' => 'available')), null, '', block_curr_admin_get_item_css_class('availablecourses')), new menuitem('waitlist', new menuitempage('coursecatalogpage', '', array('action' => 'waitlist')), null, get_string('waitlistcourses', 'block_curr_admin'), block_curr_admin_get_item_css_class('waitlist')), new menuitem('rept', null, 'root', get_string('reports', 'block_curr_admin'), block_curr_admin_get_item_css_class('rept', true))));
     if (has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $SITE->id))) {
         if ($CURMAN->config->site_course_cluster_groups) {
             $pages[] = new menuitem('frontpagegroups', new menuitempage('url_page', 'lib/menuitem.class.php', "{$CFG->wwwroot}/group/index.php?id={$SITE->id}"), 'admn', get_string('frontpagegroups', 'crlm_cluster_groups'), block_curr_admin_get_item_css_class('manageclusters'));
         }
         if ($CURMAN->config->cluster_groupings) {
             $pages[] = new menuitem('frontpagegroupings', new menuitempage('url_page', 'lib/menuitem.class.php', "{$CFG->wwwroot}/group/groupings.php?id={$SITE->id}"), 'admn', get_string('frontpagegroupings', 'crlm_cluster_groups'), block_curr_admin_get_item_css_class('manageclusters'));
         }
     }
     /**
      * This section adds all the necessary PHP reports to the menu
      */
     //get all report pages, including categories but not including the
     //topmost report element
     $report_pages = block_curr_admin_get_report_tree_items();
     //merge in the reporting page links
     $pages = array_merge($pages, $report_pages);
     if (empty($CURMAN->config->userdefinedtrack)) {
         $pages[] = new menuitem('managetracks', new menuitempage('trackpage'), null, '', block_curr_admin_get_item_css_class('managetracks'));
     }
     $access = cm_determine_access($USER->id);
     switch ($access) {
         case 'admin':
         case 'developer':
             $pages[] = new menuitem('configmanager', new menuitempage('configpage', '', array('section' => 'admn')), null, get_string('configuration'), block_curr_admin_get_item_css_class('configuration'));
             $pages[] = new menuitem('notifications', new menuitempage('notifications', 'notificationspage.class.php', array('section' => 'admn')), null, '', block_curr_admin_get_item_css_class('notifications'));
             $pages[] = new menuitem('dataimport', new menuitempage('dataimportpage', 'elis_ip/elis_ip_page.php', array('section' => 'admn')), null, '', block_curr_admin_get_item_css_class('integrationpoint'));
             $pages[] = new menuitem('defaultcls', new menuitempage('configclsdefaultpage', '', array('section' => 'admn')), null, '', block_curr_admin_get_item_css_class('defaultcls'));
             $pages[] = new menuitem('defaultcrs', new menuitempage('configcrsdefaultpage', '', array('section' => 'admn')), null, '', block_curr_admin_get_item_css_class('defaultcrs'));
             break;
         default:
             break;
     }
     //turn all pages that have no children into leaf nodes
     menuitemlisting::flag_leaf_nodes($pages);
     //combine the specific entity page listing with the general CM listing
     $menuitemlisting = new menuitemlisting(array_merge($cm_entity_pages, $pages));
     $tree = new treerepresentation($menuitemlisting);
     $this->content = new stdClass();
     $this->content->text = $tree->convert_to_markup();
     $this->content->footer = '';
     return $this->content;
 }
 /**
  * Takes a record and transforms it into an appropriate format
  * This method is set up as a hook to be implented by actual report class
  *
  * @param   stdClass  $record         The current report record
  * @param   string    $export_format  The format being used to render the report
  * @uses $CFG
  * @return stdClass  The reformatted record
  */
 function transform_record($record, $export_format)
 {
     //add entity links
     if ($export_format == table_report::$EXPORT_FORMAT_HTML) {
         //link curriculum name to its "view" page if the the current record has a curriculum
         if (!empty($record->curid) && isset($record->curriculumname)) {
             $page = new curriculumpage(array('id' => $record->curid, 'action' => 'view'));
             if ($page->can_do()) {
                 $record->curriculumname = '<span class="external_report_link"><a href="' . $page->url . '" target="_blank">' . $record->curriculumname . '</a></span>';
             }
         } else {
             //non-curriculum course, so use status string with no link
             $record->curriculumname = get_string('noncurriculumcourse', $this->languagefile);
         }
         //link course name to its "view" page
         $page = new coursepage(array('id' => $record->courseid, 'action' => 'view'));
         if ($page->can_do()) {
             $record->coursename = '<span class="external_report_link"><a href="' . $page->url . '" target="_blank">' . $record->coursename . '</a></span>';
         }
         //link class name to its "view" page
         $page = new pmclasspage(array('id' => $record->classid, 'action' => 'view'));
         if ($page->can_do()) {
             $record->classidnumber = '<span class="external_report_link"><a href="' . $page->url . '" target="_blank">' . $record->classidnumber . '</a></span>';
         }
     }
     //show environment as N/A if not set
     if (empty($record->envname)) {
         $record->envname = get_string('na', $this->languagefile);
     }
     //format the start date
     $record->startdate = $this->format_date($record->startdate);
     //show number of passed and total number of completion elements
     $record->elementsdisplayed = get_string('compelements_passed', $this->languagefile, $record);
     //convert status id to a display string
     if ($record->completestatusid == STUSTATUS_PASSED) {
         $record->completionstatus = get_string('status_passed', $this->languagefile);
     } else {
         if ($record->completestatusid == STUSTATUS_FAILED) {
             $record->completionstatus = get_string('status_failed', $this->languagefile);
         } else {
             if ($record->completestatusid == STUSTATUS_NOTCOMPLETE) {
                 $record->completionstatus = get_string('status_notcomplete', $this->languagefile);
             } else {
                 $record->completionstatus = get_string('status_notstarted', $this->languagefile);
             }
         }
     }
     //if not passed, shouldn't have any credits
     if ($record->completestatusid != STUSTATUS_PASSED) {
         $record->credits = 0;
     }
     //copy result of complex sub-query into simple field
     $record->creditsdisplayed = $this->format_credits($record->credits);
     //format the completion time
     if ($record->completestatusid == STUSTATUS_NOTCOMPLETE) {
         //not complete, so don't show a completion time
         $record->completetime = '0';
     }
     //only show a completion time if passed
     if ($record->completestatusid == STUSTATUS_PASSED || $record->completestatusid == STUSTATUS_FAILED) {
         $record->completetime = $this->format_date($record->completetime);
     } else {
         $record->completetime = get_string('na', $this->languagefile);
     }
     //display whether the current record is a student or an instructor assignment
     if ($record->isinstructor) {
         $record->classrole = get_string('instructor', $this->languagefile);
     } else {
         $record->classrole = get_string('student', $this->languagefile);
     }
     //handle custom field default values and display logic
     $this->transform_custom_field_data($record);
     return $record;
 }
Exemple #9
0
 /**
  * Test creating a new course entity with a default role assignment defined.
  */
 public function test_createcoursewithdefaultroleassignment()
 {
     global $DB;
     list($rcid, $reid) = $this->create_roles('course');
     // Setup the global USER object to be our test user.
     $USER = $DB->get_record('user', array('id' => 100));
     // Setup the editor role to be the default role for the course context.
     elis::$config->local_elisprogram->default_course_role_id = $reid;
     $sysctx = context_system::instance();
     // Assign the test user the creator role.
     role_assign($rcid, $USER->id, $sysctx->id);
     // Create a new course entity.
     $data = array('idnumber' => 'course100', 'name' => 'course100', 'syllabus' => 'course100');
     $obj = new course($data);
     $obj->save();
     // Initialize a new course management page and invoke the code that handles default role assignments.
     $page = new coursepage();
     $page->after_cm_entity_add($obj);
     $coursectx = \local_elisprogram\context\course::instance($obj->id);
     $params = array('roleid' => $reid, 'userid' => $USER->id, 'contextid' => $coursectx->id);
     $this->assertTrue($DB->record_exists('role_assignments', $params));
 }
 function action_default()
 {
     $id = $this->required_param('id', PARAM_INT);
     $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(cm_get_param('search', ''));
     $alpha = cm_get_param('alpha', '');
     $columns = array('curriculumname' => get_string('curriculum_name', 'block_curr_admin'), 'required' => get_string('required', 'block_curr_admin'), 'frequency' => get_string('frequency', 'block_curr_admin'), 'timeperiod' => get_string('time_period', 'block_curr_admin'), 'position' => get_string('position', 'block_curr_admin'), 'buttons' => get_string('management', 'block_curr_admin'));
     // ELIS-3306: back porting ELIS-2442
     //$contexts = curriculumpage::get_contexts('block/curr_admin:associate');
     $items = curriculumcourse_get_curriculum_listing($id, $sort, $dir, 0, 0, $namesearch, $alpha);
     $numitems = curriculumcourse_count_curriculum_records($id, $namesearch, $alpha);
     $formatters = $this->create_link_formatters(array('curriculumname'), 'curriculumpage', 'curriculumid');
     $this->print_num_items($numitems);
     $this->print_alpha();
     $this->print_search();
     $this->print_list_view($items, $columns, $formatters, 'curricula');
     if (coursepage::_has_capability('block/curr_admin:associate')) {
         $this->print_add_button(array('id' => $id), get_string('course_assigncurriculum', 'block_curr_admin'));
     }
     if (coursepage::_has_capability('block/curr_admin:curriculum:create')) {
         echo '<div align="center">';
         $options = array_merge(array('s' => 'cfc', 'id' => $id));
         echo print_single_button('index.php', $options, get_string('makecurcourse', 'block_curr_admin'), 'get', '_self', true, get_string('makecurcourse', 'block_curr_admin'));
         echo '</div>';
     }
 }
Exemple #11
0
 function get_content()
 {
     global $CFG, $ADMIN, $USER, $HTTPSPAGEREQUIRED, $PAGE, $DB, $SITE;
     require_once $CFG->libdir . '/adminlib.php';
     //dependencies on page classes
     require_once elispm::file('usersetpage.class.php');
     require_once elispm::file('curriculumpage.class.php');
     require_once elispm::file('coursepage.class.php');
     require_once elispm::file('trackpage.class.php');
     //require_once($CFG->dirroot . '/my/pagelib.php');
     /// Determine the users CM access level.
     $access = cm_determine_access($USER->id);
     //make sure local_elisprogram / custom contexts set up correctly
     //to prevent error before the upgrade to ELIS 2
     if (empty($access) || $this->content !== NULL || !defined('CONTEXT_ELIS_PROGRAM')) {
         return $this->content;
     }
     //if we are not on a PM page, disable the expansion of
     //entities in the curr admin tree (logic in curriculum/index.php)
     if (!is_a($PAGE, 'pm_page') && $PAGE->pagetype != 'admin-setting-local_elisprogram_settings') {
         unset($USER->currentitypath);
     }
     // Include Icon CSS.
     $PAGE->requires->css('/local/elisprogram/icons.css');
     //CM entities for placement at the top of the menu
     $cm_entity_pages = array();
     $cm_entity_pages[] = new menuitem('root');
     $num_block_icons = isset(elis::$config->local_elisprogram->num_block_icons) ? elis::$config->local_elisprogram->num_block_icons : 5;
     /*****************************************
      * Clusters
      *****************************************/
     if (!isset(elis::$config->local_elisprogram->display_clusters_at_top_level) || !empty(elis::$config->local_elisprogram->display_clusters_at_top_level)) {
         $manageclusters_css_class = block_elisadmin_get_item_css_class('manageclusters');
         $cluster_css_class = block_elisadmin_get_item_css_class('cluster_instance');
         require_once elispm::lib('contexts.php');
         $context_result = pm_context_set::for_user_with_capability('cluster', 'local/elisprogram:userset_view', $USER->id);
         $extrafilters = array('contexts' => $context_result, 'parent' => 0);
         $num_records = cluster_count_records('', '', $extrafilters);
         if ($clusters = cluster_get_listing('priority, name', 'ASC', 0, $num_block_icons, '', '', $extrafilters)) {
             foreach ($clusters as $cluster) {
                 $params = array('id' => $cluster->id, 'action' => 'view');
                 //count sub-clusters
                 $cluster_filter = array('contexts' => usersetpage::get_contexts('local/elisprogram:userset_view'));
                 $cluster_count = cluster_count_records('', '', array('parent' => $cluster->id), $cluster_filter);
                 //count associated curricula
                 $curriculum_filter = array('contexts' => curriculumpage::get_contexts('local/elisprogram:program_view'));
                 $curriculum_count = clustercurriculum::count_curricula($cluster->id, $curriculum_filter);
                 $isLeaf = empty($cluster_count) && empty($curriculum_count);
                 $cm_entity_pages[] = block_elisadmin_get_menu_item('userset', $cluster, 'root', $manageclusters_css_class, $cluster->id, 0, $params, $isLeaf);
             }
         }
         if ($num_block_icons < $num_records) {
             $cm_entity_pages[] = block_elisadmin_get_menu_summary_item('userset', $cluster_css_class, $num_records - $num_block_icons);
         }
     }
     /*****************************************
      * Curricula
      *****************************************/
     if (!empty(elis::$config->local_elisprogram->display_curricula_at_top_level)) {
         $managecurricula_css_class = block_elisadmin_get_item_css_class('managecurricula');
         $curriculum_css_class = block_elisadmin_get_item_css_class('curriculum_instance');
         require_once elispm::file('curriculumpage.class.php');
         $num_records = curriculum_count_records('', '', curriculumpage::get_contexts('local/elisprogram:program_view'));
         $curricula = $DB->get_recordset(curriculum::TABLE, null, 'priority ASC, name ASC', '*', 0, $num_block_icons);
         foreach ($curricula as $curriculum) {
             $params = array('id' => $curriculum->id, 'action' => 'view');
             //count associated courses
             $course_filter = array('contexts' => coursepage::get_contexts('local/elisprogram:course_view'));
             $course_count = curriculumcourse_count_records($curriculum->id, '', '', $course_filter);
             //count associated tracks
             $track_contexts = trackpage::get_contexts('local/elisprogram:track_view');
             $track_count = track_count_records('', '', $curriculum->id, 0, $track_contexts);
             //count associated clusters
             $cluster_filter = array('contexts' => usersetpage::get_contexts('local/elisprogram:userset_view'));
             $cluster_count = clustercurriculum::count_clusters($curriculum->id, 0, $cluster_filter);
             $isLeaf = empty($course_count) && empty($track_count) && empty($cluster_count);
             $cm_entity_pages[] = block_elisadmin_get_menu_item('curriculum', $curriculum, 'root', $managecurricula_css_class, 0, $curriculum->id, $params, $isLeaf);
         }
         unset($curricula);
         if ($num_block_icons < $num_records) {
             $cm_entity_pages[] = block_elisadmin_get_menu_summary_item('curriculum', $curriculum_css_class, $num_records - $num_block_icons);
         }
     }
     //general cm pages
     $pages = array(new menuitem('dashboard', new menuitempage('dashboardpage'), 'root', '', block_elisadmin_get_item_css_class('dashboard')), new menuitem('admn', null, 'root', get_string('admin'), block_elisadmin_get_item_css_class('admn', true)), new menuitem('bulkuser', new menuitempage('bulkuserpage'), null, get_string('userbulk', 'admin'), block_elisadmin_get_item_css_class('bulkuser')), new menuitem('resultsconfig', new menuitempage('resultsconfigpage'), null, 'Default Results Engine Score Settings', block_elisadmin_get_item_css_class('resultsconfig')));
     // ELIS-3208 - commented out this code as the Jasper reports no longer work in ELIS 2
     /*
             //show the Jasper report server link if applicable
             if (cm_jasper_link_enabled()) {
                 //page action
                 $jasper_link_params = array('action' => 'reportslist');
                 //page instance
                 $jasper_link_page = new menuitempage('jasperreportpage', '', $jasper_link_params);
                 //styling for the link
                 $jasper_link_css = block_elisadmin_get_item_css_class('reportslist');
     
                 $pages[] = new menuitem('reportslist', $jasper_link_page, null, '', $jasper_link_css);
             }
     */
     $pages = array_merge($pages, array(new menuitem('customfields', new menuitempage('customfieldpage', '', array('level' => 'user')), null, '', block_elisadmin_get_item_css_class('customfields')), new menuitem('clusterclassification', new menuitempage('usersetclassificationpage', 'plugins/usetclassify/usersetclassificationpage.class.php'), null, get_string('userset_classification', 'elisprogram_usetclassify'), block_elisadmin_get_item_css_class('clusterclassification')), new menuitem('users', null, 'root', '', block_elisadmin_get_item_css_class('users', true)), new menuitem('manageusers', new menuitempage('userpage'), null, '', block_elisadmin_get_item_css_class('manageusers')), new menuitem('manageclusters', new menuitempage('usersetpage'), null, '', block_elisadmin_get_item_css_class('manageclusters')), new menuitem('curr', null, 'root', get_string('curriculum', 'local_elisprogram'), block_elisadmin_get_item_css_class('curr', true)), new menuitem('certificatelist', new menuitempage('certificatelistpage'), null, '', block_elisadmin_get_item_css_class('certificatelist')), new menuitem('managecurricula', new menuitempage('curriculumpage'), null, '', block_elisadmin_get_item_css_class('managecurricula')), new menuitem('managecourses', new menuitempage('coursepage'), null, '', block_elisadmin_get_item_css_class('managecourses')), new menuitem('manageclasses', new menuitempage('pmclasspage'), null, '', block_elisadmin_get_item_css_class('manageclasses')), new menuitem('crscat', null, 'root', get_string('learningplan', 'local_elisprogram'), block_elisadmin_get_item_css_class('crscat', true)), new menuitem('currentcourses', new menuitempage('coursecatalogpage', '', array('action' => 'current')), null, '', block_elisadmin_get_item_css_class('currentcourses')), new menuitem('availablecourses', new menuitempage('coursecatalogpage', '', array('action' => 'available')), null, '', block_elisadmin_get_item_css_class('availablecourses')), new menuitem('waitlist', new menuitempage('coursecatalogpage', '', array('action' => 'waitlist')), null, get_string('waitlistcourses', 'local_elisprogram'), block_elisadmin_get_item_css_class('waitlist')), new menuitem('rept', null, 'root', get_string('reports', 'local_elisprogram'), block_elisadmin_get_item_css_class('rept', true))));
     if (has_capability('moodle/course:managegroups', context_course::instance($SITE->id))) {
         if (elis::$config->elisprogram_usetgroups->site_course_userset_groups) {
             $pages[] = new menuitem('frontpagegroups', new menuitempage('url_page', 'lib/menuitem.class.php', "{$CFG->wwwroot}/group/index.php?id={$SITE->id}"), 'admn', get_string('frontpagegroups', 'elisprogram_usetgroups'), block_elisadmin_get_item_css_class('manageclusters'));
         }
         if (elis::$config->elisprogram_usetgroups->userset_groupings) {
             $pages[] = new menuitem('frontpagegroupings', new menuitempage('url_page', 'lib/menuitem.class.php', "{$CFG->wwwroot}/group/groupings.php?id={$SITE->id}"), 'admn', get_string('frontpagegroupings', 'elisprogram_usetgroups'), block_elisadmin_get_item_css_class('manageclusters'));
         }
     }
     /**
      * This section adds all the necessary PHP reports to the menu
      */
     //get all report pages, including categories but not including the
     //topmost report element
     $report_pages = block_elisadmin_get_report_tree_items();
     //merge in the reporting page links
     $pages = array_merge($pages, $report_pages);
     if (empty(elis::$config->local_elisprogram->userdefinedtrack)) {
         $pages[] = new menuitem('managetracks', new menuitempage('trackpage'), null, '', block_elisadmin_get_item_css_class('managetracks'));
     }
     $syscontext = context_system::instance();
     if (has_capability('local/elisprogram:config', $syscontext)) {
         $pages[] = new menuitem('configmanager', new menuitempage('url_page', 'lib/menuitem.class.php', "{$CFG->wwwroot}/admin/settings.php?section=local_elisprogram_settings"), 'admn', get_string('configuration'), block_elisadmin_get_item_css_class('configuration'));
     }
     $pages[] = new menuitem('notifications', new menuitempage('notifications', 'notificationspage.class.php', array('section' => 'admn')), null, '', block_elisadmin_get_item_css_class('notifications'));
     //$pages[] = new menuitem('dataimport', new menuitempage('dataimportpage', 'elis_ip/elis_ip_page.php', array('section' => 'admn')), null, '', block_elisadmin_get_item_css_class('integrationpoint'));
     $pages[] = new menuitem('defaultcls', new menuitempage('configclsdefaultpage', '', array('section' => 'admn')), null, '', block_elisadmin_get_item_css_class('defaultcls'));
     $pages[] = new menuitem('defaultcrs', new menuitempage('configcrsdefaultpage', '', array('section' => 'admn')), null, '', block_elisadmin_get_item_css_class('defaultcrs'));
     //turn all pages that have no children into leaf nodes
     menuitemlisting::flag_leaf_nodes($pages);
     //combine the specific entity page listing with the general CM listing
     $menuitemlisting = new menuitemlisting(array_merge($cm_entity_pages, $pages));
     $tree = new treerepresentation($menuitemlisting);
     $this->content = new stdClass();
     $this->content->text = $tree->convert_to_markup();
     $this->content->footer = '';
     $PAGE->requires->yui_module('moodle-local_elisprogram-menuitem', 'M.local_elisprogram.init_menuitem', array($tree->get_js_object(), $CFG->httpswwwroot), null, true);
     return $this->content;
 }
 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);
 }
Exemple #13
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);
 }
 /**
  * Display form to manage corequisites.
  */
 public function display_coreqedit()
 {
     $id = $this->required_param('id', PARAM_INT);
     $curcrsid = $this->required_param('association_id', PARAM_INT);
     $curcrs = new curriculumcourse($curcrsid);
     $curcrs->seturl(null, array('s' => $this->pagename, 'action' => 'coreqedit', 'id' => $id));
     $coreqform = $curcrs->create_corequisite_form();
     if ($coreqform->is_cancelled()) {
         $this->display_default();
         return;
     } else {
         if ($coreqform->is_submitted() && $coreqform->is_validated()) {
             $formdata = $coreqform->get_data();
             $output = '';
             $added = 0;
             $deleted = 0;
             // Process requested corequisite deletions.
             $scoreqs = isset($formdata->scoreqs) ? $formdata->scoreqs : array();
             foreach ($scoreqs as $scoreq) {
                 if ($curcrs->del_corequisite($scoreq)) {
                     $deleted++;
                 }
             }
             // Process requested corequisite additions.
             $coreqs = isset($formdata->coreqs) ? $formdata->coreqs : array();
             // TODO: Ugly, this needs to be overhauled.
             $cpage = new coursepage();
             foreach ($coreqs as $coreq) {
                 if ($cpage->_has_capability('local/elisprogram:course_view', $coreq) && $curcrs->add_corequisite($coreq, !empty($formdata->add_to_curriculum))) {
                     $added++;
                 }
             }
             if ($deleted > 0) {
                 $delstring = $deleted > 1 ? 'deleted_corequisites' : 'deleted_corequisite';
                 $output .= get_string($delstring, 'local_elisprogram', $deleted);
             }
             if ($added > 0) {
                 $addstring = $added > 1 ? 'added_corequisites' : 'added_corequisite';
                 $output .= ($deleted > 0 ? ' / ' : '') . get_string($addstring, 'local_elisprogram', $added);
             }
             if ($deleted > 0 || $added > 0) {
                 $output .= "\n";
             }
             $curriculum = $curcrs->curriculum;
             if ($curriculum->iscustom) {
                 $curassid = $this->_db->get_field(curriculumstudent::TABLE, 'id', array('curriculumid' => $curriculum->id));
                 $stucur = new curriculumstudent($curassid);
                 redirect('index.php?s=stucur&amp;section=curr&amp;id=' . $stucur->id . '&amp;action=edit', $output, 3);
             }
             echo $output;
             // Recreate the form, to reflect changes in the lists.
             $coreqform = $curcrs->create_corequisite_form();
         }
     }
     $coreqform->display();
 }
Exemple #15
0
 function display_default()
 {
     // Get parameters
     $sort = optional_param('sort', 'crsname', 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);
     $id = $this->get_cm_id();
     //this parameter signifies a required relationship between a class and a track
     //through a cluster
     $parent_clusterid = $this->optional_param('parent_clusterid', 0, PARAM_INT);
     // Define columns
     $columns = array('crsname' => array('header' => get_string('class_course', 'local_elisprogram')), 'idnumber' => array('header' => get_string('class_idnumber', 'local_elisprogram')), 'moodlecourse' => array('header' => get_string('class_moodle_course', 'local_elisprogram')), 'startdate' => array('header' => get_string('class_startdate', 'local_elisprogram')), 'enddate' => array('header' => get_string('class_enddate', 'local_elisprogram')), 'starttime' => array('header' => get_string('class_starttime', 'local_elisprogram')), 'endtime' => array('header' => get_string('class_endtime', 'local_elisprogram')), 'maxstudents' => array('header' => get_string('class_maxstudents', 'local_elisprogram')));
     //set the column data needed to maintain and display current sort
     if ($dir !== 'DESC') {
         $dir = 'ASC';
     }
     if (isset($columns[$sort])) {
         $columns[$sort]['sortable'] = $dir;
     }
     $contexts = pmclasspage::get_contexts('local/elisprogram:class_view');
     $items = pmclass_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, $id, false, $contexts, $parent_clusterid);
     $numitems = pmclass_count_records($namesearch, $alpha, $id, false, $contexts, $parent_clusterid);
     pmclasspage::get_contexts('local/elisprogram:class_edit');
     pmclasspage::get_contexts('local/elisprogram:class_delete');
     if (!empty($id)) {
         $coursepage = new coursepage(array('id' => $id));
         $coursepage->print_tabs('pmclasspage', array('id' => $id));
     }
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
     unset($items);
 }
 function action_default()
 {
     // Get parameters
     $sort = optional_param('sort', 'crsname', 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);
     $id = $this->get_cm_id();
     //this parameter signifies a required relationship between a class and a track
     //through a cluster
     $parent_clusterid = $this->optional_param('parent_clusterid', 0, PARAM_INT);
     // Define columns
     $columns = array('crsname' => get_string('class_course', 'block_curr_admin'), 'idnumber' => get_string('class_idnumber', 'block_curr_admin'), 'moodlecourse' => get_string('class_moodle_course', 'block_curr_admin'), 'startdate' => get_string('class_startdate', 'block_curr_admin'), 'enddate' => get_string('class_enddate', 'block_curr_admin'), 'starttime' => get_string('class_starttime', 'block_curr_admin'), 'endtime' => get_string('class_endtime', 'block_curr_admin'), 'maxstudents' => get_string('class_maxstudents', 'block_curr_admin'), 'envname' => get_string('environment', 'block_curr_admin'));
     $items = cmclass_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, $id, false, cmclasspage::get_contexts('block/curr_admin:class:view'), $parent_clusterid);
     $numitems = cmclass_count_records($namesearch, $alpha, $id, false, cmclasspage::get_contexts('block/curr_admin:class:view'), $parent_clusterid);
     cmclasspage::get_contexts('block/curr_admin:class:edit');
     cmclasspage::get_contexts('block/curr_admin:class:delete');
     if (!empty($id)) {
         $coursepage = new coursepage(array('id' => $id));
         $coursepage->print_tabs('cmclasspage', array('id' => $id));
     }
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
 }