Skip to content

Commit

Permalink
GH-520 Updates charts for testusage tab
Browse files Browse the repository at this point in the history
  • Loading branch information
davidszkiba committed Jun 28, 2024
1 parent 8ff1048 commit 2364998
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 14 deletions.
25 changes: 20 additions & 5 deletions classes/output/catquizstatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ public function render_attempts_per_timerange_chart() {
}
$chart->get_xaxis(0, true)->set_label(get_string('date'));
$chart->get_yaxis(0, true)->set_label(get_string('numberofattempts', 'local_catquiz'));
$out = $OUTPUT->render($chart);
$chart->set_legend_options(['display' => false]);
$out = $OUTPUT->render_chart($chart, false);

return [
'charttitle' => get_string('catquizstatistics_numattempts_title', 'local_catquiz'),
Expand Down Expand Up @@ -316,10 +317,10 @@ public function render_attemptresultstackchart(int $catscaleid) {
}
}
}

$chart->set_stacked(true);
$chart->set_labels($labels);
$out = $OUTPUT->render($chart);
$chart->set_legend_options(['display' => false]);
$out = $OUTPUT->render_chart($chart, false);

return [
'chart' => $out,
Expand Down Expand Up @@ -682,8 +683,9 @@ public function render_responses_by_users_chart() {
$chart->set_labels($labels);
$chart->get_xaxis(0, true)->set_label(get_string('catquizstatistics_numberofresponses', 'local_catquiz'));
$chart->get_yaxis(0, true)->set_label(sprintf('# %s', get_string('students')));
$chart->set_legend_options(['display' => false]);

$out = $OUTPUT->render($chart);
$out = $OUTPUT->render_chart($chart, false);

return [
'charttitle' => get_string('responsesbyusercharttitle', 'local_catquiz'),
Expand Down Expand Up @@ -1096,7 +1098,8 @@ public function render_attempts_per_person_chart(): array {

$chart->get_xaxis(0, true)->set_label(get_string('numberofattempts', 'local_catquiz'));
$chart->get_yaxis(0, true)->set_label(sprintf('# %s', get_string('students')));
$out = $OUTPUT->render($chart);
$chart->set_legend_options(['display' => false]);
$out = $OUTPUT->render_chart($chart, false);

if (
optional_param('debug', false, PARAM_BOOL)
Expand All @@ -1118,7 +1121,19 @@ public function render_attempts_per_person_chart(): array {
$table = "<table class=\"table\">$thead<tbody>$tr</tbody></table>";
$out .= $table;
}

$colorbarlegend = false;
if ($this->get_quizsettings()) {
$legend = feedback_helper::get_colorbarlegend(
$this->get_quizsettings(),
$this->scaleid,
$this->check_quizsettings_are_compatible(self::COMPATIBILITY_LEVEL_DESCRIPTION),
true
);
$colorbarlegend = ['feedbackbarlegend' => $legend];
}
return [
'colorbarlegend' => $colorbarlegend,
'charttitle' => get_string('catquizstatistics_numattemptsperperson_title', 'local_catquiz'),
'chart' => $out,
];
Expand Down
1 change: 0 additions & 1 deletion classes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ public static function catquizstatistics($shortcode, $args, $content, $env, $nex
'attemptspertimerangechart' => $catquizstatistics->render_attempts_per_timerange_chart(),
'attemptsperpersonchart' => $catquizstatistics->render_attempts_per_person_chart(),
'learningprogress' => $catquizstatistics->render_learning_progress(),
'numresponsesbyusers' => $catquizstatistics->render_responses_by_users_chart(),
'exportbutton' => $catquizstatistics->render_export_button() ?: false,
// This ID will be appended to the navigation tab links, so that
// those links are unique for shortcodes with different arguments.
Expand Down
11 changes: 10 additions & 1 deletion classes/teststrategy/feedback_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,11 @@ public static function add_quotes(string $string) {
* @param object $quizsettings
* @param string|int $catscaleid
* @param bool $customlabels Use the labels defined in the settings instead of default labels
* @param bool $withuncalculated Include the color and description for the "not yet calculated" range
* @return array
*
*/
public static function get_colorbarlegend($quizsettings, $catscaleid, $customlabels = true): array {
public static function get_colorbarlegend($quizsettings, $catscaleid, $customlabels = true, $withuncalculated = false): array {
if (!$quizsettings) {
return [];
}
Expand Down Expand Up @@ -443,6 +444,14 @@ public static function get_colorbarlegend($quizsettings, $catscaleid, $customlab
];
}

if ($withuncalculated) {
$feedbacks[] = [
'subcolorcode' => LOCAL_CATQUIZ_DEFAULT_GREY,
'subfeedbacktext' => get_string('noresult', 'local_catquiz'),
'subfeedbackrange' => '',
];
}

return $feedbacks;
}
}
6 changes: 3 additions & 3 deletions lang/de/local_catquiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@

$string['studentstats'] = 'Studierende';
$string['notyetcalculated'] = 'Noch nicht berechnet';
$string['notyetattempted'] = 'Noch keine Testversuche';
$string['notyetattempted'] = 'Ohne Versuch';

// Email Templates.
$string['notificationcatscalechange'] = 'Hallo {$a->firstname} {$a->lastname},
Expand Down Expand Up @@ -487,7 +487,7 @@
$string['feedbackrange'] = 'Fähigkeits-Stufe {$a}';
$string['hasability'] = 'Fähigkeit wurde berechnet';
$string['responsesbyusercharttitle'] = 'Gesamtanzahl der gegebenen Antworten pro Person';
$string['noresult'] = 'Es wurde noch keine Fähigkeit berechnet';
$string['noresult'] = 'kein Fähigkeitswert ermittelt';
$string['selected_scales_all_ranges_label'] = 'Anzahl der Teilnehmenden';
$string['numberoffeedbackoptionpersubscale_help'] = 'Wählen Sie aus, in wievielen Fähigkeits-Stufen Sie Ihr Feedback differenzieren möchten. Mithilfe der Fähigkeits-Stufen können Sie in Abhängigkeit der ermittelten Fähigkeit für jede Skala Ihren Teilnehmenden unterschiedliche schriftliche Rückmeldungen erteilen, diese in unterschiedliche Kurse einschreiben oder diese unterschiedlichen Gruppen zuordnen.';
$string['choosesubscaleforfeedback'] = 'Skala wählen';
Expand Down Expand Up @@ -652,7 +652,7 @@
$string['catquizstatistics_timerange_both'] = 'Nur Daten von {$a->starttime} bis {$a->endtime} werden berücksichtigt.';
$string['catquizstatistics_timerange_start'] = 'Nur Daten ab {$a->starttime} werden berücksichtigt.';
$string['catquizstatistics_timerange_end'] = 'Nur Daten bis {$a->endtime} werden berücksichtigt.';
$string['catquizstatistics_numattempts_title'] = 'Anzahl von Testversuchen';
$string['catquizstatistics_numattempts_title'] = 'Anzahl an Testversuchen';
$string['catquizstatistics_numattemptsperperson_title'] = 'Testversuche pro Person';
$string['catquizstatistics_overview'] = 'Überblick';
$string['catquizstatistics_testusage'] = 'Testnutzung';
Expand Down
16 changes: 12 additions & 4 deletions templates/catscaleshortcodes/catscalestatistics.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,19 @@
{{#attemptsperpersonchart}}
<h5>{{charttitle}}</h5>
<div>{{{chart}}}</div>
{{#colorbarlegend}}
<div class="catquiz-legend">
<h4>{{#str}}feedbackbarlegend, local_catquiz{{/str}}</h4>
{{#feedbackbarlegend}}
<div>
<span class="catquiz-legend-symbol" style="background: {{subcolorcode}};"></span>
<span class="catquiz-legend-description">{{subfeedbacktext}}</span>
<span class="catquiz-legend-range">{{subfeedbackrange}}</span>
</div>
{{/feedbackbarlegend}}
</div>
{{/colorbarlegend}}
{{/attemptsperpersonchart}}
{{#numresponsesbyusers}}
<h5>{{charttitle}}</h5>
{{{chart}}}
{{/numresponsesbyusers}}
</div>
<div class="tab-pane" id="learningprogress-{{shortcodeid}}" role="tabpanel" aria-expanded="false">
{{#learningprogress}}
Expand Down

0 comments on commit 2364998

Please sign in to comment.