function action_default() { global $CFG; $type = cm_get_param('type', ''); $sort = cm_get_param('sort', ''); $dir = cm_get_param('dir', 'ASC'); $page = cm_get_param('page', 0); $perpage = cm_get_param('perpage', 30); $download = cm_get_param('download', ''); $frompage = cm_get_param('frompage', ''); if (!empty($type) && file_exists(CURMAN_DIRLOCATION . '/lib/' . $type . 'report.class.php')) { require_once CURMAN_DIRLOCATION . '/lib/' . $type . 'report.class.php'; $repclass = $type . 'report'; $report = new $repclass($repclass); $report->set_baseurl('index.php?s=rep§ion=rept&type=' . $type); $report->main($sort, $dir, $page, $perpage, $download, $frompage); return; } $bc = '<span class="breadcrumb">' . get_string('reports', 'block_curr_admin') . '</span>'; echo cm_print_heading_block($bc, '', true); echo '<br clear="all" />' . "\n"; echo get_string('choose_report_from_menu', 'block_curr_admin'); }
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); }
/** * Main display function. * * Fetch and display (or download) the required data. * * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $alpha An initial to filter results by. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $download = '', $frompage = '') { global $CFG; $this->usrid = cm_get_param('user', 0); // $this->hideins = cm_get_param('hideins', false); $this->user = new user($this->usrid); $this->baseurl .= '&user='******'&hideins=' . $this->hideins; $this->set_title(get_string('individual_report', 'block_curr_admin') . cm_fullname($this->user)); if (empty($download)) { $output = ''; if ($frompage == '') { $frompage = 'users'; } $pagename = get_string("report{$frompage}", 'block_curr_admin'); $bc = '<span class="breadcrumb"><a href="index.php?s=rep&section=rept&type=' . $frompage . '">' . $pagename . '</a> » ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; } $this->get_data(!empty($download)); $this->add_column('datecomplete', get_string('completed_label', 'block_curr_admin'), 'left', false); $this->add_column('courseidnumber', get_string('course_id', 'block_curr_admin'), 'left', false); $this->add_column('coursename', get_string('coursename', 'block_curr_admin'), 'left', false); for ($i = 1; $i <= $this->_maxexams; $i++) { $this->add_column('ccgrade' . $i, get_string('exam', 'block_curr_admin') . $i, 'left', false); } $this->add_column('classgrade', get_string('grade', 'block_curr_admin'), 'left', false); $this->add_column('credits', get_string('credits', 'block_curr_admin'), 'left', false); $this->set_default_sort('datecomplete', 'ASC'); $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = 0; $this->perpage = 9999; if (empty($download)) { $tlink = $CFG->wwwroot . '/curriculum/index.php'; $toptions = array('s' => 'rep', 'section' => 'rept', 'type' => 'induser', 'user' => $this->usrid); $tlabel = get_string('userreport', 'block_curr_admin'); $output .= '<div class="trans-button">' . print_single_button($tlink, $toptions, $tlabel, NULL, NULL, true) . '</div>'; if (!empty($this->rawdata)) { $output .= $this->print_download_menu(); } $output .= '<br />'; $output .= '<fieldset>' . "\n"; $output .= '<legend>' . get_string('user_information', 'block_curr_admin') . '</legend>'; switch ($this->user->gender) { case 'M': case 'm': $gender = get_string('male', 'block_curr_admin'); break; case 'F': case 'f': $gender = get_string('female', 'block_curr_admin'); break; default: $gender = get_string('unknown', 'block_curr_admin'); break; } $output .= '<div class="trans-userarea">'; $output .= '<div class="trans-leftside">'; $output .= cm_fullname($this->user) . "<br />\n"; $output .= $this->user->address . "<br />\n"; if (!empty($this->user->address2)) { $output .= $this->user->address2 . "<br />\n"; } $output .= $this->user->city; if (!empty($this->user->city)) { $output .= ', ' . $this->user->state; } $output .= ' ' . s($this->user->postalcode) . ' ' . cm_get_country($this->user->country) . "<br />\n"; $output .= '</div>'; $output .= '<div class="trans-rightside">'; $output .= '<div class="trans-innerleft">Sex:</div>'; $output .= '<div class="trans-innerright">' . $gender . '</div>'; $output .= '<div class="trans-innerleft">Born:</div>'; $bday = cm_timestring_to_date($this->user->birthdate); $output .= '<div class="trans-innerright">' . $bday . '</div>'; $output .= '<div class="trans-innerleft">Registration Date:</div>'; if (!empty($this->user->origenroldate)) { $enroldate = cm_timestring_to_date($this->user->origenroldate); } else { if (!empty($this->user->timecreated)) { $enroldate = cm_timestamp_to_date($this->user->timecreated); } else { $enroldate = get_string('unknown', 'block_curr_admin'); } } $output .= '<div class="trans-innerright">' . $enroldate . '</div>'; $output .= '<div class="trans-innerleft">Identification No:</div>'; $output .= '<div class="trans-innerright">' . $this->user->idnumber . '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</fieldset><br />'; $summary = ''; if (!empty($this->rawdata)) { foreach ($this->rawdata as $curid => $curlist) { $output .= '<strong>' . $curlist->curriculumname . ' - ' . get_string('enrolled_classes', 'block_curr_admin') . '</strong>'; $this->data = $curlist->data; $output .= $this->display(); unset($this->table); if ($curlist->numcredits > 0) { $gpa = sprintf('%1.2f', (double) $curlist->gpa / (double) $curlist->numcredits); } else { $gpa = '0.0'; } $summary .= "<div style=\"float:left; width: 30%;\">' . get_string('total_credits', 'block_curr_admin', {$curlist->curriculumname}) . '</div>\n <div style=\"float:left; width: 20%;\">{$curlist->numcredits}</div>\n <div style=\"float:left; width: 30%;\">{$curlist->curriculumname}' . get_string('gpa', 'block_curr_admin') . ': </div>\n <div style=\"float:left; width: 20%;\">{$gpa}</div><br />"; $output .= '<br /><br />'; } } else { $output .= '<h2>' . get_string('no_classes_completed', 'block_curr_admin') . '</h2>'; } $output .= $summary; $output .= "<br />" . get_string('transfercredits', 'block_curr_admin') . ": {$this->user->transfercredits}<br />"; echo $output; } else { $this->download($download); } }
function cluster_profile_update($cluster) { global $CURMAN, $CFG; $prof_fields = $CURMAN->db->get_records(CLSTPROFTABLE, 'clusterid', $cluster->id, '', '*', 0, 2); if (!empty($prof_fields)) { $prof_field1 = array_shift($prof_fields); } if (!empty($prof_fields)) { $prof_field2 = array_shift($prof_fields); } $oldfield1 = empty($prof_field1) ? 0 : $prof_field1->fieldid; $oldvalue1 = empty($prof_field1) ? '' : $prof_field1->value; $newfield1 = cm_get_param('profile_field1', 0); $newvalue1 = cm_get_param('profile_value1', ''); $oldfield2 = empty($prof_field2) ? 0 : $prof_field2->fieldid; $oldvalue2 = empty($prof_field2) ? '' : $prof_field2->value; $newfield2 = cm_get_param('profile_field2', 0); $newvalue2 = cm_get_param('profile_value2', ''); if ($newfield1 == -1) { $newvalue1 = ''; } /// convert checkbox values from 'on' and '' to 1 and 0 if ('checkbox' == get_field('user_info_field', 'datatype', 'id', $newfield1)) { $newvalue1 = empty($newvalue1) ? 0 : 1; } if ('checkbox' == get_field('user_info_field', 'datatype', 'id', $newfield2)) { $newvalue2 = empty($newvalue2) ? 0 : 1; } $updated = false; // Have we updated the profile field associated with this cluster? /// Update the first field. if ($oldfield1 != $newfield1 || $oldvalue1 != $newvalue1) { $updated = true; // something has changed, so update tables if (empty($newfield1)) { $CURMAN->db->delete_records(CLSTPROFTABLE, 'clusterid', $cluster->id, 'fieldid', $oldfield1); } else { if (empty($prof_field1)) { $record = new stdClass(); $record->clusterid = $cluster->id; $record->fieldid = $newfield1; $record->value = $newvalue1; $CURMAN->db->insert_record(CLSTPROFTABLE, $record); } else { $prof_field1->fieldid = $newfield1; $prof_field1->value = $newvalue1; $CURMAN->db->update_record(CLSTPROFTABLE, $prof_field1); } } } if (empty($newfield2)) { $newvalue2 = ''; } /// Update the second field. if ($oldfield2 != $newfield2 || $oldvalue2 != $newvalue2) { $updated = true; // something has changed, so update tables if (empty($newfield2)) { $CURMAN->db->delete_records(CLSTPROFTABLE, 'clusterid', $cluster->id, 'fieldid', $oldfield2); } else { if (empty($prof_field2)) { $record = new stdClass(); $record->clusterid = $cluster->id; $record->fieldid = $newfield2; $record->value = $newvalue2; $CURMAN->db->insert_record(CLSTPROFTABLE, $record); } else { $prof_field2->fieldid = $newfield2; $prof_field2->value = $newvalue2; $CURMAN->db->update_record(CLSTPROFTABLE, $prof_field2); } } } if ($updated) { // re-assign users: // remove previous cluster assignments $CURMAN->db->delete_records(CLSTASSTABLE, 'clusterid', $cluster->id, 'plugin', 'profile'); // create new cluster assignments $join = ''; $where = ''; if (!empty($newfield1)) { // check if the desired field value is equal to the field's default // value -- if so, we need to include users that don't have an // associated entry in user_info_data $defaultvalue = get_field('user_info_field', 'defaultdata', 'id', $newfield1); $isdefault = $newvalue1 == $defaultvalue; $join .= ($isdefault ? 'LEFT' : 'INNER') . " JOIN {$CFG->prefix}user_info_data inf1 ON mu.id = inf1.userid AND inf1.fieldid = {$newfield1}"; $where .= "(inf1.data = '{$newvalue1}'"; // if desired field is the default if ($isdefault) { $where .= ' OR inf1.userid IS NULL'; } $where .= ')'; } if (!empty($newfield2)) { // check if the desired field value is equal to the field's default // value -- if so, we need to include users that don't have an // associated entry in user_info_data $defaultvalue = get_field('user_info_field', 'defaultdata', 'id', $newfield2); $isdefault = $newvalue2 == $defaultvalue; $join .= (!empty($join) ? "\n" : '') . ($isdefault ? 'LEFT' : 'INNER') . " JOIN {$CFG->prefix}user_info_data inf2 ON mu.id = inf2.userid AND inf2.fieldid = {$newfield2}"; $where .= (!empty($where) ? ' AND ' : '') . "(inf2.data = '{$newvalue2}'"; // if desired field is the default if ($isdefault) { $where .= ' OR inf2.userid IS NULL'; } $where .= ')'; } if (!empty($join) && !empty($where)) { $sql = "INSERT INTO " . $CURMAN->db->prefix_table(CLSTASSTABLE) . "\n (clusterid, userid, plugin)\n SELECT {$cluster->id}, cu.id, 'profile'\n FROM " . $CURMAN->db->prefix_table(USRTABLE) . " cu\n INNER JOIN {$CFG->prefix}user mu ON mu.idnumber = cu.idnumber AND mu.mnethostid = {$CFG->mnet_localhost_id}\n {$join}\n WHERE {$where}"; $CURMAN->db->execute_sql($sql, false); } cluster::cluster_update_assignments($cluster->id); } }
function display_savenew() { // action_savenew() global $USER, $CFG, $DB; $clsid = cm_get_param('clsid', 0); $class = new pmclass($clsid); $now = time(); if (!$class->is_enrollable()) { print_error('notenrollable', 'enrol'); // TBD } // check if class is full if (!empty($class->maxstudents) && student::count_enroled($class->id) >= $class->maxstudents) { $form = $this->create_waitlistform($classid); $form->display(); return; } // call the Moodle enrolment plugin if attached to a Moodle course, and // it's not the elis plugin //todo: check Moodle enrolment plugins here $cuserid = cm_get_crlmuserid($USER->id); $sturecord = array(); $sturecord['classid'] = $class->id; $sturecord['userid'] = $cuserid; // Set the enrolment time from class startdate if it's in the future or just set // current time if class has an associated Moodle course that has already started $enrolmenttime = $class->startdate; if ($moodlecourseid = moodle_get_course($clsid)) { if ($startdate = $DB->get_field('course', 'startdate', array('id' => $moodlecourseid))) { $enrolmenttime = $startdate < $now ? $now : $class->startdate; } } $sturecord['enrolmenttime'] = max($now, $enrolmenttime); $sturecord['completetime'] = 0; $newstu = new student($sturecord); $courseid = $class->get_moodle_course_id(); if ($courseid) { $course = $DB->get_record('course', array('id' => $courseid)); // check that the elis plugin allows for enrolments from the course // catalog -- if not, see if there are other plugins that allow // self-enrolment. $plugin = enrol_get_plugin('elis'); $enrol = $plugin->get_or_create_instance($course); if (!$enrol->{enrol_elis_plugin::ENROL_FROM_COURSE_CATALOG_DB}) { // get course enrolment plugins, and see if any of them allow self-enrolment $enrols = enrol_get_plugins(true); $enrolinstances = enrol_get_instances($course->id, true); foreach ($enrolinstances as $instance) { if (!isset($enrols[$instance->enrol])) { continue; } $form = $enrols[$instance->enrol]->enrol_page_hook($instance); if ($form) { // at least one plugin allows self-enrolment -- send // the user to the course enrolment page, and prevent // automatic enrolment $newstu->no_moodle_enrol = true; $newstu->save(); redirect("{$CFG->wwwroot}/course/enrol.php?id={$courseid}"); return; } } } } $newstu->save(); $tmppage = new coursecatalogpage(array('action' => 'default')); redirect($tmppage->url); }
function action_default() { global $CFG; $action = cm_get_param('action', ''); $delete = cm_get_param('delete', 0); $confirm = cm_get_param('confirm', ''); //md5 confirmation hash $confirmuser = cm_get_param('confirmuser', 0); $insid = cm_get_param('association_id', 0); $clsid = cm_get_param('id', 0); $userid = cm_get_param('userid', 0); $sort = cm_get_param('sort', 'assigntime'); $dir = cm_get_param('dir', 'ASC'); $page = cm_get_param('page', 0); $perpage = cm_get_param('perpage', 30); // how many per page $namesearch = trim(cm_get_param('search', '')); $alpha = cm_get_param('alpha', ''); $cls = new cmclass($clsid); $columns = array('idnumber' => get_string('instructor_idnumber', 'block_curr_admin'), 'name' => get_string('instructor_name', 'block_curr_admin'), 'assigntime' => get_string('instructor_assignment', 'block_curr_admin'), 'completetime' => get_string('instructor_completion', 'block_curr_admin')); foreach ($columns as $column => $cdesc) { if ($sort != $column) { $columnicon = ""; $columndir = "ASC"; } else { $columndir = $dir == "ASC" ? "DESC" : "ASC"; $columnicon = $dir == "ASC" ? "down" : "up"; $columnicon = " <img src=\"{$CFG->pixpath}/t/{$columnicon}.gif\" alt=\"\" />"; } ${$column} = "<a href=\"index.php?s=ins&section=curr&id={$clsid}&sort={$column}&dir={$columndir}&namesearch=" . urlencode(stripslashes($namesearch)) . "&alpha={$alpha}\">" . $cdesc . "</a>{$columnicon}"; $table->head[] = ${$column}; $table->align[] = "left"; } $table->head[] = ''; $table->align[] = 'center'; $inss = instructor_get_listing($clsid, $sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $numinss = instructor_count_records($clsid); $alphabet = explode(',', get_string('alphabet')); $strall = get_string('all'); /// Bar of first initials echo "<p style=\"text-align:center\">"; echo get_string('instructor_name', 'block_curr_admin') . " : "; if ($alpha) { echo " <a href=\"index.php?s=ins&section=curr&id={$clsid}&sort=name&dir=ASC&" . "perpage={$perpage}\">{$strall}</a> "; } else { echo " <b>{$strall}</b> "; } foreach ($alphabet as $letter) { if ($letter == $alpha) { echo " <b>{$letter}</b> "; } else { echo " <a href=\"index.php?s=ins&section=curr&id={$clsid}&sort=name&dir=ASC&" . "perpage={$perpage}&alpha={$letter}\">{$letter}</a> "; } } echo "</p>"; print_paging_bar($numinss, $page, $perpage, "index.php?s=ins&section=curr&id={$clsid}&sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&namesearch=" . urlencode(stripslashes($namesearch)) . "&"); flush(); if (!$inss) { $match = array(); if ($namesearch !== '') { $match[] = s($namesearch); } if ($alpha) { $match[] = 'name' . ": {$alpha}" . "___"; } $matchstring = implode(", ", $match); echo get_string('no_instructor_matching', 'block_curr_admin') . $matchstring; $table = NULL; } else { $table->align = array("left", "left", "center", "center"); $table->width = "95%"; foreach ($inss as $ins) { $deletebutton = '<a href="index.php?s=ins&section=curr&id=' . $clsid . '&action=delete&association_id=' . $ins->id . '">' . '<img src="pix/delete.gif" alt="Delete" title="Delete" /></a>'; $editbutton = '<a href="index.php?s=ins&section=curr&id=' . $clsid . '&action=edit&association_id=' . $ins->id . '">' . '<img src="pix/edit.gif" alt="Edit" title="Edit" /></a>'; $newarr = array(); foreach ($columns as $column => $cdesc) { if ($column == 'assigntime' || $column == 'completetime') { $newarr[] = !empty($ins->{$column}) ? date('M j, Y', $ins->{$column}) : '-'; } else { $newarr[] = $ins->{$column}; } } $newarr[] = $editbutton . ' ' . $deletebutton; $table->data[] = $newarr; } } echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>"; echo "<form action=\"index.php\" method=\"get\"><fieldset class=\"invisiblefieldset\">"; echo '<input type="hidden" name="section" value="curr" />'; echo '<input type="hidden" name="s" value="ins" />'; echo '<input type="hidden" name="id" value="' . $clsid . '" />'; echo '<input type="hidden" name="sort" value="' . $sort . '" />'; echo '<input type="hidden" name="dir" value="' . $dir . '" />'; echo "<input type=\"text\" name=\"search\" value=\"" . s($namesearch, true) . "\" size=\"20\" />"; echo "<input type=\"submit\" value=\"Search\" />"; if ($namesearch) { echo "<input type=\"button\" onclick=\"document.location='index.php?s=ins&" . "section=curr&id={$clsid}&sort={$sort}&dir={$dir}&perpage={$perpage}'\"" . "value=\"Show all users\" />"; } echo "</fieldset></form>"; echo "</td></tr></table>"; if (!empty($table)) { print_heading('<a href="index.php?s=ins&section=curr&action=add&id=' . $clsid . '">' . get_string('instructor_add', 'block_curr_admin') . '</a>'); print_table($table); print_paging_bar($numinss, $page, $perpage, "index.php?s=ins&section=curr&sort={$sort}&dir={$dir}&perpage={$perpage}" . "&alpha={$alpha}&namesearch=" . urlencode(stripslashes($namesearch)) . "&"); } print_heading('<a href="index.php?s=ins&section=curr&action=add&id=' . $clsid . '">' . get_string('instructor_add', 'block_curr_admin') . '</a>'); }
/** * Main display function. * * Fetch and display (or download) the required data. * * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $alpha An initial to filter results by. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $search = '', $alpha = '', $download = '') { $this->set_title(get_string('coursereport', 'block_curr_admin')); if (empty($download)) { $output = ''; $bc = '<span class="breadcrumb"><a href="index.php?s=rep&section=rept">' . get_string('reports', 'block_curr_admin') . '</a> ' . '» ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; } $this->add_column('student', get_string('student', 'block_curr_admin'), 'left', true); $this->add_column('coursename', get_string('course', 'block_curr_admin'), 'left', true); $this->add_column('completestatus', get_string('completion_status', 'block_curr_admin'), 'left'); $this->add_column('clsend', get_string('class_end', 'block_curr_admin'), 'left', true, true); $this->add_column('recurrenttraining', get_string('recruitment_training_info', 'block_curr_admin'), 'left', false, true); // if (empty($download)) { // $this->add_column('syllabus', 'Syllabus', 'left'); // } $this->set_default_sort('coursename', 'ASC'); $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = $page; $this->perpage = empty($download) ? $perpage : 0; /// Check if we need to build a search... $this->searchu = trim(cm_get_param('searchu', '')); $this->searchc = trim(cm_get_param('searchc', '')); $this->searchl = trim(cm_get_param('searchl', '')); $this->search = ''; $this->alpha = $alpha; $this->get_data(!empty($download)); if (empty($download)) { $searchstring = !empty($this->searchu) ? '&searchu=' . urlencode(stripslashes($this->searchu)) : ''; $searchstring .= !empty($this->searchc) ? '&searchc=' . urlencode(stripslashes($this->searchc)) : ''; $searchstring .= !empty($this->searchl) ? '&searchl=' . urlencode(stripslashes($this->searchl)) : ''; $this->set_baseurl($this->baseurl . $searchstring); $output .= $this->print_download_menu(); $output .= $this->print_header(); $output .= $this->display(); $output .= $this->print_footer(); echo $output; } else { $this->download($download); } }
/** * Main display function. * * Fetch and display (or download) the required data. * * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $alpha An initial to filter results by. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $download = '') { $this->clsid = cm_get_param('id', 0); $this->hideins = cm_get_param('hideins', false); $this->hidestu = cm_get_param('hidestu', false); $this->hidesyl = cm_get_param('hidesyl', false); $class = new cmclass($this->clsid); $this->set_title('Class Roster Report for ' . $class->course->name . ' ' . $class->idnumber); $this->set_default_sort('fullname', 'ASC'); $this->baseurl .= '&id=' . $this->clsid . '&hideins=' . $this->hideins . '&hidestu=' . $this->hidestu . '&hidesyl=' . $this->hidesyl; $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = $page; $this->perpage = !empty($download) ? 9999 : $perpage; // create the user filter form $this->filter = new cm_user_filtering(null, $this->baseurl); $this->extrasql = $this->filter->get_sql_filter(); $this->get_data(!empty($download)); $this->add_column('idnumber', 'ID', 'left', true); if (!$this->hidestu) { $this->add_column('fullname', 'Student', 'left', true); } else { if ($sort == 'fullname') { $sort = 'idnumber'; } } for ($i = 1; $i <= $this->num_grade_fields; $i++) { $this->add_column('timegraded' . $i, 'Completed ' . $i, 'left'); $this->add_column('grade' . $i, 'Grade ' . $i, 'left'); } // $this->add_column('completestatus', 'Completion Status', 'left'); $this->add_column('completetime', 'Completion Time', 'left', true); $this->add_column('grade', 'Completion Grade', 'left', true); $this->add_column('credits', 'Credits Awarded', 'left'); if (empty($download)) { $output = ''; $bc = '<div style="float:right;">' . $this->numrecs . ' users found.</div>' . '<span class="breadcrumb"><a href="index.php?s=rep&section=rept">Reports</a> ' . '» ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; $output .= $this->print_download_menu(); $output .= $this->print_header(); $output .= '<br /><fieldset>' . "\n"; $output .= '<legend>Class Information</legend>'; $output .= '<form action="index.php" method="post">'; $output .= '<input type="hidden" name="s" value="rep" />'; $output .= '<input type="hidden" name="type" value="classroster" />'; $output .= '<input type="hidden" name="sort" value="' . $this->sort . '" />'; $output .= '<input type="hidden" name="dir" value="' . $this->dir . '" />'; $output .= '<input type="hidden" name="id" value="' . $this->clsid . '" />'; $output .= 'Hide student name <input type="checkbox" name="hidestu" value="1" ' . (!empty($this->hidestu) ? ' checked' : '') . ' /> '; $output .= 'Hide syllabus <input type="checkbox" name="hidesyl" value="1" ' . (!empty($this->hidesyl) ? ' checked' : '') . ' /> '; $output .= '<input type="submit" value="Update Display" />'; $output .= '</form>'; $output .= '<table width="100%"><tr>'; $output .= '<tr><td colspan="2" rowspan="1"> </td></tr>'; $output .= '<td align="left" width="50%"><b>Course name</b>: <i>' . $class->course->name . '</i></td>'; $output .= '<td align="left" width="50%"><b>Class code</b>: ' . '<i>' . $class->idnumber . '</i></td></tr>'; $startdate = !empty($class->startdate) ? date('M j, Y', $class->startdate) : '-'; $enddate = !empty($class->enddate) ? date('M j, Y', $class->enddate) : '-'; $output .= '<tr><td align="left"><b>Start Date</b>: <i>' . $startdate . '</i></td>'; $output .= '<td align="left"><b>End Date</b>: <i>' . $enddate . '</i></td></tr>'; // $ins = new instructor(); // // if ($instructors = $ins->get_instructors($this->clsid)) { // $output .= '<tr><td colspan="2" rowspan="1"> </td></tr>'; // $output .= '<tr><th align="left" colspan="2">Instructors</th></tr>'; // // foreach ($instructors as $instructor) { // if ($this->hideins) { // $output .= '<tr><td align="left" colspan="2"><b>ID</b>: <i>' . // $instructor->idnumber . '</i></td></tr>'; // } else { // $output .= '<tr><td><b>Instructor</b>: <i>' . cm_fullname($instructor) . // '</i></td>'; // $output .= '<td><b>ID</b>: <i>' . $instructor->idnumber . // '</i></td></tr>'; // } // } // } if (!$this->hidesyl && !empty($class->course->syllabus)) { $output .= '<tr><td colspan="2" rowspan="1"> </td></tr>'; $output .= '<tr><td colspan="2">'; $output .= '<fieldset>'; $output .= '<legend>Syllabus</legend>'; $output .= '<i>' . $class->course->syllabus . '</i>'; $output .= '</fieldset></td></tr>'; } $output .= '</table></fieldset><br />'; $output .= $this->display(); echo $output; } else { $this->download($download); } }
function action_default() { $id = $this->required_param('id', PARAM_INT); $sort = optional_param('sort', 'name', PARAM_ALPHA); $dir = optional_param('dir', 'ASC', PARAM_ALPHA); $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 30, PARAM_INT); // how many per page $namesearch = trim(cm_get_param('search', '')); $alpha = cm_get_param('alpha', ''); $columns = array('curriculumname' => get_string('curriculum_name', 'block_curr_admin'), 'required' => get_string('required', 'block_curr_admin'), 'frequency' => get_string('frequency', 'block_curr_admin'), 'timeperiod' => get_string('time_period', 'block_curr_admin'), 'position' => get_string('position', 'block_curr_admin'), 'buttons' => get_string('management', 'block_curr_admin')); // ELIS-3306: back porting ELIS-2442 //$contexts = curriculumpage::get_contexts('block/curr_admin:associate'); $items = curriculumcourse_get_curriculum_listing($id, $sort, $dir, 0, 0, $namesearch, $alpha); $numitems = curriculumcourse_count_curriculum_records($id, $namesearch, $alpha); $formatters = $this->create_link_formatters(array('curriculumname'), 'curriculumpage', 'curriculumid'); $this->print_num_items($numitems); $this->print_alpha(); $this->print_search(); $this->print_list_view($items, $columns, $formatters, 'curricula'); if (coursepage::_has_capability('block/curr_admin:associate')) { $this->print_add_button(array('id' => $id), get_string('course_assigncurriculum', 'block_curr_admin')); } if (coursepage::_has_capability('block/curr_admin:curriculum:create')) { echo '<div align="center">'; $options = array_merge(array('s' => 'cfc', 'id' => $id)); echo print_single_button('index.php', $options, get_string('makecurcourse', 'block_curr_admin'), 'get', '_self', true, get_string('makecurcourse', 'block_curr_admin')); echo '</div>'; } }
/** * Main display function. * * Fetch and display (or download) the required data. * * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $download = '') { $context = get_context_instance(CONTEXT_SYSTEM, SITEID); if (has_capability('block/curr_admin:viewreports', $context)) { // Okay } else { if (has_capability('block/curr_admin:viewgroupreports', $context)) { // Verify userid } else { error("No access allowed."); } } $this->daywindow = cm_get_param('daywindow', 90); if (!isset($this->valid_windows[$this->daywindow])) { $this->daywindow = key($this->valid_windows); } $this->add_column('idnumber', get_string('idnumber', 'block_curr_admin'), 'left', true); $this->add_column('student', get_string('student_name', 'block_curr_admin'), 'left', true); $this->add_column('curname', get_string('curriculum', 'block_curr_admin'), 'left', empty($this->curname) ? true : false); $this->add_column('clustername', get_string('proctor', 'block_curr_admin'), 'left', true); $this->add_column('reqcredits', get_string('required_credits', 'block_curr_admin'), 'left', true); $this->add_column('numcredits', get_string('completed_credits', 'block_curr_admin'), 'left', true); $this->add_column('transfercredits', get_string('transfercredits', 'block_curr_admin'), 'left', true); $this->add_column('completiondate', get_string('completiondate', 'block_curr_admin'), 'left', true); $this->set_default_sort('student', 'ASC'); $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = $page; $this->perpage = !empty($download) ? 9999 : $perpage; // create the user filter form $this->filter = new curricula_filtering(null, $this->baseurl); $this->extrasql = $this->filter->get_sql_filter(); $this->get_data(!empty($download)); if (empty($download)) { $output = ''; /// Nav bar information: $bc = '<div style="float:right;">' . $this->numrecs . get_string('users_found', 'block_curr_admin') . '</div>' . '<span class="breadcrumb"><a href="index.php?s=rep&section=rept">' . get_string('reports', 'block_curr_admin') . '</a> ' . '» ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; $output .= $this->print_download_menu(); $output .= $this->print_header(); if (!empty($this->data)) { $output .= $this->display(); } else { $output .= '<h2>' . get_string('no_matching_users', 'block_curr_admin') . '</h2>'; } $output .= $this->print_footer(); echo $output; } else { $this->download($download); } }
/** * Main display function. * * Fetch and display (or download) the required data. * * @uses $CURMAN * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $alpha An initial to filter results by. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $search = '', $alpha = '', $download = '') { global $CURMAN; $this->loc = cm_get_param('loc', ''); $this->baseurl .= '&loc=' . $this->loc; $this->set_title('Recurrent Course Report for ' . $this->loc); if (empty($download)) { $output = ''; $bc = '<span class="breadcrumb"><a href="index.php?s=usr&section=users">' . get_string('user_management', 'block_curr_admin') . '</a> ' . '» ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; } $this->add_column('idnumber', get_string('class_id', 'block_curr_admin'), 'left', true); $this->add_column('username', get_string('student_name', 'block_curr_admin'), 'left', true); $this->add_column('classname', get_string('class_name', 'block_curr_admin'), 'left', true); $this->add_column('datecomplete', get_string('completed_label', 'block_curr_admin'), 'left', true); $this->add_column('nextdue', get_string('next_due', 'block_curr_admin'), 'left', true); $this->set_default_sort('username', 'ASC'); $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = 0; $this->perpage = 9999; $this->search = $search; $this->alpha = $alpha; $this->get_data(!empty($download)); if (empty($download)) { if (!empty($this->data)) { $output .= $this->print_download_menu() . '<br />'; } $usercount = $CURMAN->db->count_records(USRTABLE, 'local', $this->loc); $output .= '<fieldset>' . "\n"; $output .= '<legend>' . get_string('station_location_info', 'block_curr_admin') . '</legend>'; $output .= '<b>' . get_string('location', 'block_curr_admin') . ':</b> ' . $this->loc . '<br />'; $output .= '<b>' . get_string('total_users_at_location', 'block_curr_admin') . ':</b> ' . $usercount . '<br />'; $output .= '</fieldset><br />'; if (!empty($this->data)) { $output .= $this->display(); } else { $output .= '<h2>' . get_string('no_users_with_upcoming_renew', 'block_curr_admin') . '</h2>'; } echo $output; } else { $this->download($download); } }
/** * Main display function. * * Fetch and display (or download) the required data. * * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $alpha An initial to filter results by. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $search = '', $alpha = '', $download = '') { $this->daywindow = cm_get_param('daywindow', 90); if (!isset($this->valid_windows[$this->daywindow])) { $this->daywindow = key($this->valid_windows); } $this->set_title('Non-Qualification report for ' . $this->daywindow . ' day window'); if (empty($download)) { $output = ''; $bc = '<span class="breadcrumb"><a href="index.php?s=rep&section=rept">Reports</a> ' . '» ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; } $this->add_column('idnumber', 'ID', 'left', true); $this->add_column('student', 'Student', 'left', true); $this->add_column('classname', 'Class', 'left', true); $this->add_column('strnextdue', 'Next Due', 'left', false); $this->set_default_sort('crewmember', 'ASC'); $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = 0; $this->perpage = 9999; $this->search = $search; $this->alpha = $alpha; $this->get_data(!empty($download)); if (empty($download)) { $this->baseurl .= '&daywindow=' . $this->daywindow; $output .= $this->print_download_menu(); $output .= '<br /><fieldset>' . "\n"; $output .= '<form action="index.php" method="post">'; $output .= '<input type="hidden" name="s" value="rep" />'; $output .= '<input type="hidden" name="section" value="rept" />'; $output .= '<input type="hidden" name="type" value="nonqual" />'; $output .= '<input type="hidden" name="sort" value="' . $this->sort . '" />'; $output .= '<input type="hidden" name="dir" value="' . $this->dir . '" />'; $output .= 'Display report for users who will be non-qualifieid within '; $output .= cm_choose_from_menu($this->valid_windows, 'daywindow', $this->daywindow, '', '', '', true); $output .= '<input type="submit" value="' . get_string('display', 'block_curr_admin') . '" />'; $output .= '</form>'; $output .= '</fieldset><br />'; if (!empty($this->data)) { $output .= $this->display(); } else { $output .= '<h2>' . get_string('hide_nonqualified_users', 'block_curr_admin') . ' ' . $this->valid_windows[$this->daywindow] . '</h2>'; } echo $output; } else { $this->download($download); } }
/** * List the classes the user is enrolled in or instructs. * @todo Use language strings. * @return unknown_type */ function action_current() { global $CFG, $USER, $CURMAN; $clsid = cm_get_param('clsid', 0); // This is for a Moodle user, so get the Curriculum user id. $cuserid = cm_get_crlmuserid($USER->id); // Needed for the hide buttons //require_js('yui_yahoo'); //require_js('yui_event'); require_js($CFG->wwwroot . '/curriculum/js/util.js'); $this->include_yui(); $usercurs = curriculumstudent::get_curricula($cuserid); $instrclasses = user::get_instructed_classes($cuserid); $noncurclasses = user::get_non_curriculum_classes($cuserid); $numtables = 0; if ($usercurs) { $numtables += count($usercurs); } if ($instrclasses) { $numtables += count($instrclasses); } if ($noncurclasses) { $numtables += count($noncurclasses); } if ($numtables > $CURMAN->config->catalog_collapse_count) { $buttonLabel = get_string('show', 'block_curr_admin'); $extraclass = ' hide'; } else { $buttonLabel = get_string('hide', 'block_curr_admin'); $extraclass = ''; } // Process our curricula in turn, outputting the courses within each. if ($usercurs) { $showcurid = optional_param('showcurid', 0, PARAM_INT); foreach ($usercurs as $usercur) { if ($classes = user::get_current_classes_in_curriculum($cuserid, $usercur->curid)) { if ($showcurid > 0) { // If we are passed the showcurid parameter then override the default show/hide settings $buttonLabel = $usercur->curid == $showcurid ? get_string('hide', 'block_curr_admin') : get_string('show', 'block_curr_admin'); $extraclass = $usercur->curid == $showcurid ? '' : ' hide'; } print_heading('<div class="clearfix"></div><div class="headermenu"><script id="curriculum' . $usercur->curid . 'script" type="text/javascript">toggleVisibleInit("curriculum' . $usercur->curid . 'script", "curriculum' . $usercur->curid . 'button", "' . $buttonLabel . '", "Hide", "Show", "curriculum' . $usercur->curid . '");</script></div>' . $usercur->name . ' (' . $usercur->idnumber . ')'); echo '<div id="curriculum' . $usercur->curid . '" class="yui-skin-sam ' . $extraclass . '">'; $table = new currentclasstable($classes, $this->get_moodle_url()); echo "<div id=\"{$usercur->id}\"></div>"; $table->print_yui_table($usercur->id); } else { $buttonLabel2 = $usercur->curid == $showcurid ? get_string('hide', 'block_curr_admin') : get_string('show', 'block_curr_admin'); $extraclass2 = $usercur->curid == $showcurid ? '' : ' hide'; print_heading('<div class="clearfix"></div><div class="headermenu"><script id="curriculum' . $usercur->curid . 'script" type="text/javascript">toggleVisibleInit("curriculum' . $usercur->curid . 'script", "curriculum' . $usercur->curid . 'button", "' . $buttonLabel2 . '", "Hide", "Show", "curriculum' . $usercur->curid . '");</script></div>' . $usercur->name . ' (' . $usercur->idnumber . ')'); echo '<div id="curriculum' . $usercur->curid . '" class="yui-skin-sam ' . $extraclass2 . '">'; echo '<p>' . get_string('nocoursesinthiscurriculum', 'block_curr_admin') . '</p>'; } echo '</div>'; } } else { print_heading(get_string('notassignedtocurricula', 'block_curr_admin')); } // Print out a table for classes not belonging to any curriculum if ($noncurclasses) { $labelshow = get_string('show', 'block_curr_admin'); $labelhide = get_string('hide', 'block_curr_admin'); print_heading('<div class="clearfix"></div><div class="headermenu"><script id="noncurrscript" type="text/javascript">toggleVisibleInit("noncurrscript", "noncurrbutton", "' . $buttonLabel . '", "' . $labelhide . '", "' . $labelshow . '", "noncurr");</script></div>' . get_string('othercourses', 'block_curr_admin')); echo '<div id="noncurr" class="yui-skin-sam ' . $extraclass . '">'; echo '<div id="noncurrtable"></div>'; $table = new currentclasstable($noncurclasses, $this->get_moodle_url()); $table->print_yui_table("noncurrtable"); echo '</div>'; } else { // Display nothing if we don't have any non-curriculum classes } // Print out a table for classes we instruct if ($instrclasses) { print_heading('<div class="clearfix"></div><div class="headermenu"><script id="instrscript" type="text/javascript">toggleVisibleInit("instrscript", "instrbutton", "' . $buttonLabel . '", "Hide", "Show", "instr");</script></div>' . get_string('instructedcourses', 'block_curr_admin')); echo '<div id="instr" class="yui-skin-sam ' . $extraclass . '">'; echo '<div id="instrtable"></div>'; $table = new instructortable($instrclasses, $this->get_moodle_url()); $classpage = new cmclasspage(); $table->decorators['classname'] = new recordlinkformatter($classpage, 'id'); $table->print_yui_table("instrtable"); echo '</div>'; } else { // Display nothing if we don't instruct any classes } echo '<br/>'; print_box(get_string('lp_class_instructions', 'block_curr_admin'), 'generalbox lp_instructions'); }
function get_body() { global $CFG, $CURMAN; $action = cm_get_param('action', ''); $confirm = cm_get_param('confirm', ''); //md5 confirmation hash $confirmuser = cm_get_param('confirmuser', 0); $trackid = cm_get_param('trackid', 0); $id = cm_get_param('id', 0); $sort = cm_get_param('sort', 'idnumber'); $dir = cm_get_param('dir', 'ASC'); $page = cm_get_param('page', 0); $perpage = cm_get_param('perpage', 30); // how many per page $namesearch = trim(cm_get_param('search', '')); $alpha = cm_get_param('alpha', ''); if (!($track = new track($trackid))) { return ' (' . $trackid . ')'; } switch ($action) { case 'add': return $this->get_add_form($trackid); break; case 'confirm': $tk = new trackassignmentclass($id); if (md5($tk->id) != $confirm) { echo cm_error('Invalid confirmation code!'); } else { if (!$tk->delete()) { echo cm_error('Course "name: ' . $tk->track->name . '" not deleted.'); } } break; case 'delete': return $this->get_delete_form($id); break; case 'edit': return $this->get_edit_form($id); break; case 'update': $id = cm_get_param('id', 0); $autoenrol = cm_get_param('autoenrol', 0); $trkassign = new trackassignmentclass($id); $trkassign->autoenrol = $autoenrol; $trkassign->data_update_record(); break; case 'savenew': $classes = cm_get_param('classes', ''); $classes = is_array($classes) ? $classes : array(); $trackid = cm_get_param('trackid', 0, PARAM_INT); if (!empty($classes) and !empty($trackid)) { $param = array('trackid' => $trackid); $trackobj = new track($trackid); foreach ($classes as $classid) { $classobj = new cmclass($classid); $param['classid'] = $classid; $param['courseid'] = $classobj->courseid; $param['autoenrol'] = 0; $param['required'] = 0; // Pull up the curricula assignment record(s) $curcourse = curriculumcourse_get_list_by_curr($trackobj->curid); // Traverse though curricula's courses until the the course the - // selected classs is assigned to comes up foreach ($curcourse as $recid => $curcourec) { // Only interested in the course that the class is assigned to if ($curcourec->courseid == $classobj->courseid) { if ($curcourec->required) { $param['required'] = 1; // Only one class assigned to course to enable auto enrol if (1 == cmclass::count_course_assignments($curcourec->courseid)) { $param['autoenrol'] = 1; } } } } // Assign class to track now $trkassignobj = new trackassignmentclass($param); $trkassignobj->assign_class_to_track(); } } break; } $columns = array('clsname' => get_string('class_id_number', 'block_curr_admin'), 'autoenrol' => get_string('auto_enrol', 'block_curr_admin')); foreach ($columns as $column => $cdesc) { if ($sort != $column) { $columnicon = ""; $columndir = "ASC"; } else { $columndir = $dir == "ASC" ? "DESC" : "ASC"; $columnicon = $dir == "ASC" ? "down" : "up"; $columnicon = " <img src=\"{$CFG->pixpath}/t/{$columnicon}.gif\" alt=\"\" />"; } ${$column} = "<a href=\"index.php?s=trkcls&section=curr&sort={$column}&" . "dir={$columndir}&search=" . urlencode(stripslashes($namesearch)) . "&alpha={$alpha}&trackid={$trackid}\">" . $cdesc . "</a>{$columnicon}"; $table->head[] = ${$column}; $table->align[] = 'left'; $table->wrap[] = false; } $table->head[] = ''; $table->align[] = 'center'; $table->wrap[] = true; $trks = track_assignment_get_listing($trackid, $sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $numtrk = track_assignment_count_records($trackid, $namesearch, $alpha); $alphabet = explode(',', get_string('alphabet')); $strall = get_string('all'); /// Nav bar information: $bc = '<div style="float:right;">' . $numtrk . ' track(s) found.</div>' . '<span class="breadcrumb">' . get_string('trackasso_manage_crumb', 'block_curr_admin', $track->name) . '</span>'; echo cm_print_heading_block($bc, '', true); echo '<br />' . "\n"; /// Bar of first initials echo "<p style=\"text-align:center\">"; echo 'Name' . " : "; if ($alpha) { echo " <a href=\"index.php?s=trkcls&section=curr&sort=name&dir=ASC&" . "perpage={$perpage}&trackid={$trackid}\">{$strall}</a> "; } else { echo " <b>{$strall}</b> "; } foreach ($alphabet as $letter) { if ($letter == $alpha) { echo " <b>{$letter}</b> "; } else { echo " <a href=\"index.php?s=trkcls&section=curr&sort=idnumber&dir=ASC&" . "perpage={$perpage}&trackid={$trackid}&alpha={$letter}\">{$letter}</a> "; } } echo "</p>"; print_paging_bar($numtrk, $page, $perpage, "index.php?s=trkm&section=curr&sort={$sort}&dir={$dir}&perpage={$perpage}&" . "alpha={$alpha}&trackid={$trackid}&search=" . urlencode(stripslashes($namesearch)) . "&"); if (!$trks) { $match = array(); if ($namesearch !== '') { $match[] = s($namesearch); } if ($alpha) { $match[] = 'idnumber' . ": {$alpha}" . "___"; } $matchstring = implode(", ", $match); echo get_string('no_matching_track_assign', 'block_curr_admin') . $matchstring; $table = NULL; } else { $table->width = "95%"; foreach ($trks as $trk) { $deletebutton = '<a href="index.php?s=trkcls&section=curr&action=delete&' . 'id=' . $trk->id . '">' . '<img src="pix/delete.gif" alt="Delete" title="Delete" /></a>'; $editbutton = '<a href="index.php?s=trkcls&section=curr&action=edit&id=' . $trk->id . '">' . '<img src="pix/edit.gif" alt="Edit" title="Edit" /></a>'; /*$tagbutton = '<a href="index.php?s=tagins&section=curr&t=cur&i='.$trk->id.'">'. '<img src="pix/tag.gif" alt="Tags" title="Tags" /></a>'; $clusterbutton = '<a href="index.php?s=clutrk&section=curr&mode=trk&' . 'track=' . $trk->id . '"><img src="pix/cluster.gif" alt="Clusters" '. 'title="Clusters" /></a>';*/ $newarr = array(); foreach ($columns as $column => $cdesc) { if ($column == 'clsname') { $newarr[] = '<a href="index.php?s=cls§ion=curr&action=edit&id=' . $trk->classid . '">' . $trk->{$column} . '</a>'; } else { $newarr[] = $trk->{$column}; } } $newarr[] = $editbutton . ' ' . $deletebutton; $table->data[] = $newarr; } } echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>"; echo "<form action=\"index.php\" method=\"get\"><fieldset class=\"invisiblefieldset\">"; echo '<input type="hidden" name="s" value="trkcls" />'; echo '<input type="hidden" name="section" value="curr" />'; echo '<input type="hidden" name="sort" value="' . $sort . '" />'; echo '<input type="hidden" name="dir" value="' . $dir . '" />'; echo '<input type="hidden" name="perpage" value="' . $perpage . '" />'; echo '<input type="hidden" name="trackid" value="' . $trackid . '" />'; echo "<input type=\"text\" name=\"search\" value=\"" . s($namesearch, true) . "\" size=\"40\" />"; echo "<input type=\"submit\" value=\"" . get_string('search', 'block_curr_admin') . "\" />"; if ($namesearch) { echo "<input type=\"button\" onclick=\"document.location='index.php?s=trkcls&" . "section=curr&sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&trackid={$trackid}';\" " . "value=\"" . get_string('show_all_curricula', 'block_curr_admin') . "\" />"; } echo "</fieldset></form>"; echo "</td></tr></table>"; if (!empty($table)) { print_heading('<a href="index.php?s=trkcls&section=curr&action=add&trackid=' . $trackid . '">' . get_string('trackasso_add_asso', 'block_curr_admin', $track->name) . '</a>'); print_table($table); print_paging_bar($numtrk, $page, $perpage, "index.php?s=trkcls&section=curr&sort={$sort}&dir={$dir}&perpage={$perpage}" . "&alpha={$alpha}&trackid={$trackid}&search=" . urlencode(stripslashes($namesearch)) . "&"); } print_heading('<a href="index.php?s=trkcls&section=curr&action=add&trackid=' . $trackid . '">' . get_string('trackasso_add_asso', 'block_curr_admin', $track->name) . '</a>'); }
/** * Main display function. * * Fetch and display (or download) the required data. * * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $alpha An initial to filter results by. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $download = '', $frompage = '') { $this->daywindow = cm_get_param('daywindow', 90); if (!isset($this->valid_windows[$this->daywindow])) { $this->daywindow = key($this->valid_windows); } $this->add_column('idnumber', get_string('student_id', 'block_curr_admin'), 'left', true); $this->add_column('student', get_string('student_name', 'block_curr_admin'), 'left', true); $this->add_column('email', get_string('student_email', 'block_curr_admin'), 'left', true); $this->add_column('origenroldate', get_string('curenroldate', 'block_curr_admin'), 'left', true); $this->add_column('birthdate', get_string('userbirthdate', 'block_curr_admin'), 'left', true); $this->add_column('gender', get_string('usergender', 'block_curr_admin'), 'left', true); $this->add_column('timegraded', get_string('last_activity', 'block_curr_admin'), 'left', true); $this->add_column('clustername', get_string('cluster', 'block_curr_admin'), 'left', true); $this->add_column('curricula', get_string('curriculum', 'block_curr_admin'), 'left', false); $this->add_column('country', get_string('country', 'block_curr_admin'), 'left', true); $this->set_default_sort('student', 'ASC'); $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = $page; $this->perpage = !empty($download) ? 9999 : $perpage; // create the user filter form $this->filter = new enrollment_filtering(null, $this->baseurl); $this->extrasql = $this->filter->get_sql_filter(); $this->get_data(!empty($download)); if (empty($download)) { $output = ''; /// Nav bar information: $bc = '<div style="float:right;">' . $this->numrecs . get_string('users_found', 'block_curr_admin') . '</div>' . '<span class="breadcrumb"><a href="index.php?s=rep&section=rept">' . get_string('reports', 'block_curr_admin') . '</a> ' . '» ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; $output .= $this->print_download_menu(); $output .= $this->print_header(); if (!empty($this->data)) { $output .= $this->display(); } else { $output .= '<h2>' . get_string('no_matching_users', 'block_curr_admin') . '</h2>'; } $output .= $this->print_footer(); echo $output; } else { $this->download($download); } }
function action_updateattendance() { $atnrecord = array(); $atnrecord['id'] = cm_get_param('atnid', 0); $atnrecord['classid'] = $clsid; $atnrecord['userid'] = cm_get_param('userid', 0); $startyear = cm_get_param('startyear'); $startmonth = cm_get_param('startmonth'); $startday = cm_get_param('startday'); $atnrecord['timestart'] = mktime(0, 0, 0, $startmonth, $startday, $startyear); $endyear = cm_get_param('endyear'); $endmonth = cm_get_param('endmonth'); $endday = cm_get_param('endday'); $atnrecord['timeend'] = mktime(0, 0, 0, $endmonth, $endday, $endyear); $atnrecord['note'] = cm_get_param('note', ''); $atn = new attendance($atnrecord); if (($status = $atn->update()) !== true) { echo cm_error('Record not updated. Reason: ' . $status->message); } }
/** * Main display function. * * Fetch and display (or download) the required data. * * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $alpha An initial to filter results by. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $download = '', $frompage = '') { global $CFG, $USER; $context = get_context_instance(CONTEXT_SYSTEM, SITEID); $canaccessum = false; if (has_capability('block/curr_admin:viewreports', $context)) { $this->usrid = cm_get_param('user', 0); $canaccessum = true; } else { if (has_capability('block/curr_admin:viewgroupreports', $context)) { // Verify userid $this->usrid = cm_get_param('user', 0); if (!cm_can_access_userreport($this->usrid)) { error("No access allowed."); } $canaccessum = false; } else { if (has_capability('block/curr_admin:viewownreports', $context)) { // Make sure only this user. if (!($this->usrid = cm_get_crlmuserid($USER->id))) { error("No account found."); } } else { error("No access allowed."); } } } $user = new user($this->usrid); $this->baseurl .= '&user='******'&hideins=' . $this->hideins; $this->set_title('Individual User Report for ' . cm_fullname($user)); if (empty($download)) { $output = ''; if ($frompage == '') { $frompage = 'users'; } $pagename = get_string("report{$frompage}", 'block_curr_admin'); $bc = '<span class="breadcrumb"><a href="index.php?s=rep&section=rept&type=' . $frompage . '">' . $pagename . '</a> » ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; } $this->get_data(!empty($download)); $this->add_column('courseidnumber', 'Course ID', 'left', false); $this->add_column('coursename', 'Course Name', 'left', false); $this->add_column('classidnumber', 'Class ID', 'left', false); if (!empty($this->_maxexams)) { for ($i = 1; $i <= $this->_maxexams; $i++) { $this->add_column('ccgrade' . $i, 'Exam ' . $i, 'left', false); $this->add_column('cctimegraded' . $i, 'Date ' . $i, 'left', false); } } $this->add_column('classgrade', 'Class Grade', 'left', false); $this->add_column('credits', 'Credits', 'left', false); $this->add_column('datecomplete', 'Completed', 'left', false); $this->add_column('completestatus', 'Status', 'left', false); // $this->add_column('nextdue', 'Next Due', 'left', true); // $this->add_column('insid', 'Instructor ID', 'left', true); /* if (!$this->hideins) { $this->add_column('insname', 'Instructor Name', 'left', true); } */ $this->set_default_sort('coursename', 'ASC'); $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = 0; $this->perpage = 9999; if (empty($download)) { $tlink = $CFG->wwwroot . '/curriculum/index.php'; $toptions = array('s' => 'rep', 'section' => 'rept', 'type' => 'transcript', 'user' => $this->usrid); $tlabel = get_string('transcript', 'block_curr_admin'); $output .= '<div class="trans-button">' . print_single_button($tlink, $toptions, $tlabel, NULL, NULL, true) . '</div>'; if (!empty($this->rawdata)) { $output .= $this->print_download_menu(); } $output .= '<br />'; $output .= '<fieldset>' . "\n"; /* $output .= '<form action="index.php" method="post">'; $output .= '<input type="hidden" name="s" value="rep" />'; $output .= '<input type="hidden" name="section" value="rept" />'; $output .= '<input type="hidden" name="type" value="induser" />'; $output .= '<input type="hidden" name="sort" value="' . $this->sort . '" />'; $output .= '<input type="hidden" name="dir" value="' . $this->dir . '" />'; $output .= '<input type="hidden" name="user" value="' . $this->usrid . '" />'; $output .= 'Hide instructor name <input type="checkbox" name="hideins" value="1" ' . (!empty($this->hideins) ? ' checked' : '') . ' /> '; $output .= '<input type="submit" value="Update Display" />'; $output .= '</form><br />'; */ if (empty($user->origenroldate)) { if (empty($user->timecreated)) { $origdate = get_string('unknown', 'block_curr_admin'); } else { $origdate = cm_timestamp_to_date($user->timecreated); } } else { if (!($origdate = cm_timestring_to_date($user->origenroldate))) { $origdate = get_string('unknown', 'block_curr_admin'); } } $output .= '<legend>' . get_string('user_information', 'block_curr_admin') . '</legend>'; $output .= '<div style="float: left; width: 50%;"><b>' . get_string('user_id', 'block_curr_admin') . '</b> '; if ($canaccessum) { $output .= '<a href="' . $CFG->wwwroot . '/curriculum/index.php?s=usr&userid=' . $user->id . '&action=view">' . $user->idnumber . '</a></div>'; } else { $output .= $user->idnumber . '</div>'; } $output .= '<div style="float: left; width: 50%;"><b>' . get_string('student_email', 'block_curr_admin') . ':</b> ' . $user->email . '</div><br />'; $output .= '<div style="float: left; width: 50%;"><b>' . get_string('firstname', 'block_curr_admin') . ':</b> ' . $user->firstname . '</div>'; $output .= '<div style="float: left; width: 50%;"><b>' . get_string('original_reg_date', 'block_curr_admin') . ':</b> ' . $origdate . '</div><br />'; $output .= '<div style="float: left; width: 35%;"><b>' . get_string('lastname', 'block_curr_admin') . ':</b> ' . $user->lastname . '</div><br />'; $output .= '</fieldset><br />'; if (!empty($this->rawdata)) { foreach ($this->rawdata as $curid => $curlist) { $output .= '<strong>' . $curlist->curriculumname . ' - ' . get_string('enrolled_classes', 'block_curr_admin') . '</strong>'; $this->data = $curlist->data; $output .= $this->display(); unset($this->table); $output .= '<br /><br />'; } } else { $output .= '<h2>' . get_string('no_classes_completed', 'block_curr_admin') . '</h2>'; } $output .= $this->print_footer(); echo $output; } else { $this->download($download); } }
function action_confirmdelem() { $id = required_param('id', PARAM_INT); $confirm = required_param('confirm', PARAM_TEXT); $elemid = cm_get_param('elemid', 0); $crs = new course($id); if (md5($elemid) != $confirm) { echo cm_error('Invalid confirmation code!'); } else { if (!$crs->delete_completion_element($elemid)) { echo cm_error('Completion element not deleted.'); } else { echo cm_error('Completion element deleted.'); } } $this->print_tabs('elem', array('id' => $id)); echo $this->get_completion_page($id); }
/** * Main display function. * * Fetch and display (or download) the required data. * * @param string $sort The column to sort results by. * @param string $dir The direction to sort by. * @param int $page The page number to display results for. * @param int $perpage The number of results per page. * @param string $search A string to search for. * @param string $alpha An initial to filter results by. * @param string $download The format to download the report in. */ function main($sort = '', $dir = '', $page = 0, $perpage = 20, $search = '', $alpha = '', $download = '') { $this->usrid = cm_get_param('user', 0); // $this->hideins = cm_get_param('hideins', false); $user = new user($this->usrid); $this->baseurl .= '&user='******'&hideins=' . $this->hideins; $this->set_title('Individual User Report for ' . cm_fullname($user)); if (empty($download)) { $output = ''; $bc = '<span class="breadcrumb"><a href="index.php?s=usr&section=users&search=' . urlencode(cm_fullname($user)) . '">User Management</a> » ' . $this->title . '</span>'; $output .= cm_print_heading_block($bc, '', true); $output .= '<br />' . "\n"; } $this->get_data(!empty($download)); $this->add_column('idnumber', 'ID', 'left', false); $this->add_column('coursename', 'Name', 'left', false); for ($i = 1; $i <= $this->_maxexams; $i++) { $this->add_column('ccgrade' . $i, 'Exam ' . $i, 'left', false); $this->add_column('cctimegraded' . $i, 'Date ' . $i, 'left', false); } $this->add_column('classgrade', 'Class Grade', 'left', false); $this->add_column('datecomplete', 'Completed', 'left', false); $this->add_column('completestatus', 'Status', 'left', false); // $this->add_column('nextdue', 'Next Due', 'left', true); // $this->add_column('insid', 'Instructor ID', 'left', true); /* if (!$this->hideins) { $this->add_column('insname', 'Instructor Name', 'left', true); } */ $this->set_default_sort('coursename', 'ASC'); $this->sort = !empty($sort) ? $sort : $this->defsort; $this->dir = !empty($dir) ? $dir : $this->defdir; $this->page = 0; $this->perpage = 9999; $this->search = $search; $this->alpha = $alpha; if (empty($download)) { if (!empty($this->data)) { $output .= $this->print_download_menu() . '<br />'; } $output .= '<fieldset>' . "\n"; /* $output .= '<form action="index.php" method="post">'; $output .= '<input type="hidden" name="s" value="rep" />'; $output .= '<input type="hidden" name="section" value="rept" />'; $output .= '<input type="hidden" name="type" value="induser" />'; $output .= '<input type="hidden" name="sort" value="' . $this->sort . '" />'; $output .= '<input type="hidden" name="dir" value="' . $this->dir . '" />'; $output .= '<input type="hidden" name="user" value="' . $this->usrid . '" />'; $output .= 'Hide instructor name <input type="checkbox" name="hideins" value="1" ' . (!empty($this->hideins) ? ' checked' : '') . ' /> '; $output .= '<input type="submit" value="Update Display" />'; $output .= '</form><br />'; */ $output .= '<legend>' . get_string('user_information', 'block_curr_admin') . '</legend>'; $output .= '<b>' . get_string('user_id', 'block_curr_admin') . ':</b> ' . $user->idnumber . '<br />'; $output .= '<b>' . get_string('firstname', 'block_curr_admin') . ':</b> ' . $user->firstname . '<br />'; $output .= '<b>' . get_string('lastname', 'block_curr_admin') . ':</b> ' . $user->lastname . '<br />'; $output .= '</fieldset><br />'; if (!empty($this->data)) { $datum = reset($this->data); $output .= '<strong>' . $datum->curriculumname . ' - ' . get_string('enrolled_classes', 'block_curr_admin') . '</strong>'; $output .= $this->display(); } else { $output .= '<h2>' . get_string('no_classes_completed', 'block_curr_admin') . '</h2>'; } if (isset($this->data2)) { unset($this->headers); unset($this->align); unset($this->sortable); unset($this->wrap); $output .= '<br />' . get_string('courses_not_in', 'block_curr_admin') . ': '; foreach ($this->data2 as $datum) { $output .= s($datum->coursename) . ', '; } } echo $output; } else { $this->download($download); } }