public function save_dates(cm_info $cm, array $dates)
 {
     parent::save_dates($cm, $dates);
     // Fetch module instance from $mods array.
     $workshop = $this->mods[$cm->instance];
     $workshop->instance = $cm->instance;
     $workshop->coursemodule = $cm->id;
     // Updating date values.
     foreach ($dates as $datetype => $datevalue) {
         $workshop->{$datetype} = $datevalue;
     }
     // Calling the update event method to change the calender evenrs accordingly.
     workshop_calendar_update($workshop, $cm->id);
 }
示例#2
0
/**
 * Performs upgrade of the database structure and data
 *
 * Workshop supports upgrades from version 1.9.0 and higher only. During 1.9 > 2.0 upgrade,
 * there are significant database changes.
 *
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_workshop_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    $dbman = $DB->get_manager();
    // Moodle v2.2.0 release upgrade line
    if ($oldversion < 2012033100) {
        // add the field 'phaseswitchassessment' to the 'workshop' table
        $table = new xmldb_table('workshop');
        $field = new xmldb_field('phaseswitchassessment', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'assessmentend');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_mod_savepoint(true, 2012033100, 'workshop');
    }
    /**
     * Remove all workshop calendar events
     */
    if ($oldversion < 2012041700) {
        require_once $CFG->dirroot . '/calendar/lib.php';
        $events = $DB->get_records('event', array('modulename' => 'workshop'));
        foreach ($events as $event) {
            $event = calendar_event::load($event);
            $event->delete();
        }
        upgrade_mod_savepoint(true, 2012041700, 'workshop');
    }
    /**
     * Recreate all workshop calendar events
     */
    if ($oldversion < 2012041701) {
        require_once dirname(dirname(__FILE__)) . '/lib.php';
        $sql = "SELECT w.id, w.course, w.name, w.intro, w.introformat, w.submissionstart,\n                       w.submissionend, w.assessmentstart, w.assessmentend,\n                       cm.id AS cmid\n                  FROM {workshop} w\n                  JOIN {modules} m ON m.name = 'workshop'\n                  JOIN {course_modules} cm ON (cm.module = m.id AND cm.course = w.course AND cm.instance = w.id)";
        $rs = $DB->get_recordset_sql($sql);
        foreach ($rs as $workshop) {
            $cmid = $workshop->cmid;
            unset($workshop->cmid);
            workshop_calendar_update($workshop, $cmid);
        }
        $rs->close();
        upgrade_mod_savepoint(true, 2012041701, 'workshop');
    }
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    return true;
}
示例#3
0
文件: lib.php 项目: ncsu-delta/moodle
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param stdClass $workshop An object from the form in mod_form.php
 * @return bool success
 */
function workshop_update_instance(stdclass $workshop) {
    global $CFG, $DB;
    require_once(dirname(__FILE__) . '/locallib.php');

    $workshop->timemodified          = time();
    $workshop->id                    = $workshop->instance;
    $workshop->useexamples           = (int)!empty($workshop->useexamples);
    $workshop->usepeerassessment     = (int)!empty($workshop->usepeerassessment);
    $workshop->useselfassessment     = (int)!empty($workshop->useselfassessment);
    $workshop->latesubmissions       = (int)!empty($workshop->latesubmissions);
    $workshop->phaseswitchassessment = (int)!empty($workshop->phaseswitchassessment);
    $workshop->evaluation            = 'best';

    // todo - if the grading strategy is being changed, we must replace all aggregated peer grades with nulls
    // todo - if maximum grades are being changed, we should probably recalculate or invalidate them

    $DB->update_record('workshop', $workshop);
    $context = get_context_instance(CONTEXT_MODULE, $workshop->coursemodule);

    // process the custom wysiwyg editors
    if ($draftitemid = $workshop->instructauthorseditor['itemid']) {
        $workshop->instructauthors = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructauthors',
                0, workshop::instruction_editors_options($context), $workshop->instructauthorseditor['text']);
        $workshop->instructauthorsformat = $workshop->instructauthorseditor['format'];
    }

    if ($draftitemid = $workshop->instructreviewerseditor['itemid']) {
        $workshop->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructreviewers',
                0, workshop::instruction_editors_options($context), $workshop->instructreviewerseditor['text']);
        $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format'];
    }

    // re-save the record with the replaced URLs in editor fields
    $DB->update_record('workshop', $workshop);

    // update gradebook items
    workshop_grade_item_update($workshop);
    workshop_grade_item_category_update($workshop);

    // update calendar events
    workshop_calendar_update($workshop, $workshop->coursemodule);

    return true;
}
示例#4
0
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param stdClass $workshop An object from the form in mod_form.php
 * @return bool success
 */
function workshop_update_instance(stdclass $workshop) {
    global $CFG, $DB;
    require_once(dirname(__FILE__) . '/locallib.php');

    $workshop->timemodified          = time();
    $workshop->id                    = $workshop->instance;
    $workshop->useexamples           = (int)!empty($workshop->useexamples);
    $workshop->usepeerassessment     = 1;
    $workshop->useselfassessment     = (int)!empty($workshop->useselfassessment);
    $workshop->latesubmissions       = (int)!empty($workshop->latesubmissions);
    $workshop->phaseswitchassessment = (int)!empty($workshop->phaseswitchassessment);

    if (isset($workshop->gradinggradepass)) {
        $workshop->gradinggradepass = unformat_float($workshop->gradinggradepass);
    }

    if (isset($workshop->submissiongradepass)) {
        $workshop->submissiongradepass = unformat_float($workshop->submissiongradepass);
    }

    if (isset($workshop->submissionfiletypes)) {
        $workshop->submissionfiletypes = workshop::clean_file_extensions($workshop->submissionfiletypes);
    }

    if (isset($workshop->overallfeedbackfiletypes)) {
        $workshop->overallfeedbackfiletypes = workshop::clean_file_extensions($workshop->overallfeedbackfiletypes);
    }

    // todo - if the grading strategy is being changed, we may want to replace all aggregated peer grades with nulls

    $DB->update_record('workshop', $workshop);
    $context = context_module::instance($workshop->coursemodule);

    // process the custom wysiwyg editors
    if ($draftitemid = $workshop->instructauthorseditor['itemid']) {
        $workshop->instructauthors = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructauthors',
                0, workshop::instruction_editors_options($context), $workshop->instructauthorseditor['text']);
        $workshop->instructauthorsformat = $workshop->instructauthorseditor['format'];
    }

    if ($draftitemid = $workshop->instructreviewerseditor['itemid']) {
        $workshop->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructreviewers',
                0, workshop::instruction_editors_options($context), $workshop->instructreviewerseditor['text']);
        $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format'];
    }

    if ($draftitemid = $workshop->conclusioneditor['itemid']) {
        $workshop->conclusion = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'conclusion',
                0, workshop::instruction_editors_options($context), $workshop->conclusioneditor['text']);
        $workshop->conclusionformat = $workshop->conclusioneditor['format'];
    }

    // re-save the record with the replaced URLs in editor fields
    $DB->update_record('workshop', $workshop);

    // update gradebook items
    workshop_grade_item_update($workshop);
    workshop_grade_item_category_update($workshop);

    // update calendar events
    workshop_calendar_update($workshop, $workshop->coursemodule);

    return true;
}
示例#5
0
/**
 * Performs upgrade of the database structure and data
 *
 * Workshop supports upgrades from version 1.9.0 and higher only. During 1.9 > 2.0 upgrade,
 * there are significant database changes.
 *
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_workshop_upgrade($oldversion) {
    global $CFG, $DB, $OUTPUT;

    $dbman = $DB->get_manager();

    // Moodle v2.2.0 release upgrade line

    if ($oldversion < 2012033100) {
        // add the field 'phaseswitchassessment' to the 'workshop' table
        $table = new xmldb_table('workshop');
        $field = new xmldb_field('phaseswitchassessment', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'assessmentend');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_mod_savepoint(true, 2012033100, 'workshop');
    }

    /**
     * Remove all workshop calendar events
     */
    if ($oldversion < 2012041700) {
        require_once($CFG->dirroot . '/calendar/lib.php');
        $events = $DB->get_records('event', array('modulename' => 'workshop'));
        foreach ($events as $event) {
            $event = calendar_event::load($event);
            $event->delete();
        }
        upgrade_mod_savepoint(true, 2012041700, 'workshop');
    }

    /**
     * Recreate all workshop calendar events
     */
    if ($oldversion < 2012041701) {
        require_once(dirname(dirname(__FILE__)) . '/lib.php');

        $sql = "SELECT w.id, w.course, w.name, w.intro, w.introformat, w.submissionstart,
                       w.submissionend, w.assessmentstart, w.assessmentend,
                       cm.id AS cmid
                  FROM {workshop} w
                  JOIN {modules} m ON m.name = 'workshop'
                  JOIN {course_modules} cm ON (cm.module = m.id AND cm.course = w.course AND cm.instance = w.id)";

        $rs = $DB->get_recordset_sql($sql);

        foreach ($rs as $workshop) {
            $cmid = $workshop->cmid;
            unset($workshop->cmid);
            workshop_calendar_update($workshop, $cmid);
        }
        $rs->close();
        upgrade_mod_savepoint(true, 2012041701, 'workshop');
    }

    // Moodle v2.3.0 release upgrade line

    /**
     * Add new fields conclusion and conclusionformat
     */
    if ($oldversion < 2012102400) {
        $table = new xmldb_table('workshop');

        $field = new xmldb_field('conclusion', XMLDB_TYPE_TEXT, null, null, null, null, null, 'phaseswitchassessment');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        $field = new xmldb_field('conclusionformat', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '1', 'conclusion');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        upgrade_mod_savepoint(true, 2012102400, 'workshop');
    }


    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this

    /**
     * Add overall feedback related fields into the workshop table.
     */
    if ($oldversion < 2013032500) {
        $table = new xmldb_table('workshop');

        $field = new xmldb_field('overallfeedbackmode', XMLDB_TYPE_INTEGER, '3', null, null, null, '1', 'conclusionformat');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        $field = new xmldb_field('overallfeedbackfiles', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'overallfeedbackmode');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        $field = new xmldb_field('overallfeedbackmaxbytes', XMLDB_TYPE_INTEGER, '10', null, null, null, '100000', 'overallfeedbackfiles');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        upgrade_mod_savepoint(true, 2013032500, 'workshop');
    }

    /**
     * Add feedbackauthorattachment field into the workshop_assessments table.
     */
    if ($oldversion < 2013032501) {
        $table = new xmldb_table('workshop_assessments');
        $field = new xmldb_field('feedbackauthorattachment', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'feedbackauthorformat');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        upgrade_mod_savepoint(true, 2013032501, 'workshop');
    }


    return true;
}
示例#6
0
/**
 * This standard function will check all instances of this module
 * and make sure there are up-to-date events created for each of them.
 * If courseid = 0, then every workshop event in the site is checked, else
 * only workshop events belonging to the course specified are checked.
 *
 * @param  integer $courseid The Course ID.
 * @return bool Returns true if the calendar events were successfully updated.
 */
function workshop_refresh_events($courseid = 0)
{
    global $DB;
    if ($courseid) {
        // Make sure that the course id is numeric.
        if (!is_numeric($courseid)) {
            return false;
        }
        if (!($workshops = $DB->get_records('workshop', array('course' => $courseid)))) {
            return false;
        }
    } else {
        if (!($workshops = $DB->get_records('workshop'))) {
            return false;
        }
    }
    foreach ($workshops as $workshop) {
        if (!($cm = get_coursemodule_from_instance('workshop', $workshop->id, $courseid, false))) {
            continue;
        }
        workshop_calendar_update($workshop, $cm->id);
    }
    return true;
}
示例#7
0
文件: upgrade.php 项目: JP-Git/moodle
/**
 * Performs upgrade of the database structure and data
 *
 * Workshop supports upgrades from version 1.9.0 and higher only. During 1.9 > 2.0 upgrade,
 * there are significant database changes.
 *
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_workshop_upgrade($oldversion) {
    global $CFG, $DB, $OUTPUT;

    $dbman = $DB->get_manager();

    // Moodle v2.2.0 release upgrade line

    if ($oldversion < 2012033100) {
        // add the field 'phaseswitchassessment' to the 'workshop' table
        $table = new xmldb_table('workshop');
        $field = new xmldb_field('phaseswitchassessment', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'assessmentend');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_mod_savepoint(true, 2012033100, 'workshop');
    }

    /**
     * Remove all workshop calendar events
     */
    if ($oldversion < 2012041700) {
        require_once($CFG->dirroot . '/calendar/lib.php');
        $events = $DB->get_records('event', array('modulename' => 'workshop'));
        foreach ($events as $event) {
            $event = calendar_event::load($event);
            $event->delete();
        }
        upgrade_mod_savepoint(true, 2012041700, 'workshop');
    }

    /**
     * Recreate all workshop calendar events
     */
    if ($oldversion < 2012041701) {
        require_once(dirname(dirname(__FILE__)) . '/lib.php');

        $sql = "SELECT w.id, w.course, w.name, w.intro, w.introformat, w.submissionstart,
                       w.submissionend, w.assessmentstart, w.assessmentend,
                       cm.id AS cmid
                  FROM {workshop} w
                  JOIN {modules} m ON m.name = 'workshop'
                  JOIN {course_modules} cm ON (cm.module = m.id AND cm.course = w.course AND cm.instance = w.id)";

        $rs = $DB->get_recordset_sql($sql);

        foreach ($rs as $workshop) {
            $cmid = $workshop->cmid;
            unset($workshop->cmid);
            workshop_calendar_update($workshop, $cmid);
        }
        $rs->close();
        upgrade_mod_savepoint(true, 2012041701, 'workshop');
    }

    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this

		// Teammode
		if ($oldversion < 2011112901) {
			if (! $dbman->field_exists('workshop','teammode')) {
				$table = new xmldb_table('workshop');
				$field = new xmldb_field('teammode', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0');
				$dbman->add_field($table, $field);
			}
		}
		
    if ($oldversion < 2012041703) {
     	$table = new xmldb_table('workshop');
     	$field = new xmldb_field('examplescompare', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0');
         if (!$dbman->field_exists($table, $field)) {
             $dbman->add_field($table, $field);
         }
         $field = new xmldb_field('examplesreassess', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0');
         if (!$dbman->field_exists($table, $field)) {
             $dbman->add_field($table, $field);
        }
    }

    if ($oldversion < 2012061712) {
         
        $table = new xmldb_table('workshop');
        $field = new xmldb_field('numexamples', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        // Define table workshop_user_examples to be created
        $table = new xmldb_table('workshop_user_examples');

        // Adding fields to table workshop_user_examples
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null);
        $table->add_field('submissionid', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null);

        // Adding keys to table workshop_user_examples
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));

        // Conditionally launch create table for workshop_user_examples
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        
        upgrade_mod_savepoint(true, 2012061712, 'workshop');
         
    }


    return true;
}