예제 #1
0
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_login($course, false, $cm);
$teamwork = $DB->get_record('teamwork', array('id' => $teamworkid), '*', MUST_EXIST);
$teamwork = new teamwork($teamwork, $cm, $course);
// todo: check if there already is some assessment done and do not allowed the change of the form
// once somebody already used it to assess
$team_edit_url = new moodle_url('/mod/teamwork/team_edit.php', array('id' => $templetid));
$PAGE->set_url($team_edit_url);
$PAGE->set_title($teamwork->name);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(get_string('createteam', 'teamwork'));
$mform = new teamwork_teaminfo_form($course->id, $teamworkid, $templetid);
if ($mform->is_cancelled()) {
    redirect($teamwork->view_url());
} elseif ($data = $mform->get_data()) {
    save_templet_data($data);
    redirect($teamwork->view_url());
}
// Output starts here
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($teamwork->name));
$mform->display();
echo $OUTPUT->footer();
////////////////////////////////
function save_templet_data($data)
{
    global $DB, $USER;
    $newteam = new stdClass();
    $newteam->course = $data->courseid;
    $newteam->teamwork = $data->teamworkid;
    $newteam->name = $data->title;
예제 #2
0
    $savedata->assessfirst = $data->assessfirst;
    for ($i = 1; $i <= (int) $savedata->phasenum; $i++) {
        $data = $DB->get_record('teamwork_templet_phase', array('teamwork' => $id, 'templet' => $update, 'orderid' => $i), '*', MUST_EXIST);
        $savedata->{'phasename_' . $i} = $data->name;
        $savedata->{'phasedescription_' . $i}['text'] = $data->description;
        $savedata->{'phasestart_' . $i} = $data->timestart;
        $savedata->{'phaseend_' . $i} = $data->timeend;
    }
    $mform->set_data($savedata);
} else {
    $mform = new teamwork_templet_form($id);
}
if ($mform->is_cancelled()) {
    redirect($teamwork->view_url());
} elseif ($data = $mform->get_data()) {
    save_templet_data($course, $data);
    redirect($teamwork->view_url());
}
// Output starts here
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($teamwork->name));
$mform->display();
echo $OUTPUT->footer();
////////////////////////////////
function save_templet_data($course, $data)
{
    global $DB;
    $newtemplet = new stdClass();
    $newtemplet->course = $course->id;
    $newtemplet->teamwork = $data->id;
    $newtemplet->title = $data->title;