Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
ReviewAssignmentDAO.inc.php
1 <?php
2 
18 import('lib.pkp.classes.submission.reviewAssignment.ReviewAssignment');
19 
20 class ReviewAssignmentDAO extends DAO {
21  var $userDao;
22 
26  function ReviewAssignmentDAO() {
27  parent::DAO();
28  $this->userDao = DAORegistry::getDAO('UserDAO');
29  }
30 
31 
38  function getByReviewRoundId($reviewRoundId, $excludeCancelled = false) {
39  $params = array((int)$reviewRoundId);
40 
41  $query = $this->_getSelectQuery() .
42  ' WHERE r.review_round_id = ?';
43 
44  if ($excludeCancelled) {
45  $query .= ' AND (r.cancelled = 0 OR r.cancelled IS NULL)';
46  }
47 
48  $query .= ' ORDER BY review_id';
49 
50  return $this->_getReviewAssignmentsArray($query, $params);
51  }
52 
60  function _getReviewAssignmentsArray($query, $queryParams) {
61  $reviewAssignments = array();
62 
63  $result = $this->retrieve($query, $queryParams);
64 
65  while (!$result->EOF) {
66  $reviewAssignments[$result->fields['review_id']] = $this->_fromRow($result->GetRowAssoc(false));
67  $result->MoveNext();
68  }
69 
70  $result->Close();
71  return $reviewAssignments;
72  }
73 
79  function getReviewRoundJoin() {
80  return 'r.review_round_id = r2.review_round_id';
81  }
82 
83 
84  //
85  // Public methods.
86  //
93  function getReviewAssignment($reviewRoundId, $reviewerId) {
94  $result = $this->retrieve(
95  $this->_getSelectQuery() .
96  ' WHERE r.review_round_id = ? AND
97  r.reviewer_id = ? AND
98  r.cancelled <> 1',
99  array(
100  (int) $reviewRoundId,
101  (int) $reviewerId
102  )
103  );
104 
105  $returner = null;
106  if ($result->RecordCount() != 0) {
107  $returner = $this->_fromRow($result->GetRowAssoc(false));
108  }
109 
110  $result->Close();
111  return $returner;
112  }
113 
114 
120  function getById($reviewId) {
121  $reviewRoundJoinString = $this->getReviewRoundJoin();
122  if ($reviewRoundJoinString) {
123  $result = $this->retrieve(
124  'SELECT r.*, r2.review_revision, u.first_name, u.last_name
125  FROM review_assignments r
126  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
127  LEFT JOIN review_rounds r2 ON (' . $reviewRoundJoinString . ')
128  WHERE r.review_id = ?',
129  (int) $reviewId
130  );
131 
132  $returner = null;
133  if ($result->RecordCount() != 0) {
134  $returner = $this->_fromRow($result->GetRowAssoc(false));
135  }
136 
137  $result->Close();
138  return $returner;
139  } else {
140  assert(false);
141  }
142  }
143 
150  $reviewAssignments = array();
151  $reviewRoundJoinString = $this->getReviewRoundJoin();
152  if ($reviewRoundJoinString) {
153  $result = $this->retrieve(
154  'SELECT r.*, r2.review_revision, u.first_name, u.last_name
155  FROM review_assignments r
156  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
157  LEFT JOIN review_rounds r2 ON (' . $reviewRoundJoinString . ')
159  ' ORDER BY r.submission_id'
160  );
161 
162  while (!$result->EOF) {
163  $reviewAssignments[] = $this->_fromRow($result->GetRowAssoc(false));
164  $result->MoveNext();
165  }
166 
167  $result->Close();
168  } else {
169  assert(false);
170  }
171 
172  return $reviewAssignments;
173  }
174 
181  return ' (r.cancelled IS NULL OR r.cancelled = 0) AND
182  r.date_notified IS NOT NULL AND
183  r.date_completed IS NULL AND
184  r.declined <> 1';
185  }
186 
194  function getBySubmissionId($submissionId, $reviewRoundId = null, $stageId = null) {
195  $query = $this->_getSelectQuery() .
196  ' WHERE r.submission_id = ?';
197 
198  $orderBy = ' ORDER BY review_id';
199 
200  $queryParams[] = (int) $submissionId;
201 
202  if ($reviewRoundId != null) {
203  $query .= ' AND r2.review_round_id = ?';
204  $queryParams[] = (int) $reviewRoundId;
205  } else {
206  $orderBy .= ', r2.review_round_id';
207  }
208 
209  if ($stageId != null) {
210  $query .= ' AND r2.stage_id = ?';
211  $queryParams[] = (int) $stageId;
212  } else {
213  $orderBy .= ', r2.stage_id';
214  }
215 
216  $query .= $orderBy;
217 
218  return $this->_getReviewAssignmentsArray($query, $queryParams);
219  }
220 
226  function getByUserId($userId) {
227  $reviewAssignments = array();
228  $reviewRoundJoinString = $this->getReviewRoundJoin();
229 
230  if ($reviewRoundJoinString) {
231  $result = $this->retrieve(
232  'SELECT r.*, r2.review_revision, u.first_name, u.last_name
233  FROM review_assignments r
234  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
235  LEFT JOIN review_rounds r2 ON (' . $reviewRoundJoinString . ')
236  WHERE r.reviewer_id = ?
237  ORDER BY round, review_id',
238  (int) $userId
239  );
240 
241  while (!$result->EOF) {
242  $reviewAssignments[] = $this->_fromRow($result->GetRowAssoc(false));
243  $result->MoveNext();
244  }
245 
246  $result->Close();
247  } else {
248  assert(false);
249  }
250 
251  return $reviewAssignments;
252  }
253 
260  function reviewerExists($reviewRoundId, $reviewerId) {
261  $result = $this->retrieve(
262  'SELECT COUNT(*)
263  FROM review_assignments
264  WHERE review_round_id = ? AND
265  reviewer_id = ? AND
266  cancelled = 0',
267  array((int) $reviewRoundId, (int) $reviewerId)
268  );
269  $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
270 
271  $result->Close();
272  return $returner;
273  }
274 
280  function getByReviewFormId($reviewFormId) {
281  $reviewAssignments = array();
282  $reviewRoundJoinString = $this->getReviewRoundJoin();
283 
284  if ($reviewRoundJoinString) {
285  $result = $this->retrieve(
286  'SELECT r.*, r2.review_revision, u.first_name, u.last_name
287  FROM review_assignments r
288  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
289  LEFT JOIN review_rounds r2 ON (' . $reviewRoundJoinString . ')
290  WHERE r.review_form_id = ?
291  ORDER BY round, review_id',
292  (int) $reviewFormId
293  );
294 
295  while (!$result->EOF) {
296  $reviewAssignments[] = $this->_fromRow($result->GetRowAssoc(false));
297  $result->MoveNext();
298  }
299 
300  $result->Close();
301  } else {
302  assert(false);
303  }
304 
305  return $reviewAssignments;
306  }
307 
313  function getCancelsAndRegrets($submissionId) {
314  $reviewAssignments = array();
315  $reviewRoundJoinString = $this->getReviewRoundJoin();
316 
317  if ($reviewRoundJoinString) {
318  $result = $this->retrieve(
319  'SELECT r.*, r2.review_revision, u.first_name, u.last_name
320  FROM review_assignments r
321  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
322  LEFT JOIN review_rounds r2 ON (' . $reviewRoundJoinString . ')
323  WHERE r.submission_id = ? AND
324  (r.cancelled = 1 OR r.declined = 1)
325  ORDER BY round, review_id',
326  (int) $submissionId
327  );
328 
329  while (!$result->EOF) {
330  $reviewAssignments[] = $this->_fromRow($result->GetRowAssoc(false));
331  $result->MoveNext();
332  }
333 
334  $result->Close();
335  } else {
336  assert(false);
337  }
338 
339  return $reviewAssignments;
340  }
341 
348  function getReviewIndexesForRound($submissionId, $reviewRoundId) {
349  $result = $this->retrieve(
350  'SELECT review_id
351  FROM review_assignments
352  WHERE submission_id = ? AND
353  review_round_id = ? AND
354  (cancelled = 0 OR cancelled IS NULL)
355  ORDER BY review_id',
356  array((int) $submissionId, (int) $reviewRoundId)
357  );
358 
359  $index = 0;
360  $returner = array();
361  while (!$result->EOF) {
362  $row = $result->GetRowAssoc(false);
363  $returner[$row['review_id']] = $index++;
364  $result->MoveNext();
365  }
366 
367  $result->Close();
368  return $returner;
369  }
370 
375  function insertObject($reviewAssignment) {
376  $this->update(
377  sprintf('INSERT INTO review_assignments (
378  submission_id,
379  reviewer_id,
380  stage_id,
381  review_method,
382  round,
383  competing_interests,
384  recommendation,
385  declined, replaced, cancelled,
386  date_assigned, date_notified, date_confirmed,
387  date_completed, date_acknowledged, date_due, date_response_due,
388  quality, date_rated,
389  last_modified,
390  date_reminded, reminder_was_automatic,
391  review_form_id,
392  review_round_id,
393  unconsidered
394  ) VALUES (
395  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, %s, %s, %s, %s, %s, %s, %s, ?, %s, %s, %s, ?, ?, ?, ?
396  )',
397  $this->datetimeToDB($reviewAssignment->getDateAssigned()),
398  $this->datetimeToDB($reviewAssignment->getDateNotified()),
399  $this->datetimeToDB($reviewAssignment->getDateConfirmed()),
400  $this->datetimeToDB($reviewAssignment->getDateCompleted()),
401  $this->datetimeToDB($reviewAssignment->getDateAcknowledged()),
402  $this->datetimeToDB($reviewAssignment->getDateDue()),
403  $this->datetimeToDB($reviewAssignment->getDateResponseDue()),
404  $this->datetimeToDB($reviewAssignment->getDateRated()),
405  $this->datetimeToDB($reviewAssignment->getLastModified()),
406  $this->datetimeToDB($reviewAssignment->getDateReminded())
407  ), array(
408  (int) $reviewAssignment->getSubmissionId(),
409  (int) $reviewAssignment->getReviewerId(),
410  (int) $reviewAssignment->getStageId(),
411  (int) $reviewAssignment->getReviewMethod(),
412  max((int) $reviewAssignment->getRound(), 1),
413  $reviewAssignment->getCompetingInterests(),
414  $reviewAssignment->getRecommendation(),
415  (int) $reviewAssignment->getDeclined(),
416  (int) $reviewAssignment->getReplaced(),
417  (int) $reviewAssignment->getCancelled(),
418  $reviewAssignment->getQuality(),
419  (int) $reviewAssignment->getReminderWasAutomatic(),
420  $reviewAssignment->getReviewFormId(),
421  (int) $reviewAssignment->getReviewRoundId(),
422  (int) $reviewAssignment->getUnconsidered(),
423  )
424  );
425 
426  $reviewAssignment->setId($this->getInsertId());
427  return $reviewAssignment->getId();
428  }
429 
434  function updateObject($reviewAssignment) {
435  return $this->update(
436  sprintf('UPDATE review_assignments
437  SET submission_id = ?,
438  reviewer_id = ?,
439  stage_id = ?,
440  review_method = ?,
441  round = ?,
442  competing_interests = ?,
443  recommendation = ?,
444  declined = ?,
445  replaced = ?,
446  cancelled = ?,
447  date_assigned = %s,
448  date_notified = %s,
449  date_confirmed = %s,
450  date_completed = %s,
451  date_acknowledged = %s,
452  date_due = %s,
453  date_response_due = %s,
454  quality = ?,
455  date_rated = %s,
456  last_modified = %s,
457  date_reminded = %s,
458  reminder_was_automatic = ?,
459  review_form_id = ?,
460  review_round_id = ?,
461  unconsidered = ?
462  WHERE review_id = ?',
463  $this->datetimeToDB($reviewAssignment->getDateAssigned()), $this->datetimeToDB($reviewAssignment->getDateNotified()), $this->datetimeToDB($reviewAssignment->getDateConfirmed()), $this->datetimeToDB($reviewAssignment->getDateCompleted()), $this->datetimeToDB($reviewAssignment->getDateAcknowledged()), $this->datetimeToDB($reviewAssignment->getDateDue()), $this->datetimeToDB($reviewAssignment->getDateResponseDue()), $this->datetimeToDB($reviewAssignment->getDateRated()), $this->datetimeToDB($reviewAssignment->getLastModified()), $this->datetimeToDB($reviewAssignment->getDateReminded())),
464  array(
465  (int) $reviewAssignment->getSubmissionId(),
466  (int) $reviewAssignment->getReviewerId(),
467  (int) $reviewAssignment->getStageId(),
468  (int) $reviewAssignment->getReviewMethod(),
469  (int) $reviewAssignment->getRound(),
470  $reviewAssignment->getCompetingInterests(),
471  $reviewAssignment->getRecommendation(),
472  (int) $reviewAssignment->getDeclined(),
473  (int) $reviewAssignment->getReplaced(),
474  (int) $reviewAssignment->getCancelled(),
475  $reviewAssignment->getQuality(),
476  $reviewAssignment->getReminderWasAutomatic(),
477  $reviewAssignment->getReviewFormId(),
478  (int) $reviewAssignment->getReviewRoundId(),
479  (int) $reviewAssignment->getUnconsidered(),
480  (int) $reviewAssignment->getId()
481  )
482  );
483  }
484 
490  function _fromRow($row) {
491  $reviewAssignment = $this->newDataObject();
492 
493  $reviewAssignment->setId($row['review_id']);
494  $reviewAssignment->setSubmissionId($row['submission_id']);
495  $reviewAssignment->setReviewerId($row['reviewer_id']);
496  $reviewAssignment->setReviewerFullName($row['first_name'].' '.$row['last_name']);
497  $reviewAssignment->setCompetingInterests($row['competing_interests']);
498  $reviewAssignment->setRecommendation($row['recommendation']);
499  $reviewAssignment->setDateAssigned($this->datetimeFromDB($row['date_assigned']));
500  $reviewAssignment->setDateNotified($this->datetimeFromDB($row['date_notified']));
501  $reviewAssignment->setDateConfirmed($this->datetimeFromDB($row['date_confirmed']));
502  $reviewAssignment->setDateCompleted($this->datetimeFromDB($row['date_completed']));
503  $reviewAssignment->setDateAcknowledged($this->datetimeFromDB($row['date_acknowledged']));
504  $reviewAssignment->setDateDue($this->datetimeFromDB($row['date_due']));
505  $reviewAssignment->setDateResponseDue($this->datetimeFromDB($row['date_response_due']));
506  $reviewAssignment->setLastModified($this->datetimeFromDB($row['last_modified']));
507  $reviewAssignment->setDeclined($row['declined']);
508  $reviewAssignment->setReplaced($row['replaced']);
509  $reviewAssignment->setCancelled($row['cancelled']);
510  $reviewAssignment->setQuality($row['quality']);
511  $reviewAssignment->setDateRated($this->datetimeFromDB($row['date_rated']));
512  $reviewAssignment->setDateReminded($this->datetimeFromDB($row['date_reminded']));
513  $reviewAssignment->setReminderWasAutomatic($row['reminder_was_automatic']);
514  $reviewAssignment->setRound($row['round']);
515  $reviewAssignment->setReviewFormId($row['review_form_id']);
516  $reviewAssignment->setReviewRoundId($row['review_round_id']);
517  $reviewAssignment->setReviewMethod($row['review_method']);
518  $reviewAssignment->setStageId($row['stage_id']);
519  $reviewAssignment->setUnconsidered($row['unconsidered']);
520 
521  return $reviewAssignment;
522  }
523 
528  function newDataObject() {
529  return new ReviewAssignment();
530  }
531 
536  function deleteById($reviewId) {
537  $reviewFormResponseDao = DAORegistry::getDAO('ReviewFormResponseDAO');
538  $reviewFormResponseDao->deleteByReviewId($reviewId);
539 
540  $reviewFilesDao = DAORegistry::getDAO('ReviewFilesDAO');
541  $reviewFilesDao->revokeByReviewId($reviewId);
542 
543  $notificationDao = DAORegistry::getDAO('NotificationDAO');
544  $notificationDao->deleteByAssoc(ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewId);
545 
546  return $this->update(
547  'DELETE FROM review_assignments WHERE review_id = ?',
548  (int) $reviewId
549  );
550  }
551 
557  function deleteBySubmissionId($submissionId) {
558  $returner = false;
559  $result = $this->retrieve(
560  'SELECT review_id FROM review_assignments WHERE submission_id = ?',
561  array((int) $submissionId)
562  );
563 
564  while (!$result->EOF) {
565  $row = $result->GetRowAssoc(false);
566  $this->deleteById($row['review_id']);
567  $result->MoveNext();
568  $returner = true;
569  }
570  $result->Close();
571  return $returner;
572  }
573 
578  function getInsertId() {
579  return $this->_getInsertId('review_assignments', 'review_id');
580  }
581 
588  function getLastReviewRoundReviewAssignmentByReviewer($submissionId, $reviewerId) {
589  $params = array(
590  (int) $submissionId,
591  (int) $reviewerId
592  );
593 
594  $result = $this->retrieve(
595  $this->_getSelectQuery() .
596  ' WHERE r.submission_id = ? AND
597  r.reviewer_id = ? AND
598  r.cancelled <> 1
599  ORDER BY r2.stage_id DESC, r2.round DESC LIMIT 1',
600  $params
601  );
602 
603  $returner = null;
604  if ($result->RecordCount() != 0) {
605  $returner = $this->_fromRow($result->GetRowAssoc(false));
606  }
607 
608  $result->Close();
609  return $returner;
610  }
611 
617  return array(
618  SUBMISSION_REVIEW_METHOD_DOUBLEBLIND => 'editor.submissionReview.doubleBlind',
619  SUBMISSION_REVIEW_METHOD_BLIND => 'editor.submissionReview.blind',
620  SUBMISSION_REVIEW_METHOD_OPEN => 'editor.submissionReview.open',
621  );
622  }
623 
629  function getReviewerStatistics($contextId) {
630  // Build an array of all reviewers and provide a placeholder for all statistics (so even if they don't
631  // have a value, it will be filled in as 0
632  $statistics = array();
633  $reviewerStatsPlaceholder = array('last_notified' => null, 'incomplete' => 0, 'total_span' => 0, 'completed_review_count' => 0, 'average_span' => 0);
634 
635  $userDao = DAORegistry::getDAO('UserDAO');
636  $allReviewers = $userDao->getAllReviewers($contextId);
637  while($reviewer = $allReviewers->next()) {
638  $statistics[$reviewer->getId()] = $reviewerStatsPlaceholder;
639  }
640 
641  // Get counts of completed submissions
642  $result = $this->retrieve(
643  'SELECT r.reviewer_id, MAX(r.date_notified) AS last_notified
644  FROM review_assignments r, submissions s
645  WHERE r.submission_id = s.submission_id AND
646  s.context_id = ?
647  GROUP BY r.reviewer_id',
648  (int) $contextId
649  );
650  while (!$result->EOF) {
651  $row = $result->GetRowAssoc(false);
652  if (!isset($statistics[$row['reviewer_id']])) $statistics[$row['reviewer_id']] = $reviewerStatsPlaceholder;
653  $statistics[$row['reviewer_id']]['last_notified'] = $this->datetimeFromDB($row['last_notified']);
654  $result->MoveNext();
655  }
656  $result->Close();
657 
658  // Get completion status
659  $result = $this->retrieve(
660  'SELECT r.reviewer_id, COUNT(*) AS incomplete
661  FROM review_assignments r, submissions s
662  WHERE r.submission_id = s.submission_id AND
663  r.date_notified IS NOT NULL AND
664  r.date_completed IS NULL AND
665  r.cancelled = 0 AND
666  s.context_id = ?
667  GROUP BY r.reviewer_id',
668  (int) $contextId
669  );
670  while (!$result->EOF) {
671  $row = $result->GetRowAssoc(false);
672  if (!isset($statistics[$row['reviewer_id']])) $statistics[$row['reviewer_id']] = $reviewerStatsPlaceholder;
673  $statistics[$row['reviewer_id']]['incomplete'] = $row['incomplete'];
674  $result->MoveNext();
675  }
676 
677  $result->Close();
678 
679  // Calculate time taken for completed reviews
680  $result = $this->retrieve(
681  'SELECT r.reviewer_id, r.date_notified, r.date_completed
682  FROM review_assignments r, submissions s
683  WHERE r.submission_id = s.submission_id AND
684  r.date_notified IS NOT NULL AND
685  r.date_completed IS NOT NULL AND
686  r.declined = 0 AND
687  s.context_id = ?',
688  (int) $contextId
689  );
690  while (!$result->EOF) {
691  $row = $result->GetRowAssoc(false);
692  if (!isset($statistics[$row['reviewer_id']])) $statistics[$row['reviewer_id']] = $reviewerStatsPlaceholder;
693 
694  $completed = strtotime($this->datetimeFromDB($row['date_completed']));
695  $notified = strtotime($this->datetimeFromDB($row['date_notified']));
696  if (isset($statistics[$row['reviewer_id']]['total_span'])) {
697  $statistics[$row['reviewer_id']]['total_span'] += $completed - $notified;
698  $statistics[$row['reviewer_id']]['completed_review_count'] += 1;
699  } else {
700  $statistics[$row['reviewer_id']]['total_span'] = $completed - $notified;
701  $statistics[$row['reviewer_id']]['completed_review_count'] = 1;
702  }
703 
704  // Calculate the average length of review in days.
705  $statistics[$row['reviewer_id']]['average_span'] = round(($statistics[$row['reviewer_id']]['total_span'] / $statistics[$row['reviewer_id']]['completed_review_count']) / 86400);
706  $result->MoveNext();
707  }
708 
709  $result->Close();
710  return $statistics;
711  }
712 
719  // Setup default array -- Minimum values Will always be set to 0 (to accomodate reviewers that have never reviewed, and thus aren't in review_assignment)
720  $reviewerValues = array(
721  'doneMin' => 0, // Will always be set to 0
722  'doneMax' => 0,
723  'avgMin' => 0, // Will always be set to 0
724  'avgMax' => 0,
725  'lastMin' => 0, // Will always be set to 0
726  'lastMax' => 0,
727  'activeMin' => 0, // Will always be set to 0
728  'activeMax' => 0
729  );
730 
731  // Get number of reviews completed
732  $result = $this->retrieve(
733  'SELECT r.reviewer_id, COUNT(*) as completed_count
734  FROM review_assignments r
735  WHERE r.date_completed IS NOT NULL
736  GROUP BY r.reviewer_id'
737  );
738  while (!$result->EOF) {
739  $row = $result->GetRowAssoc(false);
740  if ($reviewerValues['doneMax'] < $row['completed_count']) $reviewerValues['doneMax'] = $row['completed_count'];
741  $result->MoveNext();
742  }
743  $result->Close();
744 
745  // Get average number of days per review and days since last review
746  $result = $this->retrieve(
747  'SELECT r.reviewer_id, r.date_completed, r.date_notified
748  FROM review_assignments r
749  WHERE r.date_notified IS NOT NULL AND
750  r.date_completed IS NOT NULL AND
751  r.declined = 0'
752  );
753  $averageTimeStats = array();
754  while (!$result->EOF) {
755  $row = $result->GetRowAssoc(false);
756  if (!isset($averageTimeStats[$row['reviewer_id']])) $averageTimeStats[$row['reviewer_id']] = array();
757 
758  $completed = strtotime($this->datetimeFromDB($row['date_completed']));
759  $notified = strtotime($this->datetimeFromDB($row['date_notified']));
760  $timeSinceNotified = time() - $notified;
761  if (isset($averageTimeStats[$row['reviewer_id']]['totalSpan'])) {
762  $averageTimeStats[$row['reviewer_id']]['totalSpan'] += $completed - $notified;
763  $averageTimeStats[$row['reviewer_id']]['completedReviewCount'] += 1;
764  } else {
765  $averageTimeStats[$row['reviewer_id']]['totalSpan'] = $completed - $notified;
766  $averageTimeStats[$row['reviewer_id']]['completedReviewCount'] = 1;
767  }
768 
769  // Calculate the average length of review in days.
770  $averageTimeStats[$row['reviewer_id']]['averageSpan'] = (($averageTimeStats[$row['reviewer_id']]['totalSpan'] / $averageTimeStats[$row['reviewer_id']]['completedReviewCount']) / 86400);
771 
772  // This reviewer has the highest average; put in global statistics array
773  if ($reviewerValues['avgMax'] < $averageTimeStats[$row['reviewer_id']]['averageSpan']) $reviewerValues['avgMax'] = round($averageTimeStats[$row['reviewer_id']]['averageSpan']);
774  if ($timeSinceNotified > $reviewerValues['lastMax']) $reviewerValues['lastMax'] = $timeSinceNotified;
775 
776  $result->MoveNext();
777  }
778  $reviewerValues['lastMax'] = round($reviewerValues['lastMax'] / 86400); // Round to nearest day
779  $result->Close();
780 
781  // Get number of currently active reviews
782  $result = $this->retrieve(
783  'SELECT r.reviewer_id, COUNT(*) AS incomplete
784  FROM review_assignments r
785  WHERE r.date_notified IS NOT NULL AND
786  r.date_completed IS NULL AND
787  r.cancelled = 0
788  GROUP BY r.reviewer_id'
789  );
790  while (!$result->EOF) {
791  $row = $result->GetRowAssoc(false);
792 
793  if ($row['incomplete'] > $reviewerValues['activeMax']) $reviewerValues['activeMax'] = $row['incomplete'];
794  $result->MoveNext();
795  }
796  $result->Close();
797  return $reviewerValues;
798  }
799 
804  function _getSelectQuery() {
805  return 'SELECT r.*, r2.review_revision, u.first_name, u.last_name FROM review_assignments r
806  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
807  LEFT JOIN review_rounds r2 ON (r.review_round_id = r2.review_round_id)';
808  }
809 }
810 
811 ?>
static & getDAO($name, $dbconn=null)
getReviewIndexesForRound($submissionId, $reviewRoundId)
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
getByReviewRoundId($reviewRoundId, $excludeCancelled=false)
insertObject($reviewAssignment)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:84
getLastReviewRoundReviewAssignmentByReviewer($submissionId, $reviewerId)
updateObject($reviewAssignment)
getReviewAssignment($reviewRoundId, $reviewerId)
_getInsertId($table= '', $id= '')
Definition: DAO.inc.php:249
getBySubmissionId($submissionId, $reviewRoundId=null, $stageId=null)
datetimeFromDB($dt)
Definition: DAO.inc.php:313
_getReviewAssignmentsArray($query, $queryParams)
reviewerExists($reviewRoundId, $reviewerId)
datetimeToDB($dt)
Definition: DAO.inc.php:293
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:208
Describes review assignment properties.
Class for DAO relating reviewers to submissions.