community block MDL-24606 add information (waiting alert + expected time) when user...
authorjerome mouneyrac <jerome@moodle.com>
Tue, 12 Oct 2010 07:10:19 +0000 (07:10 +0000)
committerjerome mouneyrac <jerome@moodle.com>
Tue, 12 Oct 2010 07:10:19 +0000 (07:10 +0000)
blocks/community/communitycourse.php
blocks/community/lang/en/block_community.php
blocks/community/renderer.php
blocks/community/styles.css

index c5a391e..4e7af65 100644 (file)
@@ -94,16 +94,28 @@ $huburl = optional_param('huburl', false, PARAM_URL);
 $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);
index 9042cba..eed7d76 100644 (file)
@@ -48,6 +48,10 @@ $string['dorestore'] = 'Yes';
 $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.';
index e5e0542..7ce118d 100644 (file)
@@ -242,7 +242,7 @@ class block_community_renderer extends plugin_renderer_base {
                     $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'));
index f99c3c1..d5360b5 100644 (file)
 #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 {}