简体   繁体   中英

Set default value in Moodle form

In our Moodle installation there is the plugin Assignemnt , where we get the list with all participants in the course, so we can grade them, based on the assignment. In the table there are by default always shown 10 people and there are the options, where we can choose to see all at once, 10 , 20 , 50 or 100 per page.

The code is in gradingoptionsform.php:

 $options = array(-1=>get_string('all'), 10=>'10', 20=>'20', 50=>'50', 100=>'100');
 $mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options, $dirtyclass);

I tried with $mform-setDefault('perpage', 'all') but it didn't worked.

What I am missing?

In gradingtable.php there is:

class assign_grading_table extends table_sql implements renderable {
    /** @var assign $assignment */
    private $assignment = null;
    /** @var int $perpage */
    private $perpage = 10;  

Which doesn't seem to have any influence on the default value?

Try to set:

$mform->setDefault('perpage', -1);

EDIT: It seems that this setting gets overwritten by php code. Search in mod/assign/locallib.php :

$perpage = get_user_preferences('assign_perpage', 10);

Change is to:

$perpage = get_user_preferences('assign_perpage', -1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM