Skip to content

Commit

Permalink
Merge branch 'release-5.13.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima committed Jul 1, 2020
2 parents 093e38b + f04ef5b commit 7a78775
Show file tree
Hide file tree
Showing 95 changed files with 4,964 additions and 4,356 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2008-2018 Regent8 of the University of California (Regents). Created
Copyright (c) 2008-2020 Regents of the University of California (Regents). Created
by WISE, Graduate School of Education, University of California, Berkeley.

This software is distributed under the GNU General Public License, v3,
Expand Down
66 changes: 60 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wise",
"version": "5.12.0",
"version": "5.13.0",
"description": "Web-based Inquiry Science Environment",
"main": "app.js",
"browserslist": [
Expand Down Expand Up @@ -48,7 +48,7 @@
"compute-covariance": "^1.0.1",
"core-js": "^3.6.5",
"cssnano": "^4.1.10",
"dom-autoscroller": "^1.3.1",
"dom-autoscroller": "^2.3.4",
"eventemitter2": "^5.0.1",
"fabric": "^3.6.3",
"hammerjs": "^2.0.8",
Expand All @@ -75,15 +75,16 @@
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.3",
"@angular-builders/custom-webpack": "^9.0.0",
"@angular-devkit/build-angular": "~0.901.3",
"@angular/cli": "^9.1.3",
"@angular/compiler-cli": "^9.0.0",
"@angular/language-service": "^9.0.0",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@locl/cli": "0.0.1-beta.7",
"@types/dom-mediacapture-record": "^1.0.6",
"@types/jasmine": "^3.5.10",
"@types/jasminewd2": "^2.0.8",
"@types/jquery": "^3.3.38",
Expand Down Expand Up @@ -140,7 +141,7 @@
"watch-sass": "npm rebuild node-sass && node ./node_modules/gulp/bin/gulp.js",
"update-i18n": "node ./node_modules/gulp/bin/gulp.js update-i18n",
"compile-sass": "node ./node_modules/gulp/bin/gulp.js compile-sass",
"test": "ng test wise --karma-config src/main/webapp/site/karma.conf.js --browsers ChromeHeadlessNoSandbox --watch=false",
"test": "ng test wise --source-map=false --karma-config src/main/webapp/site/karma.conf.js --browsers ChromeHeadlessNoSandbox --watch=false",
"test-e2e-comment": "test-e2e assumes wise is already running.",
"test-e2e": "node ./node_modules/protractor/bin/protractor src/main/webapp/wise5/test-e2e/conf.js",
"locale-extractor": "./node_modules/.bin/ngx-extractor -i \"src/main/webapp/site/**/*.ts\" -o src/main/webapp/site/src/messages.xlf"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<artifactId>wise</artifactId>
<packaging>war</packaging>
<name>Web-based Inquiry Science Environment</name>
<version>5.12.0</version>
<version>5.13.0</version>
<url>http://wise5.org</url>
<licenses>
<license>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/wise/portal/dao/work/StudentWorkDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ public interface StudentWorkDao<T extends StudentWork> extends SimpleDao<T> {

List<StudentWork> getStudentWorkListByParams(Integer id, Run run, Group period,
Workgroup workgroup, Boolean isAutoSave, Boolean isSubmit, String nodeId, String componentId,
String componentType, List<JSONObject> components, Boolean latest);
String componentType, List<JSONObject> components);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;

import org.hibernate.Session;
import org.json.JSONException;
Expand All @@ -52,13 +51,13 @@
@Repository
public class HibernateStudentWorkDao extends AbstractHibernateDao<StudentWork>
implements StudentWorkDao<StudentWork> {

@PersistenceContext
private EntityManager entityManager;

private CriteriaBuilder getCriteriaBuilder() {
Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
return session.getCriteriaBuilder();
return session.getCriteriaBuilder();
}

@Override
Expand All @@ -74,34 +73,17 @@ protected Class<? extends StudentWork> getDataObjectClass() {
@Override
public List<StudentWork> getStudentWorkListByParams(Integer id, Run run, Group period,
Workgroup workgroup, Boolean isAutoSave, Boolean isSubmit, String nodeId, String componentId,
String componentType, List<JSONObject> components, Boolean onlyGetLatest) {
if (Boolean.TRUE.equals(onlyGetLatest)) {
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<StudentWork> cq = cb.createQuery(StudentWork.class);
Subquery<Long> subQuery = cq.subquery(Long.class);
Root<StudentWork> subStudentWorkRoot = subQuery.from(StudentWork.class);
List<Predicate> predicates = getStudentWorkListByParamsPredicates(cb, subStudentWorkRoot,
id, run, period, workgroup, isAutoSave, isSubmit, nodeId, componentId, componentType,
components);
subQuery.select(cb.max(subStudentWorkRoot.get("id")))
.where(predicates.toArray(new Predicate[predicates.size()]))
.groupBy(subStudentWorkRoot.get("workgroup"));
Root<StudentWork> studentWorkRoot = cq.from(StudentWork.class);
cq.select(studentWorkRoot).where(cb.in(studentWorkRoot.get("id")).value(subQuery));
TypedQuery<StudentWork> query = entityManager.createQuery(cq);
return (List<StudentWork>) query.getResultList();
} else {
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<StudentWork> cq = cb.createQuery(StudentWork.class);
Root<StudentWork> studentWorkRoot = cq.from(StudentWork.class);
List<Predicate> predicates = getStudentWorkListByParamsPredicates(cb, studentWorkRoot,
id, run, period, workgroup, isAutoSave, isSubmit, nodeId, componentId, componentType,
components);
cq.select(studentWorkRoot).where(predicates.toArray(new Predicate[predicates.size()]))
.orderBy(cb.asc(studentWorkRoot.get("serverSaveTime")));
TypedQuery<StudentWork> query = entityManager.createQuery(cq);
return (List<StudentWork>) query.getResultList();
}
String componentType, List<JSONObject> components) {
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<StudentWork> cq = cb.createQuery(StudentWork.class);
Root<StudentWork> studentWorkRoot = cq.from(StudentWork.class);
List<Predicate> predicates = getStudentWorkListByParamsPredicates(cb, studentWorkRoot,
id, run, period, workgroup, isAutoSave, isSubmit, nodeId, componentId, componentType,
components);
cq.select(studentWorkRoot).where(predicates.toArray(new Predicate[predicates.size()]))
.orderBy(cb.asc(studentWorkRoot.get("serverSaveTime")));
TypedQuery<StudentWork> query = entityManager.createQuery(cq);
return (List<StudentWork>) query.getResultList();
}

private List<Predicate> getStudentWorkListByParamsPredicates(CriteriaBuilder cb,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/wise/portal/domain/workgroup/Workgroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public interface Workgroup extends Persistable {
*/
Long getId();

void setId(Long id);

/**
* Generates a name for this workgroup.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
package org.wise.portal.service.vle.wise5.impl;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;

import javax.transaction.Transactional;
Expand Down Expand Up @@ -146,8 +148,30 @@ public List<StudentWork> getStudentWorkList(Integer id, Integer runId, Integer p
}
}

return studentWorkDao.getStudentWorkListByParams(id, run, period, workgroup, isAutoSave,
isSubmit, nodeId, componentId, componentType, components, onlyGetLatest);
List<StudentWork> studentWorkListByParams = studentWorkDao.getStudentWorkListByParams(id, run,
period, workgroup, isAutoSave, isSubmit, nodeId, componentId, componentType, components);
if (Boolean.TRUE.equals(onlyGetLatest)) {
return filterLatestWorkForEachWorkgroup(studentWorkListByParams);
} else {
return studentWorkListByParams;
}
}

private List<StudentWork> filterLatestWorkForEachWorkgroup(
List<StudentWork> allStudentWork) {
HashMap<Long, StudentWork> latestWorkPerWorkgroup = new HashMap<Long, StudentWork>();
for (StudentWork studentWork : allStudentWork) {
Long key = studentWork.getWorkgroup().getId();
if (latestWorkPerWorkgroup.containsKey(key)) {
if (studentWork.getServerSaveTime().after(
latestWorkPerWorkgroup.get(key).getServerSaveTime())) {
latestWorkPerWorkgroup.put(key, studentWork);
}
} else {
latestWorkPerWorkgroup.put(studentWork.getWorkgroup().getId(), studentWork);
}
}
return new ArrayList<StudentWork>(latestWorkPerWorkgroup.values());
}

public JSONArray getNotebookItemsExport(Integer runId) {
Expand Down
Loading

0 comments on commit 7a78775

Please sign in to comment.