Minor changes

This commit is contained in:
Mark Nelson 2015-12-06 22:18:04 +08:00
parent e441b7051b
commit 3a63a6e00a
5 changed files with 18 additions and 21 deletions

View file

@ -327,17 +327,17 @@ abstract class customcert_element_base {
public function render_form_element_position($mform) { public function render_form_element_position($mform) {
$mform->addElement('text', 'posx', get_string('posx', 'customcert'), array('size' => 10)); $mform->addElement('text', 'posx', get_string('posx', 'customcert'), array('size' => 10));
$mform->setType('posx', PARAM_INT); $mform->setType('posx', PARAM_INT);
$mform->setDefault('posx', '0'); $mform->setDefault('posx', 0);
$mform->addHelpButton('posx', 'posx', 'customcert'); $mform->addHelpButton('posx', 'posx', 'customcert');
$mform->addElement('text', 'posy', get_string('posy', 'customcert'), array('size' => 10)); $mform->addElement('text', 'posy', get_string('posy', 'customcert'), array('size' => 10));
$mform->setType('posy', PARAM_INT); $mform->setType('posy', PARAM_INT);
$mform->setDefault('posy', '0'); $mform->setDefault('posy', 0);
$mform->addHelpButton('posy', 'posy', 'customcert'); $mform->addHelpButton('posy', 'posy', 'customcert');
$mform->addElement('text', 'width', get_string('elementwidth', 'customcert'), array('size' => 10)); $mform->addElement('text', 'width', get_string('elementwidth', 'customcert'), array('size' => 10));
$mform->setType('width', PARAM_INT); $mform->setType('width', PARAM_INT);
$mform->setDefault('width', ''); $mform->setDefault('width', 0);
$mform->addHelpButton('width', 'elementwidth', 'customcert'); $mform->addHelpButton('width', 'elementwidth', 'customcert');
$refpointoptions = array(); $refpointoptions = array();
@ -347,7 +347,7 @@ abstract class customcert_element_base {
$mform->addElement('select', 'refpoint', get_string('refpoint', 'customcert'), $refpointoptions); $mform->addElement('select', 'refpoint', get_string('refpoint', 'customcert'), $refpointoptions);
$mform->setType('refpoint', PARAM_INT); $mform->setType('refpoint', PARAM_INT);
$mform->setDefault('refpoint', ''); $mform->setDefault('refpoint', CUSTOMCERT_REF_POINT_TOPCENTER);
$mform->addHelpButton('refpoint', 'refpoint', 'customcert'); $mform->addHelpButton('refpoint', 'refpoint', 'customcert');
} }

View file

@ -24,7 +24,6 @@
$string['addcertpage'] = 'Add another certificate page'; $string['addcertpage'] = 'Add another certificate page';
$string['addelement'] = 'Add element'; $string['addelement'] = 'Add element';
$string['applypositions'] = 'Save positions & continue';
$string['awardedto'] = 'Awarded to'; $string['awardedto'] = 'Awarded to';
$string['code'] = 'Code'; $string['code'] = 'Code';
$string['copy'] = 'Copy'; $string['copy'] = 'Copy';
@ -47,8 +46,8 @@ $string['elementname_help'] = 'This will be the name used to identify this eleme
page and will want to distinguish between them quickly when editing the certificate. Note: this will not displayed on the PDF.'; page and will want to distinguish between them quickly when editing the certificate. Note: this will not displayed on the PDF.';
$string['elements'] = 'Elements'; $string['elements'] = 'Elements';
$string['elements_help'] = 'These are the list of elements that will be displayed on this PDF page.'; $string['elements_help'] = 'These are the list of elements that will be displayed on this PDF page.';
$string['elementwidth'] = 'Max width'; $string['elementwidth'] = 'Width';
$string['elementwidth_help'] = 'Specify the maximum width of the element. 0 means no limit.'; $string['elementwidth_help'] = 'Specify the width of the element - \'0\' means that there is no width constraint.';
$string['errorloadingelement'] = 'Error loading the element "{$a}"'; $string['errorloadingelement'] = 'Error loading the element "{$a}"';
$string['errorsavingelement'] = 'Error saving the element "{$a}"'; $string['errorsavingelement'] = 'Error saving the element "{$a}"';
$string['font'] = 'Font'; $string['font'] = 'Font';
@ -65,7 +64,7 @@ $string['invalidcolour'] = 'Invalid colour chosen, please enter a valid HTML col
$string['invalidelementwidth'] = 'Please enter a positive number.'; $string['invalidelementwidth'] = 'Please enter a positive number.';
$string['invalidposition'] = 'Please select a positive number for position {$a}.'; $string['invalidposition'] = 'Please select a positive number for position {$a}.';
$string['invalidheight'] = 'The height has to be a valid number greater than 0.'; $string['invalidheight'] = 'The height has to be a valid number greater than 0.';
$string['invalidmargin'] = 'The margin cannot be a negative number.'; $string['invalidmargin'] = 'The margin has to be a valid number greater than 0.';
$string['invalidwidth'] = 'The width has to be a valid number greater than 0.'; $string['invalidwidth'] = 'The width has to be a valid number greater than 0.';
$string['issued'] = 'Issued'; $string['issued'] = 'Issued';
$string['landscape'] = 'Landscape'; $string['landscape'] = 'Landscape';
@ -99,8 +98,9 @@ $string['refpoint_help'] = 'This specifies which location of the element to be l
$string['replacetemplate'] = 'Replace'; $string['replacetemplate'] = 'Replace';
$string['report'] = 'Report'; $string['report'] = 'Report';
$string['save'] = 'Save'; $string['save'] = 'Save';
$string['saveandclose'] = 'Save and close';
$string['saveandcontinue'] = 'Save and continue';
$string['savechangespreview'] = 'Save changes and preview'; $string['savechangespreview'] = 'Save changes and preview';
$string['savepositions'] = 'Save positions';
$string['savetemplate'] = 'Save template'; $string['savetemplate'] = 'Save template';
$string['setprotection'] = 'Set protection'; $string['setprotection'] = 'Set protection';
$string['setprotection_help'] = 'Choose the actions you wish to prevent users from performing on this certificate.'; $string['setprotection_help'] = 'Choose the actions you wish to prevent users from performing on this certificate.';

View file

@ -55,9 +55,9 @@ $PAGE->requires->js_init_call('M.mod_customcert.rearrange.init', array($cm->id,
// Create the buttons to save the position of the elements. // Create the buttons to save the position of the elements.
$html = html_writer::start_tag('div', array('class' => 'buttons')); $html = html_writer::start_tag('div', array('class' => 'buttons'));
$html .= $OUTPUT->single_button(new moodle_url('/mod/customcert/edit.php', array('cmid' => $cm->id)), $html .= $OUTPUT->single_button(new moodle_url('/mod/customcert/edit.php', array('cmid' => $cm->id)),
get_string('savepositions', 'customcert'), 'get', array('class' => 'savepositionsbtn')); get_string('saveandclose', 'customcert'), 'get', array('class' => 'savepositionsbtn'));
$html .= $OUTPUT->single_button(new moodle_url('/mod/customcert/rearrange.php', array('id' => $pid)), $html .= $OUTPUT->single_button(new moodle_url('/mod/customcert/rearrange.php', array('id' => $pid)),
get_string('applypositions', 'customcert'), 'get', array('class' => 'applypositionsbtn')); get_string('saveandcontinue', 'customcert'), 'get', array('class' => 'applypositionsbtn'));
$html .= $OUTPUT->single_button(new moodle_url('/mod/customcert/edit.php', array('cmid' => $cm->id)), $html .= $OUTPUT->single_button(new moodle_url('/mod/customcert/edit.php', array('cmid' => $cm->id)),
get_string('cancel'), 'get', array('class' => 'cancelbtn')); get_string('cancel'), 'get', array('class' => 'cancelbtn'));
$html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('div');

View file

@ -43,14 +43,11 @@ $elements = $DB->get_records_sql('SELECT * FROM {customcert_elements} e
require_login($course, false, $cm); require_login($course, false, $cm);
require_capability('mod/customcert:manage', $context); require_capability('mod/customcert:manage', $context);
// Loop through the data // Loop through the data.
foreach ($values as $value) { foreach ($values as $value) {
// if (array_key_exists($value->id, $elements)) {
// Perform the update.
$element = new stdClass(); $element = new stdClass();
$element->id = $value->id; $element->id = $value->id;
$element->posx = $value->posx; $element->posx = $value->posx;
$element->posy = $value->posy; $element->posy = $value->posy;
$DB->update_record('customcert_elements', $element); $DB->update_record('customcert_elements', $element);
// }
} }