/instruct/evaluatee_instructor.php

https://github.com/bpbielicki/Rate-Your-Mate · PHP · 163 lines · 129 code · 16 blank · 18 comment · 46 complexity · 0204195baed590efa9d22760c7a33848 MD5 · raw file

  1. <?php include ("../includes/check_authorization.php");
  2. error_reporting(-1);
  3. include ("../includes/config.php");
  4. include ("../includes/opendb.php");
  5. $prjID = $_SESSION['prjID'];
  6. $groupChangeFlag = 0;
  7. if ( !empty( $_POST['groupID'] ) ) {
  8. if ( $_SESSION['groupID'] != $_POST['groupID'] ) {
  9. $_SESSION['groupID'] = $_POST['groupID'];
  10. // Unset the project
  11. unset( $_SESSION['studentID'] );
  12. $groupChangeFlag = 1;
  13. }
  14. else if ( !empty( $_POST['studentSelect'] ) && $_SESSION['studentID'] != $_POST['studentSelect'] ) {
  15. $_SESSION['studentID'] = $_POST['studentSelect'];
  16. }
  17. }
  18. if ( !empty( $_POST['evalType'] )) {
  19. $evalType= 'source';
  20. echo $_POST['evalType'];
  21. }
  22. else $evalType = 'target';
  23. ?>
  24. <html>
  25. <head>
  26. <link rel="stylesheet" type="text/css" href="../css/dateStyle.css" />
  27. <link rel="stylesheet" type="text/css" href="../css/style.css" />
  28. <title>Rate Your Mate</title>
  29. </head>
  30. <body>
  31. <div id="header">
  32. <h1>Instructor Evaluation</h1>
  33. </div>
  34. <div id="menu">
  35. <?php include ("../includes/instruct_menu.php"); ?>
  36. </div>
  37. <div id="content">
  38. <form id='groupSelectForm' name='form' action="evaluatee_instructor.php" method="post">
  39. <select name="groupID" onchange='this.form.submit()'>
  40. <?php
  41. // Get all groups for this project
  42. $groupIDQuery = mysql_query ( " SELECT DISTINCT G.GrpID FROM Groups G WHERE
  43. G.PrjID = ".$prjID) or die( 'Error could not retrieve the group list' );
  44. $cnt = 1;
  45. // Select the group from the project to review, all groups have a default name
  46. while ( $groupID = mysql_fetch_array ( $groupIDQuery ) ) {
  47. $groupIDArr[$cnt] = $groupID['GrpID'];
  48. if ( empty( $_SESSION['groupID'] ) || empty( $_POST['groupID'] ) )
  49. $_SESSION['groupID'] = $groupID['GrpID'];
  50. if ( $_SESSION['groupID'] == $groupID['GrpID'] )
  51. $defaultString = 'selected="selected"';
  52. else $defaultString = '';
  53. echo '<option value="' . $groupID['GrpID'] . '" ' . $defaultString . '> Team ' . $cnt++ . '</option>';
  54. }
  55. ?>
  56. </select>
  57. <select name="studentSelect" onchange='this.form.submit()'>
  58. <?php
  59. // Get the ID's of all group members
  60. $groupSdtIDQueryString = ( 'SELECT G.StudentID FROM Groups G WHERE G.GrpID = ' . $_SESSION['groupID'] );
  61. $groupSdtIDQuery = mysql_query( $groupSdtIDQueryString ) or die( 'Error could not retreive groups' );;
  62. $cnt = 0;
  63. // Select the student from the group to be reviewed
  64. while ( $studentID = mysql_fetch_array( $groupSdtIDQuery ) ) {
  65. foreach ( $_SESSION['roster'] as $student ) {
  66. if ( empty( $_SESSION['studentID'] ) || $groupChangeFlag == 1 || empty( $_POST['groupID'] ) )
  67. $_SESSION['studentID'] = $student['id'];
  68. if ( $_SESSION['studentID'] == $student['id'] ) {
  69. $defaultString = 'selected="selected"';
  70. $studentName = $student['name'];
  71. }
  72. else $defaultString = '';
  73. if ( $student['id'] == $studentID['StudentID'] ) {
  74. $groupArr[$student['id']] = $student['name'];
  75. echo '<option value = ' . $student['id'] . ' ' . $defaultString . '> ' . $student['name'] . '</option>';
  76. }
  77. }
  78. }
  79. ?>
  80. </select>
  81. <input type="checkbox" id="evalCheck" name="evalType" value="howdy" onchange='this.form.submit()'
  82. <?php if( $evalType == 'source' ) echo 'checked'; ?>/> Evaluations by this student
  83. </form>
  84. <?php
  85. // Get all the behaviors the group has
  86. $behaviorQueryString = ( 'SELECT B.BehaviorID, B.Description
  87. FROM Behaviors B
  88. WHERE B.GrpID = ' . $_SESSION['groupID'] . ';');
  89. $behaviorQuery = mysql_query( $behaviorQueryString );
  90. if ( $behaviorQuery ) {
  91. $behaviorCnt = mysql_num_rows( $behaviorQuery );
  92. }
  93. else $behaviorCnt =
  94. // Put into an array
  95. $cnt = 0;
  96. // Only try to display comments if the contract exists
  97. if ( $behaviorCnt != 0 ) {
  98. while ( $behavior = mysql_fetch_array( $behaviorQuery ) ) {
  99. $behaviorArr[ $behavior['BehaviorID'] ] = $behavior['Description'];
  100. }
  101. if ( $evalType == 'target' ) {
  102. echo '<h4>Below is the feedback for ' . $studentName . ' from their teammates </h4>';
  103. // Get all comments related to this student for this project
  104. $commentQueryString = 'SELECT C.SrcId, C.Comment, C.BehaviorId FROM Comments C
  105. WHERE C.PrjID = ' . $_SESSION['prjID'] . ' AND C.TargetId = ' . $_SESSION['studentID'] . ' ORDER BY C.BehaviorId;';
  106. $commentQuery = mysql_query( $commentQueryString ) or die ( 'Could not find student comments' );
  107. // Print out the behavior
  108. $cnt = 0;
  109. while ( $comment = mysql_fetch_array( $commentQuery ) ) {
  110. // If this is the first for this behavior, create a header
  111. if ( empty( $currBehavior ) || $currBehavior != $comment['BehaviorId'] ) {
  112. echo '<h4> ' . $behaviorArr[ $comment['BehaviorId'] ] . '</h4>';
  113. $currBehavior = $comment['BehaviorId'];
  114. }
  115. // Print out the student who wrote the review
  116. echo '<p> Source: ' . $groupArr[$comment['SrcId'] ]. '</p>';
  117. // Print out the comment
  118. echo '<textarea> ' . trim( $comment['Comment'] ) . '</textarea>';
  119. }
  120. }
  121. else if ( $evalType == 'source' ) {
  122. echo '<h4>Below is the feedback from ' . $studentName . ' for their teammates </h4>';
  123. // Get all comments related to this student for this project
  124. $commentQueryString = 'SELECT C.TargetId, C.Comment, C.BehaviorId FROM Comments C
  125. WHERE C.PrjID = ' . $_SESSION['prjID'] . ' AND C.SrcId = ' . $_SESSION['studentID'] . ' ORDER BY C.BehaviorId;';
  126. $commentQuery = mysql_query( $commentQueryString ) or die ( 'Could not find student comments' );
  127. // Print out the behavior
  128. $cnt = 0;
  129. while( $comment = mysql_fetch_array( $commentQuery ) ) {
  130. // If this is the first for this behavior, create a header
  131. if( empty( $currBehavior ) || $currBehavior != $comment['BehaviorId'] ) {
  132. echo '<h4> ' . $behaviorArr[ $comment['BehaviorId'] ] . '</h4>';
  133. $currBehavior = $comment['BehaviorId'];
  134. }
  135. // Print out student the comment is for
  136. echo '<p> Target: ' . $groupArr[ $comment['TargetId'] ] . '</p>';
  137. // Print out the comment
  138. echo '<textarea>' . trim( $comment['Comment'] ) . '</textarea>';
  139. }
  140. }
  141. }
  142. else { ?>
  143. <p> No contract was found for the group </p>
  144. <?php } ?>
  145. </div>
  146. </body>
  147. </html>