예제 #1
0
 public function definition()
 {
     $mform =& $this->_form;
     $this->user = $this->_customdata['user'];
     $mform->addElement('hidden', 'action', 'classify');
     $mform->addElement('hidden', 'id', $this->user->id);
     $selected = array();
     if ($itemptags = tag_get_tags_array('userclassify', $this->user->id)) {
         foreach ($itemptags as $itag) {
             $selected[strtolower($itag)] = 1;
         }
     }
     $types = get_records('classification_type');
     $allvalues = tao_get_classifications(false);
     $checkboxes = array();
     foreach ($allvalues as $value) {
         if (!array_key_exists($value->typeid, $checkboxes)) {
             $checkboxes[$value->typeid] = array();
         }
         $checkboxes[$value->typeid][] = $mform->createElement('checkbox', strtolower($value->value), $value->value, $value->value);
     }
     foreach ($types as $type) {
         $mform->addElement('header', $type->name);
         $mform->addGroup($checkboxes[$type->id], 'checkboxes' . $type->id, $type->name);
         $mform->setDefault('checkboxes' . $type->id, $selected);
     }
     $this->add_action_buttons(false);
 }
예제 #2
0
파일: lib.php 프로젝트: nadavkav/MoodleTAO
/**
* implement the local hook to run some custom code at course backup time.
* see lib/locallib.php
*
* @param filehandle $bf open file handle for writing to
* @param stdclass object $course course we're backing up
* @param integer $startlevel level we're currently using
*
* @return boolean
*/
function local_course_backup($bf, $course, $startlevel)
{
    // in the case of TAO we want to primarily make sure we back up course classification data.
    if (!($values = tao_get_classifications(false, $course->id))) {
        return true;
    }
    $status = fwrite($bf, start_tag('TAO_CLASSIFICATIONS', $startlevel, true));
    foreach ($values as $value) {
        $status = $status && fwrite($bf, start_tag('TAO_CLASSIFICATION', $startlevel + 1, true));
        $status = $status && fwrite($bf, full_tag('TAO_TYPE', $startlevel + 2, false, $value->type));
        $status = $status && fwrite($bf, full_tag('TAO_NAME', $startlevel + 2, false, $value->name));
        $status = $status && fwrite($bf, full_tag('TAO_VALUE', $startlevel + 2, false, $value->value));
        $status = $status && fwrite($bf, end_tag('TAO_CLASSIFICATION', $startlevel + 1, true));
    }
    $status = $status && fwrite($bf, end_tag('TAO_CLASSIFICATIONS', $startlevel, true));
    // backup the course.approval_status_id field
    $status = $status && fwrite($bf, full_tag('TAO_COURSE_APPROVAL_STATUS', $startlevel, false, $course->approval_status_id));
    return $status;
}
예제 #3
0
파일: list.php 프로젝트: nadavkav/MoodleTAO
print_header($strheading, $strheading, build_navigation($strheading));
$url = $CFG->wwwroot . '/local/lp/list.php';
if ($type = optional_param('type', 0, PARAM_INT)) {
    $first = optional_param('first', 0, PARAM_INT);
    if (($ids = tao_get_courseids_with_classification($type, $first, COURSE_STATUS_PUBLISHED, $CFG->lppublishedcategory)) && ($courses = get_courses('all', 'c.sortorder ASC', 'c.*', array_keys($ids)))) {
        foreach ($courses as $course) {
            print_course($course);
        }
        echo '<a href="' . $url . '">' . get_string('backtolist', 'local') . '</a>';
        print_footer();
        exit;
    } else {
        notify(get_string('novisiblecourses', 'local'));
    }
}
$filtervalues = tao_get_classifications(true, null, COURSE_STATUS_PUBLISHED, $CFG->lppublishedcategory);
// note only want 'published' on this screen
$filters = array();
$topcat = array();
$secondcat = array();
foreach ($filtervalues->allvalues as $f) {
    switch ($f->type) {
        case 'filter':
            if (!array_key_exists($f->typeid, $filters)) {
                $filters[$f->typeid] = array(0 => $f->name . ':');
            }
            $filters[$f->typeid][$f->id] = $f->value;
            break;
        case 'topcategory':
            if (empty($topcat)) {
                $topcat[0] = $f->name;