コード例 #1
0
/**
 * This function is a hook that contains all of the extra initialization code
 * for the collapsed labels.
 *
 */
function init_collapsed_labels()
{
    global $PAGE, $COURSE;
    $PAGE->requires->js('/course/format/collblct/js/jquery.nestedAccordion.js');
    $PAGE->requires->js('/course/format/collblct/js/init_accordion.js');
    $PAGE->requires->js('/course/format/collblct/js/setup_nested_rev07252013.js');
    $colorrecord = new course_color_record($COURSE->id);
    $PAGE->requires->js_function_call('color_init', array($colorrecord->get_background_color(), $colorrecord->get_foreground_color()), false);
}
コード例 #2
0
/**
 * This function processes the submitted form for the two requested colors.  Earlier
 * in this file, the default values are placed into the form, so I only handle updates
 * if the values have changed from the default.
 *
 */
function process_form($courseid, &$submittedform)
{
    global $DB;
    if (isset($submittedform->returndefault)) {
        $colorrecord = new course_color_record($courseid);
        $colorrecord->delete_record();
        return;
    }
    /* NOTE: I've written these as separate cases to try to only write new colors and preserve
     * the code falling back to the defaults as best as I can. */
    if ($submittedform->foregroundcolor != DEFAULT_FOREGROUND) {
        $colorrecord = new course_color_record($courseid);
        $colorrecord->set_foreground_color($submittedform->foregroundcolor);
    }
    if ($submittedform->backgroundcolor != DEFAULT_BACKGROUND) {
        $colorrecord = new course_color_record($courseid);
        $colorrecord->set_background_color($submittedform->backgroundcolor);
    }
    // Now check each of the sections.
    $sectionheaders = array();
    $numberofsections = ctwcl_get_section_titles($courseid, $sectionheaders);
    $csr = new course_section_record($courseid);
    for ($i = 0; $i < $numberofsections; $i++) {
        $sectionfield = 'sectionfield_' . "{$i}";
        $sectioncheckbox = 'sectioncheckbox_' . "{$i}";
        // Moodle sections count 1->N, section 0 is the summary area at the top.
        $csr->update_section_record($i + 1, $submittedform->{$sectioncheckbox});
    }
}
コード例 #3
0
 /**
  * This function creates the various color records that are needed
  * for testing.
  *
  */
 private function create_color_information()
 {
     $courseid = 15;
     $colorrecord = new course_color_record($courseid);
     $colorrecord->set_foreground_color('');
     $colorrecord->set_background_color('');
     $courseid = 18;
     $colorrecord = new course_color_record($courseid);
     $colorrecord->set_foreground_color('#112233');
     $colorrecord->set_background_color('#223344');
     $courseid = 19;
     $colorrecord = new course_color_record($courseid);
     $colorrecord->set_foreground_color('#aabbcc');
     $courseid = 20;
     $colorrecord = new course_color_record($courseid);
     $colorrecord->set_background_color('#667788');
 }