Course usage logs - set the default to All Days, not to Today

Course usage logs - set the default to All Days, not to Today

by Tony Delahunty -
Number of replies: 3

Juts wondering if anyone can help me find the right bit of code to tweak here.

I want the display page for course logs [course--> Report-->  Logs] to have the initial default (selected) option in that dropdown box to be 'All days' not today's date; I'm sure it's just a simple change, but I'm fiddling around with it in the dark at the moment, so it would be very helpful if someone could point me to the relevant function/line of code (probably in ...\report\log\locallib.php by the look of it)

Average of ratings: -
In reply to Tony Delahunty

Re: Course usage logs - set the default to All Days, not to Today

by lior gil -
Picture of Core developers

The default is set with a variable $selecteddate but I wouldn't suggest changing it.

Instead, you can change the call to the function that builds the select element
in file \course\report\log\lib.php

just change the original line:
choose_from_menu ($dates, "date", $selecteddate, get_string("alldays"));

To:
choose_from_menu ($dates, "date", '0', get_string("alldays"));

In reply to lior gil

Re: Course usage logs - set the default to All Days, not to Today

by Timothy Takemoto -

Thanks Lior, was useful. I thought it would solve my problem.

I am trying to set a default menu position in an old version of moodle.

I have more and more categories of questions.

Since the default position of the menu on category.php (set in category_class.php)
is "Top", when I add a new category I have to scroll through tens or hundreds ofcategories, to get to my recent additions, which are generally in numerical order.

So I tried changing this line

 $row['parent'] = choose_from_menu ($viableparents, "newparent", $this->str->top, "", "", "", true);
to
 $row['parent'] = choose_from_menu ($viableparents, "newparent", end($viableparents), "", "", "", true);

but no change

However,
 $row['parent'] = choose_from_menu ($viableparents, "newparent", end($viableparents), end($viableparents), "", "", true);

did result in the last category being desplayed, but as a replica of the last category, at the top of the menu.

I would like to start the menu at the bottom of the menu. Perhaps this is just impossible.

Better still it would be nice if it displayed the last parent category that i used in similar way to the way in which the import screen shows the last category imported to using
the following code (in my ancient moodle).

    if ($categoryid) { // update category in session variable
        $SESSION->questioncat = $categoryid;
    } else { // try to get category from modform
        $showcatmenu = true; // will ensure that user can choose category
        if (isset($SESSION->questioncat)) {
            $categoryid = $SESSION->questioncat;
        }
    }


Tim

 

In reply to Timothy Takemoto

Re: Course usage logs - set the default to All Days, not to Today

by lior gil -
Picture of Core developers

$viableparents is built as $value => $label

When you call the function you set the selected value, but you used end($viableparents), which is the label. It should be someting like:

end($viableparents);
$sel = key($arr);

Regarding the other part, if the key in the array is the category id, you can simply use $categoryid instead of $sel