Exemplo n.º 1
0
 function definition()
 {
     global $USER;
     $form =& $this->_form;
     // Lookup necessary information for generating the listing of invitations
     $user = CoursePrefsUser::findByUnique($USER->username);
     $teamteaches = $user->getDecisionTeamTeaches();
     // Pending team teaching invitations header
     $form->addElement('header', 'accept_teamteach', get_string('header_teamteach_accept', 'block_courseprefs'));
     $form->setHelpButton('accept_teamteach', array('teamteach_accept', get_string('teamteach_accept_help', 'block_courseprefs'), 'block_courseprefs', true));
     // Generate a listing of team teaching invitations the user needs to accept or reject
     $display = array();
     foreach ($teamteaches as $teamteach) {
         $teamteach_user = $teamteach->getSectionsUser();
         $display[$teamteach->getId()] = CoursePrefsSection::generateFullnameById($teamteach->getSectionsId()) . ' with ' . $teamteach_user->getLastname() . ' ' . $teamteach_user->getFirstname();
     }
     // Sort listing of invitations by semesters
     uasort($display, "cmpSemester");
     // Skip the remaining form definition if no invitations were found and display a message to the user
     if (!$display) {
         $form->addElement('static', null, null, get_string('no_accepts', 'block_courseprefs'));
         return;
     }
     // List the invitations for the user to accept or reject
     foreach ($display as $key => $teamteach) {
         $form->addElement('checkbox', PENDING_CHECKBOX . $key, null, $teamteach);
     }
     // Add submit and cancellation buttons
     $row = array();
     $row[] =& $form->createElement('submit', PENDING_ACCEPT_BUTTON, get_string('accept', 'block_courseprefs'));
     $row[] =& $form->createElement('submit', PENDING_REJECT_BUTTON, get_string('reject', 'block_courseprefs'));
     $form->addGroup($row, 'buttonarr', null, '', false);
 }
Exemplo n.º 2
0
 function definition()
 {
     global $USER;
     $form =& $this->_form;
     $user = CoursePrefsUser::findByUnique($USER->username);
     // Remove team teaching invitations header
     $form->addElement('header', 'remove_teamteach', get_string('header_teamteach_remove', 'block_courseprefs'));
     $form->setHelpButton('remove_teamteach', array('teamteach_remove', get_string('teamteach_remove_help', 'block_courseprefs'), 'block_courseprefs', true));
     // Generate a listing of team teaching invitations
     $teamteaches = $user->getRequestedTeamTeaches();
     $display = array();
     foreach ($teamteaches as $teamteach) {
         $display[$teamteach->getId()] = CoursePrefsSection::generateFullnameById($teamteach->getSectionsId()) . ' with ' . CoursePrefsSection::generateFullnameById($teamteach->getTtSectionsId());
     }
     // Skip the remaining form definition if no invitations were found and display a message to the user
     if (!$display) {
         $form->addElement('static', null, null, get_string('no_deletes', 'block_courseprefs'));
         return;
     }
     // Sort listing of invitations by semesters
     uasort($display, "cmpSemester");
     // Add checkbox elements for each team teach invitation the user can remove
     foreach ($display as $key => $teamteach) {
         $form->addElement('checkbox', DELETE_GROUP . $key, null, $teamteach);
     }
     $form->addElement('submit', 'delete_submit', get_string('remove', 'block_courseprefs'));
 }
Exemplo n.º 3
0
 function definition()
 {
     global $CFG, $USER;
     $form =& $this->_form;
     $user = CoursePrefsUser::findByUnique($USER->username);
     // Generate listing of sections the user is the primary teacher
     $dropdown_items = array();
     $sections = $user->getSectionsAsPrimaryTeacher();
     foreach ($sections as $section) {
         // Skip section if the user isn't the primary teacher of it
         if (!$user->isPrimaryTeacher($section)) {
             continue;
         }
         $dropdown_items[$section->getId()] = CoursePrefsSection::generateFullnameById($section->getId());
     }
     // Sort listing of sections by semesters and prepend the default "NONE" option
     uasort($dropdown_items, "cmpSemester");
     $dropdown_items = array("NONE" => "NONE") + $dropdown_items;
     // Adding cross listing fieldset
     $form->addElement('header', 'add_crosslist', get_string('header_crosslist_add', 'block_courseprefs'));
     $form->setHelpButton('add_crosslist', array('crosslist_add', get_string('crosslist_add_help', 'block_courseprefs'), 'block_courseprefs', true));
     // Register regular expression rules for form elements
     $form->registerRule('valid_sectionsid', 'regex', SECTIONSID_PATTERN);
     // Adding dropdown element for user-owner sections
     $form->addElement('select', SECTIONSID_FIELD, get_string('crosslist_primary_section', 'block_courseprefs'), $dropdown_items);
     $form->addRule(SECTIONSID_FIELD, get_string('err_select_section', 'block_courseprefs'), 'valid_sectionsid');
     // Adding dropdown element for cross listed section
     $form->addElement('select', CR_SECTIONSID_FIELD, get_string('crosslist_secondary_section', 'block_courseprefs'), $dropdown_items);
     $form->addRule(CR_SECTIONSID_FIELD, get_string('err_select_section', 'block_courseprefs'), 'valid_sectionsid');
     // Add submit button to form
     $form->addElement('submit', 'submit', get_string('add_entry', 'block_courseprefs'));
 }
Exemplo n.º 4
0
 function definition()
 {
     global $USER;
     $form =& $this->_form;
     $user = CoursePrefsUser::findByUnique($USER->username);
     $teamteaches = $user->getRequestedTeamTeaches();
     // Pending team teaching invitations header
     $form->addElement('header', 'pending_teamteach', get_string('header_teamteach_pending', 'block_courseprefs'));
     $form->setHelpButton('pending_teamteach', array('teamteach_pending', get_string('teamteach_pending_help', 'block_courseprefs'), 'block_courseprefs', true));
     // Generate a listing of team teaching invitation the user has made of other teachers which
     // need to be approved or rejected
     $display = array();
     foreach ($teamteaches as $teamteach) {
         // Skip the team teaching invitation if it doesn't need to be approved
         if (!$teamteach->getApprovalFlag()) {
             continue;
         }
         // Lookup information about the requesting user and user's section
         $teamteach_user = $teamteach->getTtUser();
         $display[$teamteach->getId()] = CoursePrefsSection::generateFullnameById($teamteach->getTtSectionsId()) . ' with ' . $teamteach_user->getLastname() . ' ' . $teamteach_user->getFirstname();
     }
     // Skip the remaining form definition if no invitations were found and display a message to the user
     if (!$display) {
         $form->addElement('static', null, null, get_string('no_requests', 'block_courseprefs'));
         return;
     }
     // Sort listing of invitations by semesters
     uasort($display, "cmpSemester");
     // Add static elements for each team teach invitiation that hasn't been accepted or rejected yet
     foreach ($display as $key => $teamteach) {
         $form->addElement('static', null, null, $teamteach);
     }
 }
Exemplo n.º 5
0
 function definition()
 {
     global $CFG, $USER;
     $form =& $this->_form;
     $user = CoursePrefsUser::findByUnique($USER->username);
     // Remove cross listing header
     $form->addElement('header', 'remove_crosslist', get_string('header_crosslist_remove', 'block_courseprefs'));
     $form->setHelpButton('remove_crosslist', array('crosslist_remove', get_string('crosslist_remove_help', 'block_courseprefs'), 'block_courseprefs', true));
     // Generate a listing of existing cross listing entries to delete
     $crosslists = $user->getCrosslists();
     $display = array();
     $display_secondary = array();
     foreach ($crosslists as $crosslist) {
         $sectionsid = $crosslist->getSectionsId();
         $display[$sectionsid] = CoursePrefsSection::generateFullnameById($sectionsid);
         // Create array for secondary sections if it hasn't been created yet
         if (!$display_secondary[$sectionsid]) {
             $display_secondary[$sectionsid] = array();
         }
         // Associate secondary section with primary section
         $display_secondary[$sectionsid][$crosslist->getId()] = CoursePrefsSection::generateFullnameById($crosslist->getCrSectionsId());
     }
     // Skip the remaining form definition if no cross listing entries were found and display a message to the user
     if (!$display) {
         $form->addElement('static', null, null, get_string('no_cl_deletes', 'block_courseprefs'));
         return;
     }
     // Sort listing of cross listing entries by semesters
     uasort($display, "cmpSemester");
     // Iterate over primary sections of cross listed sections to generate form elements
     foreach ($display as $key => $value) {
         // Sort listing of secondary sections this section is cross listed with
         uasort($display_secondary[$key], "cmpSemester");
         // Iterate over secondary sections and generate necessary form elements
         foreach ($display_secondary[$key] as $id => $value_secondary) {
             // Build information to be substituted in listing
             $a = new stdClass();
             $a->primary_section = $value;
             $a->secondary_section = $value_secondary;
             $form->addElement('checkbox', CROSSLIST_DELETE_GROUP . $id, null, get_string('crosslist_with', 'block_courseprefs', $a));
         }
     }
     $form->addElement('submit', 'delete_submit', get_string('remove', 'block_courseprefs'));
 }
Exemplo n.º 6
0
/**
 * Send an email announcing that a teacher is revoking his/her team teaching invitation
 */
function delete_email($teamteach, $current_user)
{
    $to_user = $teamteach->getTtUser();
    $to = get_record('user', 'username', $to_user->getUsername());
    $from = get_record('user', 'username', $current_user->getUsername());
    // Build information to be substituted in email
    $a = new stdClass();
    $a->to_name = $to_user->getFirstname() . ' ' . $to_user->getLastname();
    $a->to_section = CoursePrefsSection::generateFullnameById($teamteach->getTtSectionsId());
    $a->from_name = $current_user->getFirstname() . ' ' . $current_user->getLastname();
    $a->from_section = CoursePrefsSection::generateFullnameById($teamteach->getSectionsId());
    // Send revocation email to user
    email_to_user($to, $from->email, get_string('remove_email_subject', 'block_courseprefs'), get_string('remove_email', 'block_courseprefs', $a));
}