We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
As for the category-import and category-export commands in the past (see issue #392), there is a bug in the category-move command.
Moosh version : 1.14 and before Moodle Version : 4.1.x
Actual behaviour : see error message in issue #392 (the same with referee to coursecatlib library which no more exists)
Usage of course/renderer.php and core_course_category:: resolves this problem. See correction below for the 'CategoryMove.php' script ...
`<?php namespace Moosh\Command\Moodle39\Category; use Moosh\MooshCommand; //use coursecat; use core_course_category;
class CategoryMove extends MooshCommand { public function __construct() { parent::__construct('move', 'category');
$this->addArgument('category_id'); $this->addArgument('destination_category_id'); $this->maxArguments = 2; } public function execute() { global $DB; list($categoryid, $destcategoryid) = $this->arguments; if (!$cattomove = $DB->get_record('course_categories', array('id'=>$categoryid))) { cli_error("No category with id '$categoryid' found"); } if ($cattomove->parent != $destcategoryid) { if ($destcategoryid == 0) { $newparent = new \stdClass; $newparent->id = 0; $newparent->visible = 1; } else if (!$newparent = $DB->get_record('course_categories', array('id'=>$destcategoryid))) { cli_error("No destination category with id '$destcategoryid' found"); } $this->move_category($cattomove, $newparent); } } protected function move_category($category, $destcategory) { global $CFG; //require_once $CFG->libdir . '/coursecatlib.php'; require_once $CFG->dirroot . '/course/renderer.php'; //return coursecat::get($category->id)->change_parent($destcategory->id); return core_course_category::get($category->id)->change_parent($destcategory->id); } protected function getArgumentsHelp() { return parent::getArgumentsHelp() . "\n\t* To make a category a top-level category, specify 0 for the destination_category_id."; }
}`
It will be nice to correct this in the future versions of Moosh.
Thanks
Olivier L.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello,
As for the category-import and category-export commands in the past (see issue #392), there is a bug in the category-move command.
Moosh version : 1.14 and before
Moodle Version : 4.1.x
Actual behaviour : see error message in issue #392 (the same with referee to coursecatlib library which no more exists)
Usage of course/renderer.php and core_course_category:: resolves this problem. See correction below for the 'CategoryMove.php' script ...
`<?php
namespace Moosh\Command\Moodle39\Category;
use Moosh\MooshCommand;
//use coursecat;
use core_course_category;
class CategoryMove extends MooshCommand
{
public function __construct()
{
parent::__construct('move', 'category');
}`
It will be nice to correct this in the future versions of Moosh.
Thanks
Olivier L.
The text was updated successfully, but these errors were encountered: