ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

SchedConfStatisticsDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
15 //$Id$
16 
17 define('REPORT_TYPE_CONFERENCE', 0x00001);
18 define('REPORT_TYPE_SCHED_CONF', 0x00002);
19 define('REPORT_TYPE_DIRECTOR', 0x00003);
20 define('REPORT_TYPE_REVIEWER', 0x00004);
21 define('REPORT_TYPE_TRACK', 0x00005);
22 
23 class SchedConfStatisticsDAO extends DAO {
33  function getPaperStatistics($schedConfId, $trackIds = null, $dateStart = null, $dateEnd = null) {
34  // Bring in status constants
35  import('paper.Paper');
36 
37  $params = array($schedConfId);
38  if (!empty($trackIds)) {
39  $trackSql = ' AND (a.track_id = ?';
40  $params[] = array_shift($trackIds);
41  foreach ($trackIds as $trackId) {
42  $trackSql .= ' OR a.track_id = ?';
43  $params[] = $trackId;
44  }
45  $trackSql .= ')';
46  } else $trackSql = '';
47 
48  $sql = 'SELECT a.paper_id,
49  a.date_submitted,
50  pa.date_published,
51  pa.pub_id,
52  d.decision,
53  a.status
54  FROM papers a
55  LEFT JOIN published_papers pa ON (a.paper_id = pa.paper_id)
56  LEFT JOIN edit_decisions d ON (d.paper_id = a.paper_id)
57  WHERE a.sched_conf_id = ?' .
58  ($dateStart !== null ? ' AND a.date_submitted >= ' . $this->datetimeToDB($dateStart) : '') .
59  ($dateEnd !== null ? ' AND a.date_submitted <= ' . $this->datetimeToDB($dateEnd) : '') .
60  $trackSql .
61  ' ORDER BY a.paper_id, d.date_decided DESC';
62 
63  $result =& $this->retrieve($sql, $params);
64 
65  $returner = array(
66  'numSubmissions' => 0,
67  'numReviewedSubmissions' => 0,
68  'numPublishedSubmissions' => 0,
69  'submissionsAccept' => 0,
70  'submissionsDecline' => 0,
71  'submissionsRevise' => 0,
72  'submissionsAcceptPercent' => 0,
73  'submissionsDeclinePercent' => 0,
74  'submissionsRevisePercent' => 0,
75  'daysToPublication' => 0
76  );
77 
78  // Track which papers we're including
79  $paperIds = array();
80 
81  $totalTimeToPublication = 0;
82  $timeToPublicationCount = 0;
83 
84  while (!$result->EOF) {
85  $row = $result->GetRowAssoc(false);
86 
87  // For each paper, pick the most recent director
88  // decision only and ignore the rest. Depends on sort
89  // order. FIXME -- there must be a better way of doing
90  // this that's database independent.
91  if (!in_array($row['paper_id'], $paperIds)) {
92  $paperIds[] = $row['paper_id'];
93  $returner['numSubmissions']++;
94 
95  if (!empty($row['pub_id']) && $row['status'] == STATUS_PUBLISHED) {
96  $returner['numPublishedSubmissions']++;
97  }
98 
99  if (!empty($row['date_submitted']) && !empty($row['date_published']) && $row['status'] == STATUS_PUBLISHED) {
100  $timeSubmitted = strtotime($this->datetimeFromDB($row['date_submitted']));
101  $timePublished = strtotime($this->datetimeFromDB($row['date_published']));
102  if ($timePublished > $timeSubmitted) {
103  $totalTimeToPublication += ($timePublished - $timeSubmitted);
104  $timeToPublicationCount++;
105  }
106  }
107 
108  import('submission.common.Action');
109  switch ($row['decision']) {
111  $returner['submissionsAccept']++;
112  $returner['numReviewedSubmissions']++;
113  break;
115  $returner['submissionsRevise']++;
116  break;
118  $returner['submissionsDecline']++;
119  $returner['numReviewedSubmissions']++;
120  break;
121  }
122  }
123 
124  $result->moveNext();
125  }
126 
127  $result->Close();
128  unset($result);
129 
130  // Calculate percentages where necessary
131  if ($returner['numReviewedSubmissions'] != 0) {
132  $returner['submissionsAcceptPercent'] = round($returner['submissionsAccept'] * 100 / $returner['numReviewedSubmissions']);
133  $returner['submissionsDeclinePercent'] = round($returner['submissionsDecline'] * 100 / $returner['numReviewedSubmissions']);
134  $returner['submissionsRevisePercent'] = round($returner['submissionsRevise'] * 100 / $returner['numReviewedSubmissions']);
135  }
136 
137  if ($timeToPublicationCount != 0) {
138  // Keep one sig fig
139  $returner['daysToPublication'] = round($totalTimeToPublication / $timeToPublicationCount / 60 / 60 / 24);
140  }
141 
142  return $returner;
143  }
144 
153  function getUserStatistics($schedConfId, $dateStart = null, $dateEnd = null) {
154  $roleDao =& DAORegistry::getDAO('RoleDAO');
155 
156  // Get count of total users for this scheduled conference
157  $result =& $this->retrieve(
158  'SELECT COUNT(DISTINCT r.user_id) FROM roles r, users u WHERE r.user_id = u.user_id AND r.sched_conf_id = ?' .
159  ($dateStart !== null ? ' AND u.date_registered >= ' . $this->datetimeToDB($dateStart) : '') .
160  ($dateEnd !== null ? ' AND u.date_registered <= ' . $this->datetimeToDB($dateEnd) : ''),
161  $schedConfId
162  );
163 
164  $returner = array(
165  'totalUsersCount' => $result->fields[0]
166  );
167 
168  $result->Close();
169  unset($result);
170 
171  // Get user counts for each role.
172  $result =& $this->retrieve(
173  'SELECT r.role_id, COUNT(r.user_id) AS role_count FROM roles r LEFT JOIN users u ON (r.user_id = u.user_id) WHERE r.sched_conf_id = ?' .
174  ($dateStart !== null ? ' AND u.date_registered >= ' . $this->datetimeToDB($dateStart) : '') .
175  ($dateEnd !== null ? ' AND u.date_registered <= ' . $this->datetimeToDB($dateEnd) : '') .
176  'GROUP BY r.role_id',
177  $schedConfId
178  );
179 
180  while (!$result->EOF) {
181  $row = $result->GetRowAssoc(false);
182  $returner[$roleDao->getRolePath($row['role_id'])] = $row['role_count'];
183  $result->moveNext();
184  }
185 
186  $result->Close();
187  unset($result);
188 
189  return $returner;
190  }
191 
199  function getRegistrationStatistics($schedConfId, $dateStart = null, $dateEnd = null) {
200  $result =& $this->retrieve(
201  'SELECT st.type_id,
202  rts.setting_value AS type_name,
203  COUNT(s.registration_id) AS type_count
204  FROM registration_types st
205  LEFT JOIN sched_confs sc ON (st.sched_conf_id = sc.sched_conf_id)
206  LEFT JOIN conferences c ON (sc.conference_id = c.conference_id)
207  LEFT JOIN registration_type_settings rts ON (rts.type_id = st.type_id AND rts.setting_name = ? AND rts.locale = c.primary_locale),
208  registrations s
209  WHERE st.sched_conf_id = ? AND
210  s.type_id = st.type_id' .
211  ($dateStart !== null ? ' AND st.opening_date >= ' . $this->datetimeToDB($dateStart) : '') .
212  ($dateEnd !== null ? ' AND st.closing_date <= ' . $this->datetimeToDB($dateEnd) : '') .
213  ' GROUP BY st.type_id, rts.setting_value',
214  array('name', $schedConfId)
215  );
216 
217  $returner = array();
218 
219  while (!$result->EOF) {
220  $row = $result->getRowAssoc(false);
221  $returner[$row['type_id']] = array(
222  'name' => $row['type_name'],
223  'count' => $row['type_count']
224  );
225  $result->moveNext();
226  }
227  $result->Close();
228  unset($result);
229 
230  return $returner;
231  }
232 
241  function getIssueStatistics($schedConfId, $dateStart = null, $dateEnd = null) {
242  $result =& $this->retrieve(
243  'SELECT COUNT(*) AS count, published FROM issues WHERE sched_conf_id = ?' .
244  ($dateStart !== null ? ' AND date_published >= ' . $this->datetimeToDB($dateStart) : '') .
245  ($dateEnd !== null ? ' AND date_published <= ' . $this->datetimeToDB($dateEnd) : '') .
246  ' GROUP BY published',
247  $schedConfId
248  );
249 
250  $returner = array(
251  'numPublishedIssues' => 0,
252  'numUnpublishedIssues' => 0
253  );
254 
255  while (!$result->EOF) {
256  $row = $result->GetRowAssoc(false);
257 
258  if ($row['published']) {
259  $returner['numPublishedIssues'] = $row['count'];
260  } else {
261  $returner['numUnpublishedIssues'] = $row['count'];
262  }
263  $result->moveNext();
264  }
265 
266  $result->Close();
267  unset($result);
268 
269  $returner['numIssues'] = $returner['numPublishedIssues'] + $returner['numUnpublishedIssues'];
270 
271  return $returner;
272  }
273 
282  function getReviewerStatistics($schedConfId, $trackIds, $dateStart = null, $dateEnd = null) {
283  $params = array($schedConfId);
284  if (!empty($trackIds)) {
285  $trackSql = ' AND (a.track_id = ?';
286  $params[] = array_shift($trackIds);
287  foreach ($trackIds as $trackId) {
288  $trackSql .= ' OR a.track_id = ?';
289  $params[] = $trackId;
290  }
291  $trackSql .= ')';
292  } else $trackSql = '';
293 
294  $sql = 'SELECT a.paper_id,
295  af.date_uploaded AS date_rv_uploaded,
296  r.review_id,
297  u.date_registered,
298  r.reviewer_id,
299  r.quality AS quality,
300  r.date_assigned,
301  r.date_completed
302  FROM papers a,
303  paper_files af,
304  review_assignments r
305  LEFT JOIN users u ON (u.user_id = r.reviewer_id)
306  WHERE a.sched_conf_id = ? AND
307  r.paper_id = a.paper_id AND
308  af.paper_id = a.paper_id AND
309  af.file_id = a.review_file_id AND
310  af.revision = 1' .
311  ($dateStart !== null ? ' AND a.date_submitted >= ' . $this->datetimeToDB($dateStart) : '') .
312  ($dateEnd !== null ? ' AND a.date_submitted <= ' . $this->datetimeToDB($dateEnd) : '') .
313  $trackSql;
314  $result =& $this->retrieve($sql, $params);
315 
316  $returner = array(
317  'reviewsCount' => 0,
318  'reviewerScore' => 0,
319  'daysPerReview' => 0,
320  'reviewerAddedCount' => 0,
321  'reviewerCount' => 0,
322  'reviewedSubmissionsCount' => 0
323  );
324 
325  $scoredReviewsCount = 0;
326  $totalScore = 0;
327  $completedReviewsCount = 0;
328  $totalElapsedTime = 0;
329  $reviewerList = array();
330  $paperIds = array();
331 
332  while (!$result->EOF) {
333  $row = $result->GetRowAssoc(false);
334  $returner['reviewsCount']++;
335  if (!empty($row['quality'])) {
336  $scoredReviewsCount++;
337  $totalScore += $row['quality'];
338  }
339 
340  $paperIds[] = $row['paper_id'];
341 
342  if (!empty($row['reviewer_id']) && !in_array($row['reviewer_id'], $reviewerList)) {
343  $returner['reviewerCount']++;
344  $dateRegistered = strtotime($this->datetimeFromDB($row['date_registered']));
345  if (($dateRegistered >= $dateStart || $dateStart === null) && ($dateRegistered <= $dateEnd || $dateEnd == null)) {
346  $returner['reviewerAddedCount']++;
347  }
348  array_push($reviewerList, $row['reviewer_id']);
349  }
350 
351  if (!empty($row['date_assigned']) && !empty($row['date_completed'])) {
352  $timeReviewVersionUploaded = strtotime($this->datetimeFromDB($row['date_rv_uploaded']));
353  $timeCompleted = strtotime($this->datetimeFromDB($row['date_completed']));
354  if ($timeCompleted > $timeReviewVersionUploaded) {
355  $completedReviewsCount++;
356  $totalElapsedTime += ($timeCompleted - $timeReviewVersionUploaded);
357  }
358  }
359  $result->moveNext();
360  }
361 
362  $result->Close();
363  unset($result);
364 
365  if ($scoredReviewsCount > 0) {
366  // To one decimal place
367  $returner['reviewerScore'] = round($totalScore * 10 / $scoredReviewsCount) / 10;
368  }
369  if ($completedReviewsCount > 0) {
370  $seconds = $totalElapsedTime / $completedReviewsCount;
371  $returner['daysPerReview'] = $seconds / 60 / 60 / 24;
372  }
373 
374  $paperIds = array_unique($paperIds);
375  $returner['reviewedSubmissionsCount'] = count($paperIds);
376 
377  return $returner;
378  }
379 }
380 
381 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
const SUBMISSION_DIRECTOR_DECISION_PENDING_REVISIONS
Definition: Action.inc.php:24
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
getPaperStatistics($schedConfId, $trackIds=null, $dateStart=null, $dateEnd=null)
getReviewerStatistics($schedConfId, $trackIds, $dateStart=null, $dateEnd=null)
const SUBMISSION_DIRECTOR_DECISION_ACCEPT
Definition: Action.inc.php:23
datetimeFromDB($dt)
Definition: DAO.inc.php:276
const SUBMISSION_DIRECTOR_DECISION_DECLINE
Definition: Action.inc.php:25
& getDAO($name, $dbconn=null)
getIssueStatistics($schedConfId, $dateStart=null, $dateEnd=null)
datetimeToDB($dt)
Definition: DAO.inc.php:258
getUserStatistics($schedConfId, $dateStart=null, $dateEnd=null)
Operations for retrieving scheduled conference statistics.
getRegistrationStatistics($schedConfId, $dateStart=null, $dateEnd=null)
const STATUS_PUBLISHED
Definition: Paper.inc.php:27