/** * Install function for this plugin * * @return boolean true Returns true to satisfy install procedure */ function xmldb_elisprogram_usetclassify_install() { global $CFG, $DB; require_once elispm::lib('setup.php'); require_once elis::lib('data/customfield.class.php'); require_once elispm::file('plugins/usetclassify/usersetclassification.class.php'); // Migrate component. $oldcmp = 'pmplugins_userset_classification'; $newcmp = 'elisprogram_usetclassify'; $upgradestepfuncname = 'elisprogram_usetclassify_pre26upgradesteps'; $tablechanges = array('crlm_cluster_classification' => 'elisprogram_usetclassify'); $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname, $tablechanges); if ($migrator->old_component_installed() === true) { $migrator->migrate(); } $field = new field(); $field->shortname = USERSET_CLASSIFICATION_FIELD; $field->name = get_string('classification_field_name', 'elisprogram_usetclassify'); $field->datatype = 'char'; $category = new field_category(); $category->name = get_string('classification_category_name', 'elisprogram_usetclassify'); $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USERSET, $category); // make sure we're set as owner if (!isset($field->owners['userset_classifications'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'userset_classifications'; $owner->save(); } // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = 'moodle/user:update'; $owner->param_control = 'menu'; $owner->param_options_source = 'userset_classifications'; $owner->param_help_file = 'elisprogram_usetclassify/cluster_classification'; $owner->save(); } // make sure we have a default value set if (!field_data::get_for_context_and_field(NULL, $field)) { field_data::set_for_context_and_field(NULL, $field, 'regular'); } $regclassify = $DB->get_record(usersetclassification::TABLE, array('shortname' => 'regular')); if (empty($regclassify)) { $default = new usersetclassification(); $default->shortname = 'regular'; $default->name = get_string('cluster', 'local_elisprogram'); $default->param_autoenrol_curricula = 1; $default->param_autoenrol_tracks = 1; $default->save(); } return true; }
/** * Install function for this plugin * * @return boolean true Returns true to satisfy install procedure */ function xmldb_elisprogram_preposttest_install() { global $CFG; require_once elispm::lib('setup.php'); require_once elis::lib('data/customfield.class.php'); // Migrate component. $oldcmp = 'pmplugins_pre_post_test'; $newcmp = 'elisprogram_preposttest'; $upgradestepfuncname = 'elisprogram_preposttest_pre26upgradesteps'; $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname); if ($migrator->old_component_installed() === true) { $migrator->migrate(); } // Pre-test field $field = new field(); $field->shortname = PRE_TEST_FIELD; $field->name = get_string('pre_test_field_name', 'elisprogram_preposttest'); $field->datatype = 'char'; $category = new field_category(); $category->name = get_string('pre_post_test_category_name', 'elisprogram_preposttest'); $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_COURSE, $category); // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = ''; $owner->param_control = 'menu'; $owner->param_options_source = 'learning_objectives'; $owner->param_help_file = 'elisprogram_preposttest/pre_test'; $owner->save(); } // Post-test field $field = new field(); $field->shortname = POST_TEST_FIELD; $field->name = get_string('post_test_field_name', 'elisprogram_preposttest'); $field->datatype = 'char'; $category = new field_category(); $category->name = get_string('pre_post_test_category_name', 'elisprogram_preposttest'); $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_COURSE, $category); // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = ''; $owner->param_control = 'menu'; $owner->param_options_source = 'learning_objectives'; $owner->param_help_file = 'elisprogram_preposttest/post_test'; $owner->save(); } return true; }
/** * Return the list of tables that should be overlayed. */ protected static function get_overlay_tables() { global $CFG; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elis::lib('data/customfield.class.php'); require_once elispm::lib('data/course.class.php'); require_once elispm::lib('data/curriculum.class.php'); require_once elispm::lib('data/curriculumcourse.class.php'); require_once elispm::lib('data/pmclass.class.php'); require_once elispm::lib('data/track.class.php'); return array(course::TABLE => 'local_elisprogram', curriculum::TABLE => 'local_elisprogram', curriculumcourse::TABLE => 'local_elisprogram', field::TABLE => 'local_eliscore', pmclass::TABLE => 'local_elisprogram', track::TABLE => 'local_elisprogram', trackassignment::TABLE => 'local_elisprogram'); }
/** * Require ELIS dependencies if ELIS is installed, otherwise return false. * @return bool Whether ELIS dependencies were successfully required. */ public static function require_elis_dependencies() { global $CFG; if (file_exists($CFG->dirroot . '/local/elisprogram/lib/setup.php')) { require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elispm::lib('data/pmclass.class.php'); require_once elispm::lib('data/user.class.php'); require_once elis::lib('data/customfield.class.php'); require_once dirname(__FILE__) . '/../../importplugins/version1elis/version1elis.class.php'; return true; } else { return false; } }
/** * Get custom fields for classes. * @return array An Array of class custom fields. */ public static function get_class_custom_fields() { global $DB, $CFG; if (static::require_elis_dependencies() === true) { require_once elis::lib('data/customfield.class.php'); $sql = 'SELECT shortname, name, datatype, multivalued FROM {' . field::TABLE . '} f JOIN {' . field_contextlevel::TABLE . '} fctx ON f.id = fctx.fieldid AND fctx.contextlevel = ?'; $sqlparams = array(CONTEXT_ELIS_CLASS); return $DB->get_records_sql($sql, $sqlparams); } else { return array(); } }
function delete() { // delete associated data require_once elis::lib('data/data_filter.class.php'); //filter specific for tracks, due to different field name $filter = new field_filter('curid', $this->id); track::delete_records($filter, $this->_db); //filter for all other associations $filter = new field_filter('curriculumid', $this->id); clustercurriculum::delete_records($filter, $this->_db); curriculumcourse::delete_records($filter, $this->_db); curriculumstudent::delete_records($filter, $this->_db); parent::delete(); //clean up the curriculum context instance $context = \local_elisprogram\context\program::instance($this->id); $context->delete(); }
/** * Set up necessary data * * @param int $numfields The number of custom fields used in auto-association */ private function init_required_data($numfields = 1) { global $CFG, $DB; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php'); require_once elis::lib('data/customfield.class.php'); require_once elispm::file('accesslib.php'); require_once elispm::lib('data/userset.class.php'); require_once $CFG->dirroot . '/user/profile/definelib.php'; require_once $CFG->dirroot . '/user/profile/field/checkbox/define.class.php'; // Set up the category only once. $fieldcategory = new field_category(array('name' => 'testcategoryname')); $fieldcategory->save(); // Ste up the target userset only once. $userset = new userset(array('name' => 'testusersetname')); $userset->save(); for ($i = 1; $i <= $numfields; $i++) { // Custom field. $field = new field(array('categoryid' => $fieldcategory->id, 'shortname' => 'testfieldshortname' . $i, 'name' => 'testfieldname' . $i, 'datatype' => 'bool')); $field->save(); // Ensure manual field owner exists for syncing. field_owner::ensure_field_owner_exists($field, 'manual'); $ownerid = $DB->get_field(field_owner::TABLE, 'id', array('fieldid' => $field->id, 'plugin' => 'manual')); $owner = new field_owner($ownerid); $owner->param_control = 'checkbox'; $owner->save(); // Ensure moodle profile field owner exists. field_owner::ensure_field_owner_exists($field, 'moodle_profile'); $DB->execute("UPDATE {" . field_owner::TABLE . "} SET exclude = ?", array(pm_moodle_profile::sync_to_moodle)); // Field context level assocation. $fieldcontextlevel = new field_contextlevel(array('fieldid' => $field->id, 'contextlevel' => CONTEXT_ELIS_USER)); $fieldcontextlevel->save(); // The associated Moodle user profile field. $profiledefinecheckbox = new profile_define_checkbox(); $data = new stdClass(); $data->datatype = 'checkbox'; $data->categoryid = 99999; $data->shortname = 'testfieldshortname' . $i; $data->name = 'testfieldname' . $i; $profiledefinecheckbox->define_save($data); $mfield = $DB->get_record('user_info_field', array('shortname' => 'testfieldshortname' . $i)); // The "cluster-profile" association. $usersetprofile = new userset_profile(array('clusterid' => $userset->id, 'fieldid' => $mfield->id, 'value' => 1)); $usersetprofile->save(); } }
/** * Install function for this plugin * * @return boolean true Returns true to satisfy install procedure */ function xmldb_elisprogram_archive_install() { global $CFG; require_once elispm::lib('setup.php'); require_once elis::lib('data/customfield.class.php'); // Migrate component. $oldcmp = 'pmplugins_archive'; $newcmp = 'elisprogram_archive'; $upgradestepfuncname = 'elisprogram_archive_pre26upgradesteps'; $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname); if ($migrator->old_component_installed() === true) { $migrator->migrate(); } // Archive field $field = new field(); $field->shortname = ARCHIVE_FIELD; $field->name = get_string('archive_field_name', 'elisprogram_archive'); $field->datatype = 'bool'; $category = new field_category(); $category->name = get_string('archive_category_name', 'elisprogram_archive'); $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_PROGRAM, $category); // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_required = 0; $owner->param_view_capability = ''; $owner->param_edit_capability = ''; $owner->param_control = 'checkbox'; $owner->param_options_source = ''; $owner->param_help_file = 'elisprogram_archive/archive_program'; $owner->save(); } $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'elisprogram_archive/archive_program'); field_owner::ensure_field_owner_exists($field, 'manual', $owner_options); return true; }
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package elis * @subpackage programmanagement * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * */ defined('MOODLE_INTERNAL') || die; require_once elis::lib('data/data_filter.class.php'); function get_contexts_by_capability_for_user($contextlevel, $capability, $userid, $doanything = true) { return pm_context_set::for_user_with_capability($contextlevel, $capability, $userid, $doanything); } class pm_context_set { /** * An array of the contexts (both at the requested context level, and in * parent context levels) where the user is assigned the given * capabilities. Clusters are considered a parent context of users. The * return type is an array. The array has keys set to the name of the * context level, and the value is an array of instance IDs where the user * has the given capability. */ var $contexts;
* values are arrays to pass to setHelpButton($helpbuttonargs) * --- not implemented in all sub-filters! * * @package local_eliscore * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net) * */ defined('MOODLE_INTERNAL') || die; require_once $CFG->dirroot . '/local/eliscore/lib/filtering/lib.php'; // Include the simple filter types that will be returned by an object of this type. require_once elis::lib('filtering/simpleselect.php'); require_once elis::lib('filtering/text.php'); require_once elis::lib('filtering/date.php'); require_once elis::lib('filtering/userprofiledatetime.php'); /** * Base class for multi-filter filters. * * A multi-filter is any filter which returns a group of related filter objects. The primary * example of this filter who be a user profile filter which displays all of the profile fields * as individual filter elements. In fact, this base class is derived from just such a filter. */ // BJB110330: php_report block upgrade increased size from 50 to 255 define('MAX_FILTER_SUFFIX_LEN', 30); // was 6 before DB upgrade /** * Generic multifilter class - standalone, no parent! */ class generalized_filter_multifilter {
* * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_elisprogram * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net) * */ defined('MOODLE_INTERNAL') || die; require_once dirname(__FILE__) . '/../../../../config.php'; global $CFG; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elis::lib('data/data_object.class.php'); require_once elis::lib('table.class.php'); require_once elispm::lib('lib.php'); require_once elispm::lib('deprecatedlib.php'); require_once elispm::lib('data/classmoodlecourse.class.php'); require_once elispm::lib('data/course.class.php'); require_once elispm::lib('data/curriculumcourse.class.php'); require_once elispm::lib('data/instructor.class.php'); require_once elispm::lib('data/pmclass.class.php'); require_once elispm::lib('data/user.class.php'); require_once elispm::lib('data/waitlist.class.php'); define('STUTABLE', 'local_elisprogram_cls_enrol'); define('GRDTABLE', 'local_elisprogram_cls_graded'); define('STUSTATUS_NOTCOMPLETE', 0); define('STUSTATUS_FAILED', 1); define('STUSTATUS_PASSED', 2); class student extends elis_data_object
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_datahub * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net) * */ require_once dirname(__FILE__) . '/../../../../local/eliscore/lib/setup.php'; require_once elis::lib('testlib.php'); /** * This class is handling log maintenance */ abstract class rlip_test extends elis_database_test { static $existing_csvfiles = array(); static $existing_logfiles = array(); static $existing_zipfiles = array(); /** * Do setup before tests. */ protected function setUp() { global $CFG; $ob = ob_get_level();
/** * Create the test custom profile field and owner * * @param string $contextlevelname The name of the custom context level to create the field at * @param string $name PM custom field shortname * @param string $datatype The string identifier of the data type to use * @param string $uitype The string identifier of the UI / control type to use * @param int $categoryid PM custom field category id * @param string $options Extra parameter, used for select options * @param string $defaultdata Default value. * * @return int The id of the created field */ private function create_test_field($contextlevelname = 'user', $name = 'testfieldname', $datatype, $uitype, $categoryid, $options = null, $defaultdata = null) { global $CFG; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elis::lib('data/customfield.class.php'); // Category contextlevel. $contextlevel = \local_eliscore\context\helper::get_level_from_name($contextlevelname); $fieldcategorycontextlevel = new field_category_contextlevel(array('categoryid' => $categoryid, 'contextlevel' => $contextlevel)); $fieldcategorycontextlevel->save(); // Field. $field = new field(array('shortname' => 'testfieldshortname', 'name' => $name, 'categoryid' => $categoryid, 'datatype' => $datatype)); $field->save(); // Field_data if a default value needs to be set. if ($defaultdata !== null) { $classname = 'field_data_' . $datatype; $fielddata = new $classname(array('fieldid' => $field->id, 'data' => $defaultdata)); $fielddata->save(); } // Field contextlevel. $fieldcontextlevel = new field_contextlevel(array('fieldid' => $field->id, 'contextlevel' => $contextlevel)); $fieldcontextlevel->save(); // Field owner. $ownerdata = array('control' => $uitype); if ($options !== null) { // Set options. $options = is_array($options) ? implode("\n", $options) : $options; $ownerdata['options'] = $options; } field_owner::ensure_field_owner_exists($field, 'manual', $ownerdata); return $field; }
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_eliscore * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net) * */ defined('MOODLE_INTERNAL') || die; require_once $CFG->dirroot . '/backup/util/includes/backup_includes.php'; require_once elis::lib('rollover/backup/rollover_backup_factory.class.php'); /** * Class representing the plan used during the backup portion of the rollover */ class rollover_backup_plan extends backup_plan { /** * Entry point for building the backup plan */ public function build() { rollover_backup_factory::build_plan($this->controller); // Dispatch to correct format $this->built = true; } /**
/** * Validate that deleting a userset deletes all appropriate associations */ public function test_delete_elis_userset_deletes_associations() { global $CFG, $DB; // Entities. require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elispm::lib('data/userset.class.php'); require_once elispm::lib('data/user.class.php'); require_once elispm::lib('data/curriculum.class.php'); require_once elispm::lib('data/track.class.php'); require_once elis::lib('data/customfield.class.php'); // Associations. require_once elispm::lib('data/clusterassignment.class.php'); require_once elispm::lib('data/clustercurriculum.class.php'); require_once elispm::lib('data/clustertrack.class.php'); require_once elispm::file('enrol/userset/moodleprofile/userset_profile.class.php'); // For context level access. require_once elispm::file('accesslib.php'); $origfieldcount = $DB->count_records(field::TABLE); // Set up user set. $userset = new userset(array('name' => 'testusersetname')); $userset->save(); // Set up other entities and associations. // Cluster enrolment. $user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => '*****@*****.**', 'country' => 'CA')); $user->save(); $clusterassignment = new clusterassignment(array('clusterid' => $userset->id, 'userid' => $user->id)); $clusterassignment->save(); // Cluster-curriculum assignment. $curriculum = new curriculum(array('idnumber' => 'testcurriculumidnumber')); $curriculum->save(); $clustercurriculum = new clustercurriculum(array('clusterid' => $userset->id, 'curriculumid' => $curriculum->id)); $clustercurriculum->save(); // Cluster-track assignment. $track = new track(array('curid' => $curriculum->id, 'idnumber' => 'testtrackidnumber')); $track->save(); $clustertrack = new clustertrack(array('clusterid' => $userset->id, 'trackid' => $track->id)); $clustertrack->save(); // Custom field. $field = new field(array('name' => 'testfieldname', 'categoryid' => 9999)); $field->save(); $context = \local_elisprogram\context\userset::instance($userset->id); $data = new field_data_int(array('contextid' => $context->id, 'fieldid' => $field->id, 'data' => 1)); $data->save(); // Cluster profile criteria. $clusterprofile = new userset_profile(array('clusterid' => $userset->id, 'fieldid' => $field->id, 'value' => 0)); $clusterprofile->save(); // Validate setup. $this->assertEquals(1, $DB->count_records(userset::TABLE)); $this->assertEquals(1, $DB->count_records(user::TABLE)); $this->assertEquals(1, $DB->count_records(clusterassignment::TABLE)); $this->assertEquals(1, $DB->count_records(curriculum::TABLE)); $this->assertEquals(1, $DB->count_records(clustercurriculum::TABLE)); $this->assertEquals(1, $DB->count_records(track::TABLE)); $this->assertEquals(1, $DB->count_records(clustertrack::TABLE)); $this->assertEquals(1 + $origfieldcount, $DB->count_records(field::TABLE)); $this->assertEquals(1, $DB->count_records(field_data_int::TABLE)); $this->assertEquals(1, $DB->count_records(userset_profile::TABLE)); // Run the import. $data = array('action' => 'delete'); $this->run_core_userset_import($data, true); // Validation. $this->assertEquals(0, $DB->count_records(userset::TABLE)); $this->assertEquals(1, $DB->count_records(user::TABLE)); $this->assertEquals(0, $DB->count_records(clusterassignment::TABLE)); $this->assertEquals(1, $DB->count_records(curriculum::TABLE)); $this->assertEquals(0, $DB->count_records(clustercurriculum::TABLE)); $this->assertEquals(1, $DB->count_records(track::TABLE)); $this->assertEquals(0, $DB->count_records(clustertrack::TABLE)); $this->assertEquals(1 + $origfieldcount, $DB->count_records(field::TABLE)); $this->assertEquals(0, $DB->count_records(field_data_int::TABLE)); $this->assertEquals(0, $DB->count_records(userset_profile::TABLE)); }
* @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote Learner.net Inc http://www.remote-learner.net * */ /** * NOTE: This file only tests all ELIS custom context calls made by ELIS reports. It should not be used to verify * other report operations or data accuracy. */ require_once dirname(__FILE__) . '/../../../local/eliscore/test_config.php'; global $CFG; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; // Data objects. require_once elis::lib('data/customfield.class.php'); // Filter libs. require_once elis::lib('filtering/multifilter.php'); // require_once(elispm::lib('filtering/clustertree.php')); require_once elispm::lib('filtering/custom_field_multiselect_values.php'); /** * A mock multifilter used for testing. */ class test_multifilter extends generalized_filter_multifilter { /** * @var array Sections used for testing. */ protected $sections = array('test_cur' => array('name' => 'curriculum'), 'test_trk' => array('name' => 'track'), 'test_crs' => array('name' => 'course'), 'test_cls' => array('name' => 'class'), 'test_usr' => array('name' => 'user'), 'test_usrset' => array('name' => 'cluster')); /** * A function solely for testing to give us access to $this->sections. * @return array The $this->sections array. */
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_elisprogram * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote Learner.net Inc http://www.remote-learner.net * */ defined('MOODLE_INTERNAL') || die; require_once elis::lib('page.class.php'); abstract class pm_page extends elis_page { /** * The page's short name */ var $pagename; protected function _get_page_url() { global $CFG; return "{$CFG->wwwroot}/local/elisprogram/index.php"; } protected function _get_page_type() { return 'elispm'; }
/** * Validate that the "menu of choices" custom field type works correctly * when options are separated by a carriage return and a line feed */ public function testmenuofchoicesignorescarriagereturns() { global $CFG, $DB; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elis::lib('data/customfield.class.php'); require_once elispm::file('accesslib.php'); require_once elispm::lib('data/user.class.php'); // Setup. $field = new field(array('shortname' => 'testcustomfieldshortname', 'name' => 'testcustomfieldname', 'datatype' => 'char')); $category = new field_category(array('name' => 'testcategoryname')); field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USER, $category); $ownerparams = array('control' => 'menu', 'options' => "option1\r\noption2"); field_owner::ensure_field_owner_exists($field, 'manual', $ownerparams); // Run the create action. $record = new stdClass(); $record->action = 'create'; $record->email = '*****@*****.**'; $record->username = '******'; $record->idnumber = 'testuserid'; $record->firstname = 'testuserfirstname'; $record->lastname = 'testuserlastname'; $record->country = 'CA'; $record->testcustomfieldshortname = 'option1'; $user = new user(); $user->reset_custom_field_list(); $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis'); $importplugin->fslogger = new silent_fslogger(null); $importplugin->process_record('user', (object) $record, 'bogus'); // Validation. $user = new user(1); $user->load(); $this->assertEquals('option1', $user->field_testcustomfieldshortname); }
/** * Validate that custom user fields are synched over to Moodle when PM user is created * during an import */ public function test_user_multi_custom_field_on_user_create() { global $CFG, $DB, $USER; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elis::lib('data/customfield.class.php'); require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php'); require_once elispm::file('accesslib.php'); require_once elispm::lib('data/user.class.php'); require_once $CFG->dirroot . '/user/profile/lib.php'; require_once $CFG->dirroot . '/user/profile/definelib.php'; require_once $CFG->dirroot . '/user/profile/field/menu/define.class.php'; $CFG->filterall = true; $USER = get_admin(); $context = context_user::instance($USER->id); /* $filternames = filter_get_all_installed(); ob_start(); var_dump($filternames); $tmp = ob_get_contents(); ob_end_clean(); error_log("test_user_multi_custom_field_on_user_create: all-filters => {$tmp}"); */ // Note: >= m25 filter paths no longer prefixed with 'filter/' filter_set_global_state('multilang', TEXTFILTER_ON); filter_set_applies_to_strings('multilang', true); $multilangoption1 = '<span class="multilang" lang="en">Male</span><span class="multilang" lang="pt_br">Masculino</span>' . '<span class="multilang" lang="es">Masculino</span>'; $multilangoption2 = '<span class="multilang" lang="en">Female</span><span class="multilang" lang="pt_br">Feminino</span>' . '<span class="multilang" lang="es">Femenino</span>'; // The associated Moodle user profile field. $profiledefinemenu = new profile_define_menu(); $data = new stdClass(); $data->datatype = 'menu'; $data->categoryid = 99999; $data->shortname = 'testfieldgender'; $data->name = 'testfieldgender'; $data->param1 = "{$multilangoption1}\n{$multilangoption2}"; $data->defaultdata = $multilangoption2; $profiledefinemenu->define_save($data); // Reset cached custom fields. $user = new user(); $user->reset_custom_field_list(); // Field category. $fieldcategory = new field_category(array('name' => 'testcategoryname')); $fieldcategory->save(); // Custom field. $field = new field(array('categoryid' => $fieldcategory->id, 'shortname' => 'testfieldgender', 'name' => 'testfieldgender', 'datatype' => 'text', 'multivalued' => 1)); $field->save(); // Field owners field_owner::ensure_field_owner_exists($field, 'moodle_profile'); $manualowneroptions = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'menu', 'options' => "{$multilangoption1}\n{$multilangoption2}"); field_owner::ensure_field_owner_exists($field, 'manual', $manualowneroptions); // Field context level assocation. $fieldcontextlevel = new field_contextlevel(array('fieldid' => $field->id, 'contextlevel' => CONTEXT_ELIS_USER)); $fieldcontextlevel->save(); // Run the user create action. $record = new stdClass(); $record->action = 'create'; $record->idnumber = 'testuseridnumber'; $record->username = '******'; $record->firstname = 'testuserfirstname'; $record->lastname = 'testuserlastname'; $record->email = '*****@*****.**'; $record->address = 'testuseraddress'; $record->city = 'testusercity'; $record->country = 'CA'; $record->language = 'en'; $record->testfieldgender = 'Male/Female'; $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis'); $importplugin->fslogger = new silent_fslogger(null); $importplugin->process_record('user', $record, 'bogus'); // Validation. $userid = $DB->get_field(user::TABLE, 'id', array('username' => 'testuserusername')); $user = new user($userid); $user->load(); $user = $user->to_object(); /* $datars = field_data::get_for_context_and_field(\local_elisprogram\context\user::instance($user->id), 'testfieldgender'); foreach ($datars as $data) { ob_start(); var_dump($data); $tmp = ob_get_contents(); ob_end_clean(); error_log("test_user_multi_custom_field_on_user_create: data => {$tmp}"); } */ /* ob_start(); var_dump($user); $tmp = ob_get_contents(); ob_end_clean(); error_log("test_user_multi_custom_field_on_user_create: user => {$tmp}"); */ $this->assertEquals(array($multilangoption1, $multilangoption2), $user->field_testfieldgender); }
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_eliscore * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net) * */ defined('MOODLE_INTERNAL') || die; require_once elis::lib('rollover/backup/stepslib.php'); /** * Final task in the backup section of the rollover task, responsible for cleaning up * without creating unnecessary files and cleaning up log files created as a side-effect * of the backup */ class rollover_backup_final_task extends backup_task { /** * Create all the steps that will be part of this task */ public function build() { // Set the backup::VAR_CONTEXTID setting to course context as far as next steps require that $coursectxid = context_course::instance($this->get_courseid())->id; $this->add_setting(new backup_activity_generic_setting(backup::VAR_CONTEXTID, base_setting::IS_INTEGER, $coursectxid));
<?php /** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package elis-program * @subpackage filtering * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * */ require_once elis::lib('filtering/autocomplete.php');
/** * Create an ELIS custom field category. * @param array $name The name of the category. */ public function create_field_category($name = '') { require_once elis::lib('data/customfield.class.php'); if (empty($name)) { $name = 'Field Category ' . uniqid(); } $info = new stdClass(); $info->name = $name; $info->sortorder = 0; $info->id = $this->db->insert_record(field_category::TABLE, $info); return $info; }
/** * Set up data that is needed for testing * * @param boolean $setcustomfielddata Specify whether the userset's custom fields should be set * @param boolean $assignuser Specify whether the user should be directly assigned to the user set * @param boolean $setautoassociatefields Specity whether we should set up fields that allow userset autoassociation */ private function set_up_required_data($setcustomfielddata = true, $assignuser = true, $setautoassociatefields = false) { global $CFG, $DB; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elis::lib('data/customfield.class.php'); require_once elispm::file('accesslib.php'); require_once elispm::file('enrol/userset/moodleprofile/userset_profile.class.php'); require_once elispm::lib('data/clusterassignment.class.php'); require_once elispm::lib('data/user.class.php'); require_once elispm::lib('data/usermoodle.class.php'); require_once elispm::lib('data/userset.class.php'); $fieldcategoryid = $DB->get_field(field_category::TABLE, 'id', array('name' => 'Associated Group')); $this->assertNotEquals(false, $fieldcategoryid); $fieldcategory = new field_category($fieldcategoryid); $fieldcategory->load(); // Set up the test user. $user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => '*****@*****.**', 'country' => 'CA')); $user->save(); $user->synchronize_moodle_user(); // We need a system-level role assignment. $roleid = create_role('systemrole', 'systemrole', 'systemrole'); $userid = $DB->get_field('user', 'id', array('username' => 'testuserusername')); $context = context_system::instance(); role_assign($roleid, $userid, $context->id); // Set up the userset. $userset = new userset(); $usersetdata = array('name' => 'testusersetname'); if ($setcustomfielddata) { $usersetdata['field_userset_group'] = 1; $usersetdata['field_userset_groupings'] = 1; } $userset->set_from_data((object) $usersetdata); $userset->save(); if ($setautoassociatefields) { // Set up a file we can use to auto-associate users to a userset. $field = new field(array('categoryid' => $fieldcategory->id, 'shortname' => 'autoassociate', 'name' => 'autoassociate', 'datatype' => 'bool')); $field->save(); // Ensure manual field owner exists for syncing. field_owner::ensure_field_owner_exists($field, 'manual'); $ownerid = $DB->get_field(field_owner::TABLE, 'id', array('fieldid' => $field->id, 'plugin' => 'manual')); $owner = new field_owner($ownerid); $owner->param_control = 'checkbox'; $owner->save(); field_owner::ensure_field_owner_exists($field, 'moodle_profile'); $DB->execute("UPDATE {" . field_owner::TABLE . "} SET exclude = ?", array(pm_moodle_profile::sync_to_moodle)); $fieldcontextlevel = new field_contextlevel(array('fieldid' => $field->id, 'contextlevel' => CONTEXT_ELIS_USER)); $fieldcontextlevel->save(); // The associated Moodle user profile field. require_once $CFG->dirroot . '/user/profile/definelib.php'; require_once $CFG->dirroot . '/user/profile/field/checkbox/define.class.php'; $profiledefinecheckbox = new profile_define_checkbox(); $data = new stdClass(); $data->datatype = 'checkbox'; $data->categoryid = 99999; $data->shortname = 'autoassociate'; $data->name = 'autoassociate'; $profiledefinecheckbox->define_save($data); $mfield = $DB->get_record('user_info_field', array('shortname' => 'autoassociate')); // The "cluster-profile" association. $usersetprofile = new userset_profile(array('clusterid' => $userset->id, 'fieldid' => $mfield->id, 'value' => 1)); $usersetprofile->save(); } if ($assignuser) { // Assign the user to the user set. $clusterassignment = new clusterassignment(array('clusterid' => $userset->id, 'userid' => $user->id, 'plugin' => 'manual')); $clusterassignment->save(); } }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_elisprogram * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote Learner.net Inc http://www.remote-learner.net * */ defined('MOODLE_INTERNAL') || die; require_once dirname(__FILE__) . '/../../../../config.php'; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; require_once elis::lib('data/data_object_with_custom_fields.class.php'); require_once elispm::lib('lib.php'); require_once elispm::lib('data/classmoodlecourse.class.php'); require_once elispm::lib('data/clustertrack.class.php'); require_once elispm::lib('data/course.class.php'); require_once elispm::lib('data/coursetemplate.class.php'); require_once elispm::lib('data/curriculum.class.php'); require_once elispm::lib('data/pmclass.class.php'); require_once elispm::lib('data/user.class.php'); require_once elispm::lib('data/usertrack.class.php'); require_once elispm::lib('deprecatedlib.php'); class track extends data_object_with_custom_fields { const TABLE = 'local_elisprogram_trk'; var $verbose_name = 'track'; var $autocreate;
* GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_elisprogram * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote Learner.net Inc http://www.remote-learner.net * */ require_once dirname(__FILE__) . '/../../eliscore/test_config.php'; global $CFG; require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php'; // ELIS libs. require_once elis::lib('data/customfield.class.php'); require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php'); require_once elispm::lib('deprecatedlib.php'); require_once elispm::lib('data/user.class.php'); require_once elispm::lib('data/usermoodle.class.php'); require_once $CFG->dirroot . '/user/profile/lib.php'; /** * Test user custom fields. * @group local_elisprogram */ class usercustomfields_testcase extends elis_database_test { /** * Load initial data from CSVs. */ protected function load_csv_data()
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_eliscore * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net) * */ defined('MOODLE_INTERNAL') || die; require_once elis::lib('data/data_object.class.php'); /** * Base class for workflow instance data record. This class should not be used except * in the workflow and workflow_page classes. Use the workflow class for data * functions. */ class _workflow_instance extends elis_data_object { const TABLE = 'local_eliscore_wkflow_inst'; protected $_dbfield_type; protected $_dbfield_subtype; protected $_dbfield_userid; protected $_dbfield_data; protected $_dbfield_timemodified; /** * Load a workflow data record from the database. Returns an object of the
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_eliscore * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net) * */ defined('MOODLE_INTERNAL') || die; require_once elis::lib('rollover/restore/rollover_restore_plan.class.php'); /** * Class responsible for the top-level functionality related to the restore section * of the course rollover, specifically starting the process of building the execution * plan */ class rollover_restore_controller extends restore_controller { /** * Constructor for the rollover backup controller class * * @param string $tempdir Directory under dataroot/temp/backup awaiting restore * @param int $courseid Course id where restore is going to happen */ public function __construct($tempdir, $courseid) {
* * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_eliscore * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net) * */ require_once dirname(__FILE__) . '/../test_config.php'; global $CFG; require_once $CFG->dirroot . '/local/eliscore/lib/setup.php'; require_once elis::lib('data/data_object.class.php'); require_once 'PHPUnit/Extensions/Database/DataSet/CsvDataSet.php'; require_once elis::lib('tasklib.php'); /** * Class to test scheduled tasks. * @group local_eliscore */ class scheduled_tasks_testcase extends elis_database_test { /** * Validate scheduled tasks. */ public function test_elis_tasks_get_cached() { $dataset = $this->createCsvDataSet(array('local_eliscore_sched_tasks' => elis::component_file('eliscore', 'tests/fixtures/elis_scheduled_tasks.csv'))); $this->loadDataSet($dataset); $cachedtasks = elis_tasks_get_cached('elis_program'); $this->assertNotEmpty($cachedtasks);
/** * Update environments and environment assignments to custom fields and * custom field data (run as a one-off during the elis program upgrade) * * If there are one or more entities (courses, classes) with environments * assigned to them, a new category and custom field is created, specific to the * appropriate context level. Then, that custom field is populated for each entity * that has and environment assigned (custom field is a single-select, where the options * are all the different environments on the site). */ function pm_migrate_environments() { global $DB; require_once elis::lib('data/customfield.class.php'); require_once elispm::lib('data/course.class.php'); require_once elispm::lib('data/pmclass.class.php'); //set up our contextlevel mapping $contextlevels = array(course::TABLE => 'course', pmclass::TABLE => 'class'); //lookup on all tags $environment_lookup = $DB->get_records('local_elisprogram_env', null, '', 'id, name'); foreach ($environment_lookup as $id => $environment) { $environment_lookup[$id] = $environment->name; } //go through each contextlevel and look for tags foreach ($contextlevels as $instancetable => $contextname) { //calculate the context level integer $contextlevel = \local_eliscore\context\helper::get_level_from_name($contextname); //make sure one or more environments are used at the current context level $select = 'environmentid != 0'; if ($DB->record_exists_select($instancetable, $select)) { //used to reference the category name $category = new field_category(array('name' => get_string('misc_category', 'local_elisprogram'))); //make sure our field for storing environments is created $field = new field(array('shortname' => "_19upgrade_{$contextname}_environment", 'name' => get_string('environment', 'local_elisprogram'), 'datatype' => 'char')); $field = field::ensure_field_exists_for_context_level($field, $contextlevel, $category); //determine environment options $options = array(); if ($records = $DB->get_recordset('local_elisprogram_env', null, 'name', 'DISTINCT name')) { foreach ($records as $record) { $options[] = $record->name; } } $options = implode("\n", $options); //set up our field owner field_owner::ensure_field_owner_exists($field, 'manual', array('control' => 'menu', 'options' => $options, 'edit_capability' => '', 'view_capability' => '')); //set up data for all relevant entries $sql = "SELECT id, environmentid\n FROM {{$instancetable}}\n WHERE environmentid != 0"; if ($records = $DB->get_recordset_sql($sql)) { foreach ($records as $record) { $contextlevel = \local_eliscore\context\helper::get_level_from_name($contextname); $contextclass = \local_eliscore\context\helper::get_class_for_level($contextlevel); $context = $contextclass::instance($record->id); $environmentid = $environment_lookup[$record->environmentid]; field_data::set_for_context_and_field($context, $field, $environmentid); } } } } }
/** * Function to handle Moodle user deletion events * * @param object $user The Moodle user that was deleted * @return boolean true is successful, otherwise FALSE */ static function user_deleted_handler($user) { global $DB; require_once elis::lib('data/data_filter.class.php'); require_once elispm::lib('data/usermoodle.class.php'); usermoodle::delete_records(new field_filter('muserid', $user->id), $DB); }