Skip to content

Commit

Permalink
Merge pull request sakaiproject#1254 from adrianfish/SAK-29709
Browse files Browse the repository at this point in the history
SAK-29709 Added lessons ribbon to SiteStats
  • Loading branch information
buckett committed Dec 9, 2015
2 parents e7e9f69 + da98773 commit 559b532
Show file tree
Hide file tree
Showing 25 changed files with 1,771 additions and 96 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* $URL$
* $Id$
*
* Copyright (c) 2006-2009 The Sakai Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ECL-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sakaiproject.sitestats.api;


/**
* Represents a record from the SST_LESSONBULDER table.
*
* This must be {@link java.lang.Comparable} so that the updates can be sorted before being inserted into the database
* to avoid deadlocks.
*
* @author Adrian Fish <[email protected]>
*/
public interface LessonBuilderStat extends Stat, Comparable<LessonBuilderStat> {

/** Get the the page reference (eg. '/lessonbuilder/page/2') this record refers to. */
public String getPageRef();

/** Set the the page reference (eg. '/lessonbuilder/page/2') this record refers to. */
public void setPageRef(String pageRef);

/** Get the the page action (one of 'create','read' ...) this record refers to. */
public String getPageAction();

/** Set the the page action (one of 'create','read' ...) this record refers to. */
public void setPageAction(String pageAction);

/** Get the the page title */
public String getPageTitle();

/** Get the the page title */
public void setPageTitle(String pageTitle);

/** Get the the page id */
public long getPageId();

/** Set the the page id */
public void setPageId(long pageId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public interface StatsManager {
public final static String CONTAINER_LOGIN_EVENTID = "user.login.container";
public final static String LOGOUT_EVENTID = "user.logout";
public final static String RESOURCE_EVENTID_PREFIX = "content.";
public final static String LESSONS_EVENTID_PREFIX = "lessonbuilder.";
public final static String SITESTATS_TOOLID = "sakai.sitestats";
public final static String SITESTATS_ADMIN_TOOLID = "sakai.sitestats.admin";
public final static String LOG_APP = "sitestats";
Expand Down Expand Up @@ -82,13 +83,16 @@ public interface StatsManager {
public static final int Q_TYPE_VISITSTOTALS = 2;
public static final int Q_TYPE_ACTIVITYTOTALS = 3;
public static final int Q_TYPE_PRESENCE = 4;
public static final int Q_TYPE_LESSON = 5;
public static final String T_NONE = "none";
public static final String T_SITE = "site";
public static final String T_USER = "user";
public static final String T_EVENT = "event";
public static final String T_TOOL = "tool";
public static final String T_RESOURCE = "resource";
public static final String T_RESOURCE_ACTION = "resource-action";
public static final String T_PAGE = "page";
public static final String T_PAGE_ACTION = "page-action";
public static final String T_DATE = "date";
public static final String T_DATEMONTH = "month";
public static final String T_DATEYEAR = "year";
Expand All @@ -102,6 +106,7 @@ public interface StatsManager {
public static final List<String> TOTALSBY_VISITSTOTALS_DEFAULT = Arrays.asList(T_DATE);
public static final List<String> TOTALSBY_ACTIVITYTOTALS_DEFAULT = Arrays.asList(T_DATE);
public static final List<String> TOTALSBY_PRESENCE_DEFAULT = Arrays.asList(T_DATE);
public static final List<String> TOTALSBY_LESSONS_DEFAULT = Arrays.asList(T_USER, T_PAGE, T_PAGE_ACTION, T_DATE);

// ################################################################
// Spring bean methods
Expand Down Expand Up @@ -179,6 +184,19 @@ public interface StatsManager {

/** Get total number of resources (eventually, files only) in specified site, based on resources events (faster than consulting CHS). */
public int getTotalResources(String siteId, boolean excludeFolders);

/** Get the lesson page title from a page id */
public String getLessonPageTitle(long pageId);

/** Get total number of lesson pages in the specified site. */
public int getTotalLessonPages(String siteId);

/** Get total number of read lesson pages in the specified site. */
public int getTotalReadLessonPages(String siteId);

public String getMostReadLessonPage(final String siteId);

public String getMostActiveLessonPageReader(final String siteId);

// ################################################################
// Summary/report methods
Expand Down Expand Up @@ -369,6 +387,19 @@ public List<Stat> getResourceStats(
final String sortBy,
final boolean sortAscending,
final int maxResults);

public List<Stat> getLessonBuilderStats(final String siteId,
final String resourceAction,
final List<String> resourceIds,
final Date iDate,
final Date fDate,
final List<String> userIds,
final boolean inverseUserSelection,
final PagingPosition page,
final List<String> totalsBy,
final String sortBy,
final boolean sortAscending,
final int maxResults);

/**
* Get row count for resource statistics (totals by user/event/date).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public interface ReportManager {
public static final String WHAT_RESOURCES_ACTION_READ = "read";
public static final String WHAT_RESOURCES_ACTION_REVS = "revise";
public static final String WHAT_RESOURCES_ACTION_DEL = "delete";
public static final String WHAT_LESSONPAGES = "what-lessonpages";
public static final String WHAT_LESSONS_ACTION_CREATE = "create";
public static final String WHAT_LESSONS_ACTION_READ = "read";
public static final String WHAT_LESSONS_ACTION_UPDATE = "update";
public static final String WHAT_LESSONS_ACTION_DELETE = "delete";
public static final String WHAT_EVENTS_BYEVENTS = "what-events-byevent";
public static final String WHAT_EVENTS_BYTOOL = "what-events-bytool";
public static final String WHAT_EVENTS_ALLEVENTS = "all";
Expand Down
11 changes: 11 additions & 0 deletions sitestats/sitestats-bundle/src/resources/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ overview_title_resources_sum=Files
overview_title_openedfiles_sum=Files opened
overview_title_mostopenedfile_sum=Most opened file
overview_title_useropenedmorefile_sum=User who has opened the most files
# Overview::Lessons
overview_tab_bypage=By page
overview_title_lessonpages=Lesson Pages
overview_title_pages_sum=Pages
overview_title_readpages_sum=Pages read
overview_title_mostreadpage_sum=Most read page
overview_title_userreadmorepage_sum=User who has read the most pages

# Report list
report_my_instr=Private reports, available for this site only.
Expand Down Expand Up @@ -252,13 +259,16 @@ th_date=Date
th_lastdate=Most recent date
th_total=Total
th_resource=Resource
th_page=Page
th_action=Action
th_visits=Visits
th_uniquevisitors=Unique visitors
th_duration=Duration
action_all=All
action_create=Create
action_new=New
action_read=Read
action_update=Update
action_revise=Revise
action_delete=Delete
no_data=No data available
Expand All @@ -267,6 +277,7 @@ user_unknown=[nonexistent user]
user_anonymous=[user identity protected]
user_anonymous_access=[anonymous access]
resource_unknown=[nonexistent resource]
page_unknown=[nonexistent page]
bt_export=Export ->
bt_export_excel=Export XLS
bt_export_csv=Export CSV
Expand Down
1 change: 1 addition & 0 deletions sitestats/sitestats-impl-hib/src/ddl/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<session-factory>
<mapping resource="org/sakaiproject/sitestats/impl/hbm/PrefsImpl.hbm.xml" />
<mapping resource="org/sakaiproject/sitestats/impl/hbm/EventStatImpl.hbm.xml" />
<mapping resource="org/sakaiproject/sitestats/impl/hbm/LessonBuilderStatImpl.hbm.xml" />
<mapping resource="org/sakaiproject/sitestats/impl/hbm/ResourceStatImpl.hbm.xml" />
<mapping resource="org/sakaiproject/sitestats/impl/hbm/SiteVisitsImpl.hbm.xml" />
<mapping resource="org/sakaiproject/sitestats/impl/hbm/SitePresenceImpl.hbm.xml" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/**
* $URL$
* $Id$
*
* Copyright (c) 2006-2009 The Sakai Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ECL-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sakaiproject.sitestats.impl;

import java.io.Serializable;
import java.util.Date;

import org.sakaiproject.sitestats.api.LessonBuilderStat;

import lombok.Getter;
import lombok.Setter;

/**
* @author Adrian Fish <[email protected]>
*/
@Getter @Setter
public class LessonBuilderStatImpl implements LessonBuilderStat, Serializable {

private static final long serialVersionUID = 1L;

private long id;
private String userId;
private String siteId;
private String pageRef;
private String pageAction;
private String pageTitle;
private long pageId;
private long count;
private Date date;

public boolean equals(Object o) {

if(o == null) return false;
if(!(o instanceof LessonBuilderStatImpl)) return false;
LessonBuilderStatImpl other = (LessonBuilderStatImpl) o;
return id == other.getId()
&& siteId.equals(other.getSiteId())
&& userId.equals(other.getUserId())
&& pageRef.equals(other.getPageRef())
&& pageAction.equals(other.getPageAction())
&& pageTitle.equals(other.getPageTitle())
&& pageId == other.getPageId()
&& count == other.getCount()
&& date.equals(other.getDate());
}

@Override
public int compareTo(LessonBuilderStat other) {

int val = siteId.compareTo(other.getSiteId());
if (val != 0) return val;
val = userId.compareTo(other.getUserId());
if (val != 0) return val;
val = pageRef.compareTo(other.getPageRef());
if (val != 0) return val;
val = pageAction.compareTo(other.getPageAction());
if (val != 0) return val;
val = pageTitle.compareTo(other.getPageTitle());
if (val != 0) return val;
val = Long.signum(pageId - other.getPageId());
if (val != 0) return val;
val = date.compareTo(other.getDate());
if (val != 0) return val;
val = Long.signum(count - other.getCount());
if (val != 0) return val;
val = Long.signum(id - other.getId());
return val;
}

public int hashCode() {

if (siteId == null) return Integer.MIN_VALUE;
String hashStr = this.getClass().getName() + ":"
+ id
+ userId.hashCode()
+ siteId.hashCode()
+ pageRef.hashCode()
+ pageAction.hashCode()
+ pageTitle.hashCode()
+ pageId
+ count
+ date.hashCode();
return hashStr.hashCode();
}

public String toString() {

return siteId + " : " + userId + " : " + pageRef + " : "
+ pageAction + ":" + pageTitle + " : " + pageId + ":" + count + " : " + date;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.sakaiproject.sitestats.impl.LessonBuilderStatImpl"
table="SST_LESSONBUILDER"
lazy="true">
<id name="id" type="long" column="ID" unsaved-value="0">
<generator class="native">
<param name="sequence">SST_LESSONBUILDER_ID</param>
</generator>
</id>
<property name="userId" column="USER_ID" type="string" length="99" not-null="true" index="SST_LESSONBUILDER_USER_ID_IX" />
<property name="siteId" column="SITE_ID" type="string" length="99" not-null="true" index="SST_LESSONBUILDER_SITE_ID_IX" />
<property name="pageRef" column="PAGE_REF" type="string" length="255" not-null="true" />
<property name="pageId" column="PAGE_ID" type="long" not-null="true" />
<property name="pageAction" column="PAGE_ACTION" type="string" length="12" not-null="true" index="SST_LESSONBUILDER_PAGE_ACT_IDX"/>
<property name="date" column="PAGE_DATE" type="date" not-null="true" index="SST_LESSONBUILDER_DATE_IX" />
<property name="count" column="PAGE_COUNT" type="long" not-null="true" />
</class>
</hibernate-mapping>
4 changes: 4 additions & 0 deletions sitestats/sitestats-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
<groupId>org.sakaiproject.scheduler</groupId>
<artifactId>scheduler-component-shared</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.lessonbuilder</groupId>
<artifactId>lessonbuilder-api</artifactId>
</dependency>

<!-- Spring & Hibernate -->
<dependency>
Expand Down
1 change: 1 addition & 0 deletions sitestats/sitestats-impl/src/bundle/hbm-db.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<list>
<value>org/sakaiproject/sitestats/impl/hbm/PrefsImpl.hbm.xml</value>
<value>org/sakaiproject/sitestats/impl/hbm/EventStatImpl.hbm.xml</value>
<value>org/sakaiproject/sitestats/impl/hbm/LessonBuilderStatImpl.hbm.xml</value>
<value>org/sakaiproject/sitestats/impl/hbm/ResourceStatImpl.hbm.xml</value>
<value>org/sakaiproject/sitestats/impl/hbm/SiteVisitsImpl.hbm.xml</value>
<value>org/sakaiproject/sitestats/impl/hbm/SiteActivityImpl.hbm.xml</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<property name="siteService" ref="org.sakaiproject.site.api.SiteService"/>
<property name="serverConfigurationService" ref="org.sakaiproject.component.api.ServerConfigurationService"/>
<property name="toolManager" ref="org.sakaiproject.tool.api.ToolManager"/>
<property name="lessonBuilderService" ref="org.sakaiproject.lessonbuildertool.model.SimplePageToolDao" />
<property name="memoryService" ref="org.sakaiproject.memory.api.MemoryService" />
<property name="sessionManager" ref="org.sakaiproject.tool.api.SessionManager"/>
<property name="eventTrackingService" ref="org.sakaiproject.event.api.EventTrackingService"/>
Expand Down
Loading

0 comments on commit 559b532

Please sign in to comment.