Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-35603 - Backup - Course import/restore max results

* Unified UI for import and restore course search
  • Loading branch information...
commit 13c708233eb081c7c9a200819a08d6023186e1ab 1 parent 5a2c3ec
@rlorenzo rlorenzo authored rlorenzo committed
View
25 backup/util/ui/renderer.php
@@ -521,6 +521,15 @@ public function render_restore_course_search(restore_course_search $component) {
$url = $component->get_url();
$output = html_writer::start_tag('div', array('class' => 'restore-course-search'));
+
+ $count_str = '';
+ if ($component->has_more_results()) {
+ $count_str = get_string('morecoursesearchresults', 'backup', $component->get_count());
+ } else {
+ $count_str = get_string('totalcoursesearchresults', 'backup', $component->get_count());
+ }
+
+ $output .= html_writer::tag('div', $count_str, array('class'=>'rcs-totalresults'));
$output .= html_writer::start_tag('div', array('class' => 'rcs-results'));
$table = new html_table();
@@ -590,8 +599,14 @@ public function render_import_course_search(import_course_search $component) {
return $output;
}
- $output .= html_writer::tag('div', get_string('totalcoursesearchresults', 'backup', $component->get_count()), array('class'=>'ics-totalresults'));
+ $count_str = '';
+ if ($component->has_more_results()) {
+ $count_str = get_string('morecoursesearchresults', 'backup', $component->get_count());
+ } else {
+ $count_str = get_string('totalcoursesearchresults', 'backup', $component->get_count());
+ }
+ $output .= html_writer::tag('div', $count_str, array('class'=>'ics-totalresults'));
$output .= html_writer::start_tag('div', array('class' => 'ics-results'));
$table = new html_table();
@@ -610,6 +625,14 @@ public function render_import_course_search(import_course_search $component) {
);
$table->data[] = $row;
}
+ if ($component->has_more_results()) {
+ $cell = new html_table_cell(get_string('moreresults', 'backup'));
+ $cell->colspan = 3;
+ $cell->attributes['class'] = 'notifyproblem';
+ $row = new html_table_row(array($cell));
+ $row->attributes['class'] = 'rcs-course';
+ $table->data[] = $row;
+ }
$output .= html_writer::table($table);
$output .= html_writer::end_tag('div');
View
21 backup/util/ui/restore_ui_components.php
@@ -65,6 +65,11 @@
* @var array
*/
private $requiredcapabilities = array();
+ /**
+ * Indicates if we have more than maxresults found.
+ * @var boolean
+ */
+ private $has_more_results = false;
/**
* Constructor
@@ -177,7 +182,7 @@ public function __construct(array $config=array()) {
foreach ($this->requiredcapabilities as $cap) {
$requiredcaps[] = $cap['capability'];
}
- // Iterate while we have records and haven't reached MAXRESULTS
+ // Iterate while we have records and haven't reached $this->maxresults.
while ($totalcourses > $offs and $this->totalcount < self::$MAXRESULTS) {
$resultset = $DB->get_records_sql($sql, $params, $offs, $blocksz);
foreach ($resultset as $result) {
@@ -188,11 +193,14 @@ public function __construct(array $config=array()) {
continue;
}
}
- $this->results[$result->id] = $result;
- $this->totalcount++;
- if ($this->totalcount >= self::$MAXRESULTS) {
+ // Check if we are over the limit.
+ if ($this->totalcount+1 > self::$MAXRESULTS) {
+ $this->has_more_results = true;
break;
}
+ // If not, then continue.
+ $this->totalcount++;
+ $this->results[$result->id] = $result;
}
$offs += $blocksz;
}
@@ -201,7 +209,10 @@ public function __construct(array $config=array()) {
}
final public function has_more_results() {
- return $this->get_count() >= self::$MAXRESULTS;
+ if ($this->results === null) {
+ $this->search();
+ }
+ return $this->has_more_results;
}
/**
View
1  lang/en/backup.php
@@ -240,3 +240,4 @@
$string['setting_keep_groups_and_groupings'] = 'Keep current groups and groupings';
$string['totalcategorysearchresults'] = 'Total categories: {$a}';
$string['totalcoursesearchresults'] = 'Total courses: {$a}';
+$string['morecoursesearchresults'] = 'More than {$a} courses found, showing first {$a} results';
Please sign in to comment.
Something went wrong with that request. Please try again.