Beispiel #1
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 #2
0
     $properties->set_fullscreen($_POST['fullscreen']);
 }
 $properties->set_bgcolor($_POST['bgcolor']);
 $properties->set_fgcolor($_POST['fgcolor']);
 $properties->set_themecolor($_POST['themecolor']);
 $properties->set_labelcolor($_POST['labelcolor']);
 $properties->set_folder($_POST['folderID']);
 if ($properties->get_paper_type() == '2' and $old_marking != $properties->get_marking()) {
     $properties->set_recache_marks(1);
 }
 // Save any adjusted properties to the database.
 $properties->save();
 if (!$locked or $userObject->has_role(array('SysAdmin', 'Admin'))) {
     $old_modules = $properties->get_modules(true);
     if (!$locked or $userObject->has_role(array('SysAdmin'))) {
         Paper_utils::update_modules($paper_modules, $paperID, $mysqli, $userObject);
     }
     $paper_modules = $properties->get_modules(true);
     $utils = new GeneralUtils();
     if (!$utils->arrays_are_equal($old_modules, $paper_modules)) {
         $logger->track_change('Paper', $paperID, $userObject->get_user_ID(), implode(',', $old_modules), implode(',', $paper_modules), 'modules');
     }
     if (Paper_utils::update_reviewers($old_externals, $new_externals, 'external', $paperID, $mysqli)) {
         $logger->track_change('Paper', $paperID, $userObject->get_user_ID(), implode(',', array_keys($old_externals)), implode(',', $new_externals), 'externals');
     }
     if (Paper_utils::update_reviewers($old_internals, $new_internals, 'internal', $paperID, $mysqli)) {
         $logger->track_change('Paper', $paperID, $userObject->get_user_ID(), implode(',', array_keys($old_internals)), implode(',', $new_internals), 'internals');
     }
 }
 // Release objectives-based feedback
 if (isset($_POST['old_objectives_report']) and $_POST['old_objectives_report'] != '' and isset($_POST['objectives_report']) and $_POST['objectives_report'] == '0') {