Jump to content

Donovan

Members
  • Posts

    73
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Donovan's Achievements

Member

Member (2/5)

0

Reputation

  1. Still need help with this. I'm spinning my wheels.
  2. I have an application that uses the phpBB template engine. I needed to write some error checking logic but this has raised a problem. If I catch an error the form is not sticky and refreshes to a blank form after displaying the error message. The page is where I add a new question for exams. I don't want them to add the questions if they forgot to identify a correct answer for a multiple choice question. The questions.tpl looks like this. <tr> <td width="100%"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="borderline" align="center"> <tr> <td align="left" valign="top"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="bodyline"> <tr> <td height="240" valign="top"> <!-- BEGIN question --> <form name="{question.FORM_NAME}" action="{question.ACTION}" method="post"> {question.FORM_HIDDEN} {question.CONTENTS} </form> <!-- END question --> </td> </tr> </table> </td> </tr> </table> </td> </tr> And the last part of my question.php where I add new questions looks like this where I check for the existence of an answer. elseif ( ($mode == 'addresp' ) &&( ( $userdata['user_level'] == ADMIN ) || ( in_array ($cid, $course['teaches'] ) )) ){ .... for ( $i=1; $i<$anscounter; $i++) { $question_values['points'] .= (empty($_POST["point$i"]) ? 0 $_POST["point$i"])) ."#"; } $question -> setValue($question_values); $sql = $question -> operation('addresp'); //Lets check if the question has at least one correct answer - SFD 6/9/2010 $point_array = explode("#",$question_values['points']); $answer_exists = false; // Set to default if(in_array("1",$point_array)) { $answer_exists = true; // The answer exists - so insert into database. $db->sql_query($sql); $message = ' Question has been Created'; $nav_path .= $question_values['qname']; $template->assign_block_vars('question',array('ACTION' => '', 'FORM_NAME' => 'questions', 'FORM_HIDDEN' => '', 'CONTENTS' => '<br><br><span class="catHead">'.$message.'</span> <a href="javascript:void(0);" class="action" onClick="window.close()">Close Window</a><br><br>' )); }else{ //This is where I need to make the form sticky and re-display. All the values that are on the form look like this... $question_values['qstem'] = (isset($_POST['ques_stem']) ? $_POST['ques_stem'] : '') ; $question_values['qname'] = (isset($_POST['ques_name']) ? $_POST['ques_name'] : '') ; $question_values['qch1'] = (isset($_POST['ques_ch1']) ? $_POST['ques_ch1'] : '') ; $question_values['qch2'] = (isset($_POST['ques_ch2']) ? $_POST['ques_ch2'] : '') ; $question_values['qch3'] = (isset($_POST['ques_ch3']) ? $_POST['ques_ch3'] : '') ; $question_values['qch4'] = (isset($_POST['ques_ch4']) ? $_POST['ques_ch4'] : '') ; $question_values['qch5'] = (isset($_POST['ques_ch5']) ? $_POST['ques_ch5'] : '') ; $question_values['qch6'] = (isset($_POST['ques_ch6']) ? $_POST['ques_ch6'] : '') ; $question_values['qch7'] = (isset($_POST['ques_ch7']) ? $_POST['ques_ch7'] : '') ; $question_values['qch8'] = (isset($_POST['ques_ch8']) ? $_POST['ques_ch8'] : '') ; $question_values['qch9'] = (isset($_POST['ques_ch9']) ? $_POST['ques_ch9'] : '') ; $question_values['media_name'] = (isset($_POST['media_name']) ? $_POST['media_name'] : '') ; $question_values['feedback'] = (isset($_POST['feedback']) ? $_POST['feedback'] : '') ; } I don't know what I need here when I need to redisplay this data. }else{ $message = 'Error in Updating Question. You must have at least one correct answer marked.'; $nav_path .= $question_values['qname']; $template->assign_block_vars('question',array('ACTION' => '', 'FORM_NAME' => 'questions', 'FORM_HIDDEN' => '', 'CONTENTS' => $question -> operation('add') )); } My operation('add') is not sticky and looks like this. if ( ($mode == 'add' ) &&( ( $userdata['user_level'] == ADMIN ) || ( in_array ($cid, $course['teaches'] ) )) ) { $question = new question(); $question -> setIDs($cid,$ca,$_POST['qtype'], $userdata['session_user_id']); $template->assign_block_vars('question',array('ACTION' => append_sid('questions.php?ARG1='.$cid.'&ARG2='.$ca), 'FORM_NAME' => 'questions', 'FORM_HIDDEN' => '', 'CONTENTS' => $question -> operation('add') )); } // eof add Any help is appreciated.
  3. I've also tried this but nothing happens. $handle = fopen ($Studentfile, 'r'); while (($data = fgetcsv($handle, 1000, ',', '"')) !== FALSE) { $sql = $db->sql_query("INSERT INTO atlas_tl_students_temp VALUES ('". implode("','", $data)."')"); } Nothing gets inserted.
  4. $fileName = basename($_FILES['file_source']['name']); move_uploaded_file($_FILES['file_source']['tmp_name'], $uploadFolder.$fileName); $Studentfile = "$uploadFolder/$fileName"; //die(); if (file_exists($Studentfile) == false) { die('It doesn\'t exist!'); } if (is_readable($Studentfile) == false) { die('It doesn\'t exist or we can\'t read it!'); } else { $upload = $db->sql_query("LOAD DATA LOCAL INFILE '".$Studentfile."' INTO TABLE ".$prefix."$table_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r'"); if (!$upload) {echo("<p>Error performing query: " . mysql_error() . "</p>");} } } I am getting and I've also gotten I've used this with and without LOCAL. My website is on a different server than my MySQL database. The powers that be says it cannot be moved onto the same server. Why can't I load this file into MySQL? If this wont work can somebody give me a jump start on a parse routine where I could do inserts one at a time on about 300 or 400 records?
  5. I have a peer evaluation that students fill out. The number of members in their group is somewhere between 5 to 7. When a user clicks on the course record for peer evaluation it pulls all the groups members for that user and displays them with a drop down box and textarea. The drop down is a eval score between 7 - 13. The textarea is for eval comments for feedback on how well each member participated and contributed to the groups success. The following code pulls all group members from the users group excluding themselves, then displays the form drop down boxes so that the user can select a score for each member, and leave a feedback comment. while($row = $db->sql_fetchrow($getgroupmembers)) { $SOMS_KEY = $row['SOMS_KEY']; $UID = $row['UID']; $Name_First = $row['Name_First']; $Name_Last = $row['Name_Last']; echo"<tr>" ."<td align='center'> $Name_First $Name_Last </td>" ."<td>" ."<select name='evalscore[{$UID}]'>" ."<option value='7' selected>7</option>" ."<option value='8'>8</option>" ."<option value='9'>9</option>" ."<option value='10'>10</option>" ."<option value='11'>11</option>" ."<option value='12'>12</option>" ."<option value='13'>13</option>" ."</select>" ."</td>" ."<td align='left'><textarea name ='evalcomment[{$UID}]' cols='100' colspan='1' rows='2'></textarea></td>" ."</tr>"; } $countgroupmembers = $db->sql_query("SELECT * FROM ".$prefix."_tl_group_students WHERE Group_ID = '$UserGroup'"); $grouptotal = $db->sql_numrows($countgroupmembers); if ($grouptotal == 7) { $Total_Points = 60; } elseif ($grouptotal == 6) { $Total_Points = 50; } elseif ($grouptotal == 5) { $Total_Points = 40; } echo "<tr><td align='left'> Total Points Must = $Total_Points</td>"; This gets sent to another function where I write the values and display some sort of confirmation. function TLInsertY1PeerEvals($authuser) { global $prefix, $db; include("header.php"); session_start(); if (isset($_SESSION['authuser'])) { $authuser = $_SESSION['authuser']; } foreach ($_POST['evalscore'] as $keyUID => $score) { //Refer to the evalcomment array using the evalscore index (which is $keyUID in this case) $Course_Number = $_POST['Course_Number']; $evalcomment = $_POST['evalcomment'][$keyUID]; $sql = "INSERT INTO ".$prefix."_tl_peereval (UID, evalscore, eval_comment, Course_Number, rater, datesubmit)". "VALUES ('$keyUID', '$score', '$evalcomment', '$Course_Number', '$authuser', NOW())"; $result = $db->sql_query($sql); if (!$result) {echo("<p>Error performing query: " . mysql_error() . "</p>");} } include("header.php"); OpenTable(); echo "<br>\n" ."<form action='".$_server['php_self']."' method='post'" ."<table border=\"0\">" ."<tr><td>Thank You for submitting your peer evaluation.</td></tr>" ."<tr><td><input type=\"hidden\" name=\"op\" value=\"TLStudentGrades\">\n" ."<input type=\"submit\" value=\"Continue\"></form></td></tr></table><br>\n\n"; CloseTable(); include("footer.php"); } I assume I need javascript but have found no javascript examples I can follow. The problem is the form is dynamic depending on number of group members. If I had a static form I could just SUM the form elements.... <select id="evalscore_1" name="evalscore_1" ... <select id="evalscore_2" name="evalscore_2" etc But my form is not static. It could have anywhere from 4 members per group up to 7 members per group. What I need is to SUM all my eval_scores for each of the group members then compare that to what the average (Total_Points) should be. Example: Tim = 11 Nick = 12 Bob = 8 Lauren = 10 Steve = 9 $SUM_Points = 50 Then validate that $Total_Points and $SUM_Points match as well as each comments has a value. What would be ideal is a visible javascript running total of each listbox onchange() event. If anybody can assist it would be greatly appreciated.
  6. How can this query: SELECT Course_ID, SOMS_KEY, UID, Academic_Year, AVG( TL_Avg ) AS Final_Grade FROM atlas_tl_session_grades sg JOIN atlas_tl_session s ON ( s.Session_ID = sg.Session_ID ) WHERE s.Course_ID = 'CL00000011' GROUP BY sg.SOMS_KEY gives me 104 records which is what I want. Yet this query inserts 312 records? $insertgrades = $db->sql_query("INSERT INTO ".$prefix."_tl_course_grades (Course_ID, SOMS_KEY, UID, Academic_Year, Final_Grade)". "SELECT Course_ID, SOMS_KEY, UID, Academic_Year, AVG(TL_Avg) AS FinalGrade FROM ".$prefix."_tl_session_grades sg JOIN ".$prefix."_tl_session s ON (s.Session_ID = sg.Session_ID) WHERE s.Course_ID = '$Course_ID' GROUP BY sg.SOMS_KEY"); if (!$insertgrades) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); }
  7. Made a breakthrough. This query run in phpMyadmin seems to give me what I want. SELECT Course_ID, SOMS_KEY, UID, Academic_Year, AVG( TL_Avg ) AS Final_Grade FROM atlas_tl_session_grades sg JOIN atlas_tl_session s ON ( s.Session_ID = sg.Session_ID ) WHERE s.Course_ID = 'CL00000011' GROUP BY sg.SOMS_KEY But I have syntax errors trying to come up with an INSERT INTO $insertgrades = $db->sql_query("INSERT INTO ".$prefix."_tl_course_grades (Course_ID, SOMS_KEY, UID, Academic_Year, Final_Grade)". "VALUES (SELECT Course_ID, SOMS_KEY, UID, Academic_Year, AVG(TL_Avg) AS FinalGrade FROM ".$prefix."_tl_session_grades sg JOIN ".$prefix."_tl_session s ON (s.Session_ID = sg.Session_ID) WHERE s.Course_ID = '$Course_ID' GROUP BY sg.SOMS_KEY)"); if (!$insertgrades) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); }
  8. The UID and SOMS_KEY are used to identify the students. UID stands for University ID, and SOMS_KEY is a School of Medicine Key used to identify them as a medical student. In my students table these appear once. Here is the relevant table structure of my database. Each course would have multiple sessions of "Team Learning" Students get into their groups and do exercises. They get 3 exams during the "TL" session, and IRAT, GRAT, and AppEx. I grade these then average them against weights decided on in the beginning of the academic year. (IRAT are 30% of grade, GRAT are 40% of grade and so on. Like this: $updatetlavg = $db->sql_query("UPDATE ".$prefix."_tl_session_grades sg JOIN ".$prefix."_tl_session s SET TL_Avg = (SELECT ((IRAT_Grade * $irat_wt) + (GRAT_Grade * $grat_wt) + (Appex_Grade * $appex_wt)) AS TLAVG) WHERE sg.Session_ID = s.Session_ID"); Then for each course when all TL sessions are complete I need to AVG all TL session grades AVG(TL_Avg) for each student and write this to the course_grades table. I want to thank you for helping me figure out my logic for this. It is most appreciated.
  9. Do you think it is better to INSERT INTO ... VALUES(a, b, c), instead of trying it with subqueries.
  10. Ok. I'll leave out the avg for the initial insert, but I still have multiple records in session_grades for one course where I need to insert only one record in the course_grade table for each student. I thought if I GROUP BY SOMS_KEY I could only pull one record for each SOMS_KEY but that doesn't work. $insertgrades = $db->sql_query("INSERT INTO ".$prefix."_tl_course_grades (Course_ID, SOMS_KEY, UID, Academic_Year) SELECT DISTINCT s.Course_ID, g.SOMS_KEY, g.UID, g.Academic_Year FROM ".$prefix."_tl_session_grades g JOIN ".$prefix."_tl_session s ON (g.Session_ID = s.Session_ID) JOIN ".$prefix."_tl_courses c ON (s.Course_ID = c.Course_ID) WHERE c.Course_ID = '$Course_ID' GROUP BY SOMS_KEY"); I need to pull one record per student that exist in session_grades for sessions that exist in the Course I am trying to process. once i get this working i van go back and run my UPDATE and SET the Final_Grade
  11. Why write the course grade anywhere else but the course_grades table? How do I write a single grade to course_grades based off of three (or more) records from session_grades?
  12. Let me explain: Here is what my session_grades looks like I have three different Session_ID's all for the same student (SOMS_KEY). Each session grade has been averaged and written to TL_Avg based on a weighted value. (IRAT * .03) + GRAT *.03) + (Appex * .04) or something similar. I now want to get the average of all three TL_Avg and write that to the course_grades table. This is happening but I am writing the same record three different times. I have to join the table back like so: INSERT INTO course_grades (Course_ID, SOMS_KEY, UID, Academic_Year, Final_Grade) SELECT s.Course_ID, g.SOMS_KEY, g.UID, g.Academic_Year, AVG(TL_Avg) AS Final_Grade FROM _session_grades g JOIN session s ON (g.Session_ID = s.Session_ID) JOIN courses c ON (s.Course_ID = c.Course_ID) WHERE c.Course_ID = '$Course_ID' to make sure I am processing the correct grades for the Course I have chosen.
  13. I have a query where I'm trying to insert course grades. A course can have several "sessions" where students participate in "Team Learning". During the all day course they take 3 exams. The whole course may be 3-4 weeks long where they may have 3 or 4 or more "Team Learning" sessions (or TL sessions for short). So I have a courses table with Course_ID. I have a session table with Session_ID and Course_ID I have a session_grades table with Session_ID and a SOMS_KEY (SOMS_KEY for each student), and a TL_Avg for each grade for that session. My query looks like this: $insertgrades = $db->sql_query("INSERT INTO ".$prefix."_tl_course_grades (Course_ID, SOMS_KEY, UID, Academic_Year, Final_Grade) SELECT s.Course_ID, g.SOMS_KEY, g.UID, g.Academic_Year, AVG(TL_Avg) AS Final_Grade FROM ".$prefix."_tl_session_grades g JOIN ".$prefix."_tl_session s ON (g.Session_ID = s.Session_ID) JOIN ".$prefix."_tl_courses c ON (s.Course_ID = c.Course_ID) WHERE c.Course_ID = '$Course_ID' GROUP BY g.SOMS_KEY"); if (!$insertgrades) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); } For this example my course had 3 TL sessions. I need to get the AVG (TL_Avg) for all my sessions per course and insert it into the course_grades table. This is happening but it is happening 3 times, where I just need it to be inserted once. If I need to limit the number of inserts would a simple left join work? if so where should I put that?
  14. I'm not following you. Your reply is to vague. Do you mean something like this? $updateGrade = $db->sql_query("UPDATE ".$prefix."_tl_session_grades SET IRAT_Grade = (SELECT ((IRAT_Raw / $IratQuestions) * 100) AS IRATGrade), SET GRAT_Grade = (SELECT ((GRAT_Raw / $GratQuestions) * 100) AS GRATGrade), SET AppEx_Grade = (SELECT ((Appex_Raw / $AppExQuestions) * 100) AS AppexGrade) WHERE Session_ID = '$Session_ID'"); if (!$updateGrade) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); }
×
×
  • 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.