Skip to content

Commit

Permalink
SAK-29425 bug fix for 0 posts total (sakaiproject#8716)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjones86 authored Oct 21, 2020
1 parent 6de4039 commit a1de243
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ stat_sort_by_date=Sort by Date
stat_byUser=by User
stat_byTopic=by Topic
stat_totalMessages=Total Messages
stat_percent_read=<span class="statsTally">Percent Read:</span> {0}%
stat_num_authored=<span class="statsTally">Messages Authored:</span> {0}
stat_percent_read_user=<span class="statsTally">Percent Read:</span> {0}%
stat_num_authored_user=<span class="statsTally">Messages Authored:</span> {0}

cdfm_labels=Labels
cdfm_newflag=New!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3113,16 +3113,20 @@ private boolean isUseAnonymousId(Topic topic)
return topic.getPostAnonymous() && (!topic.getRevealIDsToRoles() || !uiPermissionsManager.isIdentifyAnonAuthors((DiscussionTopic) topic));
}

public int getPercentRead()
{
int totalPosts = 0;
List<Object[]> studentAuthoredStats = messageManager.findAuthoredMessageCountForAllStudents();
for (Object[] pair : studentAuthoredStats)
{
totalPosts += ((Long) pair[1]).intValue();
}

int numRead = getUserReadStatistics().size();
return (numRead / totalPosts) * 100;
}
public int getPercentRead()
{
int totalPosts = 0;
List<Object[]> studentAuthoredStats = messageManager.findAuthoredMessageCountForAllStudents();
for (Object[] pair : studentAuthoredStats)
{
totalPosts += ((Long) pair[1]).intValue();
}

if (totalPosts == 0)
{
return 0;
}
int numRead = getUserReadStatistics().size();
return (numRead / totalPosts) * 100;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@
<h:outputText rendered="#{ForumTool.anonymousEnabled && ForumTool.siteHasAnonymousTopics && !mfStatisticsBean.pureAnon}" value="#{msgs.stat_forum_anonymous_omitted}" styleClass="instruction" />

<div>
<h:outputFormat value="#{msgs.stat_percent_read}" escape="false">
<h:outputFormat value="#{msgs.stat_percent_read_user}" escape="false">
<f:param value="#{mfStatisticsBean.getPercentRead()}" />
</h:outputFormat>
</div>
<div>
<h:outputFormat value="#{msgs.stat_num_authored}" escape="false">
<h:outputFormat value="#{msgs.stat_num_authored_user}" escape="false">
<f:param value="#{mfStatisticsBean.userAuthoredStatistics.size()}" />
</h:outputFormat>
</div>
Expand Down

0 comments on commit a1de243

Please sign in to comment.