1<?php
2include('../Code/confHeader.inc');
3$_SESSION[Me] -> goIfInvalid($Conf->paperSite);
4$_SESSION[Me] -> goIfNotPC($Conf->paperSite);
5$Conf -> connect();
6
7// we are disabling register_globals in php.ini, so we don't need to
8// register the following session variable anymore
9
10// session_register('GradeSortKey');
11
12if (IsSet($_REQUEST[setSortKey])) {
13  $_SESSION[GradeSortKey]=$_REQUEST[setSortKey];
14}
15
16
17?>
18
19<html>
20
21<?php  $Conf->header("See Overall Merit and Grades For All Papers") ?>
22
23<body>
24
25
26<?php
27print "<p> You can see this information ";
28print $Conf->printTimeRange('PCMeetingView');
29print "</p>";
30
31if ( ! $Conf -> validTimeFor('PCMeetingView', 0) ) {
32  $Conf->errorMsg("You can not see this information right now");
33  exit();
34}
35if (!IsSet($_SESSION[GradeSortKey])) {
36  $_SESSION[GradeSortKey] = "byReviews";
37}
38
39$conflicts = $Conf->allMyConflicts($_SESSION[Me]->contactId);
40
41$pcConflicts = $Conf->allPCConflicts();
42
43$meritRange = $Conf->reviewRange('overAllMerit', 'PaperReview');
44$gradeRange = $Conf->reviewRange('grade', 'PaperGrade');
45
46
47if ($_SESSION[GradeSortKey]=="byReviews") {
48  $Conf->infoMsg("Sorting By Merit (as indicated by reviewers) ");
49  $result=$Conf->qe("SELECT Paper.paperId, Paper.title, "
50		    . " AVG(PaperReview.overAllMerit) as merit "
51		    . " FROM Paper "
52		    . " LEFT JOIN PaperReview "
53		    . " ON PaperReview.paperId=Paper.paperId "
54		    . " WHERE PaperReview.finalized=1 "
55		    . " GROUP BY PaperReview.paperId "
56		    . " ORDER BY merit DESC, Paper.paperId "
57		    );
58
59} elseif ($_SESSION[GradeSortKey]=="byGrades") {
60  $Conf->infoMsg("Sorting By Grades (as indicated by PC members)");
61  $result=$Conf->qe("SELECT Paper.paperId, Paper.title, "
62		    . " AVG(PaperGrade.grade) as merit "
63		    . " FROM Paper "
64		    . " LEFT JOIN PaperGrade "
65		    . " ON PaperGrade.paperId=Paper.paperId "
66		    . " GROUP BY PaperGrade.paperId "
67		    . " ORDER BY merit DESC, Paper.paperId "
68		    );
69
70} elseif ($_SESSION[GradeSortKey]=="byPapers") {
71  $Conf->infoMsg("Sorting By Paper Number");
72  $result=$Conf->qe("SELECT Paper.paperId, Paper.title "
73		    . " FROM Paper "
74		    . " ORDER BY Paper.paperId "
75		    );
76
77} else {
78  $Conf->errorMsg("Invalid sort key");
79  exit();
80}
81
82if (DB::isError($result)) {
83  $Conf->errorMsg("Error in sql " . $result->getMessage());
84  exit();
85}
86
87$Conf->infoMsg("This shows the histograms scoring each paper and the grades "
88	       . " assigned by PC members for all papers other than the "
89	       . " ones for which you have an indicated conflict."
90	       . " You can click on the column headers to sort by the "
91	       . " specified key");
92
93print "<center>";
94$Conf->textButtonPopup("Click here to assign grades to papers ",
95		       "GradePapers.php");
96print "</center>";
97
98
99if ( $Conf->validTimeFor('AtTheMeeting', 0) ) {
100  $Conf->errorMsg("Papers authored by program committee members (and other "
101		  . " conflicting papers ) are not shown at thise time. To "
102		  . " maintain confidentiality, please do not discuss or "
103		  . " distribute review information about papers you do not "
104		  . " see listed here. ");
105}
106?>
107
108<table border=1>
109<tr bgcolor=<?php echo $Conf->contrastColorOne?>>
110<th colspan=6> All Papers </th> </tr>
111
112<tr>
113<th width=5%> Row # </th>
114<th width=5%> <a href="<?php echo $_SERVER[PHP_SELF]?>?setSortKey=byPapers" > Paper # </a> </th>
115<th width=25%> Title </th>
116<th width=5%> <a href="<?php echo $_SERVER[PHP_SELF]?>?setSortKey=byReviews" > Merit </a> </th>
117<th width=5%> <a href="<?php echo $_SERVER[PHP_SELF]?>?setSortKey=byGrades" > Grades </a> </th>
118</tr>
119<td> <b>
120<?php
121$rowNum = 0;
122while ($row=$result->fetchRow()) {
123  $rowNum++;
124  $paperId = $row[0];
125  $title = $row[1];
126
127  //
128  // Don't show the paper if there is a personal conflict OR
129  // if it's the meeting and you're not the PC. Otherwise, another
130  // program member can lean over and see the paper
131  //
132  $noShow = $conflicts[$paperId]
133    || ( $Conf->validTimeFor('AtTheMeeting',0)
134	 && $pcConflicts[$paperId]
135	 && ! $_SESSION[Me]->isChair );
136
137
138  if ( ! $noShow ) {
139
140    print "<tr> <td> $rowNum </td> ";
141    print "<td> $paperId </td>";
142    print "<td>\n";
143
144    $Conf->linkWithPaperId($title,
145                           "../PC/PCAllAnonReviewsForPaper.php",
146                           $paperId);
147
148    print "\n";
149
150    $didBr = 0;
151    if ( $_SESSION[Me] ->isChair && $pcConflicts[$paperId] ) {
152      print " <b> PC PAPER </b>\n ";
153      $didBr = 1;
154    }
155
156    $comments = $Conf->countEntries("PaperComments.paperId",
157				    $paperId, "PaperComments");
158    if ( $comments > 0) {
159      if (! $didBr) {
160	print "<br>\n";
161      }
162      print " <b> $comments Comments </b>\n ";
163    }
164
165    print "</td>";
166
167
168    print "<td align=center>";
169    $q = "SELECT overAllMerit FROM PaperReview "
170      . " WHERE paperId=$paperId "
171      . " AND finalized = 1";
172    $Conf->graphValues($q, "overAllMerit", $meritRange['min'], $meritRange['max']);
173
174
175    print "</td>";
176
177    print "<td align=center>";
178    $q = "SELECT grade FROM PaperGrade "
179      . " WHERE paperId=$paperId ";
180    $Conf->graphValues($q, "grade", $gradeRange['min'], $gradeRange['max']);
181    print "</td>";
182    print "<tr> \n";
183  }
184}
185?>
186</table>
187
188</body>
189<?php  $Conf->footer() ?>
190</html>
191
192