Interoperable interactive geometry for Europe
I forgot my login data
Register


Report a bug


Fan club

Quick Intro Videos
click to start movie
Create A Simple
GeoGebra Resource (25Mb)
click to start movie
Filing a review
click to start movie
Find a Resource

SPONSORS
This platform is brought to you by the intergeo project, funded under the eContent Plus programme of the European commission and by partners

import com.xpn.xwiki.*; import com.xpn.xwiki.doc.*; import com.xpn.xwiki.objects.*; import com.xpn.xwiki.api.Document; import com.xpn.xwiki.api.XWiki;

/** This class supposes doc defined to be an object of type documents which contains a review object. */

public class SummaryMaintainer {

public boolean updateSummary(String resourceURL, XWiki xwiki) { System.out.println("Will update summary for resourceURL "" + resourceURL + "".");

def summary = xwiki.getDocument(resourceURL). getObject("QF.ReviewSummaryClass"); if(summary==null) { summary = xwiki.getDocument(resourceURL) .newObject("QF.ReviewSummaryClass"); summary.resource = resourceURL; }

def hql = ", BaseObject as obj, StringProperty as prop where doc.web = 'QF' " + " and obj.name=doc.fullName and obj.id=prop.id.id and prop.name='resource' " + " and prop.value='"+resourceURL +"'"; def docs = xwiki.searchDocuments(hql);

long totalScore = 0, lastReviewed = 0, numReviews = 0; for(d in docs) { System.out.println("d = " + d); d = xwiki.getDocument(d); def obj = d.getObject("QF.ReviewClass"); if(obj == null) continue; def s = d.overallRanking; def score = null; if(s==null || s == 0 || s.length()==0) continue; score = Integer.parseInt(s); if(lastReviewed < d.date.time) lastReviewed = d.date.time; totalScore += score; numReviews++; }

if(numReviews==0) { summary.summaryRank = null; summary.lastReviewDate = null; summary.numberOfReviews = numReviews; System.out.println("No reviews founds."); } else { summary.summaryRank = (int) (totalScore1.0/(numReviews1.0)); summary.lastReviewDate = new Date(lastReviewed); summary.numberOfReviews = numReviews; System.out.println("mean " + summary.summaryRank + " last " + lastReviewed + " num "+ numReviews); } return true; } }