Jump to content

Donovan

Members
  • Posts

    73
  • Joined

  • Last visited

    Never

Everything posted by Donovan

  1. Could I do something like this? $HasError=FALSE; $Session_ID = $_POST['Session_ID']; //Check if already imported checkSession($Session_ID); if (checkSession($Session_ID) == TRUE) { //Validate UID and compare to Student_ID in the imported table. checkUID(); if (checkUID()==TRUE) { //Check if all Students are assigned to a group. checkGroup() if (checkGroup()==TRUE) { //Check if any students are missing from import. checkMissingStudents(); if (checkMissingStudents()==TRUE) { $HasError=TRUE; //we have missing students } } else { $HasError=TRUE; //we have group problems } } else { $HasError=TRUE; //we have userid problems } else { $HasError=TRUE; //we Session problems } else{ //No errors detected so import grades to grades table. if ($HasError==FALSE) { $sql = ("INSERT INTO blah blah"); }
  2. I have been working on a script that is just about finished. One question I have is validating the logic. The script has become bloated and hard to follow. If I wanted to add some validation then what is the best way? I have a table I created and then imported records from a csv file. The csv is from a testing scantron that has exam grades. I want to test the following: Check if already imported Validate UID and compare to Student_ID in the imported table. Check if all Students are assigned to a group. Check if any students are missing from import. Each part of the script works but the logic does not flow. I was thinking about something like this: *Just a rough draft* $Session_ID = $_POST['Session_ID']; //Check if already imported $checked = checkSession($Session_ID); if $checked = 1 { die(); }else{ //Validate UID and compare to Student_ID in the imported table. $checked = checkUID(); if $checked = 1 { die(); }else{ //Check if all Students are assigned to a group. $checked = checkGroup(); if $checked = 1 { die(); }else{ //Check if any students are missing from import. $checked = checkMissingStudents(); if $checked = 1 { die(); } //No errors detected so import grades to grades table. } What is the proper way to trap errors and/or return from a function so that it does not continue until all logic errors are fixed?
  3. Still trying to get this working. I have been spinning my wheels for days on this and have tried 4 different ways with no success. I have a table that I create and import the exam results from a csv file. Here is the table(s) structure The import table The student table I need to find any first year students (example.. Class_Year = 1) from the student table that may have missed an exam (example..Session_ID = 45). I match the Class_Year to the Course_Year to pull any first years medical students who's UID does not exist in the imported table. So I want to find all NULL values in the imported table, but so far have not been able to, even though I know I do have missing records. My first attempt: SELECT a.* FROM atlas_tl_students a LEFT JOIN atlas_tl_session_grade_import b ON ( b.Student_ID = a.UID ) WHERE a.Class_Year = b.Course_Year AND b.Student_ID IS NULL; Does not pull any records. My second attempt: SELECT DISTINCT a. * FROM atlas_tl_students AS a WHERE a.UID NOT IN ( SELECT b.Student_ID FROM atlas_tl_session_grade_import AS b WHERE b.Student_ID = a.UID AND a.Class_Year = b.Course_Year ) Pulls 315 records. It pulls all students from all other years. 2nd year thru 4th year students. I only have 2 students who missed the exam but can't figure out the correct query to do this. What I eventually what to do is capture those students from the proper Class_Year who may have missed the exam and add them to the table and assign them a zero for this Session_ID.
  4. I simplyfied this by adding the Course_Year for each record to the import table. So now I am trying this: SELECT * FROM atlas_tl_students a LEFT JOIN atlas_tl_session_grade_import b ON b.Student_ID = a.UID AND a.Class_Year = b.Course_Year WHERE b.Student_ID IS NULL This should get me all 1st year students, but so far it is not.
  5. How could I only use two tables? I have approximately 415 students who are 1st year through 4th year students. Class_Year = 1,2,3,4 I need to find only those students for that Session_ID which belongs to the correct course for the exam given. So far the courses I have loaded are either a 1st year course or 2nd year course. I match Course_Year of the course to Class_Year of student to find the correct students to query from.
  6. I need to find all missing Student_ID's from atlas_tl_session_grade_import, that don't exist in the atlas_tl_students table. Here is my latest attempt. SELECT a.* FROM atlas_tl_students a LEFT JOIN atlas_tl_session_grade_import b ON b.Student_ID = a.UID LEFT JOIN atlas_tl_session c ON c.Session_ID = b.Session_ID LEFT JOIN atlas_tl_courses d ON d.Course_ID = c.Course_ID AND d.Course_Year = a.Class_Year WHERE a.UID IS NULL; I join atlas_tl_session c ON b.Session_ID = c.Session_ID to find out what Session (exam) they may have missed. Then match atlas_tl_courses d ON c.Course_ID = d.Course_ID to find what course this exam was given. Then constrain on Course_Year = Class_Year to find only those students (1st year or 2nd year) for that course. Here is my relevant table structure I've been working on this problem since Wednesday last week and can't seem to get it working. In my example I need to find any first year students (Class_Year = 1) that may have missed an exam (Session_ID = 45). I match the Session_ID to the Course it was assigned to, then find the Course_Year and match that to the Class_Year to pull any first years medical students who's Student_ID does not exist in the imported table. So I want to find all NULL values in the imported table, but so far have not been able to, even though I know I do have missing records.
  7. I have no way of knowing if every students for that class was present during the exam, until I join it back to the students table to see if I have missing records. My student table is atlas_tl_students My imported table from the csv is atlas_tl_session_grade_import I join these two on ( a.UID = b.Student_ID ) Then I join the Session_ID between atlas_tl_session and atlas_tl_session_grade_import ( b.Session_ID = c.Session_ID ) Then I join the Course_ID between atlas_tl_courses and atlas_tl_session ( c.Course_ID = d.Course_ID ) Then I compare where the Class_Year for a student (first year or second year students, ie 1 or 2) match the Course_Year (1 or 2) WHERE d.Course_Year = a.Class_Year AND b.Student_ID IS NULL And finally where I have missing Student_ID's
  8. Can anybody take a look at this?
  9. This gives me about 101 records of all first year students. SELECT * FROM atlas_tl_students a LEFT JOIN atlas_tl_session_grade_import b ON ( a.UID = b.Student_ID ) LEFT JOIN atlas_tl_session c ON ( b.Session_ID = c.Session_ID ) LEFT JOIN atlas_tl_courses d ON ( c.Course_ID = d.Course_ID ) WHERE d.Course_Year = a.Class_Year This gives me nothing, yet I think it should give me those students who are missing from the import. SELECT * FROM atlas_tl_students a LEFT JOIN atlas_tl_session_grade_import b ON ( a.UID = b.Student_ID ) LEFT JOIN atlas_tl_session c ON ( b.Session_ID = c.Session_ID ) LEFT JOIN atlas_tl_courses d ON ( c.Course_ID = d.Course_ID ) WHERE d.Course_Year = a.Class_Year AND b.Student_ID IS NULL
  10. I have a table that is imported from a csv file. I need to find any records that may be missing. The file in question are grades from a test. I need to find any missing students who may have missed class the day of the exam. atlas_tl_session_grade_import has Student_ID atlas_tl_students have UID that should match Student_ID's I need to find only those students for the respective year they are in. (ie.. first years students, 2nd years students) I do this by matching what Session_ID from what Course and then getting the Course_Year (ie , 1 or 2, or 3, or 4) to match the Class_Year of the students. This way I am only looking at students from the correct year rather than all 600 students from all years. Then find any student that is missing. SELECT * FROM atlas_tl_students a JOIN atlas_tl_session_grade_import b ON ( a.UID = b.Student_ID ) JOIN atlas_tl_session c ON (b.Session_ID = c.Session_ID) JOIN atlas_tl_courses d ON (c.Course_ID = d.Course_ID) WHERE d.Course_Year = a.Class_Year AND b.Student_ID IS NULL I tried a LEFT JOIN from atlas_tl_students a LEFT JOIN atlas_tl_session_grade_import b but this didn't work either. Something I am doing is not working. I erased a student record from the imported table but have yet to get any value returned. Once I get a return if ( $missingStudentTotal > 0 ) { then I will do something.
  11. It's DATETIME. I'm thinking I need a separate SELECT statement to get the value of the listbox. Opentable(); echo"<tr><center>Use drop down box to view prior years questions.</center></tr>"; echo"<tr><center>Select Year <select name=\"year\" size=\"1\" onchange=\"document.forms[0].submit();\">"; echo"<option value=\"2007\">2007</option>" ."<option value=\"2008\"selected>2008</option>" ."<option value=\"2009\">2009</option>" ."<option value=\"2010\">2010</option>" ."</select></center></tr>" ."</form>"; Closetable(); $result = $db->sql_query("SELECT YEAR(cm.time) AS qyear, * FROM comments cm JOIN course cs ON (cm.course_id = cs.course_id) JOIN reply r ON (cm.cid = r.cid) WHERE cm.course_id = '$course_id' AND qyear = '$year' ORDER BY cm.time DESC");
  12. Is this possible? I need to be able to filter the year in a select clause. I have a value in a field called time... 2008-01-17 13:02:07 I need to capture the year, which is the first 4 characters. I will do this by a list box and filter what questions are displayed. Here is a snippet: Opentable(); echo"<tr><center>Use drop down box to view prior years questions.</center></tr>"; echo"<tr><center>Select Year <select name='year' size=\"1\" onchange=\"reload(this.form)\">"; echo"<option value=\"2007\" selected>2007</option>" ."<option value=\"2008\">2008</option>" ."<option value=\"2009\">2009</option>" ."<option value=\"2010\">2010</option>" ."</select></center></tr>" ."</form>"; Closetable(); $result = $db->sql_query("SELECT substr("time",4) AS year, * FROM comments cm JOIN course cs ON (cm.course_id = cs.course_id) JOIN reply r ON (cm.cid = r.cid) WHERE cm.course_id = '$course_id' ORDER BY time DESC"); while ($row = $db->sql_fetchrow($result)) {
  13. ".$prefix."_tl_students contain all students. ".$prefix."_tl_session_grades contains all grades assigned to students. A session is equivalent to a class on a single day. The session is a "Team Learning" event where they all participate. If a students misses a "Team Learning" session then they do not get a record written to the _tl_session_grades, however I still need them to be displayed showing no grades recorded for that session. I thought the following would address what I need but I am not getting any results. I need to see all students even the ones who do not have a grade recorded. $result = $db->sql_query("SELECT * FROM ".$prefix."_tl_session_grades a LEFT JOIN ".$prefix."_tl_students b ON (a.SOMS_KEY = b.SOMS_KEY) WHERE a.Session_ID = '$Session_ID' AND a.SOMS_KEY IS NULL"); Where have I gone wrong?
  14. Here is how I did mine. It was test results from a university scantron that was a Excel file. I saved as a CSV and it works well. $file_name = $HTTP_POST_FILES['file_source']['tmp_name']; //Create the Import CSV table $sql = "CREATE TABLE IF NOT EXISTS ".$prefix."$table_name ( `ReportNumber` int(3) NULL, `Student_ID` varchar(9) NULL, `Name_Last` varchar(50) NULL, `Name_First` varchar(30) NULL, `Total_RS` tinyint(4) NULL, `Total_Percent` tinyint(3) NULL, `Percentile` tinyint(3) NULL, `Subtest_RS` tinyint(3) NULL, `Subtest_Percent` tinyint(3) NULL )"; $result = $db->sql_query($sql); if (!$result) {echo("<p>Error performing query: " . mysql_error() . "</p>");} $sql = "LOAD DATA LOCAL INFILE '".mysql_real_escape_string($file_name)."' INTO TABLE ".$prefix."$table_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r'"; if (!$sql) {echo("<p>Error performing query: " . mysql_error() . "</p>");} $result = $db->sql_query($sql);
  15. I built a question and answer system for students and faculty at the university I work at. Students can submit anonymous questions to their professors for each course they are in. Each question submitted is inserted into a comment_queue table with a timestamp now(). The record is tagged with a date/time, such as 2008-01-17 13:02:07. Currently all questions are displayed for all records for that course regardless of time/date. I want to change this to only display the current "academic" years questions. Sounds easy enough but the academic year is different than calendar year. This academic year we are in is 0708. Next academic year will be 0809. The academic year started in August like normal and will last till the following June. I had a field in a comment_config table for academic_year (value = 0708) that could be inserted for all questions posted for that year, but was wondering if I could use the timestamp value I already have. I also want to implement a way for students to be able to look at the previous years questions that were submitted at the start of that calendar year by the use of a list box for 2007, 2008...etc. I'm getting confused trying to find a use for the timestamp value I already capture and if it can be used for the purposes I need. How could I extract the date from my timestamp value and "transpose" that to compare it to an academic_year value such as 0708? I'm thinking I may need another table just for this purpose. 2006 = 0607 2007 = 0708 2008 = 0809 2009 = 0910
  16. If I have a Decimal(3,2) datatype, and try to enter a value such as 100 it returns 99.99. Why is that? I have a table for student grades and need to enter in either 100 or any other possible grade such as 98.60 or 87.43... etc. This works with Decimal(4,2) but I don't know why.
  17. Why is this causing me so much trouble. This is from a side menu and I placed a snippet of php code for a link. </ul> <br /> <strong>Files & Links</strong>:<br /> <ul class="bluebullets"> <li>Megamix Case Review</li> <li> <?php $course_id = 12; echo "<a href='../../xxxx/index.php?op=questions&course_id=$course_id'>Questions</a>"; ?> </li> </p> </div> </ul> All that shows up is ..not linked at all. Why would this be ignored by the browser? In the browser it is displaying "; from my echo and the closing php tags. I'm using Firefox.
  18. I have an email form mailer notifing a user if they is a waiting question. I can't seem to get the $link to display in the email as a a link. It just has the url displayed as all text. I cobbled this together from several sources. First from my notify () function. while ($row = $db->sql_fetchrow($sql)) { $to = $row['email']; $title = $row['title']; $lastname = $row['last_name']; $message = $row['comment_text']; $headers .= "From: do_not_reply\nReply-To: do_not_reply@xxxxx.xxx \r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $subject = "A question is waiting"; $link = 'http://www.test.edu/xxxx/admin/login.php'; if(strlen($template)==0) { // Get the welcome email body from saved .html file if(!$fp = fopen($CONF_PATH."/xxxxx/template/emailquestion.tpl", "r")) { //file open failed, create error routine here Print ("File open failed very badly!"); exit; } while (!feof($fp)) { $send_body .= fgets($fp, 100); } fclose($fp); if ($count > 1) { $template = $send_body; } } else { $send_body = $template; } $send_body = eregi_replace("__lastname__", $lastname, $send_body); $send_body = eregi_replace("__title__", $title, $send_body); $send_body = eregi_replace("__message__", $message, $send_body); $send_body = eregi_replace("__link__", $link, $send_body); //echo"$send_body"; mail($to, $subject, $send_body, $headers); } } This is passed to a template... emailquestion.tpl. Example: <table width="100%"> <tr><td>The title of the question is: __title__ </td></tr> <br /><br /> <tr><td>The contents of the question is: <quote> __message__ </quote></td></tr> <br /><br /><br /> <tr><td>Click on the following link to go to the system and sign in with your account login and password.</td></tr> <br /> <tr><td>__link__</td></tr> </table> __link__ is displayed as http://www.test.edu/xxxx/admin/login.php but is not a link to click on. It is just text. I would rather have it as a proper <a href=" whatever </a> in the email. I have tried different browser based email clients
  19. Donovan

    Sub Queries

    UID and SOMS_KEY are different values. Testing scantons from the university use UID. They put that on a excel file along with the score for that test. I save the file as a csv and then import to a table. The imported table does not contain a SOMS_KEY. I need to match UID from the import to the student table and then capture the SOMS_KEY which is also in the student_groups table (on a SOMS_KEY, Group_ID pair), to find if all the students in the imported table have been assigned to groups.
  20. Donovan

    Sub Queries

    I need to find if any students in my imported table "atlas_tl_session_grade_import" do not yet belong to a group in the "atlas_tl_group_students" The import table contains the unique field UID The student table has both SOMS_KEY and UID. The student group table contain the unique field SOMS_KEY and Group_ID The group table has Group_ID I am attempting a sub query to do this but don't know if I'm on the right track. SELECT a.UID FROM atlas_tl_session_grade_import a WHERE a.UID NOT IN ( SELECT a.SOMS_KEY FROM atlas_tl_students a JOIN atlas_tl_group_students b ON ( a.SOMS_KEY = b.SOMS_KEY ) JOIN atlas_tl_groups c ON ( b.Group_ID = c.Group_ID ) ) I then will do a sql_numrows then if ( $group_total > 0 ) { OpenTable(); echo"<tr><td>There are student grades from this import who have not yet been assigned to a group.</td></tr>"; echo"<tr><td>Please ensure all students for this class year have been assigned to their TL group.</td></tr>"; echo"<tr><td><input type=\"button\" value=\"Back\" onClick=\"history.go(-1)\"></td></tr>"; Closetable(); die(); } else { ect
  21. I usually use and alias such as SELECT SUM(`rate`) AS rate_avg
  22. I was using a foreach($_POST['a'] as $key => $value) { to process a loop, but have another issue. I have more than two values I am trying to pass to another page to process and the $key => $value isn't enough. I actually have 4 values for each record. I was loading the _POST array like this. "<td><input type='text' name='IRAT_Grade[{$SOMS_KEY}]' size='3' maxlength='3'></td>" So each grade would have a corrosponding SOMS_KEY value. But I also have $Group_ID, and $UID for each record. Is it possible for me to do this? . "<td><input type='text' name='IRAT_Grade[{$SOMS_KEY}]' size='3' maxlength='3'></td>" . "</tr>" . "<input type='hidden' name='IRAT_Grade[{$Group_ID}]' value='$Group_ID'>\n" . "<input type='hidden' name='IRAT_Grade[{$UID}]' value='$UID'>\n"; Then on the processing page do something like while (list($SOMS_KEY, $IRAT, $Group_ID, $UID) = each($IRAT_Grade)) { $sql = "INSERT INTO ".$prefix."_tl_session_grades (Session_ID, UID, Group_ID, SOMS_KEY, IRAT_Grade, Academic_Year)". "VALUES ('$Session_ID', '$UID', '$Group_ID', '$SOMS_KEY', '$IRAT', '$Academic_Year')"; $result = $db->sql_query($sql); if (!$result) {echo("<p>Error performing query: " . mysql_error() . "</p>");} } I think I would have to _POST the values somewhere as well same as I did here: foreach($_POST['a'] as $key => $value)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.