本文整理汇总了PHP中calendar_event::update方法的典型用法代码示例。如果您正苦于以下问题:PHP calendar_event::update方法的具体用法?PHP calendar_event::update怎么用?PHP calendar_event::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calendar_event
的用法示例。
在下文中一共展示了calendar_event::update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_moodle_assignment
//.........这里部分代码省略.........
$assignment->setEraterGrammar($this->turnitintooltwo->erater_grammar);
$assignment->setEraterUsage($this->turnitintooltwo->erater_usage);
$assignment->setEraterMechanics($this->turnitintooltwo->erater_mechanics);
$assignment->setEraterStyle($this->turnitintooltwo->erater_style);
$assignment->setEraterSpellingDictionary(isset($this->turnitintooltwo->erater_dictionary) ? $this->turnitintooltwo->erater_dictionary : 'en_US');
$assignment->setEraterHandbook(isset($this->turnitintooltwo->erater_handbook) ? $this->turnitintooltwo->erater_handbook : 0);
$attribute = "dtstart" . $i;
$assignment->setStartDate(gmdate("Y-m-d\\TH:i:s\\Z", $this->turnitintooltwo->{$attribute}));
$attribute = "dtdue" . $i;
$assignment->setDueDate(gmdate("Y-m-d\\TH:i:s\\Z", $this->turnitintooltwo->{$attribute}));
$attribute = "dtpost" . $i;
$assignment->setFeedbackReleaseDate(gmdate("Y-m-d\\TH:i:s\\Z", $this->turnitintooltwo->{$attribute}));
$attribute = "partname" . $i;
$assignment->setTitle($this->turnitintooltwo->name . " " . $this->turnitintooltwo->{$attribute} . " (Moodle TT)");
// Initialise part.
$part = new stdClass();
$part->turnitintooltwoid = $this->id;
$part->partname = $this->turnitintooltwo->{$attribute};
$part->deleted = 0;
$part->maxmarks = $assignment->getMaxGrade();
$part->dtstart = strtotime($assignment->getStartDate());
$part->dtdue = strtotime($assignment->getDueDate());
$part->dtpost = strtotime($assignment->getFeedbackReleaseDate());
$parttiiassignid = 0;
if ($i <= count($partids) && !empty($partids[$i - 1])) {
$partdetails = $this->get_part_details($partids[$i - 1]);
$part->submitted = $partdetails->submitted;
$part->unanon = $partdetails->unanon;
// Set anonymous marking depending on whether part has been unanonymised.
if ($config->useanon && $partdetails->unanon != 1) {
$assignment->setAnonymousMarking($this->turnitintooltwo->anon);
}
$parttiiassignid = $partdetails->tiiassignid;
}
if ($parttiiassignid > 0) {
$assignment->setAssignmentId($parttiiassignid);
$this->edit_tii_assignment($assignment);
} else {
$parttiiassignid = $this->create_tii_assignment($assignment, $this->id, $i);
$part->submitted = 0;
}
$part->tiiassignid = $parttiiassignid;
// Unanonymise part if necessary.
if ($part->dtpost < time() && $part->submitted == 1) {
$part->unanon = 1;
}
$properties = new stdClass();
$properties->name = $this->turnitintooltwo->name . ' - ' . $part->partname;
$properties->description = $this->turnitintooltwo->intro;
$properties->courseid = $this->turnitintooltwo->course;
$properties->groupid = 0;
$properties->userid = 0;
$properties->modulename = 'turnitintooltwo';
$properties->instance = $this->id;
$properties->eventtype = 'due';
$properties->timestart = $part->dtdue;
$properties->timeduration = 0;
if ($i <= count($partids) && !empty($partdetails->id)) {
$part->id = $partids[$i - 1];
// Get Current Moodle part data.
if (!($partnow = $DB->get_record("turnitintooltwo_parts", array("id" => $part->id)))) {
turnitintooltwo_print_error('partgeterror', 'turnitintooltwo', null, null, __FILE__, __LINE__);
exit;
}
if (!($dbpart = $DB->update_record('turnitintooltwo_parts', $part))) {
turnitintooltwo_print_error('partupdateerror', 'turnitintooltwo', null, $i, __FILE__, __LINE__);
exit;
} else {
turnitintooltwo_activitylog("Moodle Assignment part updated (" . $part->id . ") - " . $part->partname, "REQUEST");
}
// Delete existing events for this assignment part.
$eventname = $turnitintooltwonow->name . " - " . $partnow->partname;
$dbselect = " modulename = ? AND instance = ? AND name LIKE ? ";
// Moodle pre 2.5 on SQL Server errors here as queries weren't allowed on ntext fields, the relevant fields
// are nvarchar from 2.6 onwards so we have to cast the relevant fields in pre 2.5 SQL Server setups.
if ($CFG->branch <= 25 && $CFG->dbtype == "sqlsrv") {
$dbselect = " CAST(modulename AS nvarchar(max)) = ? AND instance = ? AND CAST(name AS nvarchar(max)) = ? ";
}
$DB->delete_records_select('event', $dbselect, array('turnitintooltwo', $this->id, $eventname));
} else {
if (!($dbpart = $DB->insert_record('turnitintooltwo_parts', $part))) {
turnitintooltwo_print_error('partdberror', 'turnitintooltwo', null, $i, __FILE__, __LINE__);
exit;
}
}
if ($createevent == true) {
require_once $CFG->dirroot . '/calendar/lib.php';
$event = new calendar_event($properties);
$event->update($properties, false);
}
}
$this->turnitintooltwo->timemodified = time();
$update = $DB->update_record("turnitintooltwo", $this->turnitintooltwo);
turnitintooltwo_activitylog("Turnitintool updated (" . $this->id . ") - " . $this->turnitintooltwo->name, "REQUEST");
// Define grade settings.
if (!isset($_SESSION['tii_assignment_reset'])) {
turnitintooltwo_grade_item_update($this->turnitintooltwo);
}
return $update;
}
开发者ID:sk-unikent,项目名称:moodle-mod_turnitintooltwo-1,代码行数:101,代码来源:turnitintooltwo_assignment.class.php
示例2: create
/**
* Creates a new event and returns a calendar_event object
*
* @param object|array $properties An object containing event properties
* @return calendar_event|false The event object or false if it failed
*/
public static function create($properties)
{
if (is_array($properties)) {
$properties = (object) $properties;
}
if (!is_object($properties)) {
throw new coding_exception('When creating an event properties should be either an object or an assoc array');
}
$event = new calendar_event($properties);
if ($event->update($properties)) {
return $event;
} else {
return false;
}
}
示例3:
/**
*
* Adds an event to the calendar of a user
* @param object $event a object containing details of an event tot be saved into a users calendar
*/
function save_event($event)
{
//we can not user add_event in moodle 2.0 as it requires the user to have persmissions to add events to the
//calendar however this capability check can be bypassed if we use the calendar event class so we will use add_event in
//1.9 and calendar_event class in 2.0
global $CFG, $USER;
if (stripos($CFG->release, "2.") !== false) {
require_once $CFG->dirroot . '/calendar/lib.php';
$calevent = new calendar_event($event);
$calevent->update($event, false);
if ($calevent !== false) {
return $calevent->id;
}
} else {
return add_event($event);
}
}
示例4: workshop_calendar_update
/**
* Updates the calendar events associated to the given workshop
*
* @param stdClass $workshop the workshop instance record
* @param int $cmid course module id
*/
function workshop_calendar_update(stdClass $workshop, $cmid) {
global $DB;
// get the currently registered events so that we can re-use their ids
$currentevents = $DB->get_records('event', array('modulename' => 'workshop', 'instance' => $workshop->id));
// the common properties for all events
$base = new stdClass();
$base->description = format_module_intro('workshop', $workshop, $cmid, false);
$base->courseid = $workshop->course;
$base->groupid = 0;
$base->userid = 0;
$base->modulename = 'workshop';
$base->eventtype = 'pluginname';
$base->instance = $workshop->id;
$base->visible = instance_is_visible('workshop', $workshop);
$base->timeduration = 0;
if ($workshop->submissionstart) {
$event = clone($base);
$event->name = get_string('submissionstartevent', 'mod_workshop', $workshop->name);
$event->timestart = $workshop->submissionstart;
if ($reusedevent = array_shift($currentevents)) {
$event->id = $reusedevent->id;
} else {
// should not be set but just in case
unset($event->id);
}
// update() will reuse a db record if the id field is set
$eventobj = new calendar_event($event);
$eventobj->update($event, false);
}
if ($workshop->submissionend) {
$event = clone($base);
$event->name = get_string('submissionendevent', 'mod_workshop', $workshop->name);
$event->timestart = $workshop->submissionend;
if ($reusedevent = array_shift($currentevents)) {
$event->id = $reusedevent->id;
} else {
// should not be set but just in case
unset($event->id);
}
// update() will reuse a db record if the id field is set
$eventobj = new calendar_event($event);
$eventobj->update($event, false);
}
if ($workshop->assessmentstart) {
$event = clone($base);
$event->name = get_string('assessmentstartevent', 'mod_workshop', $workshop->name);
$event->timestart = $workshop->assessmentstart;
if ($reusedevent = array_shift($currentevents)) {
$event->id = $reusedevent->id;
} else {
// should not be set but just in case
unset($event->id);
}
// update() will reuse a db record if the id field is set
$eventobj = new calendar_event($event);
$eventobj->update($event, false);
}
if ($workshop->assessmentend) {
$event = clone($base);
$event->name = get_string('assessmentendevent', 'mod_workshop', $workshop->name);
$event->timestart = $workshop->assessmentend;
if ($reusedevent = array_shift($currentevents)) {
$event->id = $reusedevent->id;
} else {
// should not be set but just in case
unset($event->id);
}
// update() will reuse a db record if the id field is set
$eventobj = new calendar_event($event);
$eventobj->update($event, false);
}
// delete any leftover events
foreach ($currentevents as $oldevent) {
$oldevent = calendar_event::load($oldevent);
$oldevent->delete();
}
}
示例5: grouptool_update_instance
/**
* Updates an instance of the grouptool in the database
*
* 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 $grouptool An object from the form in mod_form.php
* @param mod_grouptool_mod_form $mform
* @return boolean Success/Fail
*/
function grouptool_update_instance(stdClass $grouptool, mod_grouptool_mod_form $mform = null)
{
global $DB, $CFG;
$grouptool->timemodified = time();
$grouptool->id = $grouptool->instance;
$cmid = $grouptool->coursemodule;
if (!isset($grouptool->use_size)) {
$grouptool->use_size = 0;
}
if (!isset($grouptool->use_individual)) {
$grouptool->use_individual = 0;
}
if (!isset($grouptool->use_queue)) {
$queues = $DB->count_records_sql("SELECT COUNT(DISTINCT queues.id)\n FROM {grouptool_agrps} agrps\n LEFT JOIN {grouptool_queued} queues ON queues.agrpid = agrps.id\n WHERE agrps.grouptoolid = ?", array($grouptool->instance));
if (!empty($queues)) {
$grouptool->use_queue = 1;
} else {
$grouptool->use_queue = 0;
}
}
if (!isset($grouptool->allow_multiple)) {
$grouptool->allow_multiple = 0;
}
$grouptool->grpsize = clean_param($grouptool->grpsize, PARAM_INT);
$grouptool->choose_min = clean_param($grouptool->choose_min, PARAM_INT);
$grouptool->choose_max = clean_param($grouptool->choose_max, PARAM_INT);
// Register students if immediate registration has been turned on!
if ($grouptool->immediate_reg) {
require_once $CFG->dirroot . '/mod/grouptool/locallib.php';
$instance = new mod_grouptool($grouptool->coursemodule, $grouptool);
$instance->push_registrations();
}
require_once $CFG->dirroot . '/calendar/lib.php';
$event = new stdClass();
if ($grouptool->allow_reg) {
$event->name = get_string('registration_period_start', 'grouptool') . ' ' . $grouptool->name;
} else {
$event->name = $grouptool->name . ' ' . get_string('availabledate', 'grouptool');
}
$event->description = format_module_intro('grouptool', $grouptool, $grouptool->coursemodule);
if (!empty($grouptool->timeavailable)) {
$event->timestart = $grouptool->timeavailable;
} else {
$grouptool->timecreated = $DB->get_field('grouptool', 'timecreated', array('id' => $grouptool->id));
$event->timestart = $grouptool->timecreated;
}
$event->visible = instance_is_visible('grouptool', $grouptool);
$event->timeduration = 0;
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'grouptool', 'instance' => $grouptool->id, 'eventtype' => 'availablefrom'))) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event, false);
} else {
$event->courseid = $grouptool->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'grouptool';
$event->instance = $grouptool->id;
/*
* For activity module's events, this can be used to set the alternative text of the
* event icon. Set it to 'pluginname' unless you have a better string.
*/
$event->eventtype = 'availablefrom';
calendar_event::create($event);
}
if ($grouptool->timedue != 0) {
unset($event->id);
unset($calendarevent);
if ($grouptool->allow_reg) {
$event->name = get_string('registration_period_end', 'grouptool') . ' ' . $grouptool->name;
} else {
$event->name = $grouptool->name . ' ' . get_string('duedate', 'grouptool');
}
$event->timestart = $grouptool->timedue;
$event->eventtype = 'deadline';
/*
* For activity module's events, this can be used to set the alternative text of the
* event icon. Set it to 'pluginname' unless you have a better string.
*/
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'grouptool', 'instance' => $grouptool->id, 'eventtype' => 'due'))) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event, false);
} else {
unset($event->id);
$event->courseid = $grouptool->course;
// We've got some permission issues with calendar_event::create() so we work around that!
$calev = new calendar_event($event);
$calev->update($event, false);
}
} else {
//.........这里部分代码省略.........