$row = $result->fetch_assoc(); $id = $row['user_id']; $name = $row['first_name'] . " " . $row['last_name']; $newStudent = "\n <tr><td><input type=checkbox id=s_" . $id . " name=s_" . $id . " class=\"studentCheckbox\" /></td><td>" . $name . "</td></tr>"; } } $studentArray = array('error' => $error, 'message' => $msg, 'newStudent' => $newStudent); echo json_encode($studentArray); } if (isset($_POST['unPairStudent'])) { /** * Foreach checkbox selected, unpair... */ $students = array(); foreach ($_POST as $k => $v) { if (substr($k, 0, 2) == 's_') { list($junk, $id) = preg_split("/_/", $k); $sql = "DELETE from parent2student where parent_id=" . $_POST['parentid'] . " and student_id=" . $id; $result = $db->query($sql); if (!$result) { $error = true; $errmsg .= "There was an error executing the query \n\"" . $sql . " \"\n around line " . __LINE__ . " in file " . __FILE__; $msg .= $errmsg . "<br />There was an error un-pairing the student and parent. Please contact the system administrator."; email_admin('Q3AIT.ORG ERROR!', $errmsg); } } } $studentArray = array('error' => $error, 'message' => $msg); echo json_encode($studentArray); } }
function unregisterStudentFromCourse($roster) { global $db; $errmsg = ''; $today = date('Y-m-d'); $error = false; /** * IF the Active status is false then the student was withdrawn from the course, need to * set the isActive status in the student2class to 'N' for terms up to and including current * and remove from student2class for future terms */ foreach ($roster as $regi) { $u = $regi['user_id']; $c = $regi['class_id']; $sql = "UPDATE student2class set isActive='N' where user_id=" . $u . " and class_id=" . $c; $db->query($sql); if ($db->error) { $error = true; $errmsg .= "ERROR unregistering student {" . $u . "} from class {" . $c . "}<br>\n"; $errmsg .= $db->errno . " : " . $db->error . "<br>\n"; continue; } } if ($error) { email_admin('Q3AIT.ORG ERROR! Problem registering students in classes.', $errmsg); } return array('error' => $error, 'message' => $errmsg); }
} // end of if } function footer() { echo "<div style=\"font-family: Verdana; font-size: 10px;\">Quiz made possible with <a href=\"http://regretless.com/scripts/\" target=\"_blank\">Dodo's Quiz Script</a></div>"; } // end of footer function if (!$_GET['action']) { echo "<div class=\"header\">" . $quiz_question . "</div>\n<div class=\"just\">" . $quiz_description . "</div>"; echo "<form action=\"dodosquiz.php?n=" . $_GET['n'] . "&action=results\" method=\"post\">"; for ($i = 1; $i <= count($questions_array); $i++) { echo "<div class=\"rings\">" . $questions_array[$i] . "</div>\n"; // find the answers $this_answers = explode("\n", $answers_array[$i]); // print the answers and modify the results echo "<div class=\"just\">\n"; for ($k = 0; $k < count($this_answers); $k++) { $this_particular_answer = explode("|", $this_answers[$k]); echo "<label><input type=\"radio\" name=\"choices[" . $i . "]\" value=\"" . trim($this_particular_answer[1]) . "\">" . $this_particular_answer[0] . "</label><br /> \n"; } echo "</div><br />\n"; //print_r($this_answers); } // end of for echo "<input type=\"submit\" value=\"" . $submit_button . "\" class=\"form\"></form>"; } // end of if not action footer(); email_admin($final_result); include "footer.php";
/** * Tries to update a user comment * only admin can update all comments * users can edit their own comments if admin allow them * * @param array $comment * @param string $post_key secret key sent back to the browser * @return string validate, moderate, reject */ function update_user_comment($comment, $post_key) { global $conf, $page; $comment_action = 'validate'; if (!verify_ephemeral_key($post_key, $comment['image_id'])) { $comment_action = 'reject'; } elseif (!$conf['comments_validation'] or is_admin()) { $comment_action = 'validate'; //one of validate, moderate, reject } else { $comment_action = 'moderate'; //one of validate, moderate, reject } // perform more spam check $comment_action = trigger_change('user_comment_check', $comment_action, array_merge($comment, array('author' => $GLOBALS['user']['username']))); // website if (!empty($comment['website_url'])) { $comm['website_url'] = strip_tags($comm['website_url']); if (!preg_match('/^https?/i', $comment['website_url'])) { $comment['website_url'] = 'http://' . $comment['website_url']; } if (!url_check_format($comment['website_url'])) { $page['errors'][] = l10n('Your website URL is invalid'); $comment_action = 'reject'; } } if ($comment_action != 'reject') { $user_where_clause = ''; if (!is_admin()) { $user_where_clause = ' AND author_id = \'' . $GLOBALS['user']['id'] . '\''; } $query = ' UPDATE ' . COMMENTS_TABLE . ' SET content = \'' . $comment['content'] . '\', website_url = ' . (!empty($comment['website_url']) ? '\'' . $comment['website_url'] . '\'' : 'NULL') . ', validated = \'' . ($comment_action == 'validate' ? 'true' : 'false') . '\', validation_date = ' . ($comment_action == 'validate' ? 'NOW()' : 'NULL') . ' WHERE id = ' . $comment['comment_id'] . $user_where_clause . ' ;'; $result = pwg_query($query); // mail admin and ask to validate the comment if ($result and $conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $comment_url = get_absolute_root_url() . 'comments.php?comment_id=' . $comment['comment_id']; $keyargs_content = array(get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username'])), get_l10n_args('Comment: %s', stripslashes($comment['content'])), get_l10n_args(''), get_l10n_args('Manage this user comment: %s', $comment_url), get_l10n_args('(!) This comment requires validation')); pwg_mail_notification_admins(get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username'])), $keyargs_content); } elseif ($result) { email_admin('edit', array('author' => $GLOBALS['user']['username'], 'content' => stripslashes($comment['content']))); } } return $comment_action; }
$err .= $ret['txt']; } } } /** now remove the term... **/ $sql = "DELETE from "; $result = $db->query($sql); $t = "Message..."; $bc = "red"; $b = "The year has been deleted.<br />"; if ($errorFlag) { $b .= "However, there were some errors. A message was sent to the system administrator.<br />"; $sub = "Error removing term"; $messg = "While teacher {" . $myName . "} was attempting to remove a term, there were problems.\n"; $messg .= "The system returned the following errors\n" . $err . "\n\n"; email_admin($sub, $messg); } $main .= make_box($t, $b, $bc); } if (isset($_POST['delete_year'])) { $sql = "SELECT * from terms WHERE term_id=" . $_POST['term_id']; $result = $db->query($sql); $row = $result->fetch_assoc(); $t = "Warning..."; $bc = "red"; $b = "You have chosen to delete term...\n\t\t\t\t\tWeight = " . $row['term_weight'] . "<br />\n\t\t\t\t\tStart = " . $row['term_start_date'] . " <br />\n\t\t\t\t\tEnd = " . $row['term_end_date'] . "<br />\n\t\t\t\tAre you sure?<br />Deleting a term will also delete any classes and grades associated with that term!!!<br /></FONT><center>\n\t\t\t\t<FORM action=index.php?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=" . $_SESSION[$_CONF['sess_name'] . '_cat'] . " method=POST>\n\t\t\t\t<input type=submit class=submit name=really_delete_term value=Delete>\n\t\t\t\t<input type=submit class=submit name=cancel value=Cancel>\n\t\t\t\t<INPUT type=hidden name=term_id value=" . $_POST['term_id'] . ">\n\t\t\t\t</FORM>"; $main .= make_box($t, $b, $bc); } /** Now list the School Years. **/
$student_id = $regi['student_id'] = $q3aitUsers[$row['STGUID']]['user_id']; $course_id = $regi['course_id'] = $q3aitCourses[$row['SectionID']]['course_id']; $classes = get_classes_for_course($course_id); while ($row2 = $classes->fetch_assoc()) { array_push($register, array('user_id' => $student_id, 'class_id' => $row2['class_id'])); } } } else { //print "Student {STGUID=".$row['STGUID']."} is not in the q3ait db.<br>\n"; //continue; } } else { //print "Course {SectionID=".$row['SectionID']."} is not in the q3ait db.<br>\n"; //continue; } } $errors = registerStudentInCourse($register); if ($errors['error']) { $msg = $errors['message'] . "<BR>\n"; array_push($messages, $msg); } /** * Errors? */ $err = ''; if (count($messages) > 0) { foreach ($messages as $message) { $err .= $message . "\n"; } email_admin("Q3AIT.ORG ERROR: Sync - ROSTERS", $err); }
require '/usr/local/q3ait/config.php'; require $_CONF['webRoot'] . 'functionLib.php'; // Connect to DB $db = new mysqli($_CONF['DB_host'], $_CONF['DB_user'], $_CONF['DB_pass'], $_CONF['DB_name']); if (mysqli_connect_errno()) { die("There was an error connecting to the database: " . mysqli_connect_error()); } $regi = array(); $smsClassRosters = make_array_from_sql(getClassRostersFromSMS(), 'ms'); $q3aitUsers = make_assoc_array_from_sql(getCurrentUsersForSMS(), 'GUID', 'my'); $q3aitCourses = make_assoc_array_from_sql(getCoursesForSMS(), 'SectionID', 'my'); $smsRoster = array(); // user_id, class_id foreach ($smsClassRosters as $row) { if (array_key_exists($row['SectionID'], $q3aitCourses) && array_key_exists($row['STGUID'], $q3aitUsers)) { $msg .= "Working on Student{" . $q3aitUsers[$row['STGUID']]['first_name'] . " " . $q3aitUsers[$row['STGUID']]['last_name'] . "} in class{" . $q3aitCourses[$row['SectionID']]['course_name'] . "}...<br>"; $student_id = $regi['student_id'] = $q3aitUsers[$row['STGUID']]['user_id']; $course_id = $regi['course_id'] = $q3aitCourses[$row['SectionID']]['course_id']; $classes = get_classes_for_course($course_id); while ($row = $classes->fetch_assoc()) { array_push($smsRoster, array('user_id' => $student_id, 'class_id' => $row['class_id'])); } } else { continue; } } $errors = registerStudentInCourse($smsRoster); if ($errors['error']) { $msg .= $errors['message'] . "<BR>\n"; email_admin("Q3AIT.ORG ERROR: Syncing Class Rosters", $msg); }