Example #1
0
    $school_tmp = trim($_POST['school']);
    $faculty = trim($_POST['faculty']);
    $changed = ($curr_faculty != $faculty or $school != $school_tmp);
    if ($changed and SchoolUtils::school_exists_in_faculty($faculty, $school_tmp, $mysqli)) {
        $error = 'duplicate';
        $school = $school_tmp;
        $curr_faculty = $faculty;
    } else {
        if ($changed) {
            $result = $mysqli->prepare("UPDATE schools SET facultyID = ?, school = ? WHERE id = ?");
            $result->bind_param('isi', $faculty, $school_tmp, $schoolid);
            $result->execute();
            $result->close();
            $logger = new Logger($mysqli);
            if ($school != $school_tmp) {
                $logger->track_change('School', $schoolid, $userObject->get_user_ID(), $school, $school_tmp, $string['name']);
            }
            if ($curr_faculty != $faculty) {
                $logger->track_change('School', $schoolid, $userObject->get_user_ID(), $curr_faculty, $faculty, $string['faculty']);
            }
        }
        header("location: list_schools.php");
        exit;
    }
}
$faculties = 0;
$faculty_list = array();
$result = $mysqli->prepare("SELECT id, name FROM faculty WHERE deleted IS NULL ORDER BY name");
$result->execute();
$result->bind_result($facultyID, $name);
while ($result->fetch()) {
                $result2 = $result->execute();
                $result->store_result();
                if ($result2 == false) {
                    $status = 'ERROR';
                } else {
                    // Invalidate the cache so it will get rebuilt with new mark
                    $cache_sql = "UPDATE properties SET recache_marks = 1 WHERE property_id = ?";
                    $cache_update = $mysqli->prepare($cache_sql);
                    $cache_update->bind_param('i', $paper_id);
                    $cache_result = $cache_update->execute();
                    if ($cache_result == false) {
                        $status = 'ERROR';
                    }
                    $cache_update->close();
                }
                $result->close();
            }
        }
    } catch (exception $ex) {
        $status = 'ERROR';
    }
    if ($status == 'ERROR') {
        $mysqli->rollback();
    } else {
        $mysqli->commit();
        $logger = new Logger($mysqli);
        $logger->track_change('enhancedcalc_override', $or_id, $marker_id, $orig_mark, $new_mark, $q_id);
    }
    $mysqli->autocommit(true);
}
echo $status;
Example #3
0
if (isset($_POST['submit']) and $_POST['course'] != $_POST['old_course']) {
    // Check for unique course name
    $new_course = trim($_POST['course']);
    $course_exists = CourseUtils::course_exists($new_course, $mysqli);
}
if (isset($_POST['submit']) and $course_exists == false) {
    $new_course = trim($_POST['course']);
    $new_school = $_POST['school'];
    $new_description = trim($_POST['description']);
    $result = $mysqli->prepare("UPDATE courses SET name = ?, description = ?, schoolid = ? WHERE id = ?");
    $result->bind_param('ssii', $new_course, $new_description, $new_school, $courseID);
    $result->execute();
    $result->close();
    $logger = new Logger($mysqli);
    if ($name != $new_course) {
        $logger->track_change('Course', $courseID, $userObject->get_user_ID(), $name, $new_course, 'code');
    }
    if ($description != $new_description) {
        $logger->track_change('Course', $courseID, $userObject->get_user_ID(), $description, $new_description, 'name');
    }
    if ($current_school != $new_school) {
        $logger->track_change('Course', $courseID, $userObject->get_user_ID(), $current_school, $new_school, 'school');
    }
    $mysqli->close();
    header("location: list_courses.php");
    exit;
} else {
    ?>
<!DOCTYPE html>
<html>
<head>
Example #4
0
$result = $mysqli->prepare("SELECT id, oauth_consumer_key, secret, name, context_id FROM lti_keys WHERE id = ?");
$result->bind_param('i', $LTIkeysid);
$result->execute();
$result->bind_result($ltis['id'], $ltis['oauth_consumer_key'], $ltis['secret'], $ltis['name'], $ltis['context_id']);
$result->fetch();
$result->close();
if (isset($_POST['submit'])) {
    $ltiname = trim($_POST['ltiname']);
    $ltikey = trim($_POST['ltikey']);
    $ltisec = trim($_POST['ltisec']);
    $lticontext = trim($_POST['lticontext']);
    $insert_id = $lti->update_lti_key($LTIkeysid, $ltiname, $ltikey, $ltisec, $lticontext);
    // Log changes
    $logger = new Logger($mysqli);
    if ($ltis['name'] != $ltiname) {
        $logger->track_change('LTI Key', $LTIkeysid, $userObject->get_user_ID(), $ltis['name'], $ltiname, 'name');
    }
    if ($ltis['oauth_consumer_key'] != $ltikey) {
        $logger->track_change('LTI Key', $LTIkeysid, $userObject->get_user_ID(), $ltis['name'], $ltikey, 'key');
    }
    if ($ltis['secret'] != $ltisec) {
        $logger->track_change('LTI Key', $LTIkeysid, $userObject->get_user_ID(), $ltis['secret'], $ltisec, 'secret');
    }
    if ($ltis['context_id'] != $lticontext) {
        $logger->track_change('LTI Key', $LTIkeysid, $userObject->get_user_ID(), $ltis['context_id'], $lticontext, 'context');
    }
    header("location: lti_keys_list.php");
    exit;
} else {
    ?>
<!DOCTYPE html>
Example #5
0
require_once '../classes/paperproperties.class.php';
require_once '../classes/logger.class.php';
$paperID = check_var('paperID', 'POST', true, false, true);
$properties = PaperProperties::get_paper_properties_by_id($paperID, $mysqli, $string);
if ($properties->get_summative_lock() == 1) {
    $msg = sprintf($string['furtherassistance'], $configObject->get('support_email'), $configObject->get('support_email'));
    $notice->display_notice_and_exit($mysqli, $string['paperlocked'], $msg, $string['paperlocked'], '../artwork/padlock_48.png', '#C00000', true, true);
}
$new_title = $properties->get_paper_title() . ' [deleted ' . date($configObject->get('cfg_short_date_php')) . ']';
$properties->set_paper_title($new_title);
$delete_date = date('YmdHis');
$properties->set_deleted($delete_date);
$properties->save();
// Record the deletion.
$logger = new Logger($mysqli);
$logger->track_change('Paper', $paperID, $userObject->get_user_ID(), '', '', 'Paper Deleted');
$mysqli->close();
?>
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta http-equiv="content-type" content="text/html;charset=<?php 
echo $configObject->get('cfg_page_charset');
?>
" />
  
  <title><?php 
echo $string['questiondeleted'];
?>
</title>
Example #6
0
         echo "Error No: " . $e->getCode() . " - " . $e->getMessage() . "<br />";
         echo nl2br($e->getTraceAsString());
     }
 }
 $addQuestion->bind_param('ssssssssisssssssissss', $q_type, $theme, $scenario, $leadin, $correct_fback, $incorrect_fback, $display_method, $notes, $userObject->get_user_ID(), $new_q_media, $q_media_width, $q_media_height, $bloom, $scenario_plain, $leadin_plain, $std, $new_status, $q_option_order, $score_method, $settings, $guid);
 $addQuestion->execute();
 $new_qids[] = $question_id = $mysqli->insert_id;
 if ($q_type == 'enhancedcalc') {
     $calculation_qid_map[$q_id] = $question_id;
 }
 $addQuestion->close();
 // Add in a record to the papers table.
 Paper_utils::add_question($new_paper_id, $question_id, $screen, $display_pos, $mysqli);
 // Create a track changes record to say where question was copied from.
 $logger = new Logger($mysqli);
 $logger->track_change('Copied Question', $question_id, $userObject->get_user_ID(), $question, $question_id, 'Copied Question');
 // Create a track changes record to say new question added to paper.
 $logger->track_change('Paper', $new_paper_id, $userObject->get_user_ID(), '', $question_id, 'Add Question');
 // Lookup and copy the keywords
 $keyword_result = $mysqli->prepare("SELECT keywordID FROM keywords_question WHERE q_id = ?");
 $keyword_result->bind_param('i', $question);
 $keyword_result->execute();
 $keyword_result->store_result();
 $keyword_result->bind_result($keywordID);
 while ($keyword_result->fetch()) {
     $addKeyword = $mysqli->prepare("INSERT INTO keywords_question VALUES (?, ?)");
     $addKeyword->bind_param('ii', $question_id, $keywordID);
     $addKeyword->execute();
     $addKeyword->close();
 }
 $keyword_result->close();
Example #7
0
    $paper_no++;
}
$result->close();
// Get grade and student of the user.
$result = $mysqli->prepare("SELECT grade, yearofstudy, username FROM users WHERE id = ?");
$result->bind_param('i', $userID);
$result->execute();
$result->bind_result($grade, $yearofstudy, $new_username);
$result->fetch();
$result->close();
$mysqli->autocommit(false);
$error = false;
foreach ($papers as $paper) {
    // Record the change in 'track_changes'.
    $logger = new Logger($mysqli);
    $logger->track_change('Exam Script', $paper['ID'], $userObject->get_user_ID(), $temp_userID, $userID, 'Reassigned temporary user');
    // Transfer records in log_metadata.
    $result = $mysqli->prepare("UPDATE log_metadata SET userID = ?, student_grade = ?, year = ? WHERE userID = ? AND paperID = ? AND started = ?");
    if ($mysqli->error) {
        $error = true;
    }
    $result->bind_param('issiis', $userID, $grade, $yearofstudy, $temp_userID, $paper['ID'], $paper['started']);
    $result->execute();
    if ($mysqli->error) {
        $error = true;
    }
    $result->close();
    // Transfer textbox marking (just in case marking done before marks reasignment).
    $result = $mysqli->prepare("UPDATE textbox_marking SET student_userID = ? WHERE student_userID = ? AND paperID = ?");
    if ($mysqli->error) {
        $error = true;
Example #8
0
 if (isset($_POST['mcqconvert']) and $_POST['mcqconvert'] == '1') {
     $i = 1;
     $correct_option = 0;
     foreach ($question->options as $option) {
         if ($option->get_correct() == 'y') {
             $correct_option = $i;
             break;
         }
         $i++;
     }
     $question = $question->convert_to_mcq($correct_option);
 }
 // Insert into Papers
 if (isset($_POST['addpaper'])) {
     insert_into_papers($paper_id, $question->id, $mysqli);
     $logger->track_change('Paper', $paper_id, $userObject->get_user_ID(), '', $question->id, 'Add Question');
 }
 save_keywords($question, $userObject->get_user_ID(), true, $mysqli, $string);
 if (isset($_POST['objective_modules'])) {
     // Write out curriculum mapping.
     save_objective_mappings($mysqli, $_POST['objective_modules'], $paper_id, $question->id);
 }
 // Stuff not to do on correction/limited save
 if (!isset($_POST['submit']) or $_POST['submit'] != $string['correct']) {
     // Save review comments and responses
     if (isset($_POST['comment_ids']) and isset($_POST['actions']) and isset($_POST['responses'])) {
         save_external_responses($mysqli, $question, $_POST['comment_ids'], $_POST['actions'], $_POST['responses'], $paper_id);
     }
     // For likert, save the scale to a state to ease creation of multiple questions with same scale
     if ($mode == 'Add' and $question->get_type() == 'likert') {
         $scale_type = $question->get_scale_type();
Example #9
0
        }
    }
    if ($retired_status_id != -1) {
        $mysqli->autocommit(false);
        // Look up and retire the questions
        $result = $mysqli->prepare("SELECT question FROM papers WHERE paper = ?");
        $result->bind_param('i', $paperID);
        $result->execute();
        $result->store_result();
        $result->bind_result($question_id);
        while ($result->fetch()) {
            $stmt = $mysqli->prepare("UPDATE questions SET status=? WHERE q_id = ?");
            $stmt->bind_param('ii', $retired_status_id, $question_id);
            $stmt->execute();
            $stmt->close();
            $logger->track_change('Retire question', $question_id, $userObject->get_user_ID(), '', '', 'retired');
        }
        $result->close();
        $mysqli->commit();
        $mysqli->autocommit(true);
    }
}
// Retire the paper itself
$result = $mysqli->prepare("UPDATE properties SET retired = NOW() WHERE property_id = ?");
$result->bind_param('i', $paperID);
$result->execute();
$result->close();
$logger->track_change('paper', $paperID, $userObject->get_user_ID(), '', '', 'retired');
$mysqli->close();
?>
<!DOCTYPE html>
Example #10
0
 function Save($params, &$data)
 {
     global $mysqli, $string;
     echo "<h4>{$string['params']}</h4>";
     print_p($params);
     echo "<h4>{$string['othherdebug']}</h4>";
     $this->db = new Database();
     if (count($data->questions) == 0) {
         $this->AddError($string['noquestions']);
         return;
     }
     $paperid = $params->paper;
     $userObj = UserObject::get_instance();
     $userID = $userObj->get_user_ID();
     $db = new Database();
     $db->SetTable('properties');
     $db->AddField('*');
     $db->AddWhere('property_id', $paperid, 'i');
     $paper_row = $db->GetSingleRow();
     $ownerid = $userID;
     $data->ownerID = $userID;
     $nextscreen = 1;
     $nextid = 1;
     if ($paperid) {
         echo "{$string['addingtopaper']} {$paperid}<br>";
         $this->db->SetTable('papers');
         $this->db->AddField("max(screen) as screen");
         $this->db->AddField("max(display_pos) as display_pos");
         $this->db->AddWhere('paper', $paperid, 'i');
         $curpos = $this->db->GetSingleRow();
         $nextscreen = $curpos['screen'] + 1;
         $nextid = $curpos['display_pos'] + 1;
     }
     /*    // Get the actual ID of the module
             $this->db->SetTable('modules');
             $this->db->AddField('id');
             // Temp fix - if more than one team just get the first. Avoids error but doesn't fix the problem completely
             if (strpos($q_group, ',') !== false) {
               $q_group = strstr($q_group, ',', true);
             }
             $this->db->AddWhere('moduleid', $q_group, 's');
             $module_row = $this->db->GetSingleRow();
         */
     $module_id = -1;
     $paperutils = Paper_utils::get_instance();
     $module_id1 = $paperutils->get_modules($paper_row['property_id'], $mysqli);
     if ($module_id1 !== false) {
         $module_id = $module_id1;
     }
     $modutils = module_utils::get_instance();
     $q_group = $modutils->get_moduleid_from_id($module_id, $mysqli);
     if ($module_id !== false) {
         // Get a list of the team and user's keywords
         $user_keywords = array();
         if (is_array($module_id)) {
             foreach (array_keys($module_id) as $mod_id) {
                 $user_keywordsl = $this->GetExistingKeywords($mod_id);
                 $user_keywords = array_merge($user_keywords, $user_keywordsl);
             }
         } else {
             $user_keywords = $this->GetExistingKeywords($module_id);
         }
     }
     foreach ($data->questions as &$question) {
         $this->q_row = $this->db->GetBlankTableRow("questions");
         $this->o_row = $this->db->GetBlankTableRow("options");
         $this->o_rows = array();
         // stuff from parameters
         $this->q_row['ownerID'] = $ownerid;
         // general stuff that needs to be done for every qtype
         $this->q_row['creation_date'] = date("Y-m-d H:i:s");
         $this->q_row['last_edited'] = date("Y-m-d H:i:s");
         $this->q_row['q_type'] = $question->type;
         $this->q_row['status'] = isset($this->statuses[$question->status]) ? $this->statuses[$question->status] : $this->default_status;
         $this->q_row['theme'] = $question->theme;
         $this->q_row['notes'] = $question->notes;
         $this->q_row['leadin'] = $question->leadin;
         $this->q_row['bloom'] = $question->bloom;
         $this->q_row['q_media'] = $question->media;
         $this->q_row['q_media_width'] = $question->media_width;
         $this->q_row['q_media_height'] = $question->media_height;
         $this->q_row['deleted'] = null;
         $this->q_row['locked'] = null;
         $this->q_row['std'] = null;
         $this->q_row['q_option_order'] = $question->q_option_order;
         if (isset($question->settings)) {
             $this->q_row['settings'] = $question->settings;
         }
         $oiii = print_r($question, true);
         $t = 8;
         if ($question->type == "blank") {
             $this->SaveBlank($question);
         } elseif ($question->type == "calculation") {
             $this->SaveCalculation($question);
             $this->q_row['q_type'] = 'enhancedcalc';
         } elseif ($question->type == "dichotomous") {
             $this->SaveDichotomous($question);
         } elseif ($question->type == "extmatch") {
             $this->SaveExtMatch($question);
         } elseif ($question->type == "flash") {
             $this->SaveFlash($question);
         } elseif ($question->type == "hotspot") {
             $this->SaveHotspot($question);
         } elseif ($question->type == "info") {
             $this->SaveInfo($question);
         } elseif ($question->type == "labelling") {
             $this->SaveLabelling($question);
         } elseif ($question->type == "likert") {
             $this->SaveLikert($question);
         } elseif ($question->type == "matrix") {
             $this->SaveMatrix($question);
         } elseif ($question->type == "mcq") {
             $this->SaveMcq($question);
         } elseif ($question->type == "true_false") {
             $this->SaveTrueFalse($question);
         } elseif ($question->type == "mrq") {
             $this->SaveMrq($question);
         } elseif ($question->type == "rank") {
             $this->SaveRank($question);
         } elseif ($question->type == "textbox") {
             $this->SaveTextbox($question);
         } else {
             $this->AddError("Question type " . $question->type . " not yet supported", $question->load_id);
             continue;
         }
         if (!in_array($this->q_row['q_option_order'], array('display order', 'alphabetic', 'random'))) {
             $this->q_row['q_option_order'] = 'display order';
             print "correcting q_option_order";
         }
         if (!empty($this->q_row['scenario']) && strcasecmp("<p>&nbsp;</p>", $this->q_row['scenario']) == 0) {
             $this->q_row['scenario'] = '';
         }
         // create plain version of scenario and leadin
         $this->q_row['scenario_plain'] = empty($this->q_row['scenario']) ? '' : trim(strip_tags($this->q_row['scenario']));
         $this->q_row['leadin_plain'] = empty($this->q_row['leadin']) ? '' : trim(strip_tags($this->q_row['leadin']));
         if (!empty($this->q_row['correct_fback']) && !empty($this->q_row['incorrect_fback']) && $this->q_row['correct_fback'] == $this->q_row['incorrect_fback']) {
             $this->q_row['incorrect_fback'] = '';
         }
         // if no o_row, create a blank one
         if (count($this->o_rows) == 0 and $question->type != "calculation") {
             $this->o_row['marks_correct'] = 1;
             $this->o_row['marks_incorrect'] = 0;
             $this->o_row['marks_partial'] = 0;
             $this->o_rows[] = $this->o_row;
         }
         // store question row
         $this->db->InsertRow("questions", "q_id", $this->q_row);
         $question->save_id = $this->q_row['q_id'];
         $this->qm_row = $this->db->GetBlankTableRow("questions_modules");
         $this->qm_row['q_id'] = $this->q_row['q_id'];
         if (is_array($module_id)) {
             foreach (array_keys($module_id) as $mod_id) {
                 $this->qm_row['idMod'] = $mod_id;
                 $this->db->InsertRow("questions_modules", "temp", $this->qm_row);
             }
         } else {
             $this->qm_row['idMod'] = $module_id;
             $this->db->InsertRow("questions_modules", "temp", $this->qm_row);
         }
         $new_keywords = array();
         if ($module_id != -1) {
             if (is_array($module_id)) {
                 $user_keywords2 = array();
                 foreach (array_keys($module_id) as $mod_id) {
                     $new_keywords1 = $this->SaveKeywords($this->q_row['q_id'], $question->keywords, $mod_id, $user_keywords, $user_keywords2);
                     $new_keywords = array_merge($new_keywords, $new_keywords1);
                 }
                 $user_keywords = array_merge($user_keywords, $user_keywords2);
             } else {
                 $new_keywords = $this->SaveKeywords($this->q_row['q_id'], $question->keywords, $module_id, $user_keywords);
             }
         }
         // store option rows
         foreach ($this->o_rows as &$o_row) {
             $o_row['o_id'] = $this->q_row['q_id'];
             if (!empty($o_row['feedback_right']) && $o_row['feedback_right'] == $o_row['feedback_wrong']) {
                 $o_row['feedback_wrong'] = "";
             }
             $this->db->InsertRow("options", "id_num", $o_row);
         }
         // store additional metadata
         if ($question->load_id != '') {
             $meta_row = array('id' => null, 'questionID' => $question->save_id, 'type' => 'QTI Ident', 'value' => $question->load_id);
         }
         $this->db->InsertRow("questions_metadata", "id", $meta_row);
         echo "<h4>{$string['questiontables']}</h4>";
         echo "<div>{$string['questionsrow']}</div>";
         print_p($this->q_row, false);
         echo "<div>{$string['optionsrows']}</div>";
         print_p($this->o_rows, false, 100);
         echo "<div>{$string['newkeywords']}</div>";
         print_p($new_keywords, false);
         $track = array();
         $track['type'] = $string['qtiimport'];
         $track['typeID'] = $this->q_row['q_id'];
         $track['editor'] = $userID;
         $track['new'] = "{$string['imported1_2']} " . $params->original_filename;
         $track['part'] = "all";
         $track['changed'] = date("Y-m-d H:i:s");
         $db->InsertRow("track_changes", "id", $track);
         // we have a paper, add this question onto the list of questions for the paper
         if ($paperid && empty($data->papers)) {
             $p_row = $this->db->GetBlankTableRow('papers');
             $p_row['paper'] = $paperid;
             $p_row['question'] = $question->save_id;
             $p_row['screen'] = $nextscreen;
             $p_row['display_pos'] = $nextid++;
             $this->db->InsertRow('papers', 'p_id', $p_row);
         }
     }
     $logger = new Logger($mysqli);
     if (!empty($data->papers)) {
         foreach ($data->papers as &$paper) {
             foreach ($paper->screens as &$screen) {
                 foreach ($screen->question_ids as $q_id) {
                     $p_row = $this->db->GetBlankTableRow('papers');
                     echo sprintf($string['addingquestiondetails'], $q_id, $nextid, $nextscreen) . '<br>';
                     $p_row['paper'] = $paperid;
                     $q = FindQuestion($data->questions, $q_id);
                     $p_row['question'] = $q->save_id;
                     $p_row['screen'] = $nextscreen;
                     $p_row['display_pos'] = $nextid++;
                     $this->db->InsertRow('papers', 'p_id', $p_row);
                     $logger->track_change('Paper', $paperid, $userID, '', $q_id, 'Add Question (from QTI)');
                 }
                 $nextscreen++;
             }
         }
     }
 }
Example #11
0
        $result->execute();
        $result->bind_result($id);
        while ($result->fetch()) {
            $std_setIDs[] = $id;
        }
        $result->close();
        // Delete any corresponding standard setting record for that question and paper.
        if (count($std_setIDs) > 0) {
            $sql = "DELETE FROM std_set_questions WHERE questionID IN (" . implode(',', $tmp_questionIDs) . ") AND std_setID IN (" . implode(',', $std_setIDs) . ")";
            $result = $mysqli->prepare($sql);
            $result->execute();
            $result->close();
        }
        // Create a track changes record to say new question added.
        $logger = new Logger($mysqli);
        $logger->track_change('Paper', $tmp_paperID, $userObject->get_user_ID(), $tmp_questionIDs[$i], '', 'Delete Question');
    } else {
        display_error('Papers Delete Error', $mysqli->error);
    }
}
if ($_POST['paperID'] != '') {
    if ($result = $mysqli->prepare("UPDATE properties SET random_mark = NULL, total_mark = NULL WHERE property_id = ?")) {
        $result->bind_param('i', $tmp_paperID);
        $result->execute();
        $result->close();
    } else {
        display_error($string['updateerror'], $result->error);
    }
}
$mysqli->close();
?>
// along with Rogō.  If not, see <http://www.gnu.org/licenses/>.
/**
*
*	Work out if a question is set to be a killer question or not and then
* set or unset accordingly.
*
* @author Simon Wilkinson
* @version 1.0
* @copyright Copyright (c) 2014 The University of Nottingham
* @package
*/
require '../../include/staff_auth.inc';
require '../../include/errors.inc';
require_once '../../classes/killer_question.class.php';
require_once '../../classes/logger.class.php';
$paperID = check_var('paperID', 'POST', true, false, true);
$q_id = check_var('q_id', 'POST', true, false, true);
$qNumber = check_var('qNumber', 'POST', true, false, true);
$killer_questions = new Killer_question($paperID, $mysqli);
$killer_questions->load();
// Get the existing killer questions for the paper.
$logger = new Logger($mysqli);
if ($killer_questions->is_killer_question($q_id)) {
    $killer_questions->unset_question($q_id);
    $logger->track_change('Paper', $paperID, $userObject->get_user_ID(), 'on', 'off', "killer question {$qNumber}");
} else {
    $killer_questions->set_question($q_id);
    $logger->track_change('Paper', $paperID, $userObject->get_user_ID(), 'off', 'on', "killer question {$qNumber}");
}
$killer_questions->save();
$mysqli->close();
Example #13
0
 $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') {
     $editProperties = $mysqli->prepare("DELETE FROM feedback_release WHERE paper_id = ? AND type = 'objectives'");
     $editProperties->bind_param('i', $paperID);
     $editProperties->execute();
     $editProperties->close();
     $logger->track_change('Paper', $paperID, $userObject->get_user_ID(), 'Objectives-based Feedback', '', 'feedback');
Example #14
0
                 $total_rating += $_POST["{$qid}"];
             }
             $total_parts++;
         }
         $std_query = $mysqli->prepare("INSERT INTO std_set_questions VALUES (NULL, ?, ?, ?)");
         $std_query->bind_param('iis', $std_setID, $log_id, $rating);
         $std_query->execute();
         $std_query->close();
         if (isset($_POST['banksave']) and $_POST['banksave'] == '1') {
             $std_query = $mysqli->prepare("UPDATE questions SET std = ? WHERE q_id = ?");
             $std_query->bind_param('si', $rating, $log_id);
             $std_query->execute();
             $std_query->close();
             if ($rating != $_POST["old{$log_id}"]) {
                 $old_value = $_POST["old{$log_id}"];
                 $logger->track_change('Edit Question', $log_id, $userObject->get_user_ID(), $old_value, $rating, 'Std Setting');
             }
         }
         $rating = '';
     }
     $question_no++;
     $question_part = 0;
     $old_q_id = $q_id;
     $old_leadin = $leadin;
     $old_type = $q_type;
     $old_score_method = $score_method;
 }
 $log_id = $q_id;
 $question_part++;
 if ($question_no > 0) {
     // Default format for $qid
Example #15
0
 public function save()
 {
     $configObject = Config::get_instance();
     $userObject = UserObject::get_instance();
     if ($this->summative_lock and !$userObject->has_role('SysAdmin')) {
         // For SysAdmin drop through to bottom if
         $result = $this->db->prepare("UPDATE properties SET marking = ?, pass_mark = ?, distinction_mark = ?, display_correct_answer = ?, display_students_response = ?, display_question_mark = ?, display_feedback = ?, external_review_deadline = ?, internal_review_deadline = ?, recache_marks = ? WHERE property_id = ?");
         $result->bind_param('siissssssii', $this->marking, $this->pass_mark, $this->distinction_mark, $this->display_correct_answer, $this->display_students_response, $this->display_question_mark, $this->display_feedback, $this->external_review_deadline, $this->internal_review_deadline, $this->recache_marks, $this->property_id);
     } elseif ($configObject->get('cfg_summative_mgmt') and $this->paper_type == '2' and !$userObject->has_role(array('Admin', 'SysAdmin'))) {
         $result = $this->db->prepare("UPDATE properties SET paper_title = ?, paper_prologue = ?, paper_postscript = ?, bgcolor = ?, fgcolor = ?, themecolor = ?, labelcolor = ?, fullscreen = ?, marking = ?, bidirectional = ?, pass_mark = ?, distinction_mark = ?, folder = ?, rubric = ?, calculator = ?, display_correct_answer = ?, display_students_response = ?, display_question_mark = ?, display_feedback = ?, hide_if_unanswered = ?, external_review_deadline = ?, internal_review_deadline = ?, sound_demo = ?, password = ?, recache_marks = ? WHERE property_id = ?");
         $result->bind_param('ssssssssssiississsssssssii', $this->paper_title, $this->paper_prologue, $this->paper_postscript, $this->bgcolor, $this->fgcolor, $this->themecolor, $this->labelcolor, $this->fullscreen, $this->marking, $this->bidirectional, $this->pass_mark, $this->distinction_mark, $this->folder, $this->rubric, $this->calculator, $this->display_correct_answer, $this->display_students_response, $this->display_question_mark, $this->display_feedback, $this->hide_if_unanswered, $this->external_review_deadline, $this->internal_review_deadline, $this->sound_demo, $this->password, $this->recache_marks, $this->property_id);
     } else {
         $result = $this->db->prepare("UPDATE properties SET paper_title = ?, paper_type = ?, start_date = ?, end_date = ?, timezone = ?, paper_prologue = ?, paper_postscript = ?, bgcolor = ?, fgcolor = ?, themecolor = ?, labelcolor = ?, fullscreen = ?, marking = ?, bidirectional = ?, pass_mark = ?, distinction_mark = ?, folder = ?, labs = ?, rubric = ?, calculator = ?, exam_duration = ?, display_correct_answer = ?, display_students_response = ?, display_question_mark = ?, display_feedback = ?, hide_if_unanswered = ?, calendar_year = ?, external_review_deadline = ?, internal_review_deadline = ?, sound_demo = ?, password = ?, recache_marks = ?, deleted = ? WHERE property_id = ?");
         $result->bind_param('ssssssssssssssiisssiissssssssssisi', $this->paper_title, $this->paper_type, $this->raw_start_date, $this->raw_end_date, $this->timezone, $this->paper_prologue, $this->paper_postscript, $this->bgcolor, $this->fgcolor, $this->themecolor, $this->labelcolor, $this->fullscreen, $this->marking, $this->bidirectional, $this->pass_mark, $this->distinction_mark, $this->folder, $this->labs, $this->rubric, $this->calculator, $this->exam_duration, $this->display_correct_answer, $this->display_students_response, $this->display_question_mark, $this->display_feedback, $this->hide_if_unanswered, $this->calendar_year, $this->external_review_deadline, $this->internal_review_deadline, $this->sound_demo, $this->password, $this->recache_marks, $this->deleted, $this->property_id);
     }
     $result->execute();
     $result->close();
     // Record any changes
     $logger = new Logger($this->db);
     foreach ($this->changes as $change) {
         $logger->track_change('Paper', $this->property_id, $userObject->get_user_ID(), $change['old'], $change['new'], $change['part']);
     }
 }
 /**
  * Track the deletion of an option
  * @param Logger $logger
  * @param integer $option_number
  */
 protected function track_delete_ans($logger, $option_number)
 {
     $logger->track_change($this->_lang_strings['deletedanswer'], $this->question_id, $this->_user_id, '', '', $this->_lang_strings['answer'] . ' ' . $option_number);
 }
Example #17
0
* @copyright Copyright (c) 2014 The University of Nottingham
* @package
*/
require '../../include/staff_auth.inc';
require_once '../../classes/paperutils.class.php';
require_once '../../classes/logger.class.php';
if ($_POST['questions_to_add'] != '') {
    $logger = new Logger($mysqli);
    $questions = explode(',', $_POST['questions_to_add']);
    $display_pos = $_GET['display_pos'];
    foreach ($questions as $item) {
        Paper_utils::add_question($_GET['paperID'], $item, $_POST['screen'], $display_pos, $mysqli);
        $display_pos++;
        // Create a track changes record to say new question added.
        $tmp_paperID = intval($_GET['paperID']);
        $success = $logger->track_change('Paper', $tmp_paperID, $userObject->get_user_ID(), '', $item, 'Add Question');
    }
}
$mysqli->close();
$paperID = '';
$type = '';
$scrOfY = '';
$module = '';
$folder = '';
if (isset($_GET['paperID'])) {
    $paperID = $_GET['paperID'];
}
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
if (isset($_GET['scrOfY'])) {
Example #18
0
     $tmp_parts = explode('[/blank]', $blank_details[$i]);
     if ($i == $_GET['blank']) {
         $blank_details[$i] = ']' . $option_list . '[/blank]' . $tmp_parts[1];
     }
 }
 $new_option_text = $blank_details[0];
 for ($i = 1; $i < count($blank_details); $i++) {
     $new_option_text .= '[blank' . $blank_details[$i];
 }
 // Save the new option text back to the Questions table.
 $result = $mysqli->prepare("UPDATE options SET option_text = ? WHERE o_id = ?");
 $result->bind_param('si', $new_option_text, $q_id);
 $result->execute();
 $result->close();
 $logger = new Logger($mysqli);
 $success = $logger->track_change('Post-Exam Blank correction', $q_id, $userObject->get_user_ID(), $option_text, $new_option_text, 'Question/Stem');
 // Remark student answers
 $blank_details = explode("[blank", $new_option_text);
 $no_answers = count($blank_details) - 1;
 $totalpos = 0;
 for ($i = 1; $i <= $no_answers; $i++) {
     if (preg_match("|mark=\"([0-9]{1,3})\"|", $blank_details[$i], $mark_matches)) {
         $totalpos += $mark_matches[1];
         $individual_q_mark = $mark_matches[1];
     } else {
         $totalpos += $marks_correct;
         $individual_q_mark = $marks_correct;
     }
 }
 foreach ($log_answers as $log_type => $log_data) {
     foreach ($log_data as $id => $log_answer) {
Example #19
0
 /**
  * Update any part of a modules DB record.
  * 
  * @param integer $orig_moduleid  - the code of the module to update
  * @param type $updateData        - an array of key value pairs to update e.g 'fullname'=>'New full Name'
  * @param object $db              - MySQLi database connection.
  * @return boolean
  */
 public function update_module_by_code($orig_moduleid, $updateData, $db)
 {
     global $string;
     if ($orig_moduleid == '') {
         return false;
     }
     $orig_modinfo = $modinfo = module_utils::get_full_details_by_name($orig_moduleid, $db);
     if ($modinfo === false) {
         // The module must exist to update it!
         return false;
     }
     $orig_school_name = $modinfo['school'];
     $orig_school_id = $modinfo['schoolid'];
     $changed = false;
     foreach ($updateData as $key => $val) {
         $key = strtolower($key);
         if ($key == 'idmod') {
             //never change the id :-)
             continue;
         }
         if ($modinfo[$key] != $val) {
             $modinfo[$key] = $val;
             $changed = true;
         }
     }
     if (!$changed) {
         // Nothing has changed return
         return true;
     }
     // Check mandatory fields
     if ($modinfo['moduleid'] == '' and $modinfo['fullname'] == '') {
         return false;
     }
     if ($orig_school_name != $modinfo['school']) {
         // We have updated the school so we need to get the new id from the schools table
         if ($orig_school_id != $modinfo['schoolid']) {
             // Do nothing as the id has already been updated
         } else {
             // Lookup the schoolID
             $modinfo['schoolid'] = SchoolUtils::get_school_id_by_name($modinfo['school'], $db);
             if ($modinfo['schoolid'] === false) {
                 // School not found ERROR
                 return false;
             }
         }
     }
     $sql = "UPDATE modules SET \n               moduleid = ?,\n               fullname = ?,\n               active = ?, \n               vle_api = ?, \n               checklist = ?, \n               sms = ?, \n               selfenroll = ?, \n               schoolid = ?, \n               neg_marking = ?, \n               ebel_grid_template = ?, \n               timed_exams = ?, \n               exam_q_feedback = ?, \n               add_team_members = ?,\n               map_level = ?,\n               academic_year_start = ?\n            WHERE \n              id = ?\n            LIMIT 1\n            ";
     $result = $db->prepare($sql);
     $result->bind_param('ssisssiiiiiiiisi', $modinfo['moduleid'], $modinfo['fullname'], $modinfo['active'], $modinfo['vle_api'], $modinfo['checklist'], $modinfo['sms'], $modinfo['selfenroll'], $modinfo['schoolid'], $modinfo['neg_marking'], $modinfo['ebel_grid_template'], $modinfo['timed_exams'], $modinfo['exam_q_feedback'], $modinfo['add_team_members'], $modinfo['map_level'], $modinfo['academic_year_start'], $modinfo['idMod']);
     $res = $result->execute();
     // An array to convert DB fields to lang strings argghhh!!!!
     $lang_mappings = array('moduleid' => 'moduleid', 'fullname' => 'name', 'schoolid' => 'school', 'active' => 'active', 'vle_api' => 'objapi', 'checklist' => 'summativechecklist', 'sms' => 'smsapi', 'selfenroll' => 'allowselfenrol', 'neg_marking' => 'negativemarking', 'ebel_grid_template' => 'ebelgrid', 'timed_exams' => 'timedexams', 'exam_q_feedback' => 'questionbasedfeedback', 'add_team_members' => 'addteammembers', 'map_level' => 'map_level', 'academic_year_start' => 'academicyearstart');
     if ($res === true) {
         // Log any changes
         $logger = new Logger($db);
         $userObject = UserObject::get_instance();
         foreach ($modinfo as $key => $val) {
             $key = strtolower($key);
             if ($key == 'idmod') {
                 continue;
             }
             if ($orig_modinfo[$key] != $val) {
                 $logger->track_change('Module', $modinfo['idMod'], $userObject->get_user_ID(), $orig_modinfo[$key], $modinfo[$key], $string[$lang_mappings[$key]]);
             }
         }
     }
     return true;
 }
Example #20
0
    $notice->display_notice_and_exit($mysqli, $string['pagenotfound'], $msg, $string['pagenotfound'], '../artwork/page_not_found.png', '#C00000', true, true);
}
$duplicate = false;
if (isset($_POST['submit'])) {
    // Check for existing name
    if (FacultyUtils::facultyname_exists($_POST['new_faculty'], $mysqli)) {
        $duplicate = true;
    }
    if (!$duplicate) {
        $result = $mysqli->prepare("UPDATE faculty SET name = ? WHERE id = ?");
        $result->bind_param('si', $_POST['new_faculty'], $facultyID);
        $result->execute();
        $result->close();
        $logger = new Logger($mysqli);
        if ($name != $_POST['new_faculty']) {
            $logger->track_change('Faculty', $facultyID, $userObject->get_user_ID(), $name, $_POST['new_faculty'], 'name');
        }
        ?>
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta http-equiv="content-type" content="text/html;charset=<?php 
        echo $configObject->get('cfg_page_charset');
        ?>
" />
  <title><?php 
        echo $string['editfaculty'];
        ?>
</title>
  <script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
Example #21
0
     $logquery->bind_param('i', $user_to_delete);
     $logquery->execute();
     $logquery->close();
     $logquery = $mysqli->prepare("INSERT INTO log_metadata_deleted SELECT DISTINCT lm.* FROM log0 l INNER JOIN log_metadata lm ON l.metadataID = lm.id WHERE lm.userID = ?");
     $logquery->bind_param('i', $user_to_delete);
     $logquery->execute();
     $logquery->close();
     // Delete from formative log.
     $deletequery = $mysqli->prepare("DELETE l, lm FROM log0 l INNER JOIN log_metadata lm ON l.metadataID = lm.id WHERE lm.userID = ?");
     $deletequery->bind_param('i', $user_to_delete);
     $deletequery->execute();
     $log0_deleted = $deletequery->affected_rows;
     $log0_deleted_overall += $log0_deleted;
     $deletequery->close();
     // Record the delete in audit trail
     $logger->track_change(sprintf($string['trackchangemsg'], '0'), $user_to_delete, $my_id, $log0_deleted, 0, $string['trackchangescope']);
 }
 $lm_check = $mysqli->prepare("SELECT count(lm.id) FROM log1 l INNER JOIN log_metadata lm ON l.metadataID = lm.id WHERE lm.userID = ?");
 $lm_check->bind_param('i', $user_to_delete);
 $lm_check->execute();
 $lm_check->bind_result($lm_count);
 $lm_check->fetch();
 $lm_check->close();
 if (isset($lm_count) and $lm_count > 0) {
     $logquery = $mysqli->prepare("INSERT INTO log1_deleted SELECT l.* FROM log1 l INNER JOIN log_metadata lm ON l.metadataID = lm.id WHERE lm.userID = ?");
     $logquery->bind_param('i', $user_to_delete);
     $logquery->execute();
     $logquery->close();
     $logquery = $mysqli->prepare("INSERT INTO log_metadata_deleted SELECT DISTINCT lm.* FROM log1 l INNER JOIN log_metadata lm ON l.metadataID = lm.id WHERE lm.userID = ?");
     $logquery->bind_param('i', $user_to_delete);
     $logquery->execute();
Example #22
0
     }
     $addOption->close();
 }
 if ($save_ok === false) {
     // NO - rollback
     $mysqli->rollback();
 } else {
     // YES - commit the updates to the tables
     $mysqli->commit();
 }
 // Turn auto commit back on so future queries function as before
 $mysqli->autocommit(true);
 if ($save_ok) {
     // Create a track changes record to say where question came from.
     $question_id = intval($question_id);
     $success = $logger->track_change('Copied Question', $question_id, $userObject->get_user_ID(), $q_IDs[$i], $question_id, 'Copied Question');
     // Lookup and copy the keywords
     $keywords = QuestionUtils::get_keywords($q_IDs[$i], $mysqli);
     QuestionUtils::add_keywords($keywords, $question_id, $mysqli);
     // Lookup modules
     $modules = QuestionUtils::get_modules($q_IDs[$i], $mysqli);
     QuestionUtils::add_modules($modules, $question_id, $mysqli);
     if ($map_outcomes) {
         // Make sure that paper is on the module we're copying from
         $paper_modules = $properties->get_modules();
         if (in_array($_GET['module'], array_keys($paper_modules))) {
             if (isset($_POST['outcomes']) and $_POST['outcomes'] != '') {
                 $outcomes = json_decode($_POST['outcomes'], true);
                 $mappings = $mysqli->prepare("SELECT question_id, obj_id FROM relationships WHERE question_id = ? AND idMod = ?");
                 echo $mysqli->error;
                 $mappings->bind_param('ii', $q_IDs[$i], $_GET['module']);