$entry->timemodified = time();
$entry->teacherentry = 0;
$entry->approved = 1;
- if ($DB->insert_record('glossary_entries', $entry)) {
- $entries_count++;
- }
+ $DB->insert_record('glossary_entries', $entry);
+ $entries_count++;
}
}
if ($entries_count > 0 && !$this->get('quiet')) {
$this->created = time();
// Insert the new blog entry.
- if ($this->id = $DB->insert_record('post', $this)) {
+ $this->id = $DB->insert_record('post', $this);
- // Update tags.
- $this->add_tags_info();
+ // Update tags.
+ $this->add_tags_info();
- if (!empty($CFG->useblogassociations)) {
- $this->add_associations();
- add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$this->userid.'&entryid='.$this->id, $this->subject);
- }
-
- tag_set('post', $this->id, $this->tags);
+ if (!empty($CFG->useblogassociations)) {
+ $this->add_associations();
+ add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$this->userid.'&entryid='.$this->id, $this->subject);
}
+
+ tag_set('post', $this->id, $this->tags);
}
/**
// Else if we're allowed to create new categories, let's create this one
$newcat->name = $group->category;
$newcat->visible = 0;
- if($catid = $DB->insert_record('course_categories', $newcat)){
- $course->category = $catid;
- $this->log_line("Created new (hidden) category, #$catid: $newcat->name");
- }else{
- $this->log_line('Failed to create new category: '.$newcat->name);
- }
+ $catid = $DB->insert_record('course_categories', $newcat);
+ $course->category = $catid;
+ $this->log_line("Created new (hidden) category, #$catid: $newcat->name");
}else{
// If not found and not allowed to create, stick with default
$this->log_line('Category '.$group->category.' not found in Moodle database, so using default category instead.');
// Choose a sort order that puts us at the start of the list!
$course->sortorder = 0;
- if ($courseid = $DB->insert_record('course', $course)) {
+ $courseid = $DB->insert_record('course', $course);
- // Setup the blocks
- $course = $DB->get_record('course', array('id' => $courseid));
- blocks_add_default_course_blocks($course);
+ // Setup the blocks
+ $course = $DB->get_record('course', array('id' => $courseid));
+ blocks_add_default_course_blocks($course);
- $section = new object();
- $section->course = $course->id; // Create a default section.
- $section->section = 0;
- $section->summaryformat = FORMAT_HTML;
- $section->id = $DB->insert_record("course_sections", $section);
+ $section = new object();
+ $section->course = $course->id; // Create a default section.
+ $section->section = 0;
+ $section->summaryformat = FORMAT_HTML;
+ $section->id = $DB->insert_record("course_sections", $section);
- add_to_log(SITEID, "course", "new", "view.php?id=$course->id", "$course->fullname (ID $course->id)");
+ add_to_log(SITEID, "course", "new", "view.php?id=$course->id", "$course->fullname (ID $course->id)");
- $this->log_line("Created course $coursecode in Moodle (Moodle ID is $course->id)");
- }else{
- $this->log_line('Failed to create course '.$coursecode.' in Moodle');
- }
+ $this->log_line("Created course $coursecode in Moodle (Moodle ID is $course->id)");
}
}elseif($recstatus==3 && ($courseid = $DB->get_field('course', 'id', array('idnumber'=>$coursecode)))){
// If course does exist, but recstatus==3 (delete), then set the course as hidden
$person->confirmed = 1;
$person->timemodified = time();
$person->mnethostid = $CFG->mnet_localhost_id;
- if($id = $DB->insert_record('user', $person)){
+ $id = $DB->insert_record('user', $person);
/*
Photo processing is deactivated until we hear from Moodle dev forum about modification to gdlib.
}
}
*/
- $this->log_line("Created user record for user '$person->username' (ID number $person->idnumber).");
- }else{
- $this->log_line("Database error while trying to create user record for user '$person->username' (ID number $person->idnumber).");
- }
+ $this->log_line("Created user record for user '$person->username' (ID number $person->idnumber).");
}
} elseif ($createnewusers) {
$this->log_line("User record already exists for user '$person->username' (ID number $person->idnumber).");
//if there is no more processors that want to process this we can move message to message_read
if ( $DB->count_records('message_working', array('unreadmessageid' => $messageid)) == 0){
- if ($DB->insert_record('message_read', $savemessage)) {
- $DB->delete_records('message', array('id' => $messageid));
- }
+ $DB->insert_record('message_read', $savemessage);
+ $DB->delete_records('message', array('id' => $messageid));
}
}
$messageid = $message->id;
unset($message->id);
$message->timeread = time();
- if ($DB->insert_record('message_read', $message)) {
- $DB->delete_records('message', array('id'=>$messageid));
- }
+ $DB->insert_record('message_read', $message);
+ $DB->delete_records('message', array('id'=>$messageid));
if ($message->timecreated < $start) {
$start = $message->timecreated; // move start back so that we see all current history
}
$message->timeread = 0; //the message was never read
$messageid = $message->id;
unset($message->id);
- if ($DB->insert_record('message_read', $message)) {
- $DB->delete_records('message', array('id' => $messageid));
- $DB->delete_records('message_working', array('unreadmessageid' => $messageid));
- } else {
- return false;
- }
+ $DB->insert_record('message_read', $message);
+ $DB->delete_records('message', array('id' => $messageid));
+ $DB->delete_records('message_working', array('unreadmessageid' => $messageid));
}
}
return true;
//delete what we've processed and check if can move message
$DB->delete_records('message_working', array('id' => $msgp->id));
if ( $DB->count_records('message_working', array('unreadmessageid'=>$messageid)) == 0){
- if ($DB->insert_record('message_read', $message)) {
- $DB->delete_records('message', array('id' => $messageid));
- }
+ $DB->insert_record('message_read', $message);
+ $DB->delete_records('message', array('id' => $messageid));
}
}
}
//have all message processors completed dealing with this message?
if ( $DB->count_records('message_working', array('unreadmessageid'=>$messageid)) == 0){
- if ($DB->insert_record('message_read', $message)) {
- $DB->delete_records('message', array('id' => $messageid));
- }
+ $DB->insert_record('message_read', $message);
+ $DB->delete_records('message', array('id' => $messageid));
}
}
}
$assignment->timemodified = time();
$assignment->courseid = $assignment->course;
- if ($returnid = $DB->insert_record("assignment", $assignment)) {
- $assignment->id = $returnid;
+ $returnid = $DB->insert_record("assignment", $assignment);
+ $assignment->id = $returnid;
- if ($assignment->timedue) {
- $event = new object();
- $event->name = $assignment->name;
- $event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
- $event->courseid = $assignment->course;
- $event->groupid = 0;
- $event->userid = 0;
- $event->modulename = 'assignment';
- $event->instance = $returnid;
- $event->eventtype = 'due';
- $event->timestart = $assignment->timedue;
- $event->timeduration = 0;
-
- calendar_event::create($event);
- }
-
- assignment_grade_item_update($assignment);
+ if ($assignment->timedue) {
+ $event = new object();
+ $event->name = $assignment->name;
+ $event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
+ $event->courseid = $assignment->course;
+ $event->groupid = 0;
+ $event->userid = 0;
+ $event->modulename = 'assignment';
+ $event->instance = $returnid;
+ $event->eventtype = 'due';
+ $event->timestart = $assignment->timedue;
+ $event->timeduration = 0;
+ calendar_event::create($event);
}
+ assignment_grade_item_update($assignment);
return $returnid;
}
}
//insert answers
- if ($choice->id = $DB->insert_record("choice", $choice)) {
- foreach ($choice->option as $key => $value) {
- $value = trim($value);
- if (isset($value) && $value <> '') {
- $option = new object();
- $option->text = $value;
- $option->choiceid = $choice->id;
- if (isset($choice->limit[$key])) {
- $option->maxanswers = $choice->limit[$key];
- }
- $option->timemodified = time();
- $DB->insert_record("choice_options", $option);
+ $choice->id = $DB->insert_record("choice", $choice);
+ foreach ($choice->option as $key => $value) {
+ $value = trim($value);
+ if (isset($value) && $value <> '') {
+ $option = new object();
+ $option->text = $value;
+ $option->choiceid = $choice->id;
+ if (isset($choice->limit[$key])) {
+ $option->maxanswers = $choice->limit[$key];
}
+ $option->timemodified = time();
+ $DB->insert_record("choice_options", $option);
}
}
+
return $choice->id;
}