mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Merge branch 'MDL-59627-master' of git://github.com/jleyva/moodle
This commit is contained in:
commit
396b97b2fb
@ -1006,15 +1006,17 @@ function data_search_entries($data, $cm, $context, $mode, $currentgroup, $search
|
||||
|
||||
$recordids = data_get_all_recordids($data->id, $initialselect, $initialparams);
|
||||
$newrecordids = data_get_advance_search_ids($recordids, $searcharray, $data->id);
|
||||
$totalcount = count($newrecordids);
|
||||
$selectdata = $where . $groupselect . $approveselect;
|
||||
|
||||
if (!empty($advanced)) {
|
||||
$advancedsearchsql = data_get_advanced_search_sql($sort, $data, $newrecordids, $selectdata, $sortorder);
|
||||
$sqlselect = $advancedsearchsql['sql'];
|
||||
$allparams = array_merge($allparams, $advancedsearchsql['params']);
|
||||
$totalcount = count($newrecordids);
|
||||
} else {
|
||||
$sqlselect = "SELECT $what $fromsql $sortorder";
|
||||
$sqlcountselect = "SELECT $count $fromsql $sortorder";
|
||||
$totalcount = $DB->count_records_sql($sqlcountselect, $allparams);
|
||||
}
|
||||
|
||||
// Work out the paging numbers and counts.
|
||||
|
@ -666,8 +666,20 @@ class mod_data_external_testcase extends externallib_advanced_testcase {
|
||||
global $DB;
|
||||
list($entry11, $entry12, $entry13, $entry21) = self::populate_database_with_entries();
|
||||
|
||||
// First do a normal text search as student 1. I should see my two group entries.
|
||||
$this->setUser($this->student1);
|
||||
// Empty search, it should return all the visible entries.
|
||||
$result = mod_data_external::search_entries($this->database->id, 0, false);
|
||||
$result = external_api::clean_returnvalue(mod_data_external::search_entries_returns(), $result);
|
||||
$this->assertCount(2, $result['entries']);
|
||||
$this->assertEquals(2, $result['totalcount']);
|
||||
|
||||
// Search for something that does not exists.
|
||||
$result = mod_data_external::search_entries($this->database->id, 0, false, 'abc');
|
||||
$result = external_api::clean_returnvalue(mod_data_external::search_entries_returns(), $result);
|
||||
$this->assertCount(0, $result['entries']);
|
||||
$this->assertEquals(0, $result['totalcount']);
|
||||
|
||||
// Search by text matching all the entries.
|
||||
$result = mod_data_external::search_entries($this->database->id, 0, false, 'text');
|
||||
$result = external_api::clean_returnvalue(mod_data_external::search_entries_returns(), $result);
|
||||
$this->assertCount(2, $result['entries']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user