有没有办法将用户选择器添加到 moodle 中 activity 模块的设置页面?
Is there way to add a userselector to the settings page of an activity module in moodle?
所以,基本上就是标题所说的。
这是我希望在我的 settings.php 页面中包含的内容:
这是我的解决方法:
$warning = 'Please make sure you have no unsaved changes.';
$link = "</form><a href=".new moodle_url('/mod/game/clear.php')." class='btn btn-danger';>Empty all results</a> <strong style='color: red;'>".$warning."</strong>";
$clear_url = new moodle_url('/mod/game/clear_user_results.php');
$link .= "</br>
<form action='".$clear_url."' class='mt-3' method='POST'>
<div class='input-group rounded'>
<input type='text' class='form-control rounded' placeholder='Search a user' name='userSearch' aria-label='Search' aria-describedby='search-addon'/>
<button class='input-group-text border-0' type='submit'>
<i class='fa fa-search'></i>
</button>
</div>
</form>
";
$settings->add(new admin_setting_heading('modemptydb', get_string('modemptydb', 'game'), $link));
它有效,但我必须输入用户的确切名称,而在第一张图片中它还显示了包含该查询的其他结果。
有办法实现吗?
我已经尝试了这两种方法,但都没有用:
$settings->add(new core_role_admins_existing_selector());
$settings->add(new core_role_check_users_selector());
我是这样做的:
$userselector = new core_role_check_users_selector('reportuser', array());
$userselector->set_rows(20);
$OUTPUT->box_start('generalbox boxwidthnormal boxaligncenter', 'chooseuser');
$selector = "<div class='container'>";
$selector .= "<form method='POST' action='".$clear_url."'>";
$selector .= $userselector->display(true);
$selector .= '<p id="chooseusersubmit"><input type="submit" value="' . get_string('seeuserresults', 'game') . '" ' .
'class="btn btn-primary"/></p>';
'</form>
</div>';
$selector .= $OUTPUT->box_end();
$settings->add(new admin_setting_heading('modemptydb', get_string('modemptydb', 'game'), $link.$selector));
所以,基本上就是标题所说的。
这是我希望在我的 settings.php 页面中包含的内容:
这是我的解决方法:
$warning = 'Please make sure you have no unsaved changes.';
$link = "</form><a href=".new moodle_url('/mod/game/clear.php')." class='btn btn-danger';>Empty all results</a> <strong style='color: red;'>".$warning."</strong>";
$clear_url = new moodle_url('/mod/game/clear_user_results.php');
$link .= "</br>
<form action='".$clear_url."' class='mt-3' method='POST'>
<div class='input-group rounded'>
<input type='text' class='form-control rounded' placeholder='Search a user' name='userSearch' aria-label='Search' aria-describedby='search-addon'/>
<button class='input-group-text border-0' type='submit'>
<i class='fa fa-search'></i>
</button>
</div>
</form>
";
$settings->add(new admin_setting_heading('modemptydb', get_string('modemptydb', 'game'), $link));
它有效,但我必须输入用户的确切名称,而在第一张图片中它还显示了包含该查询的其他结果。
有办法实现吗?
我已经尝试了这两种方法,但都没有用:
$settings->add(new core_role_admins_existing_selector());
$settings->add(new core_role_check_users_selector());
我是这样做的:
$userselector = new core_role_check_users_selector('reportuser', array());
$userselector->set_rows(20);
$OUTPUT->box_start('generalbox boxwidthnormal boxaligncenter', 'chooseuser');
$selector = "<div class='container'>";
$selector .= "<form method='POST' action='".$clear_url."'>";
$selector .= $userselector->display(true);
$selector .= '<p id="chooseusersubmit"><input type="submit" value="' . get_string('seeuserresults', 'game') . '" ' .
'class="btn btn-primary"/></p>';
'</form>
</div>';
$selector .= $OUTPUT->box_end();
$settings->add(new admin_setting_heading('modemptydb', get_string('modemptydb', 'game'), $link.$selector));