How To / General

[solved] course total

More
5 years 8 months ago - 5 years 8 months ago #1 by Yusef
course total was created by Yusef
Hello.

I have set up course in moodle with a grade book which has only one category. I have set up the category total to show "mean of grades" and "max garade" to 20.

1. in joomla "user grades" the "category total" returns "20" for max mark. but for "user mark" column it doesn't show the average of user's grade in that category. it only repeats the the mark in previous row.

(Edit)-2.in moodle course total is 5.5 (for example) but the "user grades" menu doesn't show decimals. it only shows "5".

how to fix these?
Attachments:
Last edit: 5 years 8 months ago by Yusef.

Please Log in or Create an account to join the conversation.

More
5 years 8 months ago - 5 years 8 months ago #2 by Yusef
Replied by Yusef on topic course total
I created a template override and changed these codes in the mygrade
Code:
$total = array_shift ($this->gcats['data']); if (is_array($this->gcats['data'])) foreach ($this->gcats['data'] as $gcat) : $n = count ($gcat['items']); ?> <?php $cat_shown = false; foreach ($gcat['items'] as $item) : ?> <tr> <?php if (!$cat_shown) : ?> <td rowspan="<?php echo $n + 1; ?>" valign="top" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo $gcat['fullname']; ?> <br> <?php printf ("%d", $gcat['grademax']); ?> <?php echo JText::_('COM_JOOMDLE_OF_TOTAL'); $cat_shown = true; ?> </td> <?php endif; ?> <td width="30%" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php if ($item['module']) { $url = $jump_url . '&mtype=' . $item['module'] . '&id=' . $item['course_module_id'] . '&course_id=' . $this->course_info['remoteid'] . '&create_user=0&Itemid='.$itemid; echo "<a href='$url'>" . $item['name'] . '</a>'; } else { echo $item['name']; } ?> </td> <td width="5%" style="text-align:center;" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php if ($item['due']) echo JHTML::_('date', $item['due'] , JText::_('DATE_FORMAT_LC4')); ?> </td> <td width="5%" style="text-align:center; " class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php printf ("%d", $item['grademax']); ?> </td> <td width="10%" align="center" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php if ($item['finalgrade'] >= 0) { if ($this->gcats['config']['showlettergrade']) echo $item['letter']; else { printf ("%d", $item['finalgrade']); echo ""; } } else echo "-"; ?> </td> <td width="15%" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo $item['feedback']; ?> </td> </tr> <?php endforeach; // Category totals if ($n > 0) : ?> <tr style="background-color:#ff87f0;"> <td class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('COM_JOOMDLE_CATEGORY_TOTAL'); ?> </td> <td class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> </td> <td align="center" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php if ($gcat['grademax']) { printf ("%d", $gcat['grademax']); echo ""; } ?> </td> <td align="center" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php if ($item['finalgrade'] >= 0) { if ($this->gcats['config']['showlettergrade']) echo $item['letter']; else { printf ("%d", $item['finalgrade']); echo ""; } } else echo "-"; ?> </td> </tr> <?php endif; ?> <?php endforeach; ?> <?php // Course total ?> <tr style="background-color:#61f921;"> <td class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('COM_JOOMDLE_SUBJECT_TOTAL'); ?> </td> <td class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> </td> <td class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> </td> <td align="center" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php printf ("%d", $total['grademax']); ?> </td> <td align="center" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php if ($this->gcats['config']['showlettergrade']) echo $total['letter']; else { printf ("%d", $total['finalgrade']); echo ""; } ?> </td> <td align="center" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> final </td> </tr> </table> </div> <P> &nbsp; </P>

to these codes:

Code:
$total = array_shift ($this->gcats['data']); if (is_array($this->gcats)) foreach ($this->gcats['data'] as $gcat) : $n = count ($gcat['items']); ?> <?php $cat_shown = false; foreach ($gcat['items'] as $item) : ?> <tr> <?php if (!$cat_shown) : ?> <td rowspan="<?php echo $n + 1; ?>" valign="top"> <?php echo $gcat['fullname']; ?> <br> <?php printf ("%d", $gcat['grademax']); ?> <?php echo JText::_('COM_JOOMDLE_OF_TOTAL'); $cat_shown = true; ?> </td> <?php endif; ?> <td width="30%"> <?php if ($item['module']) { $url = $jump_url . '&mtype=' . $item['module'] . '&id=' . $item['course_module_id'] . '&course_id=' . $this->course_info['remoteid'] . '&create_user=0&Itemid='.$itemid; echo "<a href='$url'>" . $item['name'] . '</a>'; } else { echo $item['name']; } ?> </td> <td width="5%" style="text-align:center;"> <?php if ($item['due']) echo JHTML::_('date', $item['due'] , JText::_('DATE_FORMAT_LC4')); ?> </td> <td width="5%" style="text-align:center;"> <?php printf ("%d", $item['grademax']); ?> </td> <td align="center" width="5%"> <?php if ($item['finalgrade'] >= 0) : ?> <?php if ($this->gcats['config']['showlettergrade']) :?> <?php echo $item['letter']; ?> <?php else : ?> <?php printf ("%d", $item['finalgrade']); ?> <?php endif; ?> <?php else : ?> - <?php endif; ?> </td> <td width="15%"> <?php echo $item['feedback']; ?> </td> </tr> <?php endforeach; // Category totals ?> <tr align="center" style="background-color:#ff87f0;"> <td> <?php echo JText::_('COM_JOOMDLE_CATEGORY_TOTAL'); ?> </td> <td> </td> <td align="center"> <?php printf ("%d", $gcat['grademax']); ?> </td> <td> <?php if ($item['finalgrade'] > 0) : ?> <?php if ($this->gcats['config']['showlettergrade']) :?> <?php echo $gcat['letter']; ?> <?php else : ?> <?php printf ("%d", $gcat['finalgrade']); ?> <?php endif; ?> <?php else : ?> - <?php endif; ?> </td> </tr> <?php endforeach; ?> <?php // Course total ?> <tr style="background-color:#61f921;"> <td> <?php echo JText::_('COM_JOOMDLE_SUBJECT_TOTAL'); ?> </td> <td> </td> <td> </td> <td align="center"> <?php printf ("%d", $total['grademax']); ?> </td> <td align="center"> <?php if ($item['finalgrade'] > 0) : ?> <?php if ($this->gcats['config']['showlettergrade']) :?> <?php echo $total['letter']; ?> <?php else : ?> <?php printf ("%d", $total['finalgrade']); ?> <?php endif; ?> <?php else : ?> - <?php endif; ?> </td> </td> <td align="center" class="simpletable<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> final </td> </tr> </table> <?php if ($this->params->get('show_back_links')) : ?> <div> <P align="center"> <a href="javascript: history.go(-1)"><?php echo JText::_('COM_JOOMDLE_BACK'); ?></a> </P> </div> <?php endif; ?> </div>

now my problem "number 1"is solved.
but the other problems still exist:

1. the gradebook doesn't return decimals in joomla menu for "user grades".
2. And if the quiz or assignment before the "category grade" row is empty, the user mark isn't calculated in the category total by joomla. but everything is fine in the moodle. in pictures it is clear.
Attachments:
Last edit: 5 years 8 months ago by Yusef.

Please Log in or Create an account to join the conversation.

More
5 years 8 months ago #3 by Antonio Durán
Replied by Antonio Durán on topic course total
Hi.

About the template override: you just removed the % right?

As for the issues:

1) This is because we use this:
Code:
printf ("%d", $item['finalgrade']);

You could change it in your template override by:
Code:
printf ("%.2f", $item['finalgrade']);

2) There is a bug in the code.
In // Category totals block, change $item by $gcat

Please Log in or Create an account to join the conversation.

More
5 years 8 months ago #4 by Yusef
Replied by Yusef on topic [solved] course total
thank you Antonio.
It worked.

Please Log in or Create an account to join the conversation.