Skip to content

Commit

Permalink
T-11258: Add performance management feature
Browse files Browse the repository at this point in the history
Change-Id: I3ba4cdf0edcf7a79b219ac0a609fec9cd81e3d7e
Reviewed-on: https://review.totaralms.com/3765
Reviewed-by: Nathan Lewis <nathan.lewis@totaralms.com>
Reviewed-by: Simon Coggins <simon.coggins@totaralms.com>
Tested-by: Jenkins Automation <jenkins@totaralms.com>
  • Loading branch information
Nathan Lewis authored and simoncoggins committed Sep 26, 2013
1 parent 0935d0a commit 409700e
Show file tree
Hide file tree
Showing 546 changed files with 212,558 additions and 458 deletions.
1 change: 1 addition & 0 deletions admin/settings/top.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
$ADMIN->add('root', new admin_category('server', new lang_string('server','admin')));
$ADMIN->add('root', new admin_category('mnet', new lang_string('net','mnet'), (isset($CFG->mnet_dispatcher_mode) and $CFG->mnet_dispatcher_mode === 'off')));
$ADMIN->add('root', new admin_category('reports', new lang_string('reports')));
$ADMIN->add('root', new admin_category('appraisals', new lang_string('appraisals', 'totara_appraisal')));
$ADMIN->add('root', new admin_category('development', new lang_string('development', 'admin')));

// hidden unsupported category
Expand Down
8 changes: 6 additions & 2 deletions admin/tool/totara_sync/admin/synclog.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/totara_sync/lib.php');

$debug = optional_param('debug', false, PARAM_BOOL);
$sid = optional_param('sid', '0', PARAM_INT);
$format = optional_param('format', '', PARAM_TEXT); // export format
$delete = optional_param('del', 'none', PARAM_ALPHANUM);

Expand All @@ -43,7 +44,7 @@
$strheading = get_string('synclog', 'tool_totara_sync');
$shortname = 'totarasynclog';

if (!$report = reportbuilder_get_embedded_report($shortname)) {
if (!$report = reportbuilder_get_embedded_report($shortname, null, false, $sid)) {
print_error('error:couldnotgenerateembeddedreport', 'totara_reportbuilder');
}

Expand Down Expand Up @@ -110,11 +111,14 @@

$report->display_search();

// Print saved search buttons if appropriate.
echo $report->display_saved_search_options();

if ($countfiltered > 0) {
$report->display_table();

// export button
$renderer->export_select($report->_id);
$renderer->export_select($report->_id, $sid);
}

if (has_capability('tool/totara_sync:deletesynclog', $context)) {
Expand Down
48 changes: 37 additions & 11 deletions admin/tool/totara_sync/elements/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ function sync_user_assignments($userid, $suser) {

// If we have no position info at all we do not need to set a position.
if (!isset($suser->postitle) && empty($suser->posidnumber) && !isset($suser->posstartdate)
&& !isset($suser->posenddate) && empty($suser->orgidnumber) && empty($suser->manageridnumber)) {
&& !isset($suser->posenddate) && empty($suser->orgidnumber) && empty($suser->manageridnumber)
&& empty($suser->appraiseridnumber)) {
return false;
}
$posdata = new stdClass;
Expand All @@ -349,6 +350,7 @@ function sync_user_assignments($userid, $suser) {
$posdata->positionid = $pos_assignment->positionid;
$posdata->organisationid = $pos_assignment->organisationid;
$posdata->managerid = $pos_assignment->managerid;
$posdata->appraiserid = $pos_assignment->appraiserid;
if (isset($suser->postitle)) {
$posdata->fullname = $suser->postitle;
$posdata->shortname = empty($suser->postitleshortname) ? $suser->postitle : $suser->postitleshortname;
Expand Down Expand Up @@ -394,6 +396,18 @@ function sync_user_assignments($userid, $suser) {
}
}
}
if (isset($suser->appraiseridnumber)) {
if (empty($suser->appraiseridnumber)) {
$posdata->appraiserid = null;
} else {
try {
$posdata->appraiserid = $DB->get_field('user', 'id',
array('idnumber' => $suser->appraiseridnumber, 'deleted' => 0), MUST_EXIST);
} catch (dml_missing_record_exception $e) {
$posdata->appraiserid = null;
}
}
}

position_assignment::set_properties($pos_assignment, $posdata);

Expand Down Expand Up @@ -533,12 +547,20 @@ function check_sanity($synctable, $synctable_clone) {

// Get invalid managers and self-assigned users.
if (isset($syncfields->manageridnumber)) {
$badids = $this->get_invalid_managers($synctable, $synctable_clone);
$badids = $this->get_invalid_roles($synctable, $synctable_clone, 'manager');
$invalidids = array_merge($invalidids, $badids);
$badids = $this->check_self_assignment($synctable, 'manageridnumber', 'selfassignedmanagerx');
$invalidids = array_merge($invalidids, $badids);
}

// Get invalid appraisers and self-assigned users.
if (isset($syncfields->appraiseridnumber)) {
$badids = $this->get_invalid_roles($synctable, $synctable_clone, 'appraiser');
$invalidids = array_merge($invalidids, $badids);
$badids = $this->check_self_assignment($synctable, 'appraiseridnumber', 'selfassignedappraiserx');
$invalidids = array_merge($invalidids, $badids);
}

if (count($invalidids)) {
list($badids, $params) = $DB->get_in_or_equal($invalidids);
$DB->delete_records_select($synctable, "id $badids", $params);
Expand Down Expand Up @@ -622,34 +644,38 @@ function get_invalid_org_pos($synctable, $table, $field, $identifier) {
}

/**
* Get invalid managers
* Get invalid roles (such as managers or appraisers)
*
* @param string $synctable sync table name
* @param string $synctable_clone sync clone table name
* @param string $role Name of role to check e.g. 'manager' or 'appraiser'
* There must be a {$role}idnumber field in the sync db table and '{$role}notexist'
* language string in lang/en/tool_totara_sync.php
*
* @return array with invalid ids from synctable for managers that do not exist in synctable nor in the database
* @return array with invalid ids from synctable for roles that do not exist in synctable nor in the database
*/
function get_invalid_managers($synctable, $synctable_clone) {
function get_invalid_roles($synctable, $synctable_clone, $role) {
global $DB;

$idnumberfield = "{$role}idnumber";
$params = array();
$invalidids = array();
$sql = "SELECT s.id, s.idnumber, s.manageridnumber
$sql = "SELECT s.id, s.idnumber, s.{$idnumberfield}
FROM {{$synctable}} s
LEFT OUTER JOIN {user} u
ON s.manageridnumber = u.idnumber
WHERE s.manageridnumber IS NOT NULL
AND s.manageridnumber != ''
ON s.{$idnumberfield} = u.idnumber
WHERE s.{$idnumberfield} IS NOT NULL
AND s.{$idnumberfield} != ''
AND u.idnumber IS NULL
AND s.manageridnumber NOT IN
AND s.{$idnumberfield} NOT IN
(SELECT idnumber FROM {{$synctable_clone}})";
if (empty($this->config->sourceallrecords)) {
$sql .= ' AND s.deleted = ?'; // Avoid users that will be deleted.
$params[0] = 0;
}
$rs = $DB->get_recordset_sql($sql, $params);
foreach ($rs as $r) {
$this->addlog(get_string('managerxnotexist', 'tool_totara_sync', $r), 'error', 'checksanity');
$this->addlog(get_string($role.'xnotexist', 'tool_totara_sync', $r), 'error', 'checksanity');
$invalidids[] = $r->id;
}
$rs->close();
Expand Down
3 changes: 3 additions & 0 deletions admin/tool/totara_sync/lang/en/tool_totara_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
$string['posstartdate'] = 'Position start date';
$string['posenddate'] = 'Position end date';
$string['manageridnumber'] = 'Manager';
$string['appraiseridnumber'] = 'Appraiser';
$string['auth'] = 'Auth';
$string['password'] = 'Password';
$string['suspended'] = 'Suspended';
Expand Down Expand Up @@ -225,7 +226,9 @@
$string['orgxnotexist'] = 'Organisation {$a->orgidnumber} does not exist. Skipped user {$a->idnumber}';
$string['posxnotexist'] = 'Position {$a->posidnumber} does not exist. Skipped user {$a->idnumber}';
$string['managerxnotexist'] = 'Manager {$a->manageridnumber} does not exist. Skipped user {$a->idnumber}';
$string['appraiserxnotexist'] = 'Appraiser {$a->appraiseridnumber} does not exist. Skipped user {$a->idnumber}';
$string['selfassignedmanagerx'] = 'User {$a->idnumber} cannot be their own manager. Skipped user {$a->idnumber}';
$string['selfassignedappraiserx'] = 'User {$a->idnumber} cannot be their own appraiser. Skipped user {$a->idnumber}';
$string['optionxnotexist'] = 'Option {$a->option} does not exist for {$a->fieldname} field. Skipped user {$a->idnumber}';
$string['nosourceconfigured'] = 'No source configured, please set configuration <a href=\'{$a}\'>here</a>';
$string['duplicateuserswithidnumberx'] = 'Duplicate users with idnumber {$a->idnumber}. Skipped user {$a->idnumber}';
Expand Down
7 changes: 7 additions & 0 deletions admin/tool/totara_sync/sources/classes/source.user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function __construct() {
'posstartdate',
'posenddate',
'manageridnumber',
'appraiseridnumber',
'auth',
'password',
'suspended',
Expand Down Expand Up @@ -271,6 +272,9 @@ function prepare_temp_table($clone = false) {
if (!empty($this->config->import_manageridnumber)) {
$table->add_field('manageridnumber', XMLDB_TYPE_CHAR, '100');
}
if (!empty($this->config->import_appraiseridnumber)) {
$table->add_field('appraiseridnumber', XMLDB_TYPE_CHAR, '100');
}
if (!empty($this->config->import_auth)) {
$table->add_field('auth', XMLDB_TYPE_CHAR, '20');
}
Expand Down Expand Up @@ -304,6 +308,9 @@ function prepare_temp_table($clone = false) {
if (!empty($this->config->import_manageridnumber)) {
$table->add_index('manageridnumber', XMLDB_INDEX_NOTUNIQUE, array('manageridnumber'));
}
if (!empty($this->config->import_appraiseridnumber)) {
$table->add_index('appraiseridnumber', XMLDB_INDEX_NOTUNIQUE, array('appraiseridnumber'));
}

/// Create and truncate the table
$dbman->create_temp_table($table, false, false);
Expand Down
1 change: 1 addition & 0 deletions build/schema_relationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'org_relations#id2' => 'org#id',
'pos_assignment#organisationid' => 'org#id',
'pos_assignment#userid' => 'user#id',
'pos_assignment#appraiserid' => 'user#id',
'pos_assignment#positionid' => 'pos#id',
'pos_assignment#reportstoid' => 'role_assignments#id',
// course completion
Expand Down
21 changes: 12 additions & 9 deletions cohort/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

$contextid = optional_param('contextid', 0, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$sid = optional_param('sid', '0', PARAM_INT);
$format = optional_param('format', '', PARAM_TEXT); //export format
$debug = optional_param('debug', false, PARAM_BOOL); //report debug

Expand Down Expand Up @@ -61,13 +62,6 @@

$PAGE->set_context($context);

$report = reportbuilder_get_embedded_report('cohort_admin');
// handle report exports
if (!empty($format)) {
$report->export_data($format);
die;
}

if ($category) {
$PAGE->set_pagelayout('report');
$PAGE->set_url('/cohort/index.php', array('contextid'=>$context->id));
Expand All @@ -77,8 +71,14 @@
admin_externalpage_setup('cohorts', '', null, '', array('pagelayout'=>'report'));
}

$report = reportbuilder_get_embedded_report('cohort_admin', null, false, $sid);
if (!empty($format)) {
$report->export_data($format);
die;
}

echo $OUTPUT->header();
if($debug) {
if ($debug) {
$report->debug($debug);
}

Expand All @@ -98,8 +98,11 @@
}
$report->display_search();

// Print saved search buttons if appropriate.
echo $report->display_saved_search_options();

$report->display_table();
$output->export_select($report->_id);
$output->export_select($report->_id, $sid);
if ($manager) {
echo $OUTPUT->single_button(new moodle_url('/cohort/edit.php', array('contextid'=>$context->id)), get_string('add'));
}
Expand Down
5 changes: 5 additions & 0 deletions cohort/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ function cohort_print_tabs($currenttab, $cohortid, $cohorttype, $cohort) {
get_string('learningplan', 'totara_cohort'));
}

if ($canmanage) {
$toprow[] = new tabobject('goals', new moodle_url('/totara/cohort/goals.php', array('id' => $cohortid)),
get_string('goals', 'totara_hierarchy'));
}

$tabs = array($toprow);
return print_tabs($tabs, $currenttab, $inactive, $activetwo, true);
}
20 changes: 12 additions & 8 deletions cohort/members.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
require_once($CFG->dirroot.'/totara/reportbuilder/lib.php');

$id = optional_param('id', false, PARAM_INT);
$sid = optional_param('sid', '0', PARAM_INT);
$format = optional_param('format','',PARAM_TEXT); //export format
$debug = optional_param('debug', false, PARAM_BOOL);

Expand All @@ -37,13 +38,6 @@

$PAGE->set_context($context);

$report = reportbuilder_get_embedded_report('cohort_members', array('cohortid' => $id));
// handle report exports
if ($format != '') {
$report->export_data($format);
die;
}

$url = new moodle_url('/cohort/members.php', array('id' => $id, 'format' => $format, 'debug' => $debug));
admin_externalpage_setup('cohorts', '', null, $url, array('pagelayout' => 'report'));

Expand All @@ -57,6 +51,13 @@

$cohort = $DB->get_record('cohort',array('id' => $id), '*', MUST_EXIST);

$report = reportbuilder_get_embedded_report('cohort_members', array('cohortid' => $id), false, $sid);

if ($format != '') {
$report->export_data($format);
die;
}

$strheading = get_string('viewmembers', 'totara_cohort');
totara_cohort_navlinks($cohort->id, $cohort->name, $strheading);
echo $OUTPUT->header();
Expand All @@ -70,8 +71,11 @@

$report->display_search();

// Print saved search buttons if appropriate.
echo $report->display_saved_search_options();

$report->display_table();
$output = $PAGE->get_renderer('totara_reportbuilder');
$output->export_select($report->_id);
$output->export_select($report->_id, $sid);

echo $OUTPUT->footer();
14 changes: 5 additions & 9 deletions course/find.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
$renderer = $PAGE->get_renderer('totara_reportbuilder');
$strheading = get_string('searchcourses', 'totara_core');
$shortname = 'findcourses';
$sid = optional_param('sid', '0', PARAM_INT);

if (!$report = reportbuilder_get_embedded_report($shortname)) {
if (!$report = reportbuilder_get_embedded_report($shortname, null, false, $sid)) {
print_error('error:couldnotgenerateembeddedreport', 'totara_reportbuilder');
}

Expand Down Expand Up @@ -80,19 +81,14 @@

$report->display_search();

// print saved search buttons if appropriate
$table = new html_table();
$cells = array(new html_table_cell($renderer->save_button($report->_id)), new html_table_cell($report->view_saved_menu()));
$row = new html_table_row($cells);
$table->data[] = $row;
echo html_writer::table($table);
echo html_writer::empty_tag('br').html_writer::empty_tag('br');
// Print saved search buttons if appropriate.
echo $report->display_saved_search_options();

if ($countfiltered > 0) {
echo $renderer->showhide_button($report->_id, $report->shortname);
$report->display_table();
// export button
$renderer->export_select($report->_id);
$renderer->export_select($report->_id, $sid);
}
echo $OUTPUT->footer();

1 change: 1 addition & 0 deletions elementlibrary/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
echo html_writer::start_tag('ul');
echo html_writer::tag('li', html_writer::link(new moodle_url('/elementlibrary/toolbar.php'), 'Toolbar'));
echo html_writer::tag('li', html_writer::link(new moodle_url('/elementlibrary/dialogs.php'), 'Dialogs'));
echo html_writer::tag('li', html_writer::link(new moodle_url('/elementlibrary/verticaltabs.php'), 'Vertical tabs'));
echo html_writer::end_tag('ul');
echo $OUTPUT->container_end();

Expand Down
Loading

0 comments on commit 409700e

Please sign in to comment.