Skip to content

Commit

Permalink
MDL-26353 Database activity module: display help icon with the new he…
Browse files Browse the repository at this point in the history
…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
mudrd8mz committed Feb 11, 2011
1 parent 76179aa commit dd8ab1f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion mod/data/export_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

}
Expand Down
28 changes: 8 additions & 20 deletions mod/data/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions mod/data/lang/en/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions mod/data/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit dd8ab1f

Please sign in to comment.