Skip to content

Commit

Permalink
community block MDL-24606 add information (waiting alert + expected t…
Browse files Browse the repository at this point in the history
…ime) when user downloads a course from community block
  • Loading branch information
mouneyrac committed Oct 12, 2010
1 parent 1e72829 commit 19eb73c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
16 changes: 14 additions & 2 deletions blocks/community/communitycourse.php
Expand Up @@ -94,16 +94,28 @@
$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);
Expand Down
4 changes: 4 additions & 0 deletions blocks/community/lang/en/block_community.php
Expand Up @@ -48,6 +48,10 @@
$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.';
Expand Down
2 changes: 1 addition & 1 deletion blocks/community/renderer.php
Expand Up @@ -242,7 +242,7 @@ public function course_list($courses, $huburl, $contextcourseid) {
$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'));
Expand Down
1 change: 1 addition & 0 deletions blocks/community/styles.css
Expand Up @@ -152,3 +152,4 @@
#page-blocks-community-communitycourse .hubrateandcomment { font-size: 80%;}
#page-blocks-community-communitycourse .hubcourseoutcomes {}
#page-blocks-community-communitycourse .nextlink {text-align: center;margin-top: 6px;}
#page-blocks-community-communitycourse .textinfo {}

0 comments on commit 19eb73c

Please sign in to comment.