Skip to content

Commit

Permalink
Fixed the missing data source issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasanthlmsace committed May 8, 2024
1 parent a9634b4 commit e5ea22e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions block_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ public function get_content() {
try {
$bb = block_builder::create($this);

if (!$bb->get_configuration()){
return $this->content->text = get_string('missingdatasource', 'block_dash');
}

$datasource = $bb->get_configuration()->get_data_source();
// Conditionally hide the block when empty.
if ($datasource && isset($this->config->hide_when_empty) && $this->config->hide_when_empty
Expand Down
2 changes: 1 addition & 1 deletion classes/local/configuration/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function create_from_instance(\block_base $blockinstance) {
if (isset($blockinstance->config->data_source_idnumber)) {
if (!$datasource = data_source_factory::build_data_source($blockinstance->config->data_source_idnumber,
$parentcontext)) {
throw new \coding_exception('Missing data source.');
return false;
}

if (isset($blockinstance->config->preferences)
Expand Down
7 changes: 4 additions & 3 deletions edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public function add_datasource_group(&$mform, $config) {
} else {
$label = get_string('datasourcemissing', 'block_dash');
}
$datalabel = ($ds->is_widget()
? get_string('widget', 'block_dash') : get_string('datasource', 'block_dash'));
$datalabel = ($ds && $ds->is_widget())
? get_string('widget', 'block_dash') : get_string('datasource', 'block_dash');

$mform->addElement('static', 'data_source_label', $datalabel.' : ', $label);
}
Expand Down Expand Up @@ -279,7 +279,8 @@ public static function dash_features_list(&$mform, $context, $page) {
$widgets[] = $mform->createElement('html', html_writer::start_div('datasource-item'));
$widgets[] = $mform->createElement('radio', 'config_data_source_idnumber', '', $source['name'], $id);
if ($source['help']) {
$widgets[] = $mform->createElement('html', $OUTPUT->help_icon($source['help'], 'block_dash', $source['help']));
$widgets[] = $mform->createElement('html', $OUTPUT->help_icon($source['help'], 'block_dash',
$source['help']));
}
$widgets[] = $mform->createElement('html', html_writer::end_div());
}
Expand Down
2 changes: 2 additions & 0 deletions lang/en/block_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,3 +876,5 @@
$string['competencyheading'] = 'Setup competency appearance';
$string['competencycolor'] = 'Competency color';
$string['competencyimage'] = 'Competency image';
$string['missingdatasource'] = "The datasources are missing. Please check them.";

2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024050400; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024050800; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021051700; // Requires this Moodle version.
$plugin->component = 'block_dash'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit e5ea22e

Please sign in to comment.