KQMATH / moodle-mod_capquiz

:mushroom: Computer adaptive practice activity module for Moodle
https://moodle.org/plugins/mod_capquiz
GNU General Public License v3.0
4 stars 5 forks source link

Bug/id39 #70

Closed hgeorgsch closed 6 years ago

hgeorgsch commented 6 years ago

Negative progress towards the next star is now visualised with a red bar from the right.

hgeorgsch commented 6 years ago

On Tue, Sep 04, 2018 at 11:38:28AM -0700, skrede wrote:

skrede commented on this pull request.

@@ -84,10 +84,19 @@ public function render_review_next_button(capquiz_question_attempt $attempt) { private function render_progress(capquiz_user $user) { $questionlist = $this->capquiz->question_list(); $percent = $questionlist->next_level_percent($user->rating());

  • $abspercent = $percent ;
  • if ( $percent >= 0 ) {
  • $progressclass = "capquiz-quiz-progress-fill" ;
  • } else {
  • $progressclass = "capquiz-quiz-progress-unfill" ;

This seems a little too complex than it needs to be. Is this rendered from other places? If not, it's best to let mustache handle display/rendering (style and layout), and keep PHP to prepare and propagate data.

I agree that it feels clumsy, but I did not find a better way to do it. We need to style differently depending on the sign of $percent. AFAIU there is no way to do that in mustache.

-- :-- Hans Georg

skrede commented 6 years ago

I was too quick to comment, when I looked more closely it seemed less clumsy. However, might be better to pass a flag or simply different keys altogether. Two sections of mustache with almost similar content. Render the sections with {{student_progressed}} and {{student_regressed}}

                'student_progressed' => [
                    'percent' => $percent,
                    'abspercent' => $abspercent,
                    'stars' => $this->user_star_progress($user, $questionlist)
                ]

and

                'student_regressed' => [
                    'percent' => $percent,
                    'abspercent' => $abspercent,
                    'stars' => $this->user_star_progress($user, $questionlist)
                ]

Duplicate code in mustache, but moves responsibility of styling away from PHP.