Skip to content
Browse files

MDL-26353 Database activity module: display help icon with the new he…

…lp strings

This commit makes the new strings added by Helen used at the Import
entries page. Note that the syntax of the strings had to be fixed as
there must not be leading whitespace before the asterisk in Markdown format.

Also as requested by Helen, the wording or export/import links is
improved now.

As a bonus for free, the patch fixes incorrect API usage of get_record()
and friends.
  • Loading branch information...
1 parent 76179aa commit dd8ab1fb4a1aa3408db327d66046c3080d605a47 @mudrd8mz mudrd8mz committed Feb 11, 2011
Showing with 16 additions and 27 deletions.
  1. +1 −1 mod/data/export_form.php
  2. +8 −20 mod/data/import.php
  3. +5 −4 mod/data/lang/en/data.php
  4. +2 −2 mod/data/lib.php
View
2 mod/data/export_form.php
@@ -55,7 +55,7 @@ function definition() {
}
}
$this->add_checkbox_controller(1, null, null, 1);
- $this->add_action_buttons(true, get_string('exportdatabaserecords', 'data'));
+ $this->add_action_buttons(true, get_string('exportentries', 'data'));
}
}
View
28 mod/data/import.php
@@ -48,28 +48,16 @@
if ($id) {
$url->param('id', $id);
$PAGE->set_url($url);
- if (! $cm = get_coursemodule_from_id('data', $id)) {
- print_error('invalidcoursemodule');
- }
- if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
- print_error('coursemisconf');
- }
- if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) {
- print_error('invalidcoursemodule');
- }
+ $cm = get_coursemodule_from_id('data', $id, 0, false, MUST_EXIST);
+ $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
+ $data = $DB->get_record('data', array('id'=>$cm->instance), '*', MUST_EXIST);
} else {
$url->param('d', $d);
$PAGE->set_url($url);
- if (! $data = $DB->get_record('data', array('id'=>$d))) {
- print_error('invalidid', 'data');
- }
- if (! $course = $DB->get_record('course', array('id'=>$data->course))) {
- print_error('coursemisconf');
- }
- if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
- print_error('coursemisconf');
- }
+ $data = $DB->get_record('data', array('id'=>$d), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id'=>$data->course), '*', MUST_EXIST);
+ $cm = get_coursemodule_from_instance('data', $data->id, $course->id, false, MUST_EXIST);
}
require_login($course, false, $cm);
@@ -82,8 +70,9 @@
$PAGE->navbar->add(get_string('add', 'data'));
$PAGE->set_title($data->name);
$PAGE->set_heading($course->fullname);
+navigation_node::override_active_url(new moodle_url('/mod/data/import.php', array('d' => $data->id)));
echo $OUTPUT->header();
-echo $OUTPUT->heading(format_string($data->name));
+echo $OUTPUT->heading_with_help(get_string('uploadrecords', 'mod_data'), 'uploadrecords', 'mod_data');
/// Groups needed for Add entry tab
$currentgroup = groups_get_activity_group($cm);
@@ -93,7 +82,6 @@
/// Upload records section. Only for teachers and the admin.
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
require_once('import_form.php');
- echo $OUTPUT->heading(get_string('uploadrecords', 'data'), 3);
$form = new mod_data_import_form(new moodle_url('/mod/data/import.php'));
$formdata = new stdClass();
$formdata->d = $data->id;
View
9 mod/data/lang/en/data.php
@@ -122,8 +122,8 @@
$string['export'] = 'Export';
$string['exportaszip'] = 'Export as zip';
$string['exportaszip_help'] = 'The export as zip feature allows you to save the templates and fields as a preset zip for download. The zip may then be imported to another course.';
-$string['exportdatabaserecords'] = 'Export database records';
$string['exportedtozip'] = 'Exported to temporary zip...';
+$string['exportentries'] = 'Export entries';
$string['exportownentries'] = 'Export your own entries only? ({$a->mine}/{$a->all})';
$string['failedpresetdelete'] = 'Error deleting a preset!';
$string['fieldadded'] = 'Field added';
@@ -170,6 +170,7 @@
$string['chooseexportformat'] = 'Choose the format you wish to export to:';
$string['chooseorupload'] = 'Choose file';
$string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available';
+$string['importentries'] = 'Import entries';
$string['importsuccess'] = 'The preset has been successfully applied.';
$string['insufficiententries'] = 'more entries needed to view this database';
$string['intro'] = 'Introduction';
@@ -309,9 +310,9 @@
$string['uploadrecords'] = 'Upload entries from a file';
$string['uploadrecords_help'] = 'Entries may be uploaded via text file. The format of the file should be as follows:
- * Each line of the file contains one record
- * Each record is a series of data separated by commas (or other delimiters)
- * The first record contains a list of fieldnames defining the format of the rest of the file
+* Each line of the file contains one record
+* Each record is a series of data separated by commas (or other delimiters)
+* The first record contains a list of fieldnames defining the format of the rest of the file
The field enclosure is a character that surrounds each field in each record. It can normally be left unset.';
$string['uploadrecords_link'] = 'mod/data/import';
View
4 mod/data/lib.php
@@ -2848,10 +2848,10 @@ function data_extend_settings_navigation(settings_navigation $settings, navigati
if (has_capability(DATA_CAP_EXPORT, $PAGE->cm->context)) {
// The capability required to Export database records is centrally defined in 'lib.php'
// and should be weaker than those required to edit Templates, Fields and Presets.
- $datanode->add(get_string('export', 'data'), new moodle_url('/mod/data/export.php', array('d'=>$data->id)));
+ $datanode->add(get_string('exportentries', 'data'), new moodle_url('/mod/data/export.php', array('d'=>$data->id)));
}
if (has_capability('mod/data:manageentries', $PAGE->cm->context)) {
- $datanode->add(get_string('import'), new moodle_url('/mod/data/import.php', array('d'=>$data->id)));
+ $datanode->add(get_string('importentries', 'data'), new moodle_url('/mod/data/import.php', array('d'=>$data->id)));
}
if (has_capability('mod/data:managetemplates', $PAGE->cm->context)) {

0 comments on commit dd8ab1f

Please sign in to comment.
Something went wrong with that request. Please try again.