简体   繁体   English

在Moodle表单中设置默认值

[英]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. 在我们的Moodle安装中,有一个插件Assignemnt ,在这里我们可以获得课程中所有参与者的列表 ,因此我们可以根据任务对他们进行评分。 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. 中有默认总是表现出10人,并有选项,在这里我们可以选择查看全部一次,10,20,50100每页。

The code is in gradingoptionsform.php: 代码在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. 我尝试使用$mform-setDefault('perpage', 'all')但是没有用。

What I am missing? 我缺少什么?

In gradingtable.php there is: gradingtable.php有:

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. 编辑:似乎此设置被php代码覆盖。 Search in mod/assign/locallib.php : 在mod / assign / locallib.php中搜索:

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

Change is to: 更改为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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