コード例 #1
0
ファイル: edit.php プロジェクト: nadavkav/MoodleTAO
            if (empty($course->restrictmodules)) {
                $allowedmods = explode(',', $CFG->defaultallowedmodules);
            }
            // it'll be greyed out but we want these by default anyway.
        }
        $course->allowedmods = $allowedmods;
        if ($course->enrolstartdate) {
            $course->enrolstartdisabled = 0;
        }
        if ($course->enrolenddate) {
            $course->enrolenddisabled = 0;
        }
    }
}
/// first create the form
$editform = new course_edit_form('edit.php', compact('course', 'category'));
// now override defaults if course already exists
if (!empty($course)) {
    $course->enrolpassword = $course->password;
    // we need some other name for password field MDL-9929
    $editform->set_data($course);
}
if ($editform->is_cancelled()) {
    if (empty($course)) {
        redirect($CFG->wwwroot);
    } else {
        redirect($CFG->wwwroot . '/course/view.php?id=' . $course->id);
    }
} else {
    if ($data = $editform->get_data()) {
        $data->password = $data->enrolpassword;
コード例 #2
0
ファイル: edit.php プロジェクト: ncsu-delta/moodle
// Prepare course and the editor
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true);
if (!empty($course)) {
    //add context for editor
    $editoroptions['context'] = $coursecontext;
    $course = file_prepare_standard_editor($course, 'summary', $editoroptions, $coursecontext, 'course', 'summary', 0);

} else {
    //editor should respect category context if course context is not set.
    $editoroptions['context'] = $catcontext;
    $course = file_prepare_standard_editor($course, 'summary', $editoroptions, null, 'course', 'summary', null);
}

// first create the form
$editform = new course_edit_form(NULL, array('course'=>$course, 'category'=>$category, 'editoroptions'=>$editoroptions, 'returnto'=>$returnto));
if ($editform->is_cancelled()) {
        switch ($returnto) {
            case 'category':
                $url = new moodle_url($CFG->wwwroot.'/course/category.php', array('id'=>$categoryid));
                break;
            case 'topcat':
                $url = new moodle_url($CFG->wwwroot.'/course/');
                break;
            default:
                if (!empty($course->id)) {
                    $url = new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id));
                } else {
                    $url = new moodle_url($CFG->wwwroot.'/course/');
                }
                break;
コード例 #3
0
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_commerce/courselist.php');
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$title = 'edit_course_shopsettings';
if ($isadding) {
    $title = 'addnewcourse';
}
$PAGE->navbar->add(get_string($title, 'block_iomad_commerce'));
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_commerce', 'block', $title);
$blockpage->setup($urlparams);
require_login(null, false);
// Adds to $PAGE, creates $OUTPUT.
/* next line copied from /course/edit.php */
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);
$mform = new course_edit_form($PAGE->url, $isadding, $shopsettingsid, $course, $priceblocks, $editoroptions);
$mform->set_data($shopsettings);
if ($mform->is_cancelled()) {
    redirect($companylist);
} else {
    if ($data = $mform->get_data()) {
        $data->userid = $USER->id;
        $transaction = $DB->start_delegated_transaction();
        if ($isadding) {
            $shopsettingsid = $DB->insert_record('course_shopsettings', $data);
        } else {
            $data->id = $shopsettingsid;
            $DB->update_record('course_shopsettings', $data);
        }
        if (!isset($data->courseid) && isset($course->id)) {
            $data->courseid = $course->id;
コード例 #4
0
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_company_admin', 'block', 'createcourse_title');
$blockpage->setup();
// Set the companyid
if (!iomad::has_capability('block/iomad_company_admin:manageallcompanycourses', $context)) {
    $companyid = iomad::get_my_companyid($context);
}
$urlparams = array('companyid' => $companyid);
if ($returnurl) {
    $urlparams['returnurl'] = $returnurl;
}
$companylist = new moodle_url('/local/iomad_dashboard/index.php', $urlparams);
/* next line copied from /course/edit.php */
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);
$mform = new course_edit_form($PAGE->url, $companyid, $editoroptions);
if ($mform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $mform->get_data()) {
        $data->userid = $USER->id;
        // Merge data with course defaults.
        $company = $DB->get_record('company', array('id' => $companyid));
        if (!empty($company->category)) {
            $data->category = $company->category;
        } else {
            $data->category = $CFG->defaultrequestcategory;
        }
        $courseconfig = get_config('moodlecourse');
        $mergeddata = (object) array_merge((array) $courseconfig, (array) $data);
        // Turn on restricted modules.
コード例 #5
0
ファイル: lib.php プロジェクト: r007/PMoodle
function createCourse($categoryId)
{
    global $Out;
    $course = null;
    $category = null;
    // Must define as the compact function below expects a category variable
    if ($categoryId) {
        // creating new course in this category
        require_login();
        if (!($category = get_record('course_categories', 'id', $categoryId))) {
            error('Category ID was incorrect');
        }
        require_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $category->id));
    } else {
        require_login();
        error('Either course id or category must be specified');
    }
    // We're pretending a form has been submitted
    // Create the form
    $editform = new course_edit_form('edit.php', compact('course', 'category'));
    $editform->_form->_flagSubmitted = true;
    // Set the values for certain elements
    $elements = new object();
    $elements->name = 'SRV ' . date('Ymd H:i');
    $elements->time = time();
    // Create a data object of elements for the form
    $data = createNewCourseData($elements);
    // Set the form with the data object
    $editform->set_data($data);
    //$elements = $editform->_form->_elements;
    //$Out->print_r($elements, '$elements (1) = ', 0, true);
    // Set the submit data as the form checks these values match the form elements
    $submitData = $editform->_form->_submitValues = (array) $data;
    //$Out->print_r($submitData, '$submitData (1) = ', 0, true);
    $data = $editform->get_data();
    // Password fields must match
    $data->password = $data->enrolpassword;
    // we need some other name for password field MDL-9929
    //preprocess data
    if ($data->enrolstartdisabled) {
        $data->enrolstartdate = 0;
    }
    if ($data->enrolenddisabled) {
        $data->enrolenddate = 0;
    }
    $data->timemodified = time();
    // Now create the course from the form
    if (!($course = create_course($data))) {
        print_error('coursenotcreated');
    }
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    // assign default role to creator if not already having permission to manage course assignments
    if (!has_capability('moodle/course:view', $context) or !has_capability('moodle/role:assign', $context)) {
        role_assign($CFG->creatornewroleid, $USER->id, 0, $context->id);
    }
    // ensure we can use the course right after creating it
    // this means trigger a reload of accessinfo...
    mark_context_dirty($context->path);
    print_box('course successfully created.');
    return $course;
}
コード例 #6
0
ファイル: createCourse.php プロジェクト: r007/PMoodle
// Must define as the compact function below expects a category variable
$categoryid = 1;
if ($categoryid) {
    // creating new course in this category
    $course = null;
    require_login();
    if (!($category = get_record('course_categories', 'id', $categoryid))) {
        error('Category ID was incorrect');
    }
    require_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $category->id));
} else {
    require_login();
    error('Either course id or category must be specified');
}
/// first create the form
$editform = new course_edit_form('edit.php', compact('course', 'category'));
$editform->_form->_flagSubmitted = true;
$elements = new object();
$elements->name = 'SRV ' . date('Ymd H:i');
$Out->print_r($elements->name, '$data (1) = ', 0, true);
$elements->time = time();
$data = createNewCourseData($elements);
$Out->print_r($data, '$data (1) = ', 0, true);
$editform->set_data($data);
$elements = $editform->_form->_elements;
//$Out->print_r($elements, '$elements (1) = ', 0, true);
$submitData = $editform->_form->_submitValues = (array) $data;
//$Out->print_r($submitData, '$submitData (1) = ', 0, true);
$data = $editform->get_data();
//$Out->print_r($data, '$data (2) = ', 0, true);
//exit();
コード例 #7
0
 function no_submit_button_pressed()
 {
     global $CFG;
     $data = $this->_form->exportValues();
     if (isset($data['deletelogo']) && !empty($data['id']) && !empty($data['logofile'])) {
         /// If delete logo was pressed...
         $logo = $CFG->dataroot . '/' . $data['id'] . '/' . $data['logofile'];
         if (unlink($logo)) {
             set_field('course_config_fn', 'value', '', 'courseid', $data['id'], 'variable', 'logo');
             $this->_customdata['course']->logo = '';
             $link = get_string('notusinglogo', 'format_fn');
             $dbgrp = $this->_form->getElement('dbgrp');
             $elements = $dbgrp->getElements();
             foreach (array_keys($elements) as $key) {
                 if ('dbuttont' == $dbgrp->getElementName($key)) {
                     $element =& $elements[$key];
                     $element->setValue($link);
                     break;
                 }
             }
         }
     }
     return parent::no_submit_button_pressed();
 }
コード例 #8
0
ファイル: edit.php プロジェクト: veritech/pare-project
            if (empty($course->restrictmodules)) {
                $allowedmods = explode(',', $CFG->defaultallowedmodules);
            }
            // it'll be greyed out but we want these by default anyway.
        }
        $course->allowedmods = $allowedmods;
        if ($course->enrolstartdate) {
            $course->enrolstartdisabled = 0;
        }
        if ($course->enrolenddate) {
            $course->enrolenddisabled = 0;
        }
    }
}
/// first create the form
$editform = new course_edit_form('edit.php', compact('course', 'category'));
// now override defaults if course already exists
if (!empty($course)) {
    $editform->set_data($course);
}
if ($editform->is_cancelled()) {
    if (empty($course)) {
        redirect($CFG->wwwroot);
    } else {
        redirect($CFG->wwwroot . '/course/view.php?id=' . $course->id);
    }
} else {
    if ($data = $editform->get_data()) {
        /// process data if submitted
        //preprocess data
        if ($data->enrolstartdisabled) {