Resource drop down box ?

Resource drop down box ?

by Vitor Gonçalves -
Number of replies: 0

I need a drop down box with the name of all resources and activities in one course.

For resources, I tried to do something similar to the drop down box of course categories ( Edit course settings).

In mymodule/lib.php:

function mymodule_make_resources_list(&$list, &$parents, $resource=NULL, $path="") {
// initialize the arrays if needed
if (!is_array($list)) {
$list = array();
}
if (!is_array($parents)) {
$parents = array();
}
if ($resource) {
if ($path) {
$path = $path.' / '.$resource->name;
} else {
$path = $resource->name;
}
$list[$resource->id] = $path;
} else {
$resource->id = 0;
}
if ($resources = get_resources($resource->id)) {
foreach ($resources as $res) {
if (!empty($resource->id)) {
if (isset($parents[$resource->id])) {
$parents[$cat->id] = $parents[$resource->id];
}
$parents[$res->id][] = $resource->id;
}
mymodule_make_resources_list($list, $parents, $res, $path);
}
}
}

In mymodule/mod.html:

<tr valign="top">
<td> print_string("resource") ?>:</td>
<td><?php
$displaylist = array();
$parentlist = array();
mymodule _make_resources_list($displaylist, $parentlist);
choose_from_menu($displaylist, "resource", "$form->resource", "");
helpbutton("metadatadcresource", get_string("resource"));
?>
</td>
</tr>

But in browser:

Fatal error : Call to undefined function mymodule _make_resources_list() in C:\Apachefriends\xampp\htdocs\moodle\mod\ mymodule \mod.html on line 85

I also tried only this code in mod.html:

<select name="resource"><option value="<?php p($form->resource) ?>">
<?php
$allresources = get_records_sql("SELECT name FROM {$CFG->prefix}resource ORDER BY name ASC");
choose_from_menu($allresources, "resource", $form->resource, "");
?>
</select>

But no options appear in drop down box :-|

Anyone help me how to do this ?

Thanks

Average of ratings: -