Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom-dependency-tree.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ai.elimu:webapp:war:2.6.10-SNAPSHOT
ai.elimu:webapp:war:2.6.11-SNAPSHOT
+- ai.elimu:model:jar:model-2.0.97:compile
| \- com.google.code.gson:gson:jar:2.13.0:compile
| \- com.google.errorprone:error_prone_annotations:jar:2.37.0:compile
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ai/elimu/dao/DeviceDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import ai.elimu.entity.Device;

@Deprecated
public interface DeviceDao extends GenericDao<Device> {

Device read(String androidId) throws DataAccessException;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/ai/elimu/dao/StudentDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ai.elimu.dao;

import org.springframework.dao.DataAccessException;
import ai.elimu.entity.analytics.students.Student;

public interface StudentDao extends GenericDao<Student> {

Student read(String androidId) throws DataAccessException;
}
1 change: 1 addition & 0 deletions src/main/java/ai/elimu/dao/jpa/DeviceDaoJpa.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.springframework.dao.DataAccessException;

@Deprecated
public class DeviceDaoJpa extends GenericDaoJpa<Device> implements DeviceDao {

@Override
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/ai/elimu/dao/jpa/StudentDaoJpa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ai.elimu.dao.jpa;

import jakarta.persistence.NoResultException;
import ai.elimu.dao.StudentDao;
import ai.elimu.entity.analytics.students.Student;
import org.springframework.dao.DataAccessException;

public class StudentDaoJpa extends GenericDaoJpa<Student> implements StudentDao {

@Override
public Student read(String androidId) throws DataAccessException {
try {
return (Student) em.createQuery(
"SELECT s " +
"FROM Student s " +
"WHERE s.androidId = :androidId")
.setParameter("androidId", androidId)
.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
}
1 change: 1 addition & 0 deletions src/main/java/ai/elimu/entity/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@Entity
@Getter
@Setter
@Deprecated
public class Device extends BaseEntity {

@NotNull
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/ai/elimu/entity/analytics/students/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ai.elimu.entity.analytics.students;

import ai.elimu.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
public class Student extends BaseEntity {

/**
* A 64-bit number (expressed as a hexadecimal string), unique to each combination of
* app-signing key, user, and device.
*
* See https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID
*/
@NotNull
@Column(unique = true)
private String androidId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ai.elimu.web.analytics.students;

import ai.elimu.dao.StudentDao;
import ai.elimu.entity.analytics.students.Student;
import ai.elimu.util.AnalyticsHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/analytics/students")
@RequiredArgsConstructor
@Slf4j
public class StudentsListController {

private final StudentDao studentDao;

@GetMapping
public String handleRequest(Model model) {
log.info("handleRequest");

List<Student> students = studentDao.readAll();
for (Student student : students) {
student.setAndroidId(AnalyticsHelper.redactAndroidId(student.getAndroidId()));
}
model.addAttribute("students", students);

return "analytics/students/list";
}
}
17 changes: 17 additions & 0 deletions src/main/java/ai/elimu/web/servlet/CustomDispatcherServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import ai.elimu.dao.SoundDao;
import ai.elimu.dao.StoryBookChapterDao;
import ai.elimu.dao.StoryBookDao;
import ai.elimu.dao.StudentDao;
import ai.elimu.dao.VideoDao;
import ai.elimu.dao.WordDao;
import ai.elimu.entity.analytics.students.Student;
import ai.elimu.entity.application.Application;
import ai.elimu.entity.content.Emoji;
import ai.elimu.entity.content.Letter;
Expand Down Expand Up @@ -294,5 +296,20 @@ private void populateDatabase(WebApplicationContext webApplicationContext) {
application.setApplicationStatus(ApplicationStatus.MISSING_APK);
application.setContributor(contributor);
applicationDao.create(application);


StudentDao studentDao = (StudentDao) webApplicationContext.getBean("studentDao");

Student student1 = new Student();
student1.setAndroidId("e387e38700000001");
studentDao.create(student1);

Student student2 = new Student();
student2.setAndroidId("e387e38700000002");
studentDao.create(student2);

Student student3 = new Student();
student3.setAndroidId("e387e38700000003");
studentDao.create(student3);
}
}
11 changes: 11 additions & 0 deletions src/main/resources/META-INF/jpa-schema-export.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@

drop table if exists StoryBookPeerReviewEvent;

drop table if exists Student;

drop table if exists Syllable;

drop table if exists Syllable_Sound;
Expand Down Expand Up @@ -479,6 +481,12 @@
primary key (id)
) type=MyISAM;

create table Student (
id bigint not null auto_increment,
androidId varchar(255),
primary key (id)
) type=MyISAM;

create table Syllable (
id bigint not null auto_increment,
contentStatus varchar(255),
Expand Down Expand Up @@ -624,6 +632,9 @@
alter table Device
add constraint UK_c2646199whiqrkjbht7hwyr3v unique (androidId);

alter table Student
add constraint UK_ac9n51iqy52mto0jrnkqlk3ld unique (androidId);

alter table Application
add constraint FKn1pft600om9qs7dn754chjk67
foreign key (contributor_id)
Expand Down
97 changes: 0 additions & 97 deletions src/main/webapp/WEB-INF/jsp/analytics/layout.jsp

This file was deleted.

47 changes: 47 additions & 0 deletions src/main/webapp/WEB-INF/jsp/analytics/students/list.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<content:title>
Students (${fn:length(students)})
</content:title>

<content:banner>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</content:banner>

<content:section cssId="studentsListPage">
<div class="section row">
<table class="bordered highlight">
<thead>
<th>id</th>
<th>android_id</th>
</thead>
<tbody>
<c:forEach var="student" items="${students}">
<tr class="student">
<td>
<a href="<spring:url value='/analytics/students/${student.id}' />">
🎓 Student ${student.id}
</a>
</td>
<td>
<code>${student.androidId}</code>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</content:section>
3 changes: 0 additions & 3 deletions src/main/webapp/WEB-INF/jsp/layout.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<c:when test="${fn:contains(pageContext.request.requestURI, '/jsp/application/')}">
<%@ include file="/WEB-INF/jsp/application/layout.jsp" %>
</c:when>
<c:when test="${fn:contains(pageContext.request.requestURI, '/jsp/analytics/')}">
<%@ include file="/WEB-INF/jsp/analytics/layout.jsp" %>
</c:when>
<c:when test="${fn:contains(pageContext.request.requestURI, '/jsp/content/')}">
<%@ include file="/WEB-INF/jsp/content/layout.jsp" %>
</c:when>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<bean id="storyBookPeerReviewEventDao" class="ai.elimu.dao.jpa.StoryBookPeerReviewEventDaoJpa" />
<bean id="storyBookChapterDao" class="ai.elimu.dao.jpa.StoryBookChapterDaoJpa" />
<bean id="storyBookParagraphDao" class="ai.elimu.dao.jpa.StoryBookParagraphDaoJpa" />
<bean id="studentDao" class="ai.elimu.dao.jpa.StudentDaoJpa" />
<bean id="syllableDao" class="ai.elimu.dao.jpa.SyllableDaoJpa" />
<bean id="videoDao" class="ai.elimu.dao.jpa.VideoDaoJpa" />
<bean id="videoLearningEventDao" class="ai.elimu.dao.jpa.VideoLearningEventDaoJpa" />
Expand Down
3 changes: 0 additions & 3 deletions src/main/webapp/static/css/analytics/styles.css

This file was deleted.