/** * Constructor. * * @param stdClass $course The course. * @param stdClass[] $modules The modules. */ public function __construct(stdClass $course, array $modules) { $this->course = $course; $sections = []; $context = context_course::instance($course->id); // Activities. $activities = array_filter($modules, function ($mod) { return $mod->archetype !== MOD_ARCHETYPE_RESOURCE && $mod->archetype !== MOD_ARCHETYPE_SYSTEM; }); if (count($activities)) { $sections[] = new chooser_section('activities', new lang_string('activities'), array_map(function ($module) use($context) { return new modchooser_item($module, $context); }, $activities)); } $resources = array_filter($modules, function ($mod) { return $mod->archetype === MOD_ARCHETYPE_RESOURCE; }); if (count($resources)) { $sections[] = new chooser_section('resources', new lang_string('resources'), array_map(function ($module) use($context) { return new modchooser_item($module, $context); }, $resources)); } $actionurl = new moodle_url('/course/jumpto.php'); $title = new lang_string('addresourceoractivity'); parent::__construct($actionurl, $title, $sections, 'jumplink'); $this->set_instructions(new lang_string('selectmoduletoviewhelp')); $this->add_param('course', $course->id); }
/** * Constructor. * * @param array $real The real question types. * @param array $fake The fake question types. * @param stdClass $course The course. * @param array $hiddenparams Hidden parameters. * @param context $context The relevant context. */ public function __construct($real, $fake, $course, $hiddenparams, $context) { $sections = []; $sections[] = new chooser_section('questions', new lang_string('questions', 'question'), array_map(function ($qtype) use($context) { return new qbank_chooser_item($qtype, $context); }, $real)); $sections[] = new chooser_section('other', new lang_string('other'), array_map(function ($qtype) use($context) { return new qbank_chooser_item($qtype, $context); }, $fake)); parent::__construct(new moodle_url('/question/question.php'), new lang_string('chooseqtypetoadd', 'question'), $sections, 'qtype'); $this->set_instructions(new lang_string('selectaqtypefordescription', 'question')); $this->set_method('get'); $this->add_param('courseid', $course->id); foreach ($hiddenparams as $k => $v) { $this->add_param($k, $v); } }