Пример #1
0
        }
    }
} elseif ($action == 'submitexample') {
    require_capability('mod/workshop:manage', $context);
    // list previous submissions from teacher
    workshop_list_user_submissions($workshop, $USER);
    echo "<hr size=\"1\" noshade=\"noshade\" />";
    // print upload form
    print_heading(get_string("submitexampleassignment", "workshop") . ":");
    workshop_print_upload_form($workshop);
    print_heading("<a {$CFG->frametarget} href=\"view.php?id={$cm->id}\">" . get_string("cancel") . "</a>");
} elseif ($action == 'teachersview') {
    require_capability('mod/workshop:manage', $context);
    // automatically grade assessments if workshop has examples and/or peer assessments
    if ($workshop->gradingstrategy and ($workshop->ntassessments or $workshop->nsassessments)) {
        workshop_grade_assessments($workshop);
    }
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    /// find out current groups mode
    $groupmode = groups_get_activity_groupmode($cm);
    $currentgroup = groups_get_activity_group($cm, true);
    groups_print_activity_menu($cm, "view.php?id={$cm->id}");
    /// Print admin links
    echo "<table width=\"100%\"><tr><td>";
    echo "<a href=\"submissions.php?id={$cm->id}&amp;action=adminlist\">" . get_string("administration") . "</a>\n";
    echo '</td></tr>';
    echo '<tr><td>';
    workshop_print_assignment_info($workshop);
    print_heading("<a href=\"view.php?id={$cm->id}&amp;action=showdescription\">" . get_string("showdescription", 'workshop') . "</a>");
    echo '</td></tr>';
    /// Print grade tables /////////////////////////////////////////////////
Пример #2
0
function workshop_update_instance($workshop)
{
    // Given an object containing all the necessary data,
    // (defined by the form in mod.html) this function
    // will update an existing instance with new data.
    global $CFG;
    $workshop->timemodified = time();
    $workshop->submissionstart = make_timestamp($workshop->submissionstartyear, $workshop->submissionstartmonth, $workshop->submissionstartday, $workshop->submissionstarthour, $workshop->submissionstartminute);
    $workshop->assessmentstart = make_timestamp($workshop->assessmentstartyear, $workshop->assessmentstartmonth, $workshop->assessmentstartday, $workshop->assessmentstarthour, $workshop->assessmentstartminute);
    $workshop->submissionend = make_timestamp($workshop->submissionendyear, $workshop->submissionendmonth, $workshop->submissionendday, $workshop->submissionendhour, $workshop->submissionendminute);
    $workshop->assessmentend = make_timestamp($workshop->assessmentendyear, $workshop->assessmentendmonth, $workshop->assessmentendday, $workshop->assessmentendhour, $workshop->assessmentendminute);
    $workshop->releasegrades = make_timestamp($workshop->releaseyear, $workshop->releasemonth, $workshop->releaseday, $workshop->releasehour, $workshop->releaseminute);
    if (!workshop_check_dates($workshop)) {
        return get_string('invaliddates', 'workshop');
    }
    // set the workshop's type
    $wtype = 0;
    // 3 phases, no grading grades
    if ($workshop->includeself or $workshop->ntassessments) {
        $wtype = 1;
    }
    // 3 phases with grading grades
    if ($workshop->nsassessments) {
        $wtype = 2;
    }
    // 5 phases with grading grades
    $workshop->wtype = $wtype;
    // encode password if necessary
    if (!empty($workshop->password)) {
        $workshop->password = md5($workshop->password);
    } else {
        unset($workshop->password);
    }
    $workshop->id = $workshop->instance;
    if ($returnid = update_record("workshop", $workshop)) {
        $dates = array('submissionstart' => $workshop->submissionstart, 'submissionend' => $workshop->submissionend, 'assessmentstart' => $workshop->assessmentstart, 'assessmentend' => $workshop->assessmentend);
        $moduleid = get_field('modules', 'id', 'name', 'workshop');
        foreach ($dates as $type => $date) {
            if ($event = get_record('event', 'modulename', 'workshop', 'instance', $workshop->id, 'eventtype', $type)) {
                $event->name = get_string($type . 'event', 'workshop', $workshop->name);
                $event->description = $workshop->description;
                $event->eventtype = $type;
                $event->timestart = $date;
                update_event($event);
            } else {
                if ($date) {
                    $event = NULL;
                    $event->name = get_string($type . 'event', 'workshop', $workshop->name);
                    $event->description = $workshop->description;
                    $event->courseid = $workshop->course;
                    $event->groupid = 0;
                    $event->userid = 0;
                    $event->modulename = 'workshop';
                    $event->instance = $workshop->instance;
                    $event->eventtype = $type;
                    $event->timestart = $date;
                    $event->timeduration = 0;
                    $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $workshop->id);
                    add_event($event);
                }
            }
        }
    }
    if (time() > $workshop->assessmentstart) {
        // regrade all the submissions...
        set_field("workshop_submissions", "nassessments", 0, "workshopid", $workshop->id);
        workshop_grade_assessments($workshop);
    }
    return $returnid;
}