/** * Return the HTML to edit a specific instructor. * This could be extended to allow for application specific editing, for example * a Moodle interface to its formslib. * * @param $formid string A suffix to put on all 'id' and index for all 'name' attributes. * This should be unique if being used more than once in a form. * @param $extraclass string Any extra class information to add to the output. * * @return string The form HTML, without the form. */ function edit_form_html($classid, $sort = 'name', $dir = 'ASC', $page = 0, $perpage = 0, $namesearch = '', $alpha = '') { global $CFG; $output = ''; ob_start(); $table = new stdClass(); if (empty($this->id)) { $columns = array('assign' => 'Assign', 'idnumber' => 'ID Number', 'name' => 'Name', 'assigntime' => 'Assigned Time', 'completetime' => 'Completion Time'); } else { $columns = array('idnumber' => 'ID Number', 'name' => 'Name', 'assigntime' => 'Assigned Time', 'completetime' => 'Completion Time'); } 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=\"\" />"; } if ($column == 'name' || $column == 'description') { ${$column} = "<a href=\"index.php?s=ins&section=curr&id={$classid}&" . "action=add&sort={$column}&dir={$columndir}&search=" . urlencode(stripslashes($namesearch)) . "&alpha={$alpha}\">" . $cdesc . "</a>{$columnicon}"; } else { ${$column} = $cdesc; } $table->head[] = ${$column}; $table->align[] = "left"; $table->wrap[] = true; } if (empty($this->id)) { $users = $this->get_users_avail($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $usercount = $this->count_users_avail($namesearch, $alpha); $alphabet = explode(',', get_string('alphabet')); $strall = get_string('all'); /// Bar of first initials echo "<p style=\"text-align:center\">"; echo get_string('tag_name', 'block_curr_admin') . " : "; if ($alpha) { echo " <a href=\"index.php?s=ins&section=curr&action=add&id={$classid}&" . "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&action=add&id={$classid}&" . "sort=name&dir=ASC&perpage={$perpage}&alpha={$letter}\">{$letter}</a> "; } } echo "</p>"; print_paging_bar($usercount, $page, $perpage, "index.php?s=ins&section=curr&id={$classid}&action=add&" . "sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&" . "search=" . urlencode(stripslashes($namesearch)) . "&"); flush(); } else { $user = $this->user; $user->name = cm_fullname($this->user); $users[] = $user; $usercount = 0; } if (empty($this->id) && !$users) { $match = array(); if ($namesearch !== '') { $match[] = s($namesearch); } if ($alpha) { $match[] = 'name' . ": {$alpha}" . "___"; } $matchstring = implode(", ", $match); echo get_string('no_users_matching', 'block_curr_admin') . $matchstring; $table = NULL; } else { $insobj = new instructor(); $table->width = "100%"; foreach ($users as $user) { $newarr = array(); foreach ($columns as $column => $cdesc) { switch ($column) { case 'assign': $newarr[] = '<input type="checkbox" name="users[' . $user->id . '][assign]" value="1" />' . '<input type="hidden" name="users[' . $user->id . '][idnumber]" ' . 'value="' . $user->idnumber . '" />'; break; case 'name': case 'idnumber': case 'description': $newarr[] = $user->{$column}; break; case 'assigntime': $newarr[] = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $this->assigntime, true); break; case 'completetime': $newarr[] = cm_print_date_selector('users[' . $user->id . '][endday]', 'users[' . $user->id . '][endmonth]', 'users[' . $user->id . '][endyear]', $this->completetime, true); break; default: $newarr[] = ''; break; } } $table->data[] = $newarr; } } if (empty($this->id)) { echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>"; echo "<form action=\"index.php\" method=\"get\"><fieldset>"; echo '<input type="hidden" name="s" value="ins" />'; echo '<input type="hidden" name="section" value="curr" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="id" value="' . $classid . '" />'; 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=\"" . get_string('search', 'block_curr_admin') . "\" />"; if ($namesearch) { echo "<input type=\"button\" onclick=\"document.location='index.php?s=ins&section=curr&" . "action=add&id={$classid}';\" value=\"" . get_string('show_all_users', 'block_curr_admin') . "\" />"; } echo "</fieldset></form>"; echo "</td></tr></table>"; echo '<form method="post" action="index.php?s=ins&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="savenew" />' . "\n"; } else { echo '<form method="post" action="index.php?s=ins&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="update" />' . "\n"; echo '<input type="hidden" name="association_id" value="' . $this->id . '" />' . "\n"; echo '<input type="hidden" name="id" value="' . $this->classid . '" />' . "\n"; echo '<input type="hidden" name="userid" value="' . $this->userid . '" />' . "\n"; } if (!empty($table)) { print_table($table); print_paging_bar($usercount, $page, $perpage, "index.php?s=ins&section=curr&id={$classid}&action=add&" . "sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&" . "search=" . urlencode(stripslashes($namesearch)) . "&"); } if (empty($this->id)) { echo '<br /><input type="submit" value="' . get_string('assign_selected', 'block_curr_admin') . '">' . "\n"; } else { echo '<br /><input type="submit" value="' . get_string('update_assignment', 'block_curr_admin') . '">' . "\n"; } echo '</form>' . "\n"; $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Returns the delete student form. * * @param int $id The ID of the student. * @return string HTML for the form. * */ function print_delete_form($stu) { $url = 'index.php'; $message = get_string('student_deleteconfirm', 'block_curr_admin', cm_fullname($stu->user)); $optionsyes = array('s' => 'stu', 'section' => 'curr', 'id' => $stu->classid, 'action' => 'confirm', 'association_id' => $stu->id, 'confirm' => md5($stu->id)); $optionsno = array('s' => 'stu', 'section' => 'curr', 'id' => $stu->classid); echo cm_delete_form($url, $message, $optionsyes, $optionsno); }
public function to_string() { return cm_fullname($this); }
function get_item_display_name($column, $item) { if (isset($item->name)) { return $item->name; } else { return cm_fullname($item); } }
/** * Get the data needed for a downloadable version of the report (all data, * no paging necessary) and format it accordingly for the download file * type. * * NOTE: It is expected that the valid format types will be overridden in * an extended report class as the array is empty by default. * * @param string $format A valid format type. */ function download($format) { global $CFG; $output = ''; if (empty($this->rawdata)) { return $output; } $filename = !empty($this->title) ? $this->title : get_string('download_report', 'block_curr_admin'); switch ($format) { case 'csv': $filename .= '.csv'; header("Content-Transfer-Encoding: ascii"); header("Content-Disposition: attachment; filename={$filename}"); header("Content-Type: text/comma-separated-values"); $row = array(); $row[] = get_string('curriculum', 'block_curr_admin'); foreach ($this->headers as $header) { $row[] = $this->csv_escape_string(strip_tags($header)); } echo implode(',', $row) . "\n"; 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>'; } foreach ($this->rawdata as $curid => $curlist) { $first = $curlist->curriculumname; foreach ($curlist->data as $datum) { if (!is_object($datum)) { continue; } $row = array(); $row[] = $this->csv_escape_string($first); foreach ($this->headers as $id => $header) { if (isset($datum->{$id})) { $row[] = $this->csv_escape_string($datum->{$id}); } else { $row[] = '""'; } } echo implode(',', $row) . "\n"; } } break; case 'excel': require_once $CFG->libdir . '/excellib.class.php'; $filename .= '.xls'; /// Creating a workbook $workbook = new MoodleExcelWorkbook('-'); /// Sending HTTP headers $workbook->send($filename); /// Creating the first worksheet $sheettitle = get_string('studentprogress', 'reportstudentprogress'); $myxls =& $workbook->add_worksheet($sheettitle); /// Format types $format =& $workbook->add_format(); $format->set_bold(0); $formatbc =& $workbook->add_format(); $formatbc->set_bold(1); $formatbc->set_align('center'); $formatb =& $workbook->add_format(); $formatb->set_bold(1); $formaty =& $workbook->add_format(); $formaty->set_bg_color('yellow'); $formatc =& $workbook->add_format(); $formatc->set_align('center'); $formatr =& $workbook->add_format(); $formatr->set_bold(1); $formatr->set_color('red'); $formatr->set_align('center'); $formatg =& $workbook->add_format(); $formatg->set_bold(1); $formatg->set_color('green'); $formatg->set_align('center'); $rownum = 0; $colnum = 0; $myxls->write($rownum, $colnum++, get_string('curriculum', 'block_curr_admin'), $formatbc); foreach ($this->headers as $header) { $myxls->write($rownum, $colnum++, $header, $formatbc); } foreach ($this->rawdata as $curid => $curlist) { $first = $curlist->curriculumname; foreach ($curlist->data as $datum) { if (!is_object($datum)) { continue; } $rownum++; $colnum = 0; $myxls->write($rownum, $colnum++, $first, $format); foreach ($this->headers as $id => $header) { if (isset($datum->{$id})) { $myxls->write($rownum, $colnum++, $datum->{$id}, $format); } else { $myxls->write($rownum, $colnum++, '', $format); } } } } $workbook->close(); break; case 'pdf': require_once $CFG->libdir . '/fpdf/fpdf.php'; $filename .= '.pdf'; $this->newpdf = new FPDF('P', 'in', 'letter'); $marginx = 0.75; $marginy = 28.35 / $this->newpdf->k; $marginy = 0.75; $this->newpdf->setMargins($marginx, $marginy); $this->newpdf->SetFont('Arial', '', 9); $this->newpdf->AddPage(); $this->newpdf->SetFillColor(225, 225, 225); if (file_exists("{$CFG->dirroot}/curriculum/pix/transcript.jpg")) { $this->newpdf->Image("{$CFG->dirroot}/curriculum/pix/transcript.jpg", 0, 0, 8.5, 11.0, 'jpg'); } $this->newpdf->SetFont('Arial', 'I', 7); $this->newpdf->SetXY($marginx, 2.62); $full = 8.5 - 2.0 * $marginx; $half = $full / 2.0; $qrtr = $half / 2.0; $this->newpdf->Cell($full, 0.2, get_string('transmessage', 'block_curr_admin'), 0, 0, 'C', 0); $this->newpdf->Ln(0.15); $this->newpdf->Ln(0.15); $this->newpdf->SetFont('Arial', '', 8); /// Set the left, middle and right columns. $leftcol = array(); $middcol = array(); $rghtcol = array(); $leftcol[] = cm_fullname($this->user); 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; } $middcol[] = get_string('sex', 'block_curr_admin'); $rghtcol[] = $gender; $bday = cm_timestring_to_date($this->user->birthdate); $leftcol[] = $this->user->address; $middcol[] = get_string('born', 'block_curr_admin'); $rghtcol[] = $bday; 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'); } } if (!empty($this->user->address2)) { $leftcol[] = $this->user->address2; } $middcol[] = get_string('registrationdate', 'block_curr_admin'); $rghtcol[] = $enroldate; $text = !empty($this->user->city) ? s($this->user->city) : ''; $text .= !empty($this->user->state) ? (!empty($text) ? ', ' : '') . $this->user->state : ''; $text .= !empty($this->user->postalcode) ? (!empty($text) ? ' ' : '') . s($this->user->postalcode) : ''; $text .= !empty($this->user->country) ? (!empty($text) ? ' ' : '') . cm_get_country($this->user->country) : ''; $leftcol[] = $text; $middcol[] = get_string('nuident', 'block_curr_admin'); $rghtcol[] = $this->user->idnumber; $entrycredstr = get_string('entrycred', 'block_curr_admin') . ': ' . $this->user->entrycred; if ($this->newpdf->GetStringWidth($entrycredstr) > $half) { if ($lines = $this->split_lines($entrycredstr, $half)) { foreach ($lines as $line) { $leftcol[] = $line; } } } else { $leftcol[] = $entrycredstr; } $middcol[] = get_string('degree', 'block_curr_admin') . ':'; $rghtcol[] = $this->user->degree; $leftcol[] = get_string('awards', 'block_curr_admin') . ': ' . $this->user->awards; foreach ($leftcol as $idx => $lefttxt) { if (isset($middcol[$idx])) { $this->newpdf->Cell($half, 0.2, $lefttxt, 0, 0, 'L', 0); $this->newpdf->Cell($qrtr, 0.2, $middcol[$idx], 0, 0, 'L', 0); $this->newpdf->Cell($qrtr, 0.2, $rghtcol[$idx], 0, 0, 'L', 0); } else { $this->newpdf->Cell($full, 0.2, $lefttxt, 0, 0, 'L', 0); } $this->newpdf->Ln(0.15); } $twidth = 0; $heights = array(); $widths = array(); $hmap = array(); $rownum = 0; $this->newpdf->SetFont('Arial', '', 7); /// PASS 1 - Calculate sizes. foreach ($this->headers as $id => $header) { $widths[$id] = $this->newpdf->GetStringWidth($header) + 0.2; $twidth += $widths[$id]; } $row = 0; foreach ($this->rawdata as $curid => $curlist) { foreach ($curlist->data as $datum) { if (!isset($heights[$row])) { $heights[$row] = 0; } foreach ($this->headers as $id => $header) { if (isset($datum->{$id})) { $width = $this->newpdf->GetStringWidth($datum->{$id}) + 0.2; if ($width > $widths[$id]) { $lines = ceil($width / $widths[$id]); $lines = 1; $widths[$id] = $width; } else { $lines = 1; } $height = $lines * 0.2; if ($height > $heights[$row]) { $heights[$row] = $height; } } } $row++; } } /// Calculate the width of the table... $twidth = 0; foreach ($widths as $width) { $twidth += $width; } $curx = 0.2; $cury = $this->newpdf->GetY() + 0.1; $endx = 8.300000000000001; $endy = $cury; $this->newpdf->Line($marginx, $cury, 8.5 - $marginx, $endy); $this->newpdf->Ln(0.2); /// Readjust the left margin according to the total width... $marginx = (8.5 - $twidth) / 2.0; $this->newpdf->setMargins($marginx, $marginy); // $this->newpdf->SetX($marginx); $this->newpdf->Cell(8.300000000000001, 0.2, get_string('transmessage1', 'block_curr_admin'), 0, 0, 'L', 0); $this->newpdf->Ln(0.15); $this->newpdf->Cell(8.300000000000001, 0.2, get_string('transmessage2', 'block_curr_admin'), 0, 0, 'L', 0); $this->newpdf->Ln(0.15); $this->newpdf->Ln(0.15); $leftsummary = array(); $rightsummary = array(); foreach ($this->rawdata as $curid => $curlist) { foreach ($this->headers as $id => $header) { $text = str_replace(' ', "\n", $header); $this->newpdf->Cell($widths[$id], 0.2, "{$text}", 1, 0, 'C', 1); } $this->newpdf->Ln(); $row = 0; foreach ($curlist->data as $datum) { if (is_array($datum) && strtolower($datum[0]) == 'hr') { $curx = $this->newpdf->GetX(); $cury = $this->newpdf->GetY() + 0.1; $endx = 0; $endy = $cury; foreach ($widths as $width) { $endx += $width; } $this->newpdf->Line($curx, $cury, $endx, $endy); $this->newpdf->SetX($curx + 0.1); } else { foreach ($this->headers as $id => $header) { $text = ''; if (isset($datum->{$id})) { $text = $datum->{$id}; } $this->newpdf->Cell($widths[$id], $heights[$row], $text, 0, 0, 'L', 0); } } $this->newpdf->Ln(); $row++; } $curx = $marginx; $cury = $this->newpdf->GetY() + 0.1; $endx = 8.5 - $marginx; $endy = $cury; $this->newpdf->Line($curx, $cury, $endx, $endy); $this->newpdf->Ln(0.2); $this->newpdf->Write(0.2, "\n"); if ($curlist->numcredits > 0) { $gpa = sprintf('%1.2f', (double) $curlist->gpa / (double) $curlist->numcredits); } else { $gpa = '0.0'; } $leftsummary[] = get_string('total_credits', 'block_curr_admin', $curlist->curriculumname) . ": {$curlist->numcredits}"; $rightsummary[] = "{$curlist->curriculumname} Grade Point Average: {$gpa}"; } foreach ($leftsummary as $idx => $lsummary) { $this->newpdf->Cell(4.25, 0.2, $lsummary, 0, 0, 'L', 0); $this->newpdf->Cell(4.25, 0.2, $rightsummary[$idx], 0, 0, 'L', 0); $this->newpdf->Ln(0.15); } $this->newpdf->Ln(0.15); $this->newpdf->Cell(4.25, 0.2, get_string('transfercredits', 'block_curr_admin') . ": {$this->user->transfercredits}", 0, 0, 'L', 0); $this->newpdf->Ln(0.75); /// Signature line: $curx = $this->newpdf->GetX(); $cury = $this->newpdf->GetY() + 0.1; $endx = 0; $endy = $cury; foreach ($widths as $width) { $endx += $width; } $this->newpdf->Line($marginx, $cury, 8.5 - $marginx, $endy); $this->newpdf->Ln(0.15); $half = (8.5 - 2 * $marginx) / 2.0; $this->newpdf->Cell($half, 0.2, get_string('registrar', 'block_curr_admin'), 0, 0, 'L', 0); $this->newpdf->Cell($half, 0.2, get_string('date', 'block_curr_admin'), 0, 0, 'L', 0); $this->newpdf->Output($filename, 'I'); break; default: return $output; break; } }
/** * Return the HTML to for a view page that also allows editing. * * @return string The form HTML, without the form. */ function view_form_html($classid, $type = '', $sort = 'name', $dir = 'ASC', $page = 0, $perpage = 0, $namesearch = '', $alpha = '') { global $CURMAN, $CFG; $output = ''; ob_start(); $table = new stdClass(); $can_unenrol = cmclasspage::can_enrol_into_class($classid); if (empty($this->id)) { $columns = array('unenrol' => get_string('unenrol', 'block_curr_admin'), 'idnumber' => get_string('student_idnumber', 'block_curr_admin'), 'name' => get_string('student_name_1', 'block_curr_admin'), 'enrolmenttime' => get_string('enrolment_time', 'block_curr_admin'), 'completetime' => get_string('completion_time', 'block_curr_admin'), 'completestatusid' => get_string('student_status', 'block_curr_admin'), 'grade' => get_string('student_grade', 'block_curr_admin'), 'credits' => get_string('student_credits', 'block_curr_admin'), 'locked' => get_string('student_locked', 'block_curr_admin')); if (!$can_unenrol) { unset($columns['unenrol']); } } else { $columns = array('idnumber' => get_string('student_idnumber', 'block_curr_admin'), 'name' => get_string('student_name_1', 'block_curr_admin'), 'enrolmenttime' => get_string('enrolment_time', 'block_curr_admin'), 'completetime' => get_string('completion_time', 'block_curr_admin'), 'completestatusid' => get_string('student_status', 'block_curr_admin'), 'grade' => get_string('student_grade', 'block_curr_admin'), 'credits' => get_string('student_credits', 'block_curr_admin'), 'locked' => get_string('student_locked', '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=\"\" />"; } if ($column != 'unenrol') { ${$column} = "<a href=\"index.php?s=stu&section=curr&id={$classid}&class={$classid}&" . "action=bulkedit&sort={$column}&dir={$columndir}&stype={$type}&search=" . urlencode(stripslashes($namesearch)) . "&alpha={$alpha}\">" . $cdesc . "</a>{$columnicon}"; } else { ${$column} = $cdesc; } $table->head[] = ${$column}; $table->align[] = "left"; $table->wrap[] = true; } if (empty($this->id)) { $users = $this->get_users_enrolled($type, $sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $usercount = $this->count_users_enrolled($type, $namesearch, $alpha); $alphabet = explode(',', get_string('alphabet')); $strall = get_string('all'); /// Bar of first initials echo "<p style=\"text-align:center\">"; echo "Last Name : "; if ($alpha) { echo " <a href=\"index.php?s=stu&section=curr&action=bulkedit&id={$classid}&class={$classid}&" . "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=stu&section=curr&action=bulkedit&id={$classid}&class={$classid}&" . "action=bulkedit&sort=name&dir=ASC&perpage={$perpage}&alpha={$letter}\">{$letter}</a> "; } } echo "</p>"; print_paging_bar($usercount, $page, $perpage, "index.php?s=stu&section=curr&id={$classid}&class={$classid}&&action=bulkedit&" . "sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&stype={$type}" . "&search=" . urlencode(stripslashes($namesearch)) . "&"); flush(); } else { $user = $this->user; $user->name = cm_fullname($user); $users[] = $user; $usercount = 0; } if (empty($this->id) && !$users) { $match = array(); if ($namesearch !== '') { $match[] = s($namesearch); } if ($alpha) { $match[] = "name: {$alpha}___"; } $matchstring = implode(", ", $match); echo 'No users matching ' . $matchstring; $table = NULL; } else { $stuobj = new student(); $table->width = "100%"; foreach ($users as $user) { $newarr = array(); foreach ($columns as $column => $cdesc) { switch ($column) { case 'unenrol': $newarr[] = '<input type="checkbox" name="users[' . $user->id . '][unenrol]" value="1" />'; break; case 'name': case 'idnumber': case 'description': $newarr[] = $user->{$column}; break; case 'enrolmenttime': $newarr[] = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $user->enrolmenttime, true); break; case 'completetime': $newarr[] = cm_print_date_selector('users[' . $user->id . '][endday]', 'users[' . $user->id . '][endmonth]', 'users[' . $user->id . '][endyear]', $user->completetime, true); break; case 'completestatusid': $choices = array(); foreach (student::$completestatusid_values as $key => $csidv) { $choices[$key] = get_string($csidv, 'block_curr_admin'); } $newarr[] = cm_choose_from_menu($choices, 'users[' . $user->id . '][completestatusid]', $user->completestatusid, '', '', '', true); break; case 'grade': $newarr[] = '<input type="text" name="users[' . $user->id . '][grade]" ' . 'value="' . $user->grade . '" size="5" />'; break; case 'credits': $newarr[] = '<input type="text" name="users[' . $user->id . '][credits]" ' . 'value="' . $user->credits . '" size="5" />'; break; case 'locked': $newarr[] = '<input type="checkbox" name="users[' . $user->id . '][locked]" ' . 'value="1" ' . ($user->locked ? 'checked="checked"' : '') . '/>' . '<input type="hidden" name="users[' . $user->id . '][idnumber]" ' . 'value="' . $user->idnumber . '" />' . '<input type="hidden" name="users[' . $user->id . '][association_id]" ' . 'value="' . $user->association_id . '" />'; break; default: $newarr[] = ''; break; } } $table->data[] = $newarr; } } if (empty($this->id)) { echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>"; echo "<form action=\"index.php\" method=\"get\"><fieldset>"; echo '<input type="hidden" name="s" value="stu" />'; echo '<input type="hidden" name="section" value="curr" />'; echo '<input type="hidden" name="action" value="bulkedit" />'; echo '<input type="hidden" name="id" value="' . $classid . '" />'; echo '<input type="hidden" name="sort" value="' . $sort . '" />'; echo '<input type="hidden" name="dir" value="' . $dir . '" />'; /*echo '<input type="radio" name="stype" value="student" ' . (($type == 'student') ? ' checked' : '') . '/> Students ' . '<input type="radio" name="stype" value="instructor" ' . (($type == 'instructor') ? ' checked' : '') . '/> Instructors ' . '<input type="radio" name="stype" vale="" ' . (($type == '') ? ' checked' : '') . '/> All ';*/ echo "<input type=\"text\" name=\"search\" value=\"" . s($namesearch, true) . "\" size=\"20\" />"; echo "<input type=\"submit\" value=\"" . get_string('search', 'block_curr_admin') . "\" />"; if ($namesearch) { echo "<input type=\"button\" onclick=\"document.location='index.php?s=stu&section=curr&" . "action=bulkedit&id={$classid}';\" value=\"" . get_string('show_all_users', 'block_curr_admin') . "\" />"; } echo "</fieldset></form>"; echo "</td></tr></table>"; echo '<form method="post" action="index.php?s=stu&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="updatemultiple" />' . "\n"; } else { echo '<form method="post" action="index.php?s=stu&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="updatemultiple" />' . "\n"; echo '<input type="hidden" name="association_id" value="' . $this->id . '" />' . "\n"; echo '<input type="hidden" name="id" value="' . $this->classid . '" />' . "\n"; echo '<input type="hidden" name="userid" value="' . $this->userid . '" />' . "\n"; } if (!empty($table)) { if (empty($this->id)) { require_js($CFG->wwwroot . '/curriculum/js/classform.js'); echo '<span class="checkbox selectall">'; echo '<input type="checkbox" onclick="class_bulkedit_set_all_selected()" id="class_bulkedit_select_all" name="class_bulkedit_select_all"/>'; echo '<label for="class_bulkedit_select_all">' . get_string('bulkedit_select_all', 'block_curr_admin') . '</label>'; echo '</span>'; } print_table($table); } if (isset($this->cmclass->course) && is_object($this->cmclass->course) && get_class($this->cmclass->course) == 'course' && ($elements = $this->cmclass->course->get_completion_elements())) { $select = "classid = {$this->classid} AND userid = {$this->userid}"; $grades = $CURMAN->db->get_records_select(CLSGRTABLE, $select, 'id', 'completionid,id,classid,userid,grade,locked,timegraded,timemodified'); $table = new stdClass(); $columns = array('element' => 'Grade Element', 'grade' => 'Grade', 'locked' => 'Locked', 'timegraded' => 'Date Graded'); 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=\"\" />"; } if ($column == 'name' || $column == 'description') { ${$column} = "<a href=\"index.php?s=stu&section=curr&id={$classid}&class={$classid}&" . "action=default&sort={$column}&dir={$columndir}&stype={$type}&search=" . urlencode(stripslashes($namesearch)) . "&alpha={$alpha}\">" . $cdesc . "</a>{$columnicon}"; } else { ${$column} = $cdesc; } $table->head[] = ${$column}; $table->align[] = "left"; $table->wrap[] = true; } $table->width = "100%"; foreach ($elements as $element) { $newarr = array(); foreach ($columns as $column => $cdesc) { switch ($column) { case 'element': if (isset($grades[$element->id])) { $name = 'element[' . $grades[$element->id]->id . ']'; $value = $element->id; } else { $name = 'newelement[' . $element->id . ']'; $value = $element->id; } $newarr[] = '<input type="hidden" name="' . $name . '" ' . 'value="' . $value . '" />' . s($element->idnumber); break; case 'timegraded': if (isset($grades[$element->id])) { $name = 'timegraded[' . $grades[$element->id]->id . ']'; $value = $grades[$element->id]->timegraded; } else { $name = 'newtimegraded[' . $element->id . ']'; $value = 0; } $newarr[] = cm_print_date_selector($name . '[startday]', $name . '[startmonth]', $name . '[startyear]', $value, true); break; case 'grade': if (isset($grades[$element->id])) { $name = 'grade[' . $grades[$element->id]->id . ']'; $value = $grades[$element->id]->grade; } else { $name = 'newgrade[' . $element->id . ']'; $value = 0; } $newarr[] = '<input type="text" name="' . $name . '" ' . 'value="' . $value . '" size="5" />'; break; case 'locked': if (isset($grades[$element->id])) { $name = 'locked[' . $grades[$element->id]->id . ']'; $value = $grades[$element->id]->locked; } else { $name = 'newlocked[' . $element->id . ']'; $value = 0; } $newarr[] = '<input type="checkbox" name="' . $name . '" ' . 'value="1" ' . ($value ? 'checked="checked"' : '') . '/>'; break; default: $newarr[] = ''; break; } } $table->data[] = $newarr; } if (!empty($table)) { echo '<br />'; print_table($table); } } if (!empty($users)) { echo '<br /><input type="submit" value="' . get_string('save_enrolment_changes', 'block_curr_admin') . '">' . "\n"; } echo "<input type=\"button\" onclick=\"document.location='index.php?s=stu&section=curr&" . "action=default&id={$classid}&sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&search=" . urlencode(stripslashes($namesearch)) . "';\" value=\"Cancel\" />"; echo '</form>' . "\n"; $output = ob_get_contents(); ob_end_clean(); return $output; }
//<![CDATA[ window.opener.location = "<?php echo htmlspecialchars_decode($target->get_url()); ?> "; //]]> </script> <?php } else { $a = new object(); $a->site = $site->shortname; $a->name = $cluster->name; print_header(get_string('assign_user_cluster', 'block_curr_admin', $a)); $user = new user($userid); $a = new object(); $a->fullname = cm_fullname($user); $a->name = $cluster->name; $bc = '<span class="breadcrumb">' . get_string('cluster_manual_options', 'block_curr_admin', $a) . '</span>'; echo cm_print_heading_block($bc, '', true); $murl = new moodle_url(make_link()); $data = $murl->params; $data['userid'] = $userid; $data['autoenrol'] = true; $assignform->set_data($data); $assignform->display(); print_footer(get_string('empty', 'block_curr_admin')); exit; } } // find all users not assigned to the cluster $FULLNAME = sql_concat('usr.firstname', "' '", 'usr.lastname');
/** * Returns the delete instructor form. * * @param string $action Delete or confirm. * @param int $id The id of the instructor. * @return string HTML for the form. * */ function get_delete_form($insid) { $ins = new instructor($insid); $url = 'index.php'; $message = get_string('confirm_delete_instructor', 'block_curr_admin', cm_fullname($ins->user)); $optionsyes = array('s' => 'ins', 'section' => 'curr', 'id' => $ins->classid, 'action' => 'confirm', 'association_id' => $insid, 'confirm' => md5($insid)); $optionsno = array('s' => 'ins', 'section' => 'curr', 'id' => $ins->classid, 'search' => $ins->cmclass->idnumber); echo cm_delete_form($url, $message, $optionsyes, $optionsno); }
function get_item_display_name($column, $item) { return cm_fullname($item); }
/** * 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 get_item_display_instructor($column, $class) { if ($instructors = instructor::get_instructors($class->id)) { $ins = array(); foreach ($instructors as $instructor) { $ins[] = cm_fullname($instructor); } return implode('<br />', $ins); } else { return 'n/a'; } }
/** * Actually process the uploaded CSV organization file upon successful upload. * * NOTE: A lot o code here is borrowed / modified from Moodle. * * @see Moodle:/admin/uploaduser.php * * @uses $CURMAN * @param array $fieldata A PHP upload file array (i.e. from the $_FILES superglobal). * @param bool $update Flag for updating existing records. * @param bool $verbose Flag for verbose output. * @return string Output for display. */ function process_input_data($filedata, $update = false, $verbose = false) { global $CURMAN; $output = ''; /// Don't check for a valid mime/type as this is causing errors for the client. /* if (!in_array($filedata['type'], $this->valid_mimetypes)) { return 'The file format uploaded was incorrect'; } */ if ($filedata['size'] === 0) { return get_string('uploaded_empty_file', 'block_curr_admin'); } /** * Large files are likely to take their time and memory. Let PHP know * that we'll take longer, and that the process should be recycled soon * to free up memory. */ @set_time_limit(0); @cm_raise_memory_limit('192M'); if (function_exists('apache_child_terminate')) { @apache_child_terminate(); } $csv_encode = '/\\&\\#44/'; $csv_delimiter = "\\,"; $csv_delimiter2 = ","; $data = ''; $file = @fopen($filedata['tmp_name'], 'rb'); if ($file) { while (!feof($file)) { $data .= fread($file, 1024); } fclose($file); } if (empty($data)) { return get_string('no_data_file', 'block_curr_admin'); } /** * Removes the BOM from unicode string - see http://unicode.org/faq/utf_bom.html * * Borrowed from Moodle code - /lib/textlib.class.php */ $bom = ""; if (strpos($data, $bom) === 0) { $data = substr($data, strlen($bom)); } /** * Fix Mac/DOS newlines * * Borrowed from Moodle code - /admin/uploaduser.php */ $data = preg_replace('!\\r\\n?!', "\n", $data); $fp = fopen($filedata['tmp_name'], 'w'); fwrite($fp, $data); fclose($fp); $fp = fopen($filedata['tmp_name'], 'r'); /** * The required and optional fields we're looking for in the CSV file. */ $required = array('studentid' => 1, 'class' => 1, 'trainernum' => 1, 'startdate' => 1, 'enddate' => 1); $optional = array('firstname' => 1, 'lastname' => 1, 'curriculum' => 1, 'status' => 1, 'completed' => 1, 'grade' => 1, 'frequency' => 1, 'timeperiod' => 1); $colpos = array(); $header = split($csv_delimiter, fgets($fp, 1024)); // Check for valid field names foreach ($header as $i => $h) { $h = trim($h); $header[$i] = $h; // remove whitespace $h = ereg_replace('^\\"|\\"$', '', $h); // strip encapsulating quotes $header[$i] = $h; if (isset($required[$h])) { $required[$h] = 0; $colpos[$i] = $h; } else { if (isset($optional[$h])) { $colpos[$i] = $h; } } } /// Check for required fields foreach ($required as $key => $value) { if ($value) { //required field missing return get_string('missing_required_field', 'block_curr_admin', $key); } } $linenum = 2; // since header is line 1 $stusnew = 0; $stuserror = 0; $stusupdated = 0; $timenow = time(); while (!feof($fp)) { //Note: commas within a field should be encoded as , (for comma separated csv files) //Note: semicolon within a field should be encoded as ; (for semicolon separated csv files) $line = split($csv_delimiter, fgets($fp, 1024)); foreach ($line as $key => $value) { if (isset($colpos[$key])) { /// decode encoded commas and strip enapsulating quotes $record[$colpos[$key]] = preg_replace($csv_encode, $csv_delimiter2, trim($value)); $record[$colpos[$key]] = ereg_replace('^\\"|\\"$', '', $record[$colpos[$key]]); } } /// Got organization data if ($record[$header[0]]) { $done = false; $users = $CURMAN->db->get_records(USRTABLE, 'idnumber', $record['studentid']); $user = NULL; /// Don't worry about the actual type. Just worry about the idnumber. if (!empty($users)) { $user = current($users); } /// Only proceed if this student and instructor users actually exists. if (!empty($user->id)) { $crsidnumber = $record['class']; $dateparts = explode('/', $record['startdate']); $startdate = mktime(0, 0, 0, $dateparts[1], $dateparts[0], $dateparts[2]); $dateparts = explode('/', $record['enddate']); $enddate = mktime(0, 0, 0, $dateparts[1], $dateparts[0], $dateparts[2]); /// Check if the class as specified exists... $clsidnumber = $record['class']; if (!($class = $CURMAN->db->get_record(CLSTABLE, 'idnumber', $clsidnumber))) { $clsidnumber = $record['class'] . '-' . $record['trainernum']; /// Need to check for old classes that didn't have dates, and remove them. if ($class = $CURMAN->db->get_record(CLSTABLE, 'idnumber', $clsidnumber)) { $class = new cmclass($class); $class->delete(); } /// If the class doesn't exist, we have to create it first. $datepart = date('Ymd', $startdate); $clsidnumber = $record['class'] . '-' . $record['trainernum'] . '-' . $datepart; $class = $CURMAN->db->get_record(CLSTABLE, 'idnumber', $clsidnumber); } if (empty($class->id) || $update && !empty($class->id)) { if ($course = $CURMAN->db->get_record(CRSTABLE, 'idnumber', $crsidnumber)) { /// Do we need to add / update curriculum info for this course??? if (isset($record['curriculum'])) { if ($cur = $CURMAN->db->get_record(CURTABLE, 'idnumber', $record['curriculum'])) { $curcrs = $CURMAN->db->get_record(CURCRSTABLE, 'curriculumid', $cur->id, 'courseid', $course->id); if (!$update && empty($curcrs->id) || $update && !empty($curcrs->id)) { $cmcrec = array('curriculumid' => $cur->id, 'courseid' => $course->id); if (!empty($record['frequency'])) { $cmcrec['frequency'] = $record['frequency']; } if (!empty($record['timeperiod'])) { $cmcrec['timeperiod'] = $record['timeperiod']; } if (empty($curcrs->id)) { $curcrs = new curriculum($cmcrec); } else { $curcrs = new curriculum($curcrs->id); foreach ($cmcrec as $key => $val) { $curcrs->{$key} = $val; } } $a = new object(); $a->courseid = $course->idnumber; $a->coursename = $course->name; $a->curid = $cur->idnumber; if ($update && !empty($curcrs->id)) { if ($curcrs->data_update_record() && $verbose) { $output .= get_string('updated_curriculum_course_info', 'block_curr_admin'); } } else { if ($curcrs->data_insert_record() && $verbose) { $output .= get_string('added_curriculum_course_info', 'block_curr_admin'); } } } } } $clsrec = array('courseid' => $course->id, 'idnumber' => $clsidnumber, 'startdate' => $startdate, 'enddate' => $enddate); if (empty($class->id)) { $class = new cmclass($clsrec); } else { $class = new cmclass($class->id); foreach ($clsrec as $key => $val) { $class->{$key} = $val; } } if ($update && !empty($class->id)) { if ($class->data_update_record() && $verbose) { $output .= get_string('updated_class_info', 'block_curr_admin') . $class->idnumber . '<br /><br />' . "\n"; } } else { if ($class->data_insert_record() && $verbose) { $output .= get_string('added_class_info', 'block_curr_admin') . $class->idnumber . '<br /><br />' . "\n"; } } if (empty($class->id) && $verbose) { $output .= get_string('error_class_not_created', 'block_curr_admin') . $class->idnumber . '<br /><br />' . "\n"; } } else { if ($verbose) { $output .= get_string('error_course_not_found', 'block_curr_admin') . $crsidnumber . '<br /><br />' . "\n"; } } } /// Only proceed if we have an actual class here... if (!empty($class->id)) { $instructors = $CURMAN->db->get_records(USRTABLE, 'idnumber', $record['trainernum']); $instructor = NULL; /// Don't worry about the actual type. Just worry about the idnumber. if (!empty($instructors)) { $instructor = current($instructors); } if (!empty($instructor->id) && !$CURMAN->db->record_exists(INSTABLE, 'classid', $class->id, 'userid', $instructor->id)) { $insrec = array('classid' => $class->id, 'userid' => $instructor->id); $newins = new instructor($insrec); if ($newins->data_insert_record() && $verbose) { $output .= get_string('added_instructor_class', 'block_curr_admin', cm_fullname($instructor)) . $class->idnumber . '<br /><br />' . "\n"; } } $student = $CURMAN->db->get_record(STUTABLE, 'classid', $class->id, 'userid', $user->id); $a = new object(); $a->name = cm_fullname($user); $a->id = $class->idnumber; if (!$update && empty($student->id) || $update && !empty($student->id)) { $sturec = array('classid' => $class->id, 'userid' => $user->id); if (isset($record['status'])) { $sturec['completestatusid'] = intval($record['status']); } if (!isset($record['completed'])) { $sturec['completetime'] = $enddate; } else { $d = explode('/', $record['completed']); if (count($d) == 3) { $day = $d[0]; $month = $d[1]; $year = $d[2]; $timestamp = mktime(0, 0, 0, $month, $day, $year); $sturec['completetime'] = $timestamp; } } if (isset($record['grade'])) { $sturec['grade'] = intval($record['grade']); } if (empty($student->id)) { $student = new student($sturec); } else { $student = new student($student->id); foreach ($sturec as $key => $val) { $student->{$key} = $val; } } if ($update && !empty($student->id)) { if ($student->data_update_record() && $verbose) { $output .= get_string('update_enrolment_info', 'block_curr_admin', $a) . '<br /><br />' . "\n"; } } else { if ($student->data_insert_record() && $verbose) { $output .= get_string('add_enrolment_info', 'block_curr_admin', $a) . '<br /><br />' . "\n"; } } } else { $student = NULL; if ($verbose) { $output .= get_string('existing_enrolment_info', 'block_curr_admin') . '<br /><br />' . "\n"; } } if (!empty($student->id)) { $done = true; } } } else { $output .= get_string('error_studentid_not_found', 'block_curr_admin') . $record['studentid'] . '<br /><br />' . "\n"; } if ($update && $done) { $stusupdated++; } else { if (!$update && $done) { $stusnew++; } else { $stuserror++; } } } } if (!empty($output)) { $output .= '<br /><br />'; } if (!$stusnew && !$stusupdated && !$stuserror) { $output .= get_string('nothing_done', 'block_curr_admin'); } if ($stusnew > 0) { $output .= get_string('added_new_students', 'block_curr_admin', $stusnew); } if ($stusupdated > 0) { $output .= get_string('updated_existing_students', 'block_curr_admin', $stusupdated); } if ($stuserror > 0) { $output .= get_string('error_not_processed', 'block_curr_admin', $stuserror); } return $output; }
/** * 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); } }