Example #1
0
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_login(SITEID, false);
global $CFG, $PAGE, $OUTPUT, $DB;
require_once $CFG->dirroot . '/local/elisprogram/lib/lib.php';
require_once $CFG->dirroot . '/local/elisprogram/lib/selectionpopup.class.php';
require_once $CFG->dirroot . '/lib/weblib.php';
require_once $CFG->dirroot . '/lib/dml/moodle_database.php';
define('MAX_NUM_ROWS', 50);
$letterselect = optional_param('alpha', '', PARAM_TEXT);
$search = optional_param('search', '', PARAM_TEXT);
$element_update = required_param('id', PARAM_TEXT);
$callback = required_param('callback', PARAM_TEXT);
$baseurl = new moodle_url('/local/elisprogram/classselector.php', array('alpha' => $letterselect, 'search' => $search, 'id' => $element_update, 'callback' => $callback));
$PAGE->set_url($baseurl);
pmalphabox($baseurl);
pmsearchbox('/local/elisprogram/classselector.php');
echo html_writer::start_tag('center');
$alpha = explode(',', get_string('alphabet', 'langconfig'));
$table = new classselectiontable('classselection', $element_update, $callback);
$columns = 'cls.id,cd.syllabus,cls.idnumber';
$where = '';
$alphawhere = '';
$searchwhere = '';
$params = array();
if (!empty($letterselect)) {
    $alphawhere = $DB->sql_like('cd.syllabus', ':alphasyllabus', false) . ' OR ' . $DB->sql_like('cls.idnumber', ':alphaidnumber', false);
    $params['alphasyllabus'] = $letterselect . '%';
    $params['alphaidnumber'] = $letterselect . '%';
}
if (!empty($search)) {
    $searchwhere = $DB->sql_like('cls.idnumber', ':searchclsidnumber', false, false) . ' OR ' . $DB->sql_like('cd.syllabus', ':searchsyllabus', false, false);
Example #2
0
 /**
  * Return the HTML to edit a specific student.
  * 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.
  * @uses $CFG
  * @uses $OUTPUT
  * @return string The form HTML, without the form.
  */
 function edit_form_html($classid, $type = '', $sort = 'name', $dir = 'ASC', $page = 0, $perpage = 0, $namesearch = '', $alpha = '')
 {
     global $CFG, $OUTPUT;
     $output = '';
     ob_start();
     $columns = array('grade' => array('header' => get_string('grade', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'locked' => array('header' => get_string('student_locked', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'timegraded' => array('header' => get_string('date_graded', self::LANG_FILE), 'display_function' => 'htmltab_display_function'));
     if ($dir !== 'DESC') {
         $dir = 'ASC';
     }
     if (isset($columns[$sort])) {
         $columns[$sort]['sortable'] = $dir;
     } else {
         $sort = 'grade';
         // TBD
         $columns[$sort]['sortable'] = $dir;
     }
     //$table->width = "100%"; // TBD
     $newarr = array();
     $tabobj = new stdClass();
     foreach ($columns as $column => $cdesc) {
         switch ($column) {
             case 'timegraded':
                 $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $this->timegraded, true);
                 break;
             case 'grade':
                 $tabobj->{$column} = '<input type="text" name="users[' . $user->id . '][grade]" ' . 'value="' . $this->grade . '" size="5" />';
                 break;
             case 'locked':
                 $tabobj->{$column} = '<input type="checkbox" name="users[' . $user->id . '][locked]" ' . 'value="1" ' . ($this->locked ? 'checked="checked"' : '') . '/>';
                 break;
             default:
                 $tabobj->{$column} = '';
                 break;
         }
         //$table->data[] = $newarr;
     }
     $newarr[] = $tabobj;
     // TBD: student_table() ???
     $table = new display_table($newarr, $columns, $this->get_base_url());
     if (empty($this->id)) {
         // TBD: move up and add pmalphabox() and pmshowmatches() ???
         pmsearchbox(null, 'search', 'get', get_string('show_all_users', self::LANG_FILE), '<input type="radio" name="stype" value="student" ' . ($type == 'student' ? ' checked' : '') . '/> ' . get_string('students', self::LANG_FILE) . ' <input type="radio" name="stype" value="instructor" ' . ($type == 'instructor' ? ' checked' : '') . '/> ' . get_string('instructors', self::LANG_FILE) . ' <input type="radio" name="stype" vale="" ' . ($type == '' ? ' checked' : '') . '/> ' . get_string('all') . ' ');
         echo '<form method="post" action="index.php?s=stu&amp;section=curr&amp;class=' . $classid . '" >' . "\n";
         echo '<input type="hidden" name="action" value="savenew" />' . "\n";
     } else {
         echo '<form method="post" action="index.php?s=stu&amp;section=curr&amp;class=' . $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($newarr)) {
         // TBD: $newarr or $table?
         echo $table->get_html();
     }
     if (empty($this->id)) {
         echo '<br /><input type="submit" value="' . get_string('add_grade', self::LANG_FILE) . '">' . "\n";
     } else {
         echo '<br /><input type="submit" value="' . get_string('update_grade', self::LANG_FILE) . '">' . "\n";
     }
     echo '</form>' . "\n";
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
Example #3
0
 /**
  * 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 int $classid The class ID.
  * @param string $sort Field to sort on.
  * @param string $dir Direction of sort.
  * @param int $page The page to start at.
  * @param int $perpage Number of records per page.
  * @param string $namesearch Search string for item name.
  * @param string $alpha Start initial of item name filter.
  * @return string The form HTML, without the form.
  */
 public function edit_form_html($classid, $sort = 'name', $dir = 'ASC', $page = 0, $perpage = 30, $namesearch = '', $alpha = '')
 {
     global $CFG, $OUTPUT, $SESSION, $PAGE;
     $action = optional_param('action', '', PARAM_ALPHA);
     $this->classid = $classid;
     $output = '';
     ob_start();
     if (empty($this->id)) {
         $columns = array('assign' => array('header' => get_string('assign', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'idnumber' => array('header' => get_string('class_idnumber', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'name' => array('header' => get_string('tag_name', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'assigntime' => array('header' => get_string('assigntime', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'completetime' => array('header' => get_string('completion_time', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false));
     } else {
         $columns = array('idnumber' => array('header' => get_string('class_idnumber', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'name' => array('header' => get_string('tag_name', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'assigntime' => array('header' => get_string('assigntime', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'completetime' => array('header' => get_string('completion_time', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false));
     }
     if ($dir !== 'DESC') {
         $dir = 'ASC';
     }
     if (isset($columns[$sort])) {
         $columns[$sort]['sortable'] = $dir;
     } else {
         $sort = 'name';
         $columns[$sort]['sortable'] = $dir;
     }
     $newarr = array();
     $users = array();
     if (empty($this->id)) {
         $users = $this->get_users_avail($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha);
         $usercount = $this->count_users_avail($namesearch, $alpha);
         pmalphabox(new moodle_url('/local/elisprogram/index.php', array('s' => 'ins', 'section' => 'curr', 'action' => 'add', 'id' => $classid, 'sort' => $sort, 'dir' => $dir, 'perpage' => $perpage)), 'alpha', get_string('tag_name', self::LANG_FILE) . ':');
         $pagingbar = new paging_bar($usercount, $page, $perpage, "index.php?s=ins&amp;section=curr&amp;id={$classid}&amp;action=add&amp;" . "sort={$sort}&amp;dir={$dir}&amp;perpage={$perpage}&amp;alpha={$alpha}&amp;" . "search=" . urlencode($namesearch));
         // TBD: .'&amp;'
         echo $OUTPUT->render($pagingbar);
         flush();
     } else {
         //error_log("instructor.class.php::edit_form_html(); userid = {$this->userid}");
         $user = new stdClass();
         $user->name = '?';
         if ($tmpuser = new user($this->userid)) {
             $tmpuser->load();
             $user = $tmpuser->to_object();
             $user->name = $tmpuser->moodle_fullname();
         }
         $users[] = $user;
         $usercount = 0;
         // TBD: 1 ???
     }
     $has_users = is_array($users) && !empty($users) || $users instanceof Iterator && $users->valid() === true ? true : false;
     if (empty($this->id) && $has_users === false) {
         $table = NULL;
     } else {
         $insobj = new instructor();
         //$table->width = "100%";
         foreach ($users as $user) {
             $tabobj = new stdClass();
             $assigntime = $this->assigntime;
             $completetime = $this->completetime;
             $selection = json_decode(retrieve_session_selection($user->id, 'add'));
             if ($selection) {
                 $assigntime = pm_timestamp(0, 0, 0, $selection->enrolment_date->month, $selection->enrolment_date->day, $selection->enrolment_date->year);
                 $completetime = pm_timestamp(0, 0, 0, $selection->completion_date->month, $selection->completion_date->day, $selection->completion_date->year);
             }
             /* **** debug code
                  ob_start();
                  var_dump($user);
                  $tmp = ob_get_contents();
                  ob_end_clean();
                  error_log("instructor.class.php::edit_form_html() user = $tmp");
                **** */
             foreach ($columns as $column => $cdesc) {
                 switch ($column) {
                     case 'assign':
                         $tabobj->{$column} = '<input type="checkbox" id="checkbox' . $user->id . '" onClick="select_item(' . $user->id . ')" name="users[' . $user->id . '][assign]" value="1" ' . ($selection ? 'checked="checked"' : '') . '/>' . '<input type="hidden" name="users[' . $user->id . '][idnumber]" ' . 'value="' . $user->idnumber . '" />';
                         break;
                     case 'name':
                     case 'idnumber':
                     case 'description':
                         $tabobj->{$column} = $user->{$column};
                         break;
                     case 'assigntime':
                         $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $assigntime, true);
                         break;
                     case 'completetime':
                         $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][endday]', 'users[' . $user->id . '][endmonth]', 'users[' . $user->id . '][endyear]', $completetime, true);
                         break;
                     default:
                         $tabobj->{$column} = '';
                         break;
                 }
             }
             $newarr[] = $tabobj;
             //$table->data[] = $newarr;
         }
         $table = new display_table($newarr, $columns, get_pm_url(), 'sort', 'dir', array('id' => 'selectiontbl'));
     }
     unset($users);
     print_checkbox_selection($classid, 'ins', 'add');
     if (empty($this->id)) {
         pmsearchbox(null, 'search', 'get', get_string('show_all_users', self::LANG_FILE));
         echo '<form method="post" action="index.php?s=ins&amp;section=curr&amp;id=' . $classid . '" >' . "\n";
         echo '<input type="hidden" name="action" value="savenew" />' . "\n";
     } else {
         echo '<form method="post" action="index.php?s=ins&amp;section=curr&amp;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) && !empty($newarr)) {
         if ($action == 'add') {
             $PAGE->requires->js('/local/elisprogram/js/classform.js');
             echo '<input type="button" onclick="checkbox_select(true,\'[assign]\')" value="' . get_string('selectall') . '" /> ';
             echo '<input type="button" onclick="checkbox_select(false,\'[assign]\')" value="' . get_string('deselectall') . '" /> ';
         }
         echo $table->get_html();
         $pagingbar = new paging_bar($usercount, $page, $perpage, "index.php?s=ins&amp;section=curr&amp;id={$classid}&amp;action=add&amp;" . "sort={$sort}&amp;dir={$dir}&amp;perpage={$perpage}&amp;alpha={$alpha}&amp;" . "search=" . urlencode($namesearch));
         // TBD: .'&amp;'
         echo $OUTPUT->render($pagingbar);
     }
     if (empty($this->id)) {
         if ($has_users === false) {
             pmshowmatches($alpha, $namesearch);
         }
         echo '<br /><input type="submit" value="' . get_string('assign_selected', self::LANG_FILE) . '">' . "\n";
     } else {
         echo '<br /><input type="submit" value="' . get_string('update_assignment', self::LANG_FILE) . '">' . "\n";
     }
     echo '</form>' . "\n";
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
Example #4
0
 /**
  * Prints the text substring search interface.
  */
 public function print_search()
 {
     pmsearchbox($this);
 }
Example #5
0
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_login(SITEID, false);
global $CFG, $PAGE, $OUTPUT, $DB;
require_once $CFG->dirroot . '/local/elisprogram/lib/lib.php';
require_once $CFG->dirroot . '/local/elisprogram/lib/selectionpopup.class.php';
require_once $CFG->dirroot . '/lib/weblib.php';
require_once $CFG->dirroot . '/lib/dml/moodle_database.php';
define('MAX_NUM_ROWS', 50);
$letterselect = optional_param('alpha', '', PARAM_TEXT);
$search = optional_param('search', '', PARAM_TEXT);
$element_update = required_param('id', PARAM_TEXT);
$callback = required_param('callback', PARAM_TEXT);
$baseurl = new moodle_url('/local/elisprogram/trackselector.php', array('alpha' => $letterselect, 'search' => $search, 'id' => $element_update, 'callback' => $callback));
$PAGE->set_url($baseurl);
pmalphabox($baseurl);
pmsearchbox('/local/elisprogram/trackselector.php');
echo html_writer::start_tag('center');
$alpha = explode(',', get_string('alphabet', 'langconfig'));
$table = new trackselectiontable('trackselection', $element_update, $callback);
$columns = 'id,name,description';
$where = '';
$alphawhere = '';
$searchwhere = '';
$params = array();
if (!empty($letterselect)) {
    $alphawhere = $DB->sql_like('name', ':alphaname', false, false);
    $params['alphaname'] = $letterselect . '%';
}
if (!empty($search)) {
    $searchwhere = $DB->sql_like('name', ':searchname', false, false) . ' OR ' . $DB->sql_like('description', ':searchdescription', false, false);
    $params['searchname'] = '%' . $search . '%';
Example #6
0
 function print_selection_filter($filter)
 {
     $id = $this->required_param('id', PARAM_INT);
     pmalphabox(new moodle_url($this->_get_page_url(), array('s' => $this->pagename, 'id' => $id)), 'alpha', get_string('tag_name', self::LANG_FILE) . ':');
     pmsearchbox($this, 'search', 'get', get_string('show_all_users', self::LANG_FILE));
 }