/**
  * should display header of ccform then the extra fields followed by footer of ccform
  */
 public function body_definition()
 {
     $mform =& $this->_form;
     $parent_obj = $this->_customdata['parent_obj'];
     $coursecurriculum = new curriculumcourse();
     $coursecurriculum->courseid = $parent_obj->id;
     if (isset($this->_customdata['obj'])) {
         $course = $this->_customdata['obj']->course;
         $curriculum = $this->_customdata['obj']->curriculum;
         $curriculas[$curriculum->id] = $curriculum->name;
     } else {
         $contexts = curriculumpage::get_contexts('block/curr_admin:associate');
         $curricula_avail = $coursecurriculum->get_curricula_avail(array('contexts' => $contexts));
         $curriculas = array();
         if (is_array($curricula_avail)) {
             foreach ($curricula_avail as $crsid => $c) {
                 $curriculas[$crsid] = $c->name . ' (' . $c->idnumber . ')';
             }
             natcasesort($curriculas);
         }
     }
     $mform->addElement('select', 'curriculumid', get_string('curriculum', 'block_curr_admin') . ':', $curriculas);
     $mform->addRule('curriculumid', null, 'required', null, 'client');
     $mform->setHelpButton('curriculumid', array('coursecurriculumform/curriculumname', get_string('curriculum', 'block_curr_admin'), 'block_curr_admin'));
     $mform->addElement('hidden', 'courseid', $parent_obj->id);
     $mform->setType('courseid', PARAM_INT);
     $mform->addElement('text', 'coursename', get_string('course', 'block_curr_admin') . ':', 'readonly="readonly"');
     $mform->setType('coursename', PARAM_TEXT);
     $mform->setHelpButton('coursename', array('coursecurriculumform/coursename', get_string('course', 'block_curr_admin'), 'block_curr_admin'));
     $this->set_data(array('coursename' => $parent_obj->name));
 }
Пример #2
0
 /**
  * Test that a user without program_view permissions does not get any data returned
  */
 public function test_nocurriculumpermission()
 {
     $this->load_csv_data();
     $this->setGuestUser();
     $curriculumfilter = array('contexts' => curriculumpage::get_contexts('local/elisprogram:program_view'));
     $curricula = clustercurriculum::get_curricula(1, 0, 5, 'cur.priority ASC, cur.name ASC', $curriculumfilter);
     $this->assertInternalType('array', $curricula);
     $this->assertEmpty($curricula);
 }
Пример #3
0
 function print_tabs()
 {
     $id = $this->required_param('id', PARAM_INT);
     $page = $this->get_tab_page();
     $params = array('id' => $id);
     $rows = array();
     $row = array();
     // main row of tabs
     foreach ($page->tabs as $tab) {
         $tab = $page->add_defaults_to_tab($tab);
         if ($tab['showtab'] === true) {
             $target = new $tab['page'](array_merge($tab['params'], $params));
             if (!$target->can_do()) {
                 //insufficient permissions according to tab's page, so don't add it
                 continue;
             }
             $row[] = new tabobject($tab['tab_id'], $target->url, $tab['name']);
         }
     }
     if (!empty($row)) {
         $rows[] = $row;
     }
     // assigned/unassigned tabs
     //$assignedpage = clone($this->get_basepage());
     //unset($assignedpage->params['_assign']);
     $assignedpage = $this->get_new_page(array('id' => $id, '_assign' => 'unassign'));
     // TBD: arbitrary != 'assign' ???
     //$unassignedpage = clone($assignedpage);
     //$unassignedpage->params['_assign'] = 'assign';
     $unassignedpage = $this->get_new_page(array('id' => $id, '_assign' => 'assign'));
     list($assigned_string, $unassigned_string) = $this->get_assigned_strings();
     $iscurstupage = get_class($this) == 'curriculumstudentpage';
     if (!$iscurstupage && $this->can_do_default() || $iscurstupage && curriculumpage::can_enrol_into_curriculum($id)) {
         $row = array(new tabobject('assigned', $assignedpage->url, $assigned_string), new tabobject('unassigned', $unassignedpage->url, $unassigned_string));
     } else {
         $row = array(new tabobject('assigned', $assignedpage->url, $assigned_string));
     }
     $rows[] = $row;
     print_tabs($rows, $this->is_assigning() ? 'unassigned' : 'assigned', array(), array(get_class($this)));
 }
 /**
  * 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)
 {
     global $CFG;
     $showcurricula = $this->check_curricula();
     if (isset($record->id)) {
         //add a default curriculum name if appropriate
         if ($showcurricula && empty($record->name)) {
             if (!empty($record->preservecurname)) {
                 //actually corresponds to class enrolments
                 $record->name = get_string('noncurriculumcourses', $this->languagefile);
             } else {
                 //doesn't correspond to anything
                 $record->name = get_string('na', $this->languagefile);
             }
         }
         //link curriculum name to its "view" page if the the current record has a curriculum
         if ($export_format == table_report::$EXPORT_FORMAT_HTML && !empty($record->curid)) {
             $page = new curriculumpage(array('id' => $record->curid, 'action' => 'view'));
             if ($page->can_do()) {
                 $url = $page->get_url();
                 $record->name = '<a href="' . $url . '" target="_blank">' . $record->name . '</a>';
             }
         }
         //base url
         $url = "{$CFG->wwwroot}/blocks/php_report/render_report_page.php";
         //params being passed via url
         $url_params = array('report' => 'user_class_completion_details', 'idnumber' => urlencode($record->useridnumber), 'idnumber_op' => generalized_filter_text::$OPERATOR_IS_EQUAL_TO);
         //used to track whether to add a ? or a &
         $first = true;
         foreach ($url_params as $key => $value) {
             //append the parameter to the url
             if ($first) {
                 $url .= '?';
             } else {
                 $url .= '&';
             }
             $url .= "{$key}={$value}";
             //signal the use of & on subsequent iterations
             $first = false;
         }
         //add parameters related to all these groups to the report
         $groupnames = array('filter-detailheaders', 'filter-detailcolumns');
         foreach ($groupnames as $groupname) {
             if ($first) {
                 $url .= '?';
             } else {
                 $url .= '&';
             }
             $url .= $this->get_param_url_string($groupname);
         }
         //extra attributes we are including in the anchor tag
         $tag_attributes = array('class' => 'external_report_link', 'target' => 'blank_');
         //build the additional attributes
         $attribute_string = '';
         foreach ($tag_attributes as $key => $value) {
             $attribute_string .= " {$key}={$value}";
         }
         //details label for the link.  First check to see if this is the first instance of the
         // student's record.  If so then show the details link.
         $link_text = '';
         if (0 != strcmp($this->student_id_num, $record->useridnumber)) {
             $link_text = get_string('details', $this->languagefile);
             $this->student_id_num = $record->useridnumber;
         }
         if ($export_format == table_report::$EXPORT_FORMAT_HTML) {
             //replace the empty column with the appropriate link
             $record->id = '<a href="' . $url . '"' . $attribute_string . '>' . $link_text . '</a>';
         } else {
             //in an export, so don't show link
             $record->id = '';
         }
     }
     //show link to user's profile based on capability to view the student management capability
     $fullname = fullname($record);
     if ($export_format == php_report::$EXPORT_FORMAT_HTML) {
         $userpage = new usermanagementpage(array('id' => $record->userid, 'action' => 'view'));
         if ($userpage->can_do()) {
             $record->lastname = '<span class="external_report_link"><a href="' . $userpage->get_url() . '" target="_blank">' . $fullname . '</a></span>';
         } else {
             $record->lastname = $fullname;
         }
     } else {
         $record->lastname = $fullname;
     }
     //convert times to appropriate format
     if (!empty($record->timecompleted) && !empty($record->completed)) {
         $record->timecompleted = $this->format_date($record->timecompleted);
     } else {
         $record->timecompleted = get_string('na', $this->languagefile);
     }
     if (!empty($record->timeexpired) && !empty($record->completed)) {
         $record->timeexpired = $this->format_date($record->timeexpired);
     } else {
         $record->timeexpired = get_string('na', $this->languagefile);
     }
     //N/A for cretificate number if a valid one is not set
     if (empty($record->certificatecode) || empty($record->completed)) {
         $record->certificatecode = get_string('na', $this->languagefile);
     }
     //copy result of complex query into simple field
     if (!empty($record->numcredits)) {
         //use the provided value
         $record->displaynumcredits = $this->format_credits($record->numcredits);
     } else {
         //default to zero
         $record->displaynumcredits = $this->format_credits(0);
     }
     //handle custom field default values and display logic
     $this->transform_custom_field_data($record);
     return $record;
 }
Пример #5
0
 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;
 }
 function can_do_default()
 {
     $id = $this->required_param('id', PARAM_INT);
     return curriculumpage::_has_capability('block/curr_admin:curriculum:edit', $id);
 }
Пример #7
0
 /**
  * Display the track listing, filtering on curriculum if the id parameter is present
  */
 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);
     $parent_clusterid = $this->optional_param('parent_clusterid', 0, PARAM_INT);
     //curriculum id
     $id = $this->get_cm_id();
     // Define columns
     $columns = array('name' => get_string('track_name', 'block_curr_admin'), 'description' => get_string('track_description', 'block_curr_admin'), 'parcur' => get_string('track_parcur', 'block_curr_admin'), 'class' => get_string('track_classes', 'block_curr_admin'));
     $items = track_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, $id, $parent_clusterid, trackpage::get_contexts('block/curr_admin:track:view'));
     $numitems = track_count_records($namesearch, $alpha, $id, $parent_clusterid, trackpage::get_contexts('block/curr_admin:track:view'));
     trackpage::get_contexts('block/curr_admin:track:edit');
     trackpage::get_contexts('block/curr_admin:track:delete');
     if (!empty($id)) {
         //print curriculum tabs if viewing from the curriculum view
         $curriculumpage = new curriculumpage(array('id' => $id));
         $curriculumpage->print_tabs('trackpage', array('id' => $id));
     }
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
 }
 function can_do_default()
 {
     $id = $this->required_param('id', PARAM_INT);
     if (curriculumpage::_has_capability('block/curr_admin:curriculum:view', $id)) {
         //allow viewing but not managing associations
         return true;
     }
     return curriculumpage::_has_capability('block/curr_admin:associate', $id);
 }
Пример #9
0
 /**
  * Display the track listing, filtering on curriculum if the id parameter is present
  */
 function display_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);
     $parent_clusterid = $this->optional_param('parent_clusterid', 0, PARAM_INT);
     //curriculum id
     $id = $this->get_cm_id();
     // Define columns
     $columns = array('name' => array('header' => get_string('track_name', 'local_elisprogram')), 'description' => array('header' => get_string('track_description', 'local_elisprogram')), 'parcur' => array('header' => get_string('track_parcur', 'local_elisprogram')), 'class' => array('header' => get_string('track_classes', 'local_elisprogram')));
     // TBD
     if ($dir !== 'DESC') {
         $dir = 'ASC';
     }
     if (isset($columns[$sort])) {
         $columns[$sort]['sortable'] = $dir;
     } else {
         $sort = 'name';
         $columns[$sort]['sortable'] = $dir;
     }
     $items = track_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, $id, $parent_clusterid, trackpage::get_contexts('local/elisprogram:track_view'));
     $numitems = track_count_records($namesearch, $alpha, $id, $parent_clusterid, trackpage::get_contexts('local/elisprogram:track_view'));
     trackpage::get_contexts('local/elisprogram:track_edit');
     trackpage::get_contexts('local/elisprogram:track_delete');
     if (!empty($id)) {
         //print curriculum tabs if viewing from the curriculum view
         $curriculumpage = new curriculumpage(array('id' => $id));
         $curriculumpage->print_tabs('trackpage', array('id' => $id));
     }
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
 }
Пример #10
0
 /**
  * Unassign the user from the program.
  * @param array $elements An array of elements to perform the action on.
  * @param bool $bulkaction Whether this is a bulk-action or not.
  * @return array An array to format as JSON and return to the Javascript.
  */
 protected function _respond_to_js(array $elements, $bulkaction)
 {
     global $DB;
     $pgmid = required_param('id', PARAM_INT);
     // Permissions.
     $cpage = new curriculumpage();
     if ($cpage->_has_capability('local/elisprogram:program_view', $pgmid) !== true) {
         return array('result' => 'fail', 'msg' => get_string('not_permitted', 'local_elisprogram'));
     }
     foreach ($elements as $userid => $label) {
         if ($this->can_unassign($pgmid, $userid) === true) {
             $assignrec = $DB->get_record(curriculumstudent::TABLE, array('userid' => $userid, 'curriculumid' => $pgmid));
             if (!empty($assignrec)) {
                 $curstu = new curriculumstudent($assignrec);
                 $curstu->delete();
             }
         }
     }
     return array('result' => 'success', 'msg' => 'Success');
 }
Пример #11
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(cm_get_param('search', ''));
     $alpha = cm_get_param('alpha', '');
     // Define columns
     $columns = array('name' => get_string('curriculum_name', 'block_curr_admin'), 'description' => get_string('curriculum_shortdescription', 'block_curr_admin'), 'reqcredits' => get_string('curriculum_reqcredits', 'block_curr_admin'), 'courses' => get_string('courses', 'block_curr_admin'), 'priority' => get_string('priority', 'block_curr_admin'));
     // Get list of users
     $items = curriculum_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, curriculumpage::get_contexts('block/curr_admin:curriculum:view'));
     $numitems = curriculum_count_records($namesearch, $alpha, curriculumpage::get_contexts('block/curr_admin:curriculum:view'));
     curriculumpage::get_contexts('block/curr_admin:curriculum:edit');
     curriculumpage::get_contexts('block/curr_admin:curriculum:delete');
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
 }
Пример #12
0
/**
 * Dynamically loads child menu items for a cluster 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_userset($id, $parent_cluster_id, $parent_curriculum_id, $num_block_icons, $parent_path = '')
{
    global $CFG;
    //page dependencies
    require_once elispm::file('coursepage.class.php');
    $result_items = array();
    /*****************************************
     * Cluster - Child Cluster Associations
     *****************************************/
    //note - no need to worry about permissions since there is no prevents/prohibits in ELIS
    $cluster_css_class = block_elisadmin_get_item_css_class('cluster_instance');
    $listing = cluster_get_listing('name', 'ASC', 0, $num_block_icons, '', '', array('parent' => $id));
    //$listing = cluster_get_listing('priority, name', 'ASC', 0, $num_block_icons, '', '', array('parent' => $id));
    if (!empty($listing)) {
        foreach ($listing as $item) {
            $params = array('id' => $item->id, 'action' => 'view');
            $cluster_count = cluster_count_records('', '', array('parent' => $item->id));
            $curriculum_count = clustercurriculum::count_curricula($item->id);
            $isLeaf = empty($cluster_count) && empty($curriculum_count);
            $result_items[] = block_elisadmin_get_menu_item('userset', $item, 'root', $cluster_css_class, $item->id, $parent_curriculum_id, $params, $isLeaf, $parent_path);
        }
    }
    //summary item
    $num_records = cluster_count_records('', '', array('parent' => $id));
    if ($num_block_icons < $num_records) {
        $params = array('id' => $parent_cluster_id);
        $result_items[] = block_elisadmin_get_menu_summary_item('userset', $cluster_css_class, $num_records - $num_block_icons, $params, '', $parent_path);
    }
    /*****************************************
     * Cluster - Curriculum
     *****************************************/
    $curriculum_css_class = block_elisadmin_get_item_css_class('curriculum_instance');
    //permissions filter
    $curriculum_filter = array('contexts' => curriculumpage::get_contexts('local/elisprogram:program_view'));
    $curricula = clustercurriculum::get_curricula($id, 0, $num_block_icons, 'cur.priority ASC, cur.name ASC', $curriculum_filter);
    if (!empty($curricula)) {
        foreach ($curricula as $curriculum) {
            $curriculum->id = $curriculum->curriculumid;
            $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, $parent_cluster_id, $track_contexts);
            //count associated clusters
            $cluster_filter = array('contexts' => usersetpage::get_contexts('local/elisprogram:userset_view'));
            $cluster_count = clustercurriculum::count_clusters($curriculum->id, $parent_cluster_id, $cluster_filter);
            $isLeaf = empty($course_count) && empty($track_count) && empty($cluster_count);
            $result_items[] = block_elisadmin_get_menu_item('curriculum', $curriculum, 'root', $curriculum_css_class, $parent_cluster_id, $curriculum->id, $params, $isLeaf, $parent_path);
        }
    }
    //summary item
    $num_records = clustercurriculum::count_curricula($id, $curriculum_filter);
    if ($num_block_icons < $num_records) {
        $params = array('id' => $id);
        $result_items[] = block_elisadmin_get_menu_summary_item('clustercurriculum', $curriculum_css_class, $num_records - $num_block_icons, $params, '', $parent_path);
    }
    return $result_items;
}
Пример #13
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;
 }
 /**
  * Specifies whether the current user can edit corequisites
  *
  * @return  boolean  true if allowed, otherwise false
  */
 function can_do_coreqedit()
 {
     $id = $this->required_param('id', PARAM_INT);
     return curriculumpage::_has_capability('block/curr_admin:associate', $id);
 }
Пример #15
0
/**
 * Dynamically loads child menu items for a cluster entity
 *
 * @param   int             $id                    The entity id
 * @param   int             $parent_cluster_id     The last cluster passed going down the curr_admin tree, or 0 if none
 * @param   int             $parent_curriculum_id  The last curriculum passed going down the curr_admin 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_curr_admin_load_menu_children_cluster($id, $parent_cluster_id, $parent_curriculum_id, $num_block_icons, $parent_path = '')
{
    global $CFG, $USER;
    // page dependencies
    require_once $CFG->dirroot . '/curriculum/coursepage.class.php';
    //error_log("block_curr_admin_load_menu_children_cluster($id, $parent_cluster_id, $parent_curriculum_id, $num_block_icons, $parent_path)");
    $result_items = array();
    /*****************************************
     * Cluster - Child Cluster Associations
     *****************************************/
    // TBD: no permission check 'cause currently there is no prevents/prohibits in ELIS
    $cluster_css_class = block_curr_admin_get_item_css_class('cluster_instance');
    $parent_clst_filter = array('contexts' => clusterpage::get_contexts('block/curr_admin:cluster:view'), 'parent' => $id);
    $listing = cluster_get_listing('priority, name', 'ASC', 0, $num_block_icons, '', '', $parent_clst_filter);
    $curriculum_filter = array('contexts' => curriculumpage::get_contexts('block/curr_admin:curriculum:view'));
    if (!empty($listing)) {
        foreach ($listing as $item) {
            $params = array('id' => $item->id, 'action' => 'view');
            $cluster_filter = array('contexts' => clusterpage::get_contexts('block/curr_admin:cluster:view'), 'parent' => $item->id);
            $cluster_count = cluster_count_records('', '', $cluster_filter);
            $curriculum_count = clustercurriculum::count_curricula($item->id, $curriculum_filter);
            $isLeaf = empty($cluster_count) && empty($curriculum_count);
            $result_items[] = block_curr_admin_get_menu_item('cluster', $item, 'root', $cluster_css_class, $item->id, $parent_curriculum_id, $params, $isLeaf, $parent_path);
            //error_log("block_curr_admin_load_menu_children_cluster(); parent of cluster child = {$result_items[count($result_items) - 1]->parent}");
        }
    }
    //summary item
    $num_records = cluster_count_records('', '', $parent_clst_filter);
    if ($num_block_icons < $num_records) {
        $params = array('id' => $parent_cluster_id);
        $result_items[] = block_curr_admin_get_menu_summary_item('cluster', $cluster_css_class, $num_records - $num_block_icons, $params, '', $parent_path);
    }
    /*****************************************
     * Cluster - Curriculum
     *****************************************/
    $curriculum_css_class = block_curr_admin_get_item_css_class('curriculum_instance');
    // permissions filter
    $curricula = clustercurriculum::get_curricula($id, 0, $num_block_icons, 'cur.priority ASC, cur.name ASC', $curriculum_filter);
    if (!empty($curricula)) {
        foreach ($curricula as $curriculum) {
            $curriculum->id = $curriculum->curriculumid;
            $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, $parent_cluster_id, $track_contexts);
            // count associated clusters
            $cluster_filter = array('contexts' => clusterpage::get_contexts('block/curr_admin:cluster:view'));
            $cluster_count = clustercurriculum::count_clusters($curriculum->id, $parent_cluster_id, $cluster_filter);
            $isLeaf = empty($course_count) && empty($track_count) && empty($cluster_count);
            $result_items[] = block_curr_admin_get_menu_item('curriculum', $curriculum, 'root', $curriculum_css_class, $parent_cluster_id, $curriculum->id, $params, $isLeaf, $parent_path);
        }
    }
    //summary item
    $num_records = clustercurriculum::count_curricula($id, $curriculum_filter);
    if ($num_block_icons < $num_records) {
        $params = array('id' => $id);
        $result_items[] = block_curr_admin_get_menu_summary_item('clustercurriculum', $curriculum_css_class, $num_records - $num_block_icons, $params, '', $parent_path);
    }
    //error_log("block_curr_admin_load_menu_children_cluster => " . count($result_items) . " child meuitems.");
    return $result_items;
}
Пример #16
0
 /**
  * Determine whether the current user can enrol students into the class.
  * @return bool Whether the user can enrol users into the class or not.
  */
 public function can_do_add()
 {
     $id = $this->required_param('id');
     return curriculumpage::can_enrol_into_curriculum($id);
 }
 function __construct(&$items, $columns, $pageurl, $decorators = array())
 {
     global $CURMAN, $USER;
     parent::__construct($items, $columns, $pageurl, $decorators);
     $id = required_param('id', PARAM_INT);
     if (!curriculumpage::_has_capability('block/curr_admin:curriculum:enrol', $id)) {
         $context = cm_context_set::for_user_with_capability('cluster', 'block/curr_admin:curriculum:enrol_cluster_user', $USER->id);
         $allowed_clusters = array();
         //get the clusters assigned to this curriculum
         $clusters = clustercurriculum::get_clusters($id);
         if (!empty($clusters)) {
             foreach ($clusters as $cluster) {
                 if ($context->context_allowed($cluster->clusterid, 'cluster')) {
                     $allowed_clusters[] = $cluster->id;
                 }
             }
         }
         $this->allowed_clusters = $allowed_clusters;
     }
 }
Пример #18
0
 function definition()
 {
     $mform =& $this->_form;
     $id = required_param('id', PARAM_INT);
     if (curriculumpage::can_enrol_into_curriculum($id)) {
         $mform->addElement('hidden', 'id');
         $mform->setType('id', PARAM_INT);
         $mform->addElement('hidden', '_assign', 'unassign');
         $mform->setType('_assign', PARAM_TEXT);
         $mform->addElement('hidden', 's', 'curstu');
         $mform->setType('s', PARAM_TEXT);
         $mform->addElement('hidden', '_selection');
         $mform->setType('_selection', PARAM_TEXT);
         $this->add_action_buttons(false, $this->get_submit_button_name());
     }
 }
 /**
  * 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;
 }
Пример #20
0
 /**
  * Transforms each result.
  * @param array $row An array for a single result.
  * @return array The transformed result.
  */
 protected function results_row_transform(array $row)
 {
     $row = parent::results_row_transform($row);
     // Whether the user can unassign from the program at all.
     static $canunassignany = null;
     // Whether the user can unassin any user from the program.
     static $canunassignall = null;
     // If not already set, determine whether the user can do any unassigning.
     if ($canunassignany === null) {
         $canunassignany = curriculumpage::can_enrol_into_curriculum($this->programid);
     }
     // If not already set, determine whether the user can unassign anyone - but only if $canunassignany is true.
     if ($canunassignany === true && $canunassignall === null) {
         $cpage = new curriculumpage();
         if ($cpage->_has_capability('local/elisprogram:program_enrol', $this->programid)) {
             $canunassignall = true;
         }
     }
     // Set the 'canunassign' parameter for use in javascript.
     if ($canunassignall === true) {
         $row['canunassign'] = '1';
     } else {
         if ($canunassignany === true) {
             $row['canunassign'] = curriculumstudent::can_manage_assoc($row['element_id'], $this->programid) === true ? '1' : '0';
         } else {
             $row['canunassign'] = '0';
         }
     }
     return $row;
 }
Пример #21
0
 /**
  * Test creating a new program entity with a default role assignment defined.
  */
 public function test_createprogramwithdefaultroleassignment()
 {
     global $DB, $USER;
     list($rcid, $reid) = $this->create_roles('program');
     // Setup the editor role to be the default role for the program context.
     elis::$config->local_elisprogram->default_curriculum_role_id = $reid;
     $sysctx = context_system::instance();
     // Assign the test user the creator role.
     role_assign($rcid, 100, $sysctx->id);
     // Create a new program entity.
     $data = array('idnumber' => 'program100', 'name' => 'program100', 'description' => 'program100');
     $obj = new curriculum($data);
     $obj->save();
     // Initialize a new program management page and invoke the code that handles default role assignments.
     $page = new curriculumpage();
     $page->after_cm_entity_add($obj);
     $programctx = \local_elisprogram\context\program::instance($obj->id);
     $params = array('roleid' => $reid, 'userid' => $USER->id, 'contextid' => $programctx->id);
     $this->assertTrue($DB->record_exists('role_assignments', $params));
 }
Пример #22
0
 /**
  * Determines whether the current user is allowed to create, edit, and delete associations
  * between a user and a curriculum
  *
  * @param    int      $userid  The id of the user being associated to the curricula
  * @param    int      $curid   The id of the curricula we are associating the user to
  *
  * @return   boolean           True if the current user has the required permissions, otherwise false
  */
 public static function can_manage_assoc($userid, $curid)
 {
     global $USER, $DB;
     // TODO: Ugly, this needs to be overhauled
     $cpage = new curriculumpage();
     if (!curriculumpage::can_enrol_into_curriculum($curid)) {
         //the users who satisfty this condition are a superset of those who can manage associations
         return false;
     } else {
         if ($cpage->_has_capability('local/elisprogram:program_enrol', $curid)) {
             //current user has the direct capability
             return true;
         }
     }
     //get the context for the "indirect" capability
     $context = pm_context_set::for_user_with_capability('cluster', 'local/elisprogram:program_enrol_userset_user', $USER->id);
     $allowedclusters = array();
     // Get the clusters and check the context against them.
     $clusters = clustercurriculum::get_clusters($curid);
     $allowedclusters = $context->get_allowed_instances($clusters, 'cluster', 'clusterid');
     // Query to get users associated to at least one enabling cluster.
     $clusterselect = '';
     if (empty($allowedclusters)) {
         $clusterselect = '0=1';
     } else {
         $clusterselect = 'clusterid IN (' . implode(',', $allowedclusters) . ')';
     }
     $select = "userid = {$userid} AND {$clusterselect}";
     //user just needs to be in one of the possible clusters
     if ($DB->record_exists_select(clusterassignment::TABLE, $select)) {
         return true;
     }
     return false;
 }
 /**
  * Determines whether the current user is allowed to create, edit, and delete associations
  * between a user and a curriculum
  *
  * @param    int      $userid  The id of the user being associated to the curricula
  * @param    int      $curid   The id of the curricula we are associating the user to
  *
  * @return   boolean           True if the current user has the required permissions, otherwise false
  */
 public static function can_manage_assoc($userid, $curid)
 {
     global $USER;
     if (!curriculumpage::can_enrol_into_curriculum($curid)) {
         //the users who satisfty this condition are a superset of those who can manage associations
         return false;
     } else {
         if (curriculumpage::_has_capability('block/curr_admin:curriculum:enrol', $curid)) {
             //current user has the direct capability
             return true;
         }
     }
     //get the context for the "indirect" capability
     $context = cm_context_set::for_user_with_capability('cluster', 'block/curr_admin:curriculum:enrol_cluster_user', $USER->id);
     $allowed_clusters = array();
     //get the clusters and check the context against them
     $clusters = clustercurriculum::get_clusters($curid);
     $allowed_clusters = $context->get_allowed_instances($clusters, 'cluster', 'id');
     //query to get users associated to at least one enabling cluster
     $cluster_select = '';
     if (empty($allowed_clusters)) {
         $cluster_select = '0=1';
     } else {
         $cluster_select = 'clusterid IN (' . implode(',', $allowed_clusters) . ')';
     }
     $select = "userid = {$userid} AND {$cluster_select}";
     //user just needs to be in one of the possible clusters
     if (record_exists_select(CLSTUSERTABLE, $select)) {
         return true;
     }
     return false;
 }
Пример #24
0
 function display_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' => array('header' => get_string('curriculum_name', 'local_elisprogram')), 'description' => array('header' => get_string('description', 'local_elisprogram')), 'reqcredits' => array('header' => get_string('curriculum_reqcredits', 'local_elisprogram')), 'courses' => array('header' => get_string('courses', 'local_elisprogram')), 'priority' => array('header' => get_string('priority', 'local_elisprogram')));
     if ($dir !== 'DESC') {
         $dir = 'ASC';
     }
     if (isset($columns[$sort])) {
         $columns[$sort]['sortable'] = $dir;
     }
     // Get list of users
     $items = curriculum_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, curriculumpage::get_contexts('local/elisprogram:program_view'));
     $numitems = curriculum_count_records($namesearch, $alpha, curriculumpage::get_contexts('local/elisprogram:program_view'));
     curriculumpage::get_contexts('local/elisprogram:program_edit');
     curriculumpage::get_contexts('local/elisprogram:program_delete');
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
 }
Пример #25
0
 /**
  * Do copy curriculum.
  */
 public function do_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', 'local_elisprogram'), 'red');
     }
     $targetcluster = new userset($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;
             }
             $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;
                     pmclasspage::after_cm_entity_add($class);
                 }
             }
             if (!empty($rv['curricula'])) {
                 $newcurr = new curriculum($rv['curricula'][$curr->id]);
                 $tempcurr = new stdClass();
                 $tempcurr->name = $curr->name;
                 $tempcurr->newname = $newcurr->name;
                 notify(get_string('clustcpycurr', 'local_elisprogram', $tempcurr), 'notifysuccess');
             }
         }
     }
     $tmppage = new clustercurriculumpage(array('id' => $data['id']));
     redirect($tmppage->url, '', 2);
 }