MDL-53374 tool_lp: Add progressbar to learning plans

This commit is contained in:
Damyon Wiese 2016-03-31 13:31:12 +08:00 committed by Frederic Massart
parent 96f4d771bf
commit cd378576e7
5 changed files with 29 additions and 5 deletions

View File

@ -3285,7 +3285,11 @@ class external extends external_api {
'usercompetency' => $uc,
'usercompetencyplan' => $ucp
))
)
),
'competencycount' => new external_value(PARAM_INT, 'Count of competencies'),
'proficientcompetencycount' => new external_value(PARAM_INT, 'Count of proficientcompetencies'),
'proficientcompetencypercentage' => new external_value(PARAM_FLOAT, 'Percentage of competencies proficient'),
'proficientcompetencypercentageformatted' => new external_value(PARAM_RAW, 'Displayable percentage'),
));
}

View File

@ -82,6 +82,7 @@ class plan_page implements renderable, templatable {
}
$pclist = api::list_plan_competencies($this->plan);
$proficientcount = 0;
foreach ($pclist as $pc) {
$comp = $pc->competency;
$usercomp = $pc->$ucproperty;
@ -121,7 +122,18 @@ class plan_page implements renderable, templatable {
$record->$ucproperty = $exporter->export($output);
$data->competencies[] = $record;
if ($usercomp->get_proficiency()) {
$proficientcount++;
}
}
$data->competencycount = count($data->competencies);
$data->proficientcompetencycount = $proficientcount;
if ($data->competencycount) {
$data->proficientcompetencypercentage = ((float) $proficientcount / (float) $data->competencycount) * 100.0;
} else {
$data->proficientcompetencypercentage = 0.0;
}
$data->proficientcompetencypercentageformatted = format_float($data->proficientcompetencypercentage);
return $data;
}
}

View File

@ -286,6 +286,7 @@ $string['points'] = 'Points';
$string['pointsgivenfor'] = 'Points given for \'{$a}\'';
$string['pointsrequiredaremet'] = 'Points required are met';
$string['proficient'] = 'Proficient';
$string['progress'] = 'Progress';
$string['pushcourseratingstouserplans'] = 'Push course ratings to individual learning plans';
$string['pushcourseratingstouserplans_desc'] = 'Default value for the course setting to update individual learning plans when course competencies are rated.';
$string['rate'] = 'Rate';
@ -430,4 +431,5 @@ $string['visible_help'] = 'A competency framework can be hidden from teachers. T
$string['when'] = 'When';
$string['xcompetenciesproficientoutofyincourse'] = 'You are proficient in {$a->x} out of {$a->y} competencies in this course.';
$string['xcompetencieslinkedoutofy'] = '{$a->x} out of {$a->y} competencies linked to courses';
$string['xcompetenciesproficientoutofy'] = '{$a->x} out of {$a->y} competencies are proficient';
$string['xplanscompletedoutofy'] = '{$a->x} out of {$a->y} plans completed for this template';

View File

@ -4,14 +4,12 @@
.path-admin-tool-lp [data-region="competencylinktree"] ul li {
list-style-type: none;
}
.path-admin-tool-lp [data-region="coursecompetencystatistics"] .progresstext,
.path-admin-tool-lp [data-region="templatestatistics"] .progresstext {
.path-admin-tool-lp .progresstext {
display: inline-block;
height: 40px;
vertical-align: top;
}
.path-admin-tool-lp [data-region="coursecompetencystatistics"] .progress,
.path-admin-tool-lp [data-region="templatestatistics"] .progress {
.path-admin-tool-lp .progress {
width: 10em;
display: inline-block;
margin-left: 2em;

View File

@ -80,6 +80,14 @@
<dt>{{#str}}description{{/str}}</dt>
<dd>{{{plan.description}}}</dd>
{{/description}}
<dt>{{#str}}progress, tool_lp{{/str}}</dt>
<dd><span class="progresstext">{{#str}}xcompetenciesproficientoutofy, tool_lp, { "x": "{{proficientcompetencycount}}", "y": "{{competencycount}}" }{{/str}}</span>
<div class="progress">
<div class="bar" style="width: {{proficientcompetencypercentage}}%;">
{{proficientcompetencypercentageformatted}} %
</div>
</div>
</dd>
</dl>
</div>
{{#plan.commentarea}}