Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Donovan
Client


Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Mon Sep 29, 2008 10:09 am Reply with quote

I have a peer evaluation I've been working on for awhile (seems like forever).

Management now wants course directors and or the Dean of Academic Affairs to be able to view all evaluation submitted by the students. All students are put into teams of 5 or 6 in the beginning of the academic year.
Code:


`atlas_tl_students`
  `Name_Last` text,
  `Name_First` text,
  `Email` varchar(30) default NULL,
  `LDAP_USER` varchar(255) NOT NULL default '',
  `Class_Year` varchar(6) default NULL,
  `SOMS_KEY` int(11) default NULL,
  `UID` varchar(9) default NULL

`atlas_tl_groups`
`Group_ID` int(11) NOT NULL auto_increment,
`Group_Name` varchar(32) NOT NULL default '',

`atlas_tl_group_students`
  `Group_ID` int(11) NOT NULL default '0',
  `SOMS_KEY` int(11) NOT NULL default '0',
  `LDAP_USER` varchar(255) NOT NULL default ''


At the end of each course they do a peer evaluation on each other.

`LDAP_USER` is my student table becomes a "rater" and evaluated all his team members.

The peereval table looks like this
Code:


`atlas_tl_peereval`
  `UID` varchar(9) NOT NULL,
  `rater` varchar(255) default NULL,    <-- LDAP_USER
  `evalscore` tinyint(2) NOT NULL,
  `eval_comment` text NOT NULL,
  `Course_Number` mediumint(6) NOT NULL,
  `datesubmit` date NOT NULL,
  `Academic_Year` varchar(5) NOT NULL


What I am trying to do is display this grouped by rater.

Such as:
Quote:

<table>
<th>Rater: - Score - Comment </th>
Student Name - Score - Comment
Student Name - Score - Comment
Student Name - Score - Comment
Student Name - Score - Comment
Student Name - Score - Comment
</table>

<table>
<th>Rater: - Score - Comment </th>
Student Name - Score - Comment
Student Name - Score - Comment
Student Name - Score - Comment
Student Name - Score - Comment
Student Name - Score - Comment
</table>


Here is my code so far.

Code:


TLAdminMenu();
echo "<br />\n";
$Course_Number = intval($_POST['Course_Number']);

//Get the academic year
$Get_Academic_Year = $db->sql_query("SELECT Academic_Year FROM ".$prefix."_tl_config");
$info = $db->sql_fetchrow($Get_Academic_Year);
$Academic_Year = $info['Academic_Year'];

//Get the Rater name and rater_id
$SQLRaterName = $db->sql_query("SELECT CONCAT(s.Name_First,' ',s.Name_Last) AS RaterName, s.LDAP_USER, pe.Course_Number, pe.rater, pe.Academic_Year
FROM ".$prefix."_tl_students s JOIN ".$prefix."_tl_peereval pe 
WHERE s.LDAP_USER = pe.rater
AND pe.Course_Number = '$Course_Number'
AND pe.Academic_Year = '$Academic_Year'");
OpenTable();
echo "<br />\n";
$tlstudent = "<img src='modules/$modname/images/member.png'>";   

    $current_rater = '';
    while ( $row = $db->sql_fetchrow($SQLRaterName) ) {       
             
            if ($current_rater != $row['rater']){           
           
            // set $current_rater to the new rater   
            $current_rater = $row['rater'];
            $RaterName = $row['RaterName'];
           
            // start a new table and write the first two rows
            echo "<table width='100%' border='1' cellspacing='0' cellpadding='2'>\n";
            echo "<tr><td width='100%' colspan='3'>Rater: $RaterName</td></tr>\n";
            echo "<tr><td width='10%' bgcolor='$bgcolor2'><b>Team Mates</b></td><td width='10%' align='center' bgcolor='$bgcolor2'><b>Score</b></td><td width='50%' align='center' bgcolor='$bgcolor2'><b>Evaluation</b></td></tr>\n";
            }
           
            //Query for student evaluation
$studentM1result = $db->sql_query("SELECT pe.Course_Number, pe.rater, pe.evalscore, pe.eval_comment, pe.Academic_Year, s.LDAP_USER, s.Name_First, s.Name_Last, s.UID FROM ".$prefix."_tl_students s JOIN ".$prefix."_tl_peereval pe 
WHERE pe.Academic_Year = '$Academic_Year'
AND pe.Course_Number = '$Course_Number'
AND s.UID = pe.UID
AND pe.rater = '$current_rater'
ORDER BY pe.rater");
while ( $row = $db->sql_fetchrow($studentM1result) ) {       
        $SOMS_KEY = $row['SOMS_KEY'];
        $First = $row['Name_First'];
        $Last = $row['Name_Last'];
        $UID = $row['UID'];
        $evalscore = $row['evalscore'];
        $comment = $row['eval_comment'];
        }
           
        // this bit of the loop fills in the table untill we encounter a new rater
         echo "<tr><td width='20%'>$tlstudent $First $Last</td>\n";
    echo "<td width='10%' align='center'>$evalscore</td>\n";       
    echo "<td width='50%' align='center'>$comment</td>\n";
    echo"</tr>\n";       
    }
echo"</table>";
CloseTable();
include("footer.php");
?> 


The problem is it is repeating values from the query. It is repeating the last value for the inner loop.

Quote:
Rater: Tom Thumb
Team Mates Score Evaluation
Bill Anderson 13 whatever
Bill Anderson 13 whatever
Bill Anderson 13 whatever
Bill Anderson 13 whatever

Rater: John Public
Team Mates Score Evaluation
Bob Smith 11 okay feedback.
Bob Smith 11 okay feedback.
Bob Smith 11 okay feedback.


I think I need one loop and use some sort of control break and group the results by rater. Or maybe I'm close but don't know it... Laughing

I kinda see a problem though as both rater and UID refer back to the students table to get Name_First, and Name_Last.
 
View user's profile Send private message Visit poster's website ICQ Number
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©