Skip to content

Commit

Permalink
SAK-47224 Forums > Stats & Grading > EID is not displayed (sakaiproje…
Browse files Browse the repository at this point in the history
  • Loading branch information
bjones86 authored Apr 28, 2022
1 parent 1094d44 commit 83ffb1b
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ cdfm_readby= - Read by:
stat_list = Statistics & Grading
stat_list_student = Statistics
stat_name = Name
stat_eid = ID
stat_anon_user = User
stat_authored = Authored
stat_read = Read
Expand All @@ -84,6 +85,7 @@ stat_forum_date = Date
stat_forum_subject = Subject
stat_forum_more_details = More Details
stat_sort_name = Sort By Name
stat_sort_eid = Sort By ID
stat_sort_authored = Sort By Num Authored
stat_sort_read = Sort By Num Read
stat_sort_unread = Sort By Num Unread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang3.StringUtils;

import org.sakaiproject.api.app.messageforums.AnonymousManager;
import org.sakaiproject.api.app.messageforums.Attachment;
import org.sakaiproject.api.app.messageforums.DBMembershipItem;
import org.sakaiproject.api.app.messageforums.DiscussionForum;
import org.sakaiproject.api.app.messageforums.DiscussionForumService;
import org.sakaiproject.api.app.messageforums.DiscussionTopic;
Expand Down Expand Up @@ -93,110 +95,26 @@ public class MessageForumStatisticsBean {
*/

public class DecoratedCompiledMessageStatistics {
private String siteName;
private String siteId;
private String siteUser;
private String siteUserId;
private String siteAnonId = null;
private boolean useAnonId;
private int authoredForumsAmt;
private int readForumsAmt;
private int unreadForumsAmt;
private Double percentReadForumsAmt;
private DecoratedGradebookAssignment gradebookAssignment;

public String getSiteName(){
return this.siteName;
}

public void setSiteName(String newValue){
this.siteName = newValue;
}

public String getSiteId(){
return this.siteId;
}

public void setSiteId(String newValue){
this.siteId = newValue;
}

public String getSiteUser(){
return this.siteUser;
}

public void setSiteUser(String newValue){
this.siteUser = newValue;
}

public String getSiteUserId(){
return this.siteUserId;
}

public void setSiteUserId(String newValue){
this.siteUserId = newValue;
}

public String getSiteAnonId(){
return this.siteAnonId;
}

public void setSiteAnonId(String newValue){
this.siteAnonId = newValue;
}
@Getter @Setter private String siteName;
@Getter @Setter private String siteId;
@Getter @Setter private String siteUser;
@Getter @Setter private String siteUserId;
@Getter @Setter private String siteUserDisplayId;
@Getter @Setter private String siteAnonId = null;
@Setter private boolean useAnonId;
@Getter @Setter private int authoredForumsAmt;
@Getter @Setter private int readForumsAmt;
@Getter @Setter private int unreadForumsAmt;
@Getter @Setter private Double percentReadForumsAmt;
@Getter @Setter private DecoratedGradebookAssignment gradebookAssignment;

public boolean getUseAnonId(){
return this.useAnonId;
}

public void setUseAnonId(boolean newValue){
this.useAnonId = newValue;
}

public String getAnonAwareId(){
return useAnonId ? siteAnonId : siteUser;
}

public int getAuthoredForumsAmt(){
return this.authoredForumsAmt;
}

public void setAuthoredForumsAmt(int newValue){
this.authoredForumsAmt = newValue;
}

public int getReadForumsAmt(){
return this.readForumsAmt;
}

public void setReadForumsAmt(int newValue){
this.readForumsAmt = newValue;
}

public int getUnreadForumsAmt(){
return this.unreadForumsAmt;
}

public void setUnreadForumsAmt(int newValue){
this.unreadForumsAmt = newValue;
}

public Double getPercentReadForumsAmt(){
return this.percentReadForumsAmt;
}

public void setPercentReadFOrumsAmt(Double newValue){
this.percentReadForumsAmt = newValue;
}

public DecoratedGradebookAssignment getGradebookAssignment() {
return gradebookAssignment;
}

public void setGradebookAssignment(
DecoratedGradebookAssignment gradebookAssignment) {
this.gradebookAssignment = gradebookAssignment;
}
}
/* === End DecoratedCompiledMessageStatistics === */

Expand Down Expand Up @@ -346,6 +264,7 @@ public void setGradebookAssignment(

private static final String LIST_PAGE = "dfStatisticsList";
private static final String NAME_SORT = "sort_by_name";
private static final String ID_SORT = "sort_by_id";
private static final String AUTHORED_SORT = "sort_by_num_authored";
private static final String READ_SORT = "sort_by_num_read";
private static final String UNREAD_SORT = "sort_by_num_unread";
Expand Down Expand Up @@ -400,12 +319,14 @@ public void setGradebookAssignment(

//Comparatibles
public static Comparator nameComparatorAsc;
public static Comparator displayNameComparatorAsc;
public static Comparator authoredComparatorAsc;
public static Comparator readComparatorAsc;
public static Comparator unreadComparatorAsc;
public static Comparator percentReadComparatorAsc;
public static Comparator GradeComparatorAsc;
public static Comparator nameComparatorDesc;
public static Comparator displayNameComparatorDesc;
public static Comparator authoredComparatorDesc;
public static Comparator readComparatorDesc;
public static Comparator unreadComparatorDesc;
Expand Down Expand Up @@ -647,6 +568,7 @@ public List getAllUserStatistics(){
String userId = item.getUser().getId();
userInfo.setSiteUserId(userId);
userInfo.setSiteUser(item.getName());
userInfo.setSiteUserDisplayId(item.getUser().getDisplayId());
if (m_displayAnonIds)
{
String anonId = userIdAnonIdMap.get(userId);
Expand All @@ -665,10 +587,10 @@ public List getAllUserStatistics(){
}
if (totalForum > 0) {
userInfo.setUnreadForumsAmt(totalForum - userInfo.getReadForumsAmt());
userInfo.setPercentReadFOrumsAmt((double)userInfo.getReadForumsAmt() / (double)totalForum);
userInfo.setPercentReadForumsAmt((double)userInfo.getReadForumsAmt() / (double)totalForum);
} else {
userInfo.setUnreadForumsAmt(0);
userInfo.setPercentReadFOrumsAmt((double)0);
userInfo.setPercentReadForumsAmt((double)0);
}

statistics.add(userInfo);
Expand Down Expand Up @@ -851,7 +773,7 @@ public List getTopicStatistics(){
Entry entry = (Entry) i.next();
MembershipItem item = (MembershipItem) entry.getValue();
if (null != item.getUser()) {
dUsers.add(new DecoratedUser(item.getUser().getId(), item.getName()));
dUsers.add(new DecoratedUser(item.getUser().getId(), item.getName(), item.getUser().getDisplayId()));
}
}
}
Expand Down Expand Up @@ -880,6 +802,7 @@ public List getTopicStatistics(){

userInfo.setSiteUserId(item.getId());
userInfo.setSiteUser(item.getName());
userInfo.setSiteUserDisplayId(item.getDisplayId());
// Set up the anonId for this userInfo if appropriate
userInfo.setUseAnonId(m_displayAnonIds);
if (m_displayAnonIds)
Expand All @@ -892,10 +815,10 @@ public List getTopicStatistics(){
}
if (totalForum > 0) {
userInfo.setUnreadForumsAmt(totalForum - userInfo.getReadForumsAmt());
userInfo.setPercentReadFOrumsAmt((double)userInfo.getReadForumsAmt() / (double)totalForum);
userInfo.setPercentReadForumsAmt((double)userInfo.getReadForumsAmt() / (double)totalForum);
} else {
userInfo.setUnreadForumsAmt(0);
userInfo.setPercentReadFOrumsAmt((double)0);
userInfo.setPercentReadForumsAmt((double)0);
}

DecoratedGradebookAssignment decoGradeAssgn = studentGradesMap.get(item.getId());
Expand Down Expand Up @@ -1305,6 +1228,11 @@ public String toggleNameSort() {
toggleSort(NAME_SORT);
return LIST_PAGE;
}

public String toggleIdSort() {
toggleSort(ID_SORT);
return LIST_PAGE;
}

public String toggleAuthoredSort() {
toggleSort(AUTHORED_SORT);
Expand Down Expand Up @@ -1491,6 +1419,11 @@ public String toggleTopicNameSort() {
toggleSort(NAME_SORT);
return FORUM_STATISTICS_BY_TOPIC;
}

public String toggleTopicIdSort() {
toggleSort(ID_SORT);
return FORUM_STATISTICS_BY_TOPIC;
}

public String toggleTopicAuthoredSort() {
toggleSort(AUTHORED_SORT);
Expand Down Expand Up @@ -1523,7 +1456,11 @@ public boolean isNameSort() {
return true;
return false;
}


public boolean isIdSort() {
return sortBy.equals(ID_SORT);
}

public boolean isAuthoredSort() {
if (sortBy.equals(AUTHORED_SORT))
return true;
Expand Down Expand Up @@ -1578,6 +1515,8 @@ private Comparator determineComparator(){
if(ascending){
if (sortBy.equals(NAME_SORT)){
return nameComparatorAsc;
}else if (sortBy.equals(ID_SORT)){
return displayNameComparatorAsc;
}else if (sortBy.equals(AUTHORED_SORT)){
return authoredComparatorAsc;
}else if (sortBy.equals(READ_SORT)){
Expand All @@ -1592,6 +1531,8 @@ private Comparator determineComparator(){
}else{
if (sortBy.equals(NAME_SORT)){
return nameComparatorDesc;
}else if (sortBy.equals(ID_SORT)){
return displayNameComparatorDesc;
}else if (sortBy.equals(AUTHORED_SORT)){
return authoredComparatorDesc;
}else if (sortBy.equals(READ_SORT)){
Expand Down Expand Up @@ -1720,7 +1661,15 @@ public int compare(Object item, Object anotherItem){
return name1.compareTo(name2);
}
};


displayNameComparatorAsc = new Comparator(){
public int compare(Object item1, Object item2) {
String displayName1 = ((DecoratedCompiledMessageStatistics) item1).getSiteUserDisplayId();
String displayName2 = ((DecoratedCompiledMessageStatistics) item2).getSiteUserDisplayId();
return displayName1.compareTo(displayName2);
}
};

authoredComparatorAsc = new Comparator(){
public int compare(Object item, Object anotherItem){
int authored1 = ((DecoratedCompiledMessageStatistics) item).getAuthoredForumsAmt();
Expand Down Expand Up @@ -1791,6 +1740,8 @@ public int compare(Object item, Object anotherItem){
return name2.compareTo(name1);
}
};

displayNameComparatorDesc = displayNameComparatorAsc.reversed();

forumTitleComparatorAsc = new Comparator(){
public int compare(Object item, Object anotherItem){
Expand Down Expand Up @@ -2922,27 +2873,20 @@ public void setSelectedGroup(String selectedGroup) {
}

private class DecoratedUser{
private String id;
private String name;
@Getter @Setter private String id;
@Getter @Setter private String name;
@Getter @Setter private String displayId;

public DecoratedUser(String id, String name){
this.id = id;
this.name = name;
}

public String getId() {
return id;
}
public void setId(String id) {

public DecoratedUser(String id, String name, String displayId){
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
this.displayId = displayId;
}

}

public Map<String, Integer> getStudentTopicMessagCount(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@
<h:outputText rendered="#{stat.useAnonId}" value="#{stat.siteAnonId}" styleClass="anonymousAuthor"/>
</h:commandLink>
</h:column>
<h:column rendered="#{!mfStatisticsBean.pureAnon}">
<f:facet name="header">
<h:commandLink action="#{mfStatisticsBean.toggleIdSort}" title="#{msgs.stat_eid}">
<h:outputText value="#{msgs.stat_eid}" />
<h:graphicImage value="/images/sortascending.gif" rendered="#{mfStatisticsBean.idSort && mfStatisticsBean.ascending}" alt="#{msgs.stat_sort_eid}"/>
<h:graphicImage value="/images/sortdescending.gif" rendered="#{mfStatisticsBean.idSort && !mfStatisticsBean.ascending}" alt="#{msgs.stat_sort_eid}"/>
</h:commandLink>
</f:facet>
<h:commandLink action="#{mfStatisticsBean.processActionStatisticsUser}" immediate="true">
<f:param value="#{stat.siteUserId}" name="siteUserId"/>
<h:outputText value="#{stat.siteUserDisplayId}" />
</h:commandLink>
</h:column>
<h:column>
<f:facet name="header">
<h:commandLink action="#{mfStatisticsBean.toggleAuthoredSort}" title="#{msgs.stat_authored}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@
<h:outputText rendered="#{stat.useAnonId}" value="#{stat.siteAnonId}" styleClass="anonymousAuthor"/>
</h:outputLink>
</h:column>
<h:column rendered="#{!mfStatisticsBean.pureAnon}">
<f:facet name="header">
<h:commandLink action="#{mfStatisticsBean.toggleTopicIdSort}" title="#{msgs.stat_eid}">
<h:outputText value="#{msgs.stat_eid}" />
<h:graphicImage value="/images/sortascending.gif" rendered="#{mfStatisticsBean.idSort && mfStatisticsBean.ascending}" alt="#{msgs.stat_sort_eid}"/>
<h:graphicImage value="/images/sortdescending.gif" rendered="#{mfStatisticsBean.idSort && !mfStatisticsBean.ascending}" alt="#{msgs.stat_sort_eid}"/>
</h:commandLink>
</f:facet>
<h:outputLink value="/tool/#{ForumTool.currentToolId}/discussionForum/statistics/dfStatisticsAllAuthoredMsgForOneUser" target="dialogFrame" onclick="dialogLinkClick(this);">
<f:param value="#{stat.siteUserId}" name="siteUserId"/>
<f:param value="dialogDiv" name="dialogDivId"/>
<f:param value="dialogFrame" name="frameId"/>
<h:outputText value="#{stat.siteUserDisplayId}" />
</h:outputLink>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgs.stat_forum_details}" />
Expand Down

0 comments on commit 83ffb1b

Please sign in to comment.