Beispiel #1
0
/**
 *Prints form items with the names $hour and $minute
 *
 * @param string $hour  fieldname
 * @param string ? $minute  fieldname
 * @param $currenttime A default timestamp in GMT
 * @param int $step minute spacing
 * @param boolean $return
 */
function cm_print_time_selector($hour, $minute, $currenttime = 0, $step = 5, $return = false)
{
    if (!$currenttime) {
        $currenttime = time();
    }
    $currentdate = usergetdate($currenttime);
    // was cm_usergetdate
    if ($step != 1) {
        $currentdate['minutes'] = ceil($currentdate['minutes'] / $step) * $step;
    }
    for ($i = 0; $i <= 23; $i++) {
        $hours[$i] = sprintf("%02d", $i);
    }
    for ($i = 0; $i <= 59; $i += $step) {
        $minutes[$i] = sprintf("%02d", $i);
    }
    return cm_choose_from_menu($hours, $hour, $currentdate['hours'], '', '', '0', $return) . cm_choose_from_menu($minutes, $minute, $currentdate['minutes'], '', '', '0', $return);
}
Beispiel #2
0
 /**
  * Returns the HTML for the Bulk Apply Inputs Box
  * @return string the HTML for the Bulk Apply Inputs Box
  */
 public function get_bulk_edit_ui()
 {
     // generate choices for the completion status menu
     $statuschoices = array();
     foreach (student::$completestatusid_values as $key => $csidv) {
         $statuschoices[$key] = get_string($csidv, self::LANG_FILE);
     }
     $blktpl_table = new html_table();
     $blktpl_table->head = array('enable' => get_string('blktpl_enable', self::LANG_FILE), 'label' => get_string('blktpl_field', self::LANG_FILE), 'value' => get_string('blktpl_value', self::LANG_FILE));
     $blktpl_table->data = array(array('<input type="checkbox" id="blktpl_enrolmenttime_checked">', get_string('enrolment_time', self::LANG_FILE), cm_print_date_selector('blktpl_enrolmenttime_d', 'blktpl_enrolmenttime_m', 'blktpl_enrolmenttime_y', 0, true)), array('<input type="checkbox" id="blktpl_completetime_checked">', get_string('completion_time', self::LANG_FILE), cm_print_date_selector('blktpl_completetime_d', 'blktpl_completetime_m', 'blktpl_completetime_y', 0, true)), array('<input type="checkbox" id="blktpl_status_checked">', get_string('student_status', self::LANG_FILE), cm_choose_from_menu($statuschoices, 'blktpl_status', '', '', '', '', true)), array('<input type="checkbox" id="blktpl_grade_checked">', get_string('student_grade', self::LANG_FILE), '<input type="text" id="blktpl_grade" name="blktpl_grade" size="5"/>'), array('<input type="checkbox" id="blktpl_credits_checked">', get_string('student_credits', self::LANG_FILE), '<input type="text" id="blktpl_credits" name="blktpl_credits" size="5"/>'), array('<input type="checkbox" id="blktpl_locked_checked">', get_string('student_locked', self::LANG_FILE), '<input type="checkbox" id="blktpl_locked" name="blktpl_locked"/>'), array('', '', '<input type="button" onclick="do_bulk_value_apply();return false;" value="' . get_string('blktpl_applytousers_button', self::LANG_FILE) . '"/>'));
     return html_writer::table($blktpl_table);
 }
Beispiel #3
0
 /**
  * Print the download menu.
  *
  * @param none
  * @return string HTML output for display.
  */
 function print_download_menu()
 {
     $output = '';
     if (!empty($this->fileformats)) {
         $output .= '<form action="reportdownload.php" method="post">' . "\n";
         /// Print out the necessary hidden form vars.
         $parts = explode('?', $this->baseurl);
         if (count($parts) == 2 && strlen($parts[1])) {
             $args = explode('&', str_replace('&amp;', '&', $parts[1]));
             if (count($args) === 0) {
                 $args = explode('&amp;', $parts[1]);
             }
             if (!empty($args)) {
                 foreach ($args as $arg) {
                     $vals = explode('=', $arg);
                     if (!empty($vals[1])) {
                         $output .= '<input type="hidden" name="' . $vals[0] . '" value="' . urldecode($vals[1]) . '" />';
                     }
                 }
             }
         }
         $output .= cm_choose_from_menu($this->fileformats, 'download', '', 'choose', '', '0', true);
         $output .= '<input type="submit" value="' . get_string('download_report', 'block_curr_admin') . '" />' . "\n";
         $output .= '</form>' . "\n";
     }
     return $output;
 }
 /**
  * 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&amp;section=curr&amp;id={$classid}&amp;class={$classid}&amp;" . "action=bulkedit&amp;sort={$column}&amp;dir={$columndir}&amp;stype={$type}&amp;search=" . urlencode(stripslashes($namesearch)) . "&amp;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&amp;section=curr&amp;action=bulkedit&amp;id={$classid}&amp;class={$classid}&amp;" . "sort=name&amp;dir=ASC&amp;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&amp;section=curr&amp;action=bulkedit&amp;id={$classid}&amp;class={$classid}&amp;" . "action=bulkedit&amp;sort=name&amp;dir=ASC&amp;perpage={$perpage}&amp;alpha={$letter}\">{$letter}</a> ";
             }
         }
         echo "</p>";
         print_paging_bar($usercount, $page, $perpage, "index.php?s=stu&amp;section=curr&amp;id={$classid}&amp;class={$classid}&amp;&amp;action=bulkedit&amp;" . "sort={$sort}&amp;dir={$dir}&amp;perpage={$perpage}&amp;alpha={$alpha}&amp;stype={$type}" . "&amp;search=" . urlencode(stripslashes($namesearch)) . "&amp;");
         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&amp;section=curr&amp;" . "action=bulkedit&amp;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&amp;section=curr&amp;id=' . $classid . '" >' . "\n";
         echo '<input type="hidden" name="action" value="updatemultiple" />' . "\n";
     } else {
         echo '<form method="post" action="index.php?s=stu&amp;section=curr&amp;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&amp;section=curr&amp;id={$classid}&amp;class={$classid}&amp;" . "action=default&amp;sort={$column}&amp;dir={$columndir}&amp;stype={$type}&amp;search=" . urlencode(stripslashes($namesearch)) . "&amp;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&amp;section=curr&amp;" . "action=default&amp;id={$classid}&amp;sort={$sort}&amp;dir={$dir}&amp;perpage={$perpage}&amp;alpha={$alpha}&amp;search=" . urlencode(stripslashes($namesearch)) . "';\" value=\"Cancel\" />";
     echo '</form>' . "\n";
     $output = ob_get_contents();
     ob_end_clean();
     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->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&amp;section=rept">Reports</a> ' . '&raquo; ' . $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 .= '&amp;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);
     }
 }