Beispiel #1
0
//
// You should have received a copy of the GNU General Public License
// along with Rogo.  If not, see <http://www.gnu.org/licenses/>.
/**
* 
* @author Simon Wilkinson
* @version 1.0
* @copyright Copyright (c) 2014 The University of Nottingham
* @package
*/
require '../include/sysadmin_auth.inc';
require_once '../include/errors.inc';
require_once '../classes/paperutils.class.php';
require_once '../include/demo_replace.inc';
$paperid = check_var('paperID', 'GET', true, false, true);
$paper_modules = Paper_utils::get_modules($paperid, $mysqli);
$module_id_list = implode(',', array_keys($paper_modules));
// Get data about the paper which needs scheduling
$results = $mysqli->prepare("SELECT property_id, paper_title, calendar_year, period, barriers_needed, cohort_size, notes, sittings, campus, title, first_names, surname, email, exam_duration FROM (properties, scheduling, users) WHERE property_id = ? AND properties.property_id = scheduling.paperID AND properties.paper_ownerID = users.id");
$results->bind_param('i', $paperid);
$results->execute();
$results->store_result();
$results->bind_result($property_id, $paper_title, $calendar_year, $period, $barriers_needed, $cohort_size, $notes, $sittings, $campus, $title, $first_names, $surname, $email, $exam_duration);
$results->fetch();
if ($results->num_rows == 0) {
    $results->close();
    $msg = sprintf($string['furtherassistance'], $configObject->get('support_email'), $configObject->get('support_email'));
    $notice->display_notice_and_exit($mysqli, $string['pagenotfound'], $msg, $string['pagenotfound'], '../artwork/page_not_found.png', '#C00000', true, true);
}
$results->close();
// Get student enrolments
Beispiel #2
0
 /**
  * Get the details of the papers that are currently available for the current user and lab
  * @param  array      $paper_display Reference to array in which to build details of available papers
  * @param  array      $types         Array of paper types to check for
  * @param  UserObject $userObj       The current user
  * @param  mysqli     $db            Database reference
  * @param  string     $exclude       Option ID of a paper to exclude from the check
  * @return integer                   The number of currently active papers
  */
 public function get_active_papers(&$paper_display, $types, $userObj, $db, $exclude = '')
 {
     $type_sql = '';
     foreach ($types as $type) {
         if ($type_sql != '') {
             $type_sql .= ' OR ';
         }
         $type_sql .= "paper_type='{$type}'";
     }
     $exclude_sql = '';
     if ($exclude != '') {
         $exclude_sql = ' AND property_id != ' . $exclude;
     }
     $paper_no = 0;
     $paper_query = $db->prepare("SELECT property_id, paper_type, crypt_name, paper_title, bidirectional, fullscreen, MAX(screen) AS max_screen, labs, calendar_year, password, completed FROM (papers, properties) LEFT JOIN log_metadata ON properties.property_id = log_metadata.paperID AND userID = ? WHERE papers.paper = properties.property_id AND (labs != '' OR password != '') AND ({$type_sql}) AND deleted IS NULL AND start_date < DATE_ADD(NOW(),interval 15 minute) AND end_date > NOW() {$exclude_sql} GROUP BY paper");
     $paper_query->bind_param('i', $userObj->get_user_ID());
     $paper_query->execute();
     $paper_query->store_result();
     $paper_query->bind_result($property_id, $paper_type, $crypt_name, $paper_title, $bidirectional, $fullscreen, $max_screen, $labs, $calendar_year, $password, $completed);
     while ($paper_query->fetch()) {
         if ($labs != '') {
             $machineOK = false;
             $labs = str_replace(",", " OR lab=", $labs);
             $lab_info = $db->query("SELECT address FROM client_identifiers WHERE address = '" . NetworkUtils::get_client_address() . "' AND (lab = {$labs})");
             if ($lab_info->num_rows > 0) {
                 $machineOK = true;
             }
             $lab_info->close();
         } else {
             $machineOK = true;
         }
         if (strpos($userObj->get_username(), 'user') !== 0) {
             $moduleIDs = Paper_utils::get_modules($property_id, $db);
             if (count($moduleIDs) > 0) {
                 $moduleOK = false;
                 if ($calendar_year != '') {
                     $cal_sql = "AND calendar_year = '" . $calendar_year . "'";
                 } else {
                     $cal_sql = '';
                 }
                 $module_in = implode(',', array_keys($moduleIDs));
                 $moduleInfo = $db->prepare("SELECT userID FROM modules_student WHERE userID = ? {$cal_sql} AND idMod IN ({$module_in})");
                 $moduleInfo->bind_param('i', $userObj->get_user_ID());
                 $moduleInfo->execute();
                 $moduleInfo->store_result();
                 $moduleInfo->bind_result($tmp_userID);
                 $moduleInfo->fetch();
                 if ($moduleInfo->num_rows() > 0) {
                     $moduleOK = true;
                 }
                 $moduleInfo->close();
             } else {
                 $moduleOK = true;
             }
         } else {
             $moduleOK = true;
         }
         if ($machineOK == true and $moduleOK == true) {
             $paper_display[$paper_no]['id'] = $property_id;
             $paper_display[$paper_no]['paper_title'] = $paper_title;
             $paper_display[$paper_no]['crypt_name'] = $crypt_name;
             $paper_display[$paper_no]['paper_type'] = $paper_type;
             $paper_display[$paper_no]['max_screen'] = $max_screen;
             $paper_display[$paper_no]['bidirectional'] = $bidirectional;
             $paper_display[$paper_no]['password'] = $password;
             $paper_display[$paper_no]['completed'] = $completed;
             $paper_no++;
         }
     }
     $paper_query->close();
     return $paper_no;
 }
Beispiel #3
0
function marks_from_file($fileName, $paperID, $string, $properties, $db)
{
    $configObject = Config::get_instance();
    $configObject->get('cfg_tmpdir');
    $userObject = UserObject::get_instance();
    // Get properties of the paper.
    $session = $properties->get_calendar_year();
    $paper_date = $properties->get_raw_start_date();
    $moduleIDs = Paper_utils::get_modules($paperID, $db);
    // Get the questions on the paper.
    $paper = array();
    $question_no = 0;
    $result = $db->prepare("SELECT question, sum(marks_correct) AS sum FROM papers, options WHERE paper = ? AND papers.question = options.o_id GROUP BY question ORDER BY screen, display_pos");
    $result->bind_param('i', $paperID);
    $result->execute();
    $result->bind_result($question, $marks_correct);
    while ($result->fetch()) {
        $question_no++;
        $paper[$question_no]['id'] = $question;
        $paper[$question_no]['marks_correct'] = $marks_correct;
    }
    $result->close();
    // Get student data.
    $students = array();
    $modids = implode(',', array_keys($moduleIDs));
    $result = $db->prepare("SELECT users.id, student_id, username, yearofstudy, grade, title, surname, first_names FROM users, sid, modules_student WHERE users.id = sid.userID AND users.id = modules_student.userID AND idMod IN ({$modids}) AND calendar_year = ?");
    $result->bind_param('s', $session);
    $result->execute();
    $result->bind_result($id, $student_id, $username, $year, $grade, $title, $surname, $first_names);
    while ($result->fetch()) {
        $students[$student_id]['username'] = $username;
        $students[$student_id]['title'] = $title;
        $students[$student_id]['surname'] = $surname;
        $students[$student_id]['first_names'] = $first_names;
        $students[$student_id]['year'] = $year;
        $students[$student_id]['grade'] = $grade;
        $students[$student_id]['id'] = $id;
    }
    $result->close();
    $lines = file($fileName);
    $line_written = 0;
    echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" style=\"margin-left:10px; border-collapse:collapse\">\n";
    foreach ($lines as $separate_line) {
        $error = '';
        if ($line_written == 0 and isset($_POST['header_row']) and $_POST['header_row'] == 1) {
            // Write out the header line.
            $fields = explode(',', $separate_line);
            echo "<tr><th></th><th colspan=\"3\">Student Name</th>";
            foreach ($fields as $field) {
                if (trim($field) != '') {
                    echo "<th>{$field}</th>";
                }
            }
            echo "</tr>\n";
        }
        if (!isset($_POST['header_row']) or $_POST['header_row'] != 1 or $line_written > 0) {
            $fields = explode(',', $separate_line);
            $sid = trim($fields[0]);
            if (!isset($students[$sid]['username'])) {
                // Student is not in class List.
                // Look up to see if anywhere else in Authentication database.
                $result = $db->prepare("SELECT id, student_id, users.username, yearofstudy, grade, title, surname, first_names FROM users, sid WHERE users.id = sid.userID AND sid.student_id = ?");
                $result->bind_param('s', $sid);
                $result->execute();
                $result->store_result();
                $result->bind_result($id, $student_id, $username, $year, $grade, $title, $surname, $first_names);
                if ($result->num_rows > 0) {
                    $result->fetch();
                    $students[$student_id]['username'] = $username;
                    $students[$student_id]['title'] = $title;
                    $students[$student_id]['surname'] = $surname;
                    $students[$student_id]['first_names'] = $first_names;
                    $students[$student_id]['year'] = $year;
                    $students[$student_id]['grade'] = $grade;
                    $students[$student_id]['id'] = $id;
                }
                $result->close();
            }
            if (isset($students[$sid]) and $students[$sid]['username'] != '') {
                // Student is in class List.
                $save_ok = true;
                $db->autocommit(false);
                $result = $db->prepare("SELECT id FROM log_metadata WHERE userID = ? AND paperID = ? AND started = ?");
                $result->bind_param('iis', $students[$sid]['id'], $paperID, $paper_date);
                $result->execute();
                $result->store_result();
                $result->bind_result($lmd_id);
                if ($result->num_rows > 0) {
                    $result->fetch();
                    $delete1 = $db->prepare("DELETE FROM log5 WHERE metadataID = ?");
                    $delete1->bind_param('i', $lmd_id);
                    $res = $delete1->execute();
                    if ($res == false) {
                        $save_ok = false;
                    }
                    $delete1->close();
                    if ($save_ok) {
                        $delete2 = $db->prepare("DELETE FROM log_metadata WHERE id = ?");
                        $delete2->bind_param('i', $lmd_id);
                        $res = $delete2->execute();
                        if ($res == false) {
                            $save_ok = false;
                        }
                        $delete2->close();
                    }
                }
                $result->close();
                //
                // did the all the save to log operations succeed?
                //
                if ($save_ok === false) {
                    //NO - rollback
                    $db->rollback();
                    $error = $string['errorsaving'];
                    break;
                } else {
                    //YES - commit the updates to the log tables
                    $db->commit();
                }
                $result = $db->prepare("INSERT INTO log_metadata (userID, paperID, started, ipaddress, student_grade, year, attempt) " . "VALUES (?, ?, ?, ?, ?, ?, ?)");
                $ip = '127.0.0.1';
                $attempt = 1;
                $result->bind_param('iisssii', $students[$sid]['id'], $paperID, $paper_date, $ip, $students[$sid]['grade'], $students[$sid]['year'], $attempt);
                $res = $result->execute();
                if ($res == false) {
                    $save_ok = false;
                } else {
                    $lmd_id = $db->insert_id;
                }
                $result->close();
                if ($save_ok) {
                    echo "<tr><td><img src=\"../artwork/green_plus_16.png\" wodth=\"16\" height=\"16\" alt=\"Add\" /></td><td>" . $students[$sid]['title'] . "</td><td>" . $students[$sid]['surname'] . "</td><td>" . $students[$sid]['first_names'] . "</td><td>{$sid}</td>";
                    for ($q = 1; $q <= $question_no; $q++) {
                        $result = $db->prepare("INSERT INTO log5 (q_id, mark, adjmark, totalpos, metadataID) VALUES (?, ?, ?, ?, ?)");
                        $mark = trim($fields[$q]);
                        if ($mark > $paper[$q]['marks_correct']) {
                            $save_mark = NULL;
                        } else {
                            $save_mark = floatval($mark);
                        }
                        $result->bind_param('iddii', $paper[$q]['id'], $save_mark, $save_mark, $paper[$q]['marks_correct'], $lmd_id);
                        $res = $result->execute();
                        if ($res == false) {
                            echo "<td>error</td>";
                            $save_ok = false;
                            break;
                        } else {
                            if ($mark > $paper[$q]['marks_correct']) {
                                echo '<td class="failed">too high</td>';
                            } elseif ($mark === '') {
                                echo '<td class="failed">missing</td>';
                            } else {
                                echo "<td class=\"num\">{$mark}</td>";
                            }
                        }
                        $result->close();
                    }
                    echo "</tr>\n";
                }
                //
                // did the all the save to log operations succeed?
                //
                if ($save_ok === false) {
                    //NO - rollback
                    $db->rollback();
                    $error = $string['errorsaving'];
                    break;
                } else {
                    //YES - commit the updates to the log tables
                    $db->commit();
                }
            } else {
                echo "<tr><td><img src=\"../artwork/red_cross_16.png\" wodth=\"16\" height=\"16\" alt=\"Failed\" /></td><td colspan=\"3\" class=\"failed\">Student not found.</td><td>{$sid}</td><td colspan=\"" . $question_no . "\" class=\"failed\">&nbsp;</td></tr>";
            }
        }
        $line_written++;
    }
    //if ($error != '') {
    //  echo "<li style=\"color:C00000\">$error</li>";
    //}
    echo "</table>\n";
    //turn auto commit back on so future queries function as before
    $db->autocommit(true);
}
Beispiel #4
0
/**
 * Copies the paper properties record.
 *
 * @param object $db						- Link to MySQL database
 * @param string $calendar_year	- Looks up and updates the academic session - used with learning objectives
 * @param string $moduleIDs			- Looks up and updates the modules the paper is on - used with learning objectives
 * @param object $userObj				- Currently logged in user object.
 * @param object $configObject	- Configuration settings object.
 *
 * @return int - ID of the newly inserted property record.
 */
function copyProperties($db, &$calendar_year, &$new_calendar_year, &$moduleIDs, $userObj, $configObject)
{
    $userID = $userObj->get_user_ID();
    $moduleIDs = Paper_utils::get_modules($_POST['paperID'], $db);
    $result = $db->prepare("SELECT * FROM properties WHERE property_id = ? LIMIT 1");
    $result->bind_param('i', $_POST['paperID']);
    $result->execute();
    $result->store_result();
    $result->bind_result($property_id, $paper_title, $start_date, $end_date, $timezone, $paper_type, $paper_prologue, $paper_postscript, $bgcolor, $fgcolor, $themecolor, $labelcolor, $fullscreen, $marking, $bidirectional, $pass_mark, $distinction_mark, $paper_owner, $folder, $labs, $rubric, $calculator, $exam_duration, $deleted, $created, $random_mark, $total_mark, $display_correct_answer, $display_question_mark, $display_students_response, $display_feedback, $hide_if_unanswered, $calendar_year, $external_review_deadline, $internal_review_deadline, $sound_demo, $latex_needed, $password, $retired, $crypt_name, $recache_marks);
    $result->fetch();
    $result->close();
    $paper_type = $_POST['paper_type'];
    // Override the paper type with what is posted.
    if ($paper_type == 2 and $configObject->get('cfg_summative_mgmt')) {
        $duration = 0;
        if (isset($_POST['duration_hours'])) {
            $duration += $_POST['duration_hours'] * 60;
        }
        if (isset($_POST['duration_mins'])) {
            $duration += $_POST['duration_mins'];
        }
        $tmp_exam_duration = $duration;
    } else {
        $tmp_exam_duration = $exam_duration;
    }
    if ($paper_type == 2) {
        if ($configObject->get('cfg_summative_mgmt')) {
            $tmp_start_date = NULL;
            $tmp_end_date = NULL;
            $labs = NULL;
        } else {
            $tmp_start_date = '20200505090000';
            $tmp_end_date = '20200505100000';
        }
    } else {
        $tmp_start_date = $start_date;
        $tmp_end_date = $end_date;
    }
    $tmp_random_mark = $random_mark;
    if ($tmp_random_mark == '') {
        $tmp_random_mark = NULL;
    }
    $tmp_total_mark = $total_mark;
    if ($tmp_total_mark == '') {
        $tmp_total_mark = NULL;
    }
    $tmp_external_review_deadline = $external_review_deadline;
    if ($tmp_external_review_deadline == '') {
        $tmp_external_review_deadline = NULL;
    }
    $tmp_internal_review_deadline = $internal_review_deadline;
    if ($tmp_internal_review_deadline == '') {
        $tmp_internal_review_deadline = NULL;
    }
    if (isset($_POST['session'])) {
        $new_calendar_year = $_POST['session'];
        if ($new_calendar_year == '') {
            $new_calendar_year = NULL;
        }
    } else {
        $academic_year_title = Paper_utils::academic_year_from_title($_POST['new_paper']);
        if ($academic_year_title !== false) {
            $new_calendar_year = $academic_year_title;
        } else {
            $new_calendar_year = $calendar_year;
        }
    }
    $addPaper = $db->prepare("INSERT INTO properties VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, 0)");
    $addPaper->bind_param('ssssssssssssisiiisssiidisssssssssis', $_POST['new_paper'], $tmp_start_date, $tmp_end_date, $timezone, $paper_type, $paper_prologue, $paper_postscript, $bgcolor, $fgcolor, $themecolor, $labelcolor, $fullscreen, $marking, $bidirectional, $pass_mark, $distinction_mark, $userID, $folder, $labs, $rubric, $calculator, $tmp_exam_duration, $tmp_random_mark, $tmp_total_mark, $display_correct_answer, $display_question_mark, $display_students_response, $display_feedback, $hide_if_unanswered, $new_calendar_year, $tmp_external_review_deadline, $tmp_internal_review_deadline, $sound_demo, $latex_needed, $password);
    $addPaper->execute();
    $new_paper_id = $db->insert_id;
    $addPaper->close();
    // Get the old reviewers and populate the new paper with.
    $result2 = $db->prepare("SELECT reviewerID, type FROM properties_reviewers WHERE paperID = ?");
    $result2->bind_param('i', $_POST['paperID']);
    $result2->execute();
    $result2->store_result();
    $result2->bind_result($reviewerID, $type);
    while ($result2->fetch()) {
        $stmt = $db->prepare("INSERT INTO properties_reviewers VALUES (NULL, ?, ?, ?)");
        $stmt->bind_param('iis', $new_paper_id, $reviewerID, $type);
        $stmt->execute();
        $stmt->close();
    }
    $result2->close();
    // Set the modules on the new paper
    Paper_utils::update_modules($moduleIDs, $new_paper_id, $db, $userObj);
    if ($paper_type == 2 and $configObject->get('cfg_summative_mgmt')) {
        if (isset($_POST['barriers_needed'])) {
            $barriers_needed = 1;
        } else {
            $barriers_needed = 0;
        }
        $result = $db->prepare("INSERT INTO scheduling VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)");
        $result->bind_param('isissis', $new_paper_id, $_POST['period'], $barriers_needed, $_POST['cohort_size'], $_POST['notes'], $_POST['sittings'], $_POST['campus']);
        $result->execute();
        $result->close();
    }
    // Query the database to get the creation date and then set crypt_name.
    $result2 = $db->prepare("SELECT property_id, UNIX_TIMESTAMP(created), paper_ownerID FROM properties WHERE property_id = ?");
    $result2->bind_param('i', $new_paper_id);
    $result2->execute();
    $result2->store_result();
    $result2->bind_result($property_id, $created, $paper_ownerID);
    $result2->fetch();
    $result2->close();
    $hash = $property_id . $created . $paper_ownerID;
    $update = $db->prepare("UPDATE properties SET crypt_name = ? WHERE property_id = ?");
    $update->bind_param('si', $hash, $property_id);
    $update->execute();
    $update->close();
    return $new_paper_id;
}
Beispiel #5
0
$is_preview_mode = ($userObject->has_role(array('Staff', 'SysAdmin')) and isset($_REQUEST['mode']) and $_REQUEST['mode'] == 'preview');
// Are we in a staff test and preview mode and on the first screen?
$is_preview_mode_first_launch = ($is_preview_mode == true and isset($_GET['mode']) and $_GET['mode'] == 'preview');
// Are we in a staff single question testmode
$is_question_preview_mode = isset($_GET['q_id']);
/*
* Set the default colour scheme for this paper and allow current users' special settings to override
* $bgcolor, $fgcolor, $textsize, $marks_color, $themecolor, $labelcolor, $font, $unanswered_color are passed by reference!!
*/
$bgcolor = $fgcolor = $textsize = $marks_color = $themecolor = $labelcolor = $font = $unanswered_color = $dismiss_color = '';
$propertyObj->set_paper_colour_scheme($userObject, $bgcolor, $fgcolor, $textsize, $marks_color, $themecolor, $labelcolor, $font, $unanswered_color, $dismiss_color);
$original_paper_type = $paper_type;
//store the original paper type - needed to retrieve answers from the correct log and functionality related decisions
$attempt = 1;
//default attempt to 1 overwritten if the student is resit candidate
$modIDs = array_keys(Paper_utils::get_modules($property_id, $mysqli));
$current_address = NetworkUtils::get_client_address();
$moduleID = $propertyObj->get_modules();
if ($userObject->has_role('Staff') and check_staff_modules($moduleID, $userObject)) {
    // No further security checks.
} else {
    // Treat as student with extra security checks.
    // Check for additional password on the paper
    check_paper_password($password, $string, $mysqli);
    // Check time security
    check_datetime($start_date, $end_date, $string, $mysqli);
    // Check room security
    $low_bandwidth = check_labs($propertyObj->get_paper_type(), $propertyObj->get_labs(), $current_address, $propertyObj->get_password(), $string, $mysqli);
    // Get modules if the user is a student and the paper is not formative
    $attempt = check_modules($userObject, $modIDs, $calendar_year, $string, $mysqli);
    // Check for any metadata security restrictions
Beispiel #6
0
$session = $propertyObj->get_calendar_year();
$pass_mark = $propertyObj->get_pass_mark();
$random_mark = $propertyObj->get_random_mark();
$total_mark = $propertyObj->get_total_mark();
$marking = $propertyObj->get_marking();
$exam_duration = $propertyObj->get_exam_duration();
$start_date = $propertyObj->get_start_date();
$end_date = $propertyObj->get_end_date();
if ($userObject->has_role('Student')) {
    $logger->record_access($userObject->get_user_ID(), 'Objectives-based feedback report', $paperID);
    // Students write in the paperID
} else {
    $logger->record_access($userObject->get_user_ID(), 'Objectives-based feedback report', '/mapping/user_feedback.php?' . $_SERVER['QUERY_STRING']);
    // Staff write in the URL details
}
$moduleID = Paper_utils::get_modules($paperID, $mysqli);
// Check the user sat the paper!
$bound = false;
if ($paper_type == '0' or $paper_type == '1') {
    $result = $mysqli->prepare("SELECT DATE_FORMAT(started,'%H:%i:%s') AS started, DATE_FORMAT(updated,'%H:%i:%s') AS updated FROM log0, log_metadata WHERE log0.metadataID = log_metadata.id AND paperID = ? AND userID = ? UNION SELECT DATE_FORMAT(started,'%H:%i:%s') AS started, DATE_FORMAT(updated,'%H:%i:%s') AS updated FROM log1, log_metadata WHERE log1.metadataID = log_metadata.id AND paperID = ? AND userID = ? LIMIT 1");
    $result->bind_param('iiii', $paperID, $userID, $paperID, $userID);
    $bound = true;
} elseif ($paper_type == '4') {
    $result = $mysqli->prepare("SELECT DATE_FORMAT(started,'%H:%i:%s') AS started, NULL AS updated FROM log4_overall WHERE q_paper = ? AND userID = ? LIMIT 1");
} elseif ($paper_type == '5') {
    $result = $mysqli->prepare("SELECT DATE_FORMAT(started,'%H:%i:%s') AS started, NULL AS updated FROM log5, log_metadata WHERE log{$paper_type}.metadataID = log_metadata.id AND paperID = ? AND userID = ? LIMIT 1");
} else {
    $result = $mysqli->prepare("SELECT DATE_FORMAT(started,'%H:%i:%s') AS started, DATE_FORMAT(updated,'%H:%i:%s') AS updated FROM log{$paper_type}, log_metadata WHERE log{$paper_type}.metadataID = log_metadata.id AND paperID = ? AND userID = ? ORDER BY screen DESC LIMIT 1");
}
if (!$bound) {
    $result->bind_param('ii', $paperID, $userID);
Beispiel #7
0
* $bgcolor, $fgcolor, $textsize, $marks_color, $themecolor, $labelcolor, $font, $unanswered_color are passed by reference!!
*/
$bgcolor = $fgcolor = $textsize = $marks_color = $themecolor = $labelcolor = $font = $unanswered_color = $dismiss_color = '';
$propertyObj->set_paper_colour_scheme($userObject, $bgcolor, $fgcolor, $textsize, $marks_color, $themecolor, $labelcolor, $font, $unanswered_color, $dismiss_color);
$attempt = 1;
//default attempt to 1 overwritten if the student is resit candidate by (check_modules)
$low_bandwidth = 0;
//default to off overwritten by (check_labs) if lab has low_bandwidth set
$lab_name = NULL;
//default overwritten by (check_labs)
$lab_id = NULL;
$current_address = NULL;
//default overwritten by (check_labs)
$current_address = NetworkUtils::get_client_address();
//get the module Ids for this paper
$modIDs = array_keys(Paper_utils::get_modules($paperID, $mysqli));
$moduleID = $propertyObj->get_modules();
if ($userObject->has_role('Staff') and check_staff_modules($moduleID, $userObject)) {
    // No further security checks.
} else {
    // Treat as student with extra security checks.
    // Check for additional password on the paper.
    check_paper_password($propertyObj->get_password(), $string, $mysqli);
    // Check time security.
    check_datetime($propertyObj->get_start_date(), $propertyObj->get_end_date(), $string, $mysqli);
    //Check room security.
    $low_bandwidth = check_labs($propertyObj->get_paper_type(), $propertyObj->get_labs(), $current_address, $propertyObj->get_password(), $string, $mysqli);
    // Check modules if the user is a student and the paper is not formative.
    $attempt = check_modules($userObject, $modIDs, $propertyObj->get_calendar_year(), $string, $mysqli);
    // Check for any metadata security restrictions.
    check_metadata($paperID, $userObject, $modIDs, $string, $mysqli);
    $q_result->bind_param('i', $paperID);
    $q_result->execute();
    $q_result->store_result();
    $q_result->bind_result($questionID);
    while ($q_result->fetch()) {
        // Check the question isn't used on any other papers
        $check = $mysqli->prepare("SELECT question FROM papers WHERE question=?");
        $check->bind_param('i', $questionID);
        $check->execute();
        $check->store_result();
        $check->bind_result($questionID);
        $check->fetch();
        if ($check->num_rows == 1) {
            //delete the question its only on 1 training paper
            QuestionUtils::delete_question($questionID, $mysqli);
        } else {
            //remove from the TRAIN module dont delete ;-) its used elsewhere
            QuestionUtils::remove_modules(array($trainIdMod => 'TRAIN'), $questionID, $mysqli);
        }
        $check->close();
    }
    $q_result->close();
    //delete the paper if it is not on any other modules
    $tmp_paper_modules = Paper_utils::get_modules($paperID, $mysqli);
    if (count($tmp_paper_modules) == 0) {
        Paper_utils::delete_paper($paperID, $mysqli);
    }
}
$result->close();
$mysqli->close();
header("location: index.php");
Beispiel #9
0
$q_no = '';
$q_type_full = '';
$errors = array();
if (!isset($_REQUEST['q_id']) or $_REQUEST['q_id'] == -1) {
    // We're adding a new question
    $mode = $string['add'];
    if (!isset($_GET['type'])) {
        $critical_error = $string['typeundefined'];
    } elseif (!in_array($_GET['type'], QuestionEdit::$types)) {
        $critical_error = sprintf($string['typeinvalid'], htmlentities($_GET['type']));
    } else {
        try {
            $question = QuestionEdit::question_factory($mysqli, $userObject, $string, $_GET['type']);
            $question->set_type($_GET['type']);
            $question->set_owner_id($userObject->get_user_ID());
            $question->set_teams(Paper_utils::get_modules($paper_id, $mysqli));
        } catch (ClassNotFoundException $ex) {
            $critical_error = $ex->getMessage();
        }
    }
} else {
    // We're editing an existing question
    $mode = $string['edit'];
    try {
        $question = QuestionEdit::question_factory($mysqli, $userObject, $string, $_REQUEST['q_id']);
    } catch (Exception $ex) {
        $critical_error = $ex->getMessage();
    }
}
// Handle upload of files for question types that require it
if ($critical_error == '' and $question->requires_media() and (isset($_POST['submit_media']) or isset($_POST['q_media']))) {
Beispiel #10
0
 /**
  * Initiates the building of the main Class Totals report.
  * @param bool $recache - True = will force paper caches to be updated.
  * @param bool $review - If true we are reviewing so should not cache.
  */
 public function compile_report($recache, $review = false)
 {
     $results_cache = new ResultsCache($this->db);
     if (!$review and ($recache or $results_cache->should_cache($this->propertyObj, $this->percent, $this->absent))) {
         $this->recache = true;
     } else {
         $this->recache = false;
     }
     $moduleID = Paper_utils::get_modules($this->paperID, $this->db);
     $this->moduleID_in = implode(',', array_keys($moduleID));
     $this->exclusions->load();
     // Get any questions to exclude.
     $this->load_answers();
     $this->set_log_late();
     $this->load_absent();
     $this->find_users();
     // Get all the users on the module(s) the paper is on.
     $this->load_metadata();
     // Query for metadata
     $this->load_overrides();
     // Load marking overrides (e.g. Calculation question).
     $this->load_results();
     // Load the student data
     $this->adjust_marks();
     // Scale marks (random marks or standards setting)
     $this->add_rank();
     // Add in rank data.
     $this->convert_moduleIDs();
     // Convert Module IDs into codes
     $this->flag_subpart();
     // Used to flag subsets of the cohort (i.e. top 33%)
     $this->add_absent_students();
     // Add any absent students into main dataset
     $this->generate_stats();
     // Generate the main statistics
     $this->add_deciles();
     // Add in deciles per student
     $this->sort_results();
     // Sort the whole array by the right column
     $this->load_special_needs();
     // Load which users have special needs
     if ($this->recache) {
         $results_cache->save_paper_cache($this->paperID, $this->stats);
         // Cache general paper stats
         $results_cache->save_student_mark_cache($this->paperID, $this->user_results);
         // Cache student/paper marks
         $results_cache->save_median_question_marks($this->paperID, $this->q_medians);
         // Cache the question/paper medians
         // Unset the re-caching flag now we have just cached the marks.
         $this->propertyObj->set_recache_marks(0);
         $this->propertyObj->save();
     }
 }
Beispiel #11
0
$start_date = $propertyObj->get_start_date();
$end_date = $propertyObj->get_end_date();
$marking = $propertyObj->get_marking();
$password = $propertyObj->get_password();
$paper_prologue = $propertyObj->get_paper_prologue();
// TODO: remove nasty oveloaded database fields
$display_photos = $propertyObj->get_display_correct_answer();
$review = $propertyObj->get_display_question_mark();
$type = $propertyObj->get_rubric();
/*
* Set the default colour scheme for this paper and allow current users' special settings to override
* $bgcolor, $fgcolor, $textsize, $marks_color, $themecolor, $labelcolor, $font, $unanswered_color are passed by reference!!
*/
$bgcolor = $paper_fgcolor = $textsize = $marks_color = $themecolor = $labelcolor = $font = $unanswered_color = $dismiss_color = '';
$propertyObj->set_paper_colour_scheme($userObject, $bgcolor, $fgcolor, $textsize, $marks_color, $themecolor, $labelcolor, $font, $unanswered_color, $dismiss_color);
$modules = Paper_utils::get_modules($property_id, $mysqli);
if ($calendar_year == '') {
    display_error($string['Error'], $string['NoAcademicSession'], false, true);
}
if ($type == '') {
    // What metadata field to use.
    display_error($string['Error'], $string['NoFieldMetadata'], false, true);
}
// Get lab info
$current_address = NetworkUtils::get_client_address();
$lab_factory = new LabFactory($mysqli);
if ($lab_object = $lab_factory->get_lab_based_on_client($current_address)) {
    $lab_name = $lab_object->get_name();
    $lab_id = $lab_object->get_id();
}
if ($userObject->has_role('Student')) {