Delete courses

@param array $courseids A list of course ids
@since Moodle 2.2
498510
public static function delete_courses($courseids) {
        global $CFG, $DB;
        require_once($CFG->dirroot."/course/lib.php");

        // Parameter validation.
        $params = self::validate_parameters(self::delete_courses_parameters(), array('courseids'=>$courseids));

        $warnings = array();

        foreach ($params['courseids'] as $courseid) {
            $course = $DB->get_record('course', array('id' => $courseid));

            if ($course === false) {
                $warnings[] = array(
                                'item' => 'course',
                                'itemid' => $courseid,
                                'warningcode' => 'unknowncourseidnumber',
                                'message' => 'Unknown course ID ' . $courseid
                            );
                continue;
            }

            // Check if the context is valid.
            $coursecontext = context_course::instance($course->id);
            self::validate_context($coursecontext);

            // Check if the current user has permission.
            if (!can_delete_course($courseid)) {
                $warnings[] = array(
                                'item' => 'course',
                                'itemid' => $courseid,
                                'warningcode' => 'cannotdeletecourse',
                                'message' => 'You do not have the permission to delete this course' . $courseid
                            );
                continue;
            }

            if (delete_course($course, false) === false) {
                $warnings[] = array(
                                'item' => 'course',
                                'itemid' => $courseid,
                                'warningcode' => 'cannotdeletecategorycourse',
                                'message' => 'Course ' . $courseid . ' failed to be deleted'
                            );
                continue;
            }
        }

        fix_course_sortorder();

        return array('warnings' => $warnings);
    }
914342
def clear_courses(self):
        
        # Implemented from template for osid.learning.ActivityForm.clear_assets_template
        if (self.get_courses_metadata().is_read_only() or
                self.get_courses_metadata().is_required()):
            raise errors.NoAccess()
        self._my_map['courseIds'] = self._courses_default
1120124
public static function delete_multiple_relations($competencyids) {
        global $DB;
        if (empty($competencyids)) {
            return true;
        }

        list($insql, $params) = $DB->get_in_or_equal($competencyids);
        return $DB->delete_records_select(self::TABLE,
                                            "competencyid $insql OR relatedcompetencyid $insql",
                                            array_merge($params, $params)
                                            );
    }
831971
public function deletePictures($ids)
    {
        $pictures = $this->pictures()->whereIn('id', $ids)->get();

        $pictures->each(function ($item) {
            $item->delete();
        });
    }
848283
public function deleteForce(array $userIds): void
    {
        $deleted = $this->getRepository()->deleteForce($userIds);

        event(new HCUserForceDeleted($deleted));
    }
1260520
protected function delete_dimensions(array $ids) {
        global $DB, $PAGE;

        $fs = get_file_storage();
        foreach ($ids as $id) {
            if (!empty($id)) {   // to prevent accidental removal of all files in the area
                $fs->delete_area_files($PAGE->context->id, 'workshopform_accumulative', 'description', $id);
            }
        }
        $DB->delete_records_list('workshopform_accumulative', 'id', $ids);
    }
320274
protected function removeIds(array $recipeIds): void
    {
        // First delete the ingredients...
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->delete(RecipeIngredient::class, 'ri')
                     ->andWhere('ri.recipe IN (:recipeIds)')
                     ->setParameter('recipeIds', array_values($recipeIds));
        $queryBuilder->getQuery()->execute();

        // ... and the products.
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->delete(RecipeProduct::class, 'rp')
                     ->andWhere('rp.recipe IN (:recipeIds)')
                     ->setParameter('recipeIds', array_values($recipeIds));
        $queryBuilder->getQuery()->execute();

        // And finally the recipes itself.
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->delete(Recipe::class, 'r')
                     ->andWhere('r.id IN (:recipeIds)')
                     ->setParameter('recipeIds', array_values($recipeIds));

        $queryBuilder->getQuery()->execute();
    }
748622
public function get_course_ids($categories) {
        $courseids = array();
        foreach ($categories as $key=>$cat) {
            $courseids[$key] = $cat->course;
            if (!empty($cat->children)) {
                $courseids = array_merge($courseids, $this->get_course_ids($cat->children));
            }
        }
        return $courseids;
    }
275184
public function delete($ids) {
		if (URequest::isAjax ()) {
			$instance = $this->getModelInstance ( $ids );
			$instanceString = $this->getInstanceToString ( $instance );
			if (sizeof ( $_POST ) > 0) {
				try {
					if (DAO::remove ( $instance )) {
						$message = new CRUDMessage ( "Deletion of `<b>" . $instanceString . "</b>`", "Deletion", "info", "info circle", 4000 );
						$message = $this->_getEvents ()->onSuccessDeleteMessage ( $message, $instance );
						$this->jquery->exec ( "$('._element[data-ajax={$ids}]').remove();", true );
					} else {
						$message = new CRUDMessage ( "Can not delete `" . $instanceString . "`", "Deletion", "warning", "warning circle" );
						$message = $this->_getEvents ()->onErrorDeleteMessage ( $message, $instance );
					}
				} catch ( \Exception $e ) {
					$message = new CRUDMessage ( "Exception : can not delete `" . $instanceString . "`", "Exception", "warning", "warning" );
					$message = $this->_getEvents ()->onErrorDeleteMessage ( $message, $instance );
				}
				$message = $this->_showSimpleMessage ( $message );
			} else {
				$message = new CRUDMessage ( "Do you confirm the deletion of `<b>" . $instanceString . "</b>`?", "Remove confirmation", "error", "question circle" );
				$message = $this->_getEvents ()->onConfDeleteMessage ( $message, $instance );
				$message = $this->_showConfMessage ( $message, $this->_getBaseRoute () . "/delete/{$ids}", "#table-messages", $ids );
			}
			echo $message;
			echo $this->jquery->compile ( $this->view );
		} else {
			$this->jquery->execAtLast ( "$('._delete[data-ajax={$ids}]').trigger('click');" );
			$this->index ();
		}
	}
1178217
def delete_course(self, courseid):
        
        # Wipes the course (delete database)
        self.wipe_course(courseid)

        # Deletes the course from the factory (entire folder)
        self.course_factory.delete_course(courseid)

        # Removes backup
        filepath = os.path.join(self.backup_dir, courseid)
        if os.path.exists(os.path.dirname(filepath)):
            for backup in glob.glob(os.path.join(filepath, '*.zip')):
                os.remove(backup)

        self._logger.info("Course %s files erased.", courseid)
268563
public function deleteByIds($ids)
    {
        $qb = $this->createQueryBuilder('filter')->delete()->where(
            'filter.id IN (:ids)'
        )->setParameter('ids', $ids);
        $qb->getQuery()->execute();
    }
1031227
public static function hook_course_deleted(stdClass $course) {
        global $DB;
        $DB->delete_records(course_competency::TABLE, array('courseid' => $course->id));
        $DB->delete_records(course_competency_settings::TABLE, array('courseid' => $course->id));
        $DB->delete_records(user_competency_course::TABLE, array('courseid' => $course->id));
    }
628050
public function deleteAssignment($ruleId, $assignmentId)
    {
        return $this->client->delete("/validation-rules/" . rawurlencode($ruleId) . "/assignments/" . rawurlencode($assignmentId));
    }
117572
public function deleteEvents(array $eventIds)
    {
        $connection = $this->getConnection();
        $connection->delete($this->getMainTable(), $connection->quoteInto('event_id IN(?)', $eventIds));
    }
6240
private function DeleteOldGroups(array $selGroupIDs)
    {
        $tblMmg = MemberMembergroup::Schema()->Table();
        $sql = Access::SqlBuilder();
        $where = $sql->Equals($tblMmg->Field('Member'), $sql->Value($this->member->GetID()));
        if (count($selGroupIDs) > 0)
        {
            $selectedList = $sql->InListFromValues($selGroupIDs);
            $where = $where->And_($sql->NotIn($tblMmg->Field('MemberGroup'), $selectedList));
        }
        MemberMembergroup::Schema()->Delete($where);
    }
1086359
public function deleteRoles(array $ids): void
	{
		if ($this->isAjax()) {
			$roles = $this->orm->aclRoles->findById($ids);
			foreach ($roles as $role) {
				$this->orm->aclRoles->remove($role);
			}
			$this->orm->flush();
			$this['permissionsList']->reload();
		} else {
			$this->terminate();
		}
	}
1228168
public function deleteItems( array $ids )
	{
		if( empty( $ids ) ) { return; }

		foreach( $this->_getSubManagers() as $submanager ) {
			$submanager->deleteItems( $ids );
		}

		$path = 'mshop/catalog/manager/index/catalog/default/item/delete';
		$this->_deleteItems( $ids, $this->_getContext()->getConfig()->get( $path, $path ), true, 'prodid' );
	}