$download = optional_param('download', -1, PARAM_INTEGER);
$downloadcourseid = optional_param('downloadcourseid', '', PARAM_INTEGER);
$coursefullname = optional_param('coursefullname', '', PARAM_ALPHANUMEXT);
+$backupsize = optional_param('backupsize', 0, PARAM_INT);
if ($usercandownload and $download != -1 and !empty($downloadcourseid) and confirm_sesskey()) {
$course = new stdClass();
$course->fullname = $coursefullname;
$course->id = $downloadcourseid;
$course->huburl = $huburl;
- $filenames = $communitymanager->block_community_download_course_backup($course);
//OUTPUT: display restore choice page
echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('restorecourse', 'block_community'), 3, 'main');
+ echo $OUTPUT->heading(get_string('downloadingcourse', 'block_community'), 3, 'main');
+ echo html_writer::tag('div', get_string('downloading', 'block_community'),
+ array('class' => 'textinfo'));
+ $sizeinfo = new stdClass();
+ $sizeinfo->total = $backupsize / 1000000;
+ $sizeinfo->modem = (int) ($backupsize / 5000);
+ $sizeinfo->dsl = (int) $sizeinfo->total;
+ echo html_writer::tag('div', get_string('downloadingsize', 'block_community', $sizeinfo),
+ array('class' => 'textinfo'));
+ flush();
+ echo html_writer::tag('div', get_string('downloaded', 'block_community'),
+ array('class' => 'textinfo'));
+ $filenames = $communitymanager->block_community_download_course_backup($course);
echo $OUTPUT->notification(get_string('downloadconfirmed', 'block_community',
'/downloaded_backup/' . $filenames['privatefile']), 'notifysuccess');
echo $renderer->restore_confirmation_box($filenames['tmpfile'], $context);
$string['download'] = 'Download';
$string['downloadable'] = 'courses I can download';
$string['downloadconfirmed'] = 'The backup has been saved in your private files {$a}';
+$string['downloaded'] = '...finished.';
+$string['downloading'] = 'Do not refresh your browser ! The site is downloading the course backup...';
+$string['downloadingcourse'] = 'Downloading course';
+$string['downloadingsize'] = 'Downloading the backup ({$a->total}Mb) should take approximately between {$a->dsl}s and {$a->modem}s, depending on the site/hub connection...';
$string['downloadtemplate'] = 'Create course from template';
$string['educationallevel'] = 'Educational level';
$string['educationallevel_help'] = 'What educational level are you searching for? In the case of communities of educators, this level describes the level they are teaching.';
$params = array('sesskey' => sesskey(), 'download' => 1, 'confirmed' => 1,
'remotemoodleurl' => $CFG->wwwroot, 'courseid' => $contextcourseid,
'downloadcourseid' => $course->id, 'huburl' => $huburl,
- 'coursefullname' => $course->fullname);
+ 'coursefullname' => $course->fullname, 'backupsize' => $course->backupsize);
$downloadurl = new moodle_url("/blocks/community/communitycourse.php", $params);
$downloadbuttonhtml = html_writer::tag('a', get_string('download', 'block_community'),
array('href' => $downloadurl, 'class' => 'centeredbutton, hubcoursedownload'));