Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1893 [Control] add: progress bar of different colors #1913

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion view/control/control_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,18 @@
<div class="progress-info">
<span class="badge badge-info" style="margin-right: 10px;"><?php print $answerCounter . '/' . $questionCounter; ?></span>
<div class="progress-bar" style="margin-right: 10px;">
<div class="progress progress-bar-success" style="width:<?php print ($questionCounter > 0 ? ($answerCounter / $questionCounter) * 100 : 0) . '%'; ?>;" title="<?php print($questionCounter > 0 ? $answerCounter . '/' . $questionCounter : 0); ?>"></div>
<?php
$percentage = ($answerCounter / $questionCounter) * 100;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici il y a un problème structurel
Le code ne protège pas de la division par 0
C'est pas de ton fait car c'est pas check plus haut mais si tu fait rien ca reste une fatal possible

if ($percentage == 0) {
print ('<div class="progress progress-bar-danger" style="width: 0%;" title="' . ($questionCounter > 0 ? $answerCounter . '/' . $questionCounter : 0) . '"></div>');
}
if ($percentage > 0 && $percentage < 100) {
print ('<div class="progress progress-bar-warning" style="width:' . ($questionCounter > 0 ? ($answerCounter / $questionCounter) * 100 : 0) . '%;" title="' . ($questionCounter > 0 ? $answerCounter . '/' . $questionCounter : 0) . '"></div>');
}
if ($percentage == 100) {
print ('<div class="progress progress-bar-success" style="width: 100%;" title="' . ($questionCounter > 0 ? $answerCounter . '/' . $questionCounter : 0) . '"></div>');
}
?>
Comment on lines +901 to +910
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ca passe en soit mais pourquoi ne pas utiliser l'attribut html progress car la c'est pas posssible

</div>
<?php if ($answerCounter != $questionCounter) {
print $user->conf->DIGIQUALI_SHOW_ONLY_QUESTIONS_WITH_NO_ANSWER ? img_picto($langs->trans('Enabled'), 'switch_on', 'class="show-only-questions-with-no-answer marginrightonly"') : img_picto($langs->trans('Disabled'), 'switch_off', 'class="show-only-questions-with-no-answer marginrightonly"');
Expand Down