Skip to content

Commit

Permalink
GH-765 Add settings to enable remote sync options
Browse files Browse the repository at this point in the history
This adds checkboxes so that users can opt-in to either share data with a
central hub or to make the instance act as a central hub.

Also, it removes the obsolete `sync_scales` config that was used by just a page
to test submission of items.
  • Loading branch information
davidszkiba committed Dec 10, 2024
1 parent 39b9fb9 commit b6b43a8
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 119 deletions.
2 changes: 2 additions & 0 deletions classes/output/catscaledashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ public function export_scaledetails(\renderer_base $output): array {
'submitresponsesbutton' => $this->render_submitresponses_button(),
'is_root' => $this->is_root_scale(),
'centralhost' => get_config('local_catquiz', 'central_host'),
'sync_as_node_enabled' => get_config('local_catquiz', 'enable_sync_as_node'),
'sync_as_hub_enabled' => get_config('local_catquiz', 'enable_sync_as_hub'),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public function __construct() {
* @return void
*/
public function render_remote_calculation_config() {
$show = get_config('local_catquiz', 'enable_sync_as_client');
if (!$show) {
return '';
}

$form = new remote_settings_form();
return html_writer::div($form->render(), '', ['id' => 'remote_settings_form']);
}
Expand Down
79 changes: 0 additions & 79 deletions client/submit_responses.php

This file was deleted.

6 changes: 4 additions & 2 deletions lang/de/local_catquiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@
$string['central_scale_labels'] = 'Zentrale Skala-Labels';
$string['central_scale_labels_desc'] = 'Ein Skala-Label pro Zeile eingeben. Nur diese Skalen werden vom Remote-Berechnungstask verarbeitet.';
$string['syncbutton'] = 'Parameter abrufen';
$string['sync_scale'] = 'Label der zu synchronisierenden CAT Skala';
$string['sync_scale_desc'] = 'Parameter dieser Skala werden mit der zentralen Berechnungsinstanz synchronisiert.';
$string['central_token'] = 'Token zum Zugriff auf die zentrale Berechnungsinstanz';
$string['central_token_desc'] = 'Das webtoken, das für sie auf der zentralen Berechnungsinstanz eingerichtet worden ist';
$string['central_token_help'] = 'Das webtoken, das für sie auf der zentralen Berechnungsinstanz eingerichtet worden ist';
Expand Down Expand Up @@ -281,6 +279,10 @@
$string['edititemparams'] = 'Daten ändern';
$string['edittestenvironment'] = 'Bearbeite Testumgebung';
$string['emptyfirstquestionlist'] = 'Kann keine Startfrage wählen da die Liste leer ist';
$string['enable_sync_as_hub'] = 'Instanz agiert als Hub';
$string['enable_sync_as_hub_desc'] = 'Wenn aktiviert, können andere Instanzen (nodes) Frage-Daten mit dieser Instanz austauschen';
$string['enable_sync_as_node'] = 'Datenaustausch mit Hub erlauben';
$string['enable_sync_as_node_desc'] = 'Wenn aktiviert, ist es möglich, Frage-Daten mit einer zentralen Instanz (Hub) zu synchronisieren';
$string['endtime'] = 'Ende';
$string['endtimestamp'] = 'Zeitraum Ende';
$string['enrol_only_to_reported_scales'] = 'Benutzer nur in Kurse von detektierter Skala einschreiben';
Expand Down
6 changes: 4 additions & 2 deletions lang/en/local_catquiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@
$string['central_host_desc'] = 'The host that will perform parameter calculations. E.g. https://www.example.com';
$string['central_host_help'] = 'The host that will perform parameter calculations. E.g. https://www.example.com';
$string['syncbutton'] = 'Fetch item parameters';
$string['sync_scale'] = 'Label of the CAT scale to sync';
$string['sync_scale_desc'] = 'Parameters of this scale will be synced with the compute instance';
$string['central_scale_labels'] = 'Central scale labels';
$string['central_scale_labels_desc'] = 'Enter one scale label per line. Only these scales will be processed by the remote calculation task.';
$string['central_token'] = 'Token to access compute instance';
Expand Down Expand Up @@ -278,6 +276,10 @@
$string['edititemparams'] = 'Edit item params';
$string['edittestenvironment'] = 'Edit testenvironment';
$string['emptyfirstquestionlist'] = 'Can’t select a start question because the list is empty';
$string['enable_sync_as_hub'] = 'Instance acts as hub';
$string['enable_sync_as_hub_desc'] = 'When activated, other catquiz instances (nodes) can exchange data with this instance';
$string['enable_sync_as_node'] = 'Allow syncronization with hub';
$string['enable_sync_as_node_desc'] = 'When activated, it is possible to exchange data with a central instance (hub)';
$string['endtime'] = 'End';
$string['endtimestamp'] = 'Endtime';
$string['enrol_only_to_reported_scales'] = 'Enrol users only to courses of detected primary scale(s).';
Expand Down
27 changes: 20 additions & 7 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,36 @@
24, // Default value.
PARAM_INT // Expect integer type.
));

$settings->add(new admin_setting_configcheckbox(
'local_catquiz/enable_sync_as_node',
get_string('enable_sync_as_node', 'local_catquiz'),
get_string('enable_sync_as_node_desc', 'local_catquiz'),
false, // Default value.
PARAM_BOOL
));
$settings->add(new admin_setting_configtext(
'local_catquiz/central_host',
get_string('central_host', 'local_catquiz'),
get_string('central_host_desc', 'local_catquiz'),
PARAM_URL
'',
PARAM_HOST
));

$settings->hide_if('local_catquiz/central_host', 'local_catquiz/enable_sync_as_node', 'notchecked', '0');
$settings->add(new admin_setting_configtext(
'local_catquiz/central_token',
get_string('central_token', 'local_catquiz'),
get_string('central_token_desc', 'local_catquiz'),
'',
PARAM_ALPHANUM
));
$settings->add(new admin_setting_configtext(
'local_catquiz/sync_scale',
get_string('sync_scale', 'local_catquiz'),
get_string('sync_scale_desc', 'local_catquiz'),
PARAM_INT
$settings->hide_if('local_catquiz/central_token', 'local_catquiz/enable_sync_as_node', 'notchecked', '0');
$settings->add(new admin_setting_configcheckbox(
'local_catquiz/enable_sync_as_hub',
get_string('enable_sync_as_hub', 'local_catquiz'),
get_string('enable_sync_as_hub_desc', 'local_catquiz'),
false, // Default value.
PARAM_BOOL
));
$settings->add(new admin_setting_configtextarea(
'local_catquiz/central_scale_labels',
Expand All @@ -153,4 +165,5 @@
'', // Default value.
PARAM_TEXT
));
$settings->hide_if('local_catquiz/central_scale_labels', 'local_catquiz/enable_sync_as_hub', 'notchecked', '0');
}
60 changes: 32 additions & 28 deletions templates/catscalemanager/catscales.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -52,40 +52,44 @@
</div>
</div>

<div class="card mb-3">
{{! Local calculation section }}
<div class="card-header">
<h5 class="accordion-header">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#syncActions">
{{#str}}syncactions, local_catquiz{{/str}}
</button>
</h5>
<div id="syncActions" class="accordion-collapse collapse show">
<div class="accordion-body">
<p class="mb-2">{{#str}}syncactionshelp, local_catquiz{{/str}}</p>
{{{syncbutton}}}
{{{submitresponsesbutton}}}
{{#sync_as_node_enabled}}
<div class="card mb-3">
{{! Local calculation section }}
<div class="card-header">
<h5 class="accordion-header">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#syncActions">
{{#str}}syncactions, local_catquiz{{/str}}
</button>
</h5>
<div id="syncActions" class="accordion-collapse collapse show">
<div class="accordion-body">
<p class="mb-2">{{#str}}syncactionshelp, local_catquiz{{/str}}</p>
{{{syncbutton}}}
{{{submitresponsesbutton}}}
</div>
</div>
</div>
</div>
</div>

<div class="card mb-3">
{{! Local calculation section }}
<div class="card-header">
<h5 class="accordion-header">
<button class="btn btn-link" data-toggle="collapse" data-target="#hubActions">
{{#str}}hubactions, local_catquiz{{/str}}
</button>
</h5>
<div id="hubActions" class="accordion-collapse collapse show">
<div class="accordion-body">
<p class="mb-2">{{#str}}hubactionshelp, local_catquiz{{/str}}</p>
{{{remotecalcbutton}}}
{{/sync_as_node_enabled}}

{{#sync_as_hub_enabled}}
<div class="card mb-3">
{{! Local calculation section }}
<div class="card-header">
<h5 class="accordion-header">
<button class="btn btn-link" data-toggle="collapse" data-target="#hubActions">
{{#str}}hubactions, local_catquiz{{/str}}
</button>
</h5>
<div id="hubActions" class="accordion-collapse collapse show">
<div class="accordion-body">
<p class="mb-2">{{#str}}hubactionshelp, local_catquiz{{/str}}</p>
{{{remotecalcbutton}}}
</div>
</div>
</div>
</div>
</div>
{{/sync_as_hub_enabled}}

{{/is_root}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

$plugin->component = 'local_catquiz';
$plugin->release = '1.1.2';
$plugin->version = 2024120500;
$plugin->version = 2024121000;
$plugin->requires = 2022041900;
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = [
Expand Down

0 comments on commit b6b43a8

Please sign in to comment.