if (trim($leadin) == '') { $leadin = '<span style="color:#C00000">' . $string['noquestionleadin'] . '</span>'; } if (strlen($leadin) > 160) { $leadin = mb_substr($leadin, 0, 160) . '...'; } if ($locked == '') { echo '<td class="u">'; } else { echo '<td class="l">'; } if (trim($theme) != '') { echo '<span class="t">' . $theme . '</span><br /> '; } //sl change this from echo $leadin to below echo QuestionUtils::clean_leadin($leadin) . '</td>'; echo '<td class="nobr">' . $string[$q_type] . '</td>'; if ($type == 'keyword' or $type == 'bloom') { echo '<td>' . $extra_field . '</td>'; } elseif ($type == 'performance') { echo '<td>' . $p / 100 . '</td>'; echo '<td>' . $d / 100 . '</td>'; } echo '<td>' . $modified . '</td>'; echo "<td>" . $status_array[$status]->get_name() . "</td></tr>\n"; $display_no++; } $search_results->close(); if (isset($_GET['sortby'])) { $stateutil->setState($userObject->get_user_ID(), 'sortby', $_GET['sortby'], $_SERVER['PHP_SELF'], $mysqli); }
/** * Persist the object to the database * @return boolean Success or failure of the save operation * @throws ValidationException */ public function save($clear_checkout = true) { $success = false; if ($this->_logger == null) { $this->_logger = new Logger($this->_mysqli); } $valid = $this->validate(); if ($valid === true) { // Clear any existing checkout if ($clear_checkout) { $this->checkout_author_id = null; $this->checkout_time = null; } // Make sure plain versions of scenario and leadin are up to date $this->get_scenario_plain(); $this->get_leadin_plain(); $this->serialize_settings(); if ($this->bloom == '') { $this->bloom = null; } // If $id is -1 we're inserting a new record if ($this->id == -1) { $this->created = date('Y-m-d H:i:s'); $this->last_edited = date('Y-m-d H:i:s'); $server_ipaddress = str_replace('.', '', NetworkUtils::get_server_address()); $this->guid = $server_ipaddress . uniqid('', true); $params = array_merge(array('ssssssssssssssissssisssssss'), $this->_data); $query = <<<QUERY INSERT INTO questions (q_type, theme, scenario, scenario_plain, leadin, leadin_plain, notes, correct_fback, incorrect_fback, score_method, display_method, q_option_order, std, bloom, ownerID, q_media, q_media_width, q_media_height, checkout_time, checkout_authorID, creation_date, last_edited, locked, deleted, status, settings, guid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) QUERY; } else { // Otherwise we're updating an existing one $params = array_merge(array('ssssssssssssssissssisssssssi'), $this->_data, array(&$this->id)); $this->last_edited = date('Y-m-d H:i:s'); $query = <<<QUERY UPDATE questions SET q_type = ?, theme = ?, scenario = ?, scenario_plain = ?, leadin = ?, leadin_plain = ?, notes = ?, correct_fback = ?, incorrect_fback = ?, score_method = ?, display_method = ?, q_option_order = ?, std = ?, bloom = ?, ownerID = ?, q_media = ?, q_media_width = ?, q_media_height = ?, checkout_time = ?, checkout_authorID = ?, creation_date = ?, last_edited = ?, locked = ?, deleted = ?, status = ?, settings = ?, guid = ? WHERE q_id = ? QUERY; } $result = $this->_mysqli->prepare($query); call_user_func_array(array($result, 'bind_param'), $params); $result->execute(); $success = $result->affected_rows > -1; if ($this->_mysqli->error) { try { throw new Exception("MySQL error " . $this->_mysqli->error . "<br /> Query:<br /> {$query}", $this->_mysqli->errno); } catch (Exception $e) { echo "Error No: " . $e->getCode() . " - " . $e->getMessage() . "<br />"; echo nl2br($e->getTraceAsString()); } } if ($success) { if ($this->id == -1) { $this->id = $this->_mysqli->insert_id; $this->_logger->track_change('New Question', $this->id, $this->_user_id, $this->get_leadin(), '', ''); } else { // Log any changes foreach ($this->_modified_fields as $key => $value) { $db_field = in_array($key, array_keys($this->_field_map)) ? $this->_field_map[$key] : $key; $change_field = in_array($db_field, array_keys($this->_change_field_map)) ? $this->_change_field_map[$db_field] : $db_field; // Exception for media as it returns an array. Need better solution if other properties do the same in the future $get_method = 'get_' . $key . ($key == 'media' ? '_filename' : ''); if ($value['message'] == '') { $this->_logger->track_change($this->_lang_strings['editquestion'], $this->id, $this->_user_id, $value['value'], $this->{$get_method}(), $change_field); } else { $this->_logger->track_change($value['message'], $this->id, $this->_user_id, $value['value'], $this->{$get_method}(), $change_field); } } } } $result->close(); if ($success) { // Updates the teams/question modules QuestionUtils::update_modules($this->teams, $this->id, $this->_mysqli, $this->_userObj); } if ($success) { $success = $this->save_options(); } $this->_modified_fields = array(); } else { throw new ValidationException($valid); } return $success; }
* @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/question_status.class.php'; require_once '../classes/questionutils.class.php'; $status_id = check_var('id', 'GET', true, false, true); try { $status = new QuestionStatus($mysqli, $string, $status_id); } catch (DatabaseException $ex) { $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); } $q_count = QuestionUtils::get_question_count_by_status($status_id, $mysqli); ?> <!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['confirmdelete']; ?> </title>
$question_no++; } if ($screen > $old_screen) { echo '<tr><td colspan="7" style="height:10px"></td></tr>'; echo '<tr><td colspan="7"><table border="0" style="padding-left:10px; padding-right:2px; padding-bottom:5px; width:100%; color:#1E3287"><tr><td><nobr>' . $string['screen'] . ' ' . $screen . '</nobr></td><td style="width:98%"><hr noshade="noshade" style="border:0px; height:1px; color:#E5E5E5; background-color:#E5E5E5; width:100%" /></td></tr></table></td></tr>'; } if ($q_type == 'info') { echo "<tr><td class=\"q_no\"><img src=\"../../artwork/black_white_info_icon.png\" width=\"6\" height=\"12\" alt=\"Info\" /> </td><td>"; } else { $status_class = 'status' . $status; echo "<tr class=\"{$status_class}\"><td class=\"q_no\">{$question_no}.</td><td>"; } if ($locked != '') { echo '<img src="../../artwork/small_padlock.png" width="18" height="18" alt="Locked" />'; } echo "</td><td style=\"width:25px\"><input onclick=\"parent.top.controls.checkStatus(this)\" type=\"checkbox\" name=\"{$q_id}\" id=\"{$q_id}\" value=\"{$q_id}\" /></td>"; if ($parts == '') { echo '<td onclick="Qpreview(' . $q_id . ')">'; } else { echo '<td style="color:red; text-decoration:line-through" onclick="Qpreview(' . $q_id . ')">'; } $leadin = QuestionUtils::clean_leadin($leadin); echo $leadin . "</td><td class=\"s\"><nobr>" . fullQuestionType($q_type, $string) . "</nobr></td><td class=\"s\">{$last_edited}</td><td>" . $status_array[$status]->get_name() . "</td></tr>\n"; $old_screen = $screen; } $stmt->close(); ?> </table> </form> </body> </html>
/** * Determins if there is an interactive question (e.g. image hotspot, labelling, * area) on a particular screen of a paper. Speeds system up if not loading * unnecessary HTML5/Flash include files. * @param array $screen_data Array of screen/question information * @param array $screen The screen number to check * @return bool True = HTML5 or Flash neeed, False=no interactive questions found. */ function need_interactiveQ($screen_data, $screen, $db) { $interactive = false; $checktypes = array('hotspot', 'labelling', 'area'); if (isset($screen_data[$screen])) { foreach ($screen_data[$screen] as $question_part) { if (in_array($question_part[0], $checktypes)) { $interactive = true; } else { if ($question_part[0] == 'random') { $options = QuestionUtils::get_options_text($question_part[1], $db); $types = array(); foreach ($options as $opt) { $qtype = QuestionUtils::get_question_type($opt, $db); $types[] = $qtype; } foreach ($types as $t) { if (in_array($t, $checktypes)) { $interactive = true; break; } } } else { if ($question_part[0] == 'keyword_based') { $options = QuestionUtils::get_options_text($question_part[1], $db); foreach ($options as $opt) { $keywords = keyword_utils::get_keyword_questions($opt, $db); $types = array(); foreach ($keywords as $key) { $qtype = QuestionUtils::get_question_type($key, $db); $types[] = $qtype; } } foreach ($types as $t) { if (in_array($t, $checktypes)) { $interactive = true; break; } } } } } } } return $interactive; }
?> " class="form-med" /> </td> </tr> <tr> <th><span class="mandatory">*</span> <label for="option_text1"><?php echo $string['questions']; ?> </label></th> <td> <div id="qlist-holder" class="select-group"> <ul id="questionlist" class="radio-list clearfix"> <?php $i = 1; foreach ($question->options as $option) { $option_text = ltrim(strip_tags(QuestionUtils::get_leadin($option->get_text(), $mysqli))); if (strlen($option_text) > 200) { $option_text = wordwrap($option_text, 200); $option_text = substr($option_text, 0, strpos($option_text, "\n")) . '…'; } ?> <li><label for="option_text<?php echo $i; ?> " class="fullwidth"><input id="option_text<?php echo $i; ?> " name="option_text<?php echo $i; ?> " value="<?php
} $logtype = $_POST["logtype{$i}"]; $log_id = $_POST["log_id{$i}"]; $result = $mysqli->prepare("UPDATE log{$logtype} SET mark = ?, adjmark = ? WHERE id = ?"); $result->bind_param('ddi', $tmp_mark, $tmp_mark, $log_id); $result->execute(); $result->close(); } header("location: ../reports/textbox_select_q.php?action=finalise&paperID={$paperID}&startdate=" . $_POST['startdate'] . "&enddate=" . $_POST['enddate'] . "&module=" . $_GET['module'] . "&folder=" . $_GET['folder'] . "&repcourse=" . $_GET['repcourse']); exit; } else { $q_id = check_var('q_id', 'GET', true, false, true); $startdate = check_var('startdate', 'GET', true, false, true); $enddate = check_var('enddate', 'GET', true, false, true); // Check the question exists. if (!QuestionUtils::question_exists($q_id, $mysqli)) { $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); } $primary_marks = load_marks($paperID, $q_id, 1, $mysqli); $secondary_marks = load_marks($paperID, $q_id, 2, $mysqli); $marks_correct = load_question_mark($q_id, $mysqli); ?> <!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'); ?> " />
private function load_unmarked_enhancedcalc() { $this->unmarked_enhancedcalc = false; if (!isset($this->questions)) { $this->load_questions(); } $enhancedcalc_ids = array(); $paperID = $this->get_property_id(); $excluded = new Exclusion($paperID, $this->db); $excluded->load(); if (is_array($this->questions) and count($this->questions) > 0) { // Calculation questions may be hidden in random blocks of keyword baed questions so we have to check all possibilities. foreach ($this->questions as $question) { // Skip excluded questions. if (!$excluded->is_question_excluded($question['q_id'])) { switch ($question['type']) { case 'random': foreach (QuestionUtils::get_random_calc_question($question['q_id'], $this->db) as $possible) { $enhancedcalc_ids[] = $possible; } break; case 'keyword_based': foreach (QuestionUtils::get_keyword_calc_question($question['q_id'], $this->db) as $possible) { $enhancedcalc_ids[] = $possible; } break; case 'enhancedcalc': $enhancedcalc_ids[] = $question['q_id']; break; default: break; } } } } // Find unmarked questions. if (count($enhancedcalc_ids) > 0) { $result = $this->db->prepare("SELECT log2.id FROM log2, log_metadata WHERE log2.metadataID = log_metadata.id " . "AND q_id IN (" . implode(',', $enhancedcalc_ids) . ") AND paperID = ? AND mark IS NULL LIMIT 1"); $result->bind_param('i', $paperID); $result->execute(); $result->store_result(); $result->bind_result($id); if ($result->num_rows > 0) { $this->unmarked_enhancedcalc = true; } $result->close(); } }
$qIDs = check_var('q_id', 'POST', true, false, true); if ($qIDs[0] == ',') { $qIDs = substr($qIDs, 1); } $tmp_q_ids = explode(',', $_POST['q_id']); $result = $mysqli->prepare("SELECT DISTINCT paper_title, paper, paper_type FROM (papers, properties) WHERE papers.paper = properties.property_id AND properties.deleted IS NULL AND question IN ({$qIDs})"); $result->execute(); $result->store_result(); $result->bind_result($paper_title, $paper, $paper_type); $found = $result->num_rows; $result->close(); if ($found == 0) { // Only delete if the question is on zero papers. for ($i = 1; $i < count($tmp_q_ids); $i++) { $qID = $tmp_q_ids[$i]; QuestionUtils::delete_question($qID, $mysqli); } } $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'];
/** * Get the question information * @param integer $q_id * @param object $db * @return formated HTML for display of question information */ static function full_question_information($q_id, $db, $userObj, $string, $notice) { global $configObject, $string; echo '<table cellpadding="5" cellspacing="0" border="0" width="100%">'; echo '<tr><td colspan="2" valign="middle" style="background-color:white; text-align:left; border-bottom:1px solid #CCD9EA">'; echo '<img src="../artwork/lrg_info_icon.png" width="37" height="37" alt="Information" style="float:left" /><span style="color:#295AAD; font-size:18pt; font-weight:bold"> ' . $string['questioninformation'] . '</span></td></tr>'; $question_data = $db->prepare("SELECT email, title, surname, initials, DATE_FORMAT(creation_date,\"%d/%m/%Y %H:%i\") AS creation_date, DATE_FORMAT(last_edited,\"%d/%m/%Y %H:%i\") AS last_edited, DATE_FORMAT(locked,\"{$configObject->get('cfg_long_date_time')}\") AS locked, q_type, std, status FROM (users, questions) WHERE users.id=questions.ownerID AND q_id = ? LIMIT 1"); $question_data->bind_param('i', $q_id); $question_data->execute(); $question_data->bind_result($email, $title, $surname, $initials, $creation_date, $last_edited, $locked, $q_type, $std, $status); $question_data->store_result(); $question_data->fetch(); $question_data->close(); if (!isset($creation_date)) { $msg = sprintf($string['furtherassistance'], $configObject->get('support_email'), $configObject->get('support_email')); $notice->display_notice_and_exit($db, $string['pagenotfound'], $msg, $string['pagenotfound'], '../artwork/page_not_found.png', '#C00000', false, true); } $modules = QuestionUtils::get_modules($q_id, $db); $q_group = ''; if (count($modules) == 0) { $q_group = '<span style="color:#808080">' . $string['na'] . '</span>'; } else { foreach ($modules as $code => $module) { if ($q_group == '') { $q_group = $module; } else { $q_group .= ', ' . $module; } } } if ($locked == '') { $locked = '<span style="color:#808080">' . $string['na'] . '</span>'; } if ($userObj->has_role('Demo')) { $owner = 'Dr J, Bloggs (<a href="">joe.bloggs@uni.ac.uk</a>)'; } else { $owner = "{$title} {$initials} {$surname} (<a href=\"mailto:{$email}\">{$email}</a>)"; } echo "<tr><td style=\"width:70px\">" . $string['author'] . "</td><td>{$owner}</td></tr>\n"; echo "<tr><td>" . $string['created'] . "</td><td>{$creation_date}</td></tr>\n"; echo "<tr><td>" . $string['modified'] . "</td><td>{$last_edited}</td></tr>\n"; echo "<tr><td>" . $string['locked'] . "</td><td>{$locked}</td></tr>\n"; echo "<tr><td>" . $string['teams'] . "</td><td>{$q_group}</td></tr>\n"; echo "<tr><td>" . $string['copies'] . "</td><td></td></tr>\n"; echo "</table>\n"; echo "<div style=\"margin:5px; display:block; height:95px; overflow-y:scroll; border:1px solid #295AAD; font-size:100%; background-color:white\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" style=\"width:100%\">"; echo "<tr><th>" . $string['type'] . "</th><th>" . $string['papername'] . "</th><th>" . $string['questionno'] . "</th></tr>\n"; $data = question_info::check_copies($q_id, $db); $rows = count($data); for ($i = 0; $i < $rows; $i++) { if (isset($data[$i]['paperID'])) { echo "<tr><td>" . $string['copyof'] . "</td><td><a href=\"\" onclick=\"loadPaper('" . $data[$i]['paperID'] . "')\">" . $data[$i]['paper_title'] . "</a></td><td>" . $data[$i]['question_no'] . "</td></tr>\n"; } else { echo "<tr><td>" . $string['copyof'] . "</td><td colspan=\"2\">Question ID #" . $data[$i]['question_id'] . "</td></tr>\n"; } } unset($data); $data = question_info::check_copied($q_id, $db); $rows = count($data); for ($i = 0; $i < $rows; $i++) { if (isset($data[$i]['paperID'])) { echo "<tr><td>" . $string['sourcefor'] . "</td><td><a href=\"\" onclick=\"loadPaper('" . $data[$i]['paperID'] . "')\">" . $data[$i]['paper_title'] . "</a></td><td>" . $data[$i]['question_no'] . "</td></tr>\n"; } else { echo "<tr><td>" . $string['sourcefor'] . "</td><td colspan=\"2\">Question ID #" . $data[$i]['question_id'] . "</td></tr>\n"; } } echo "</table>\n</div>\n"; echo "<table style=\"width:100%\">\n"; echo "<tr><td colspan=\"2\"> </td></tr>\n"; echo "<tr><td>" . $string['followingpapers'] . "</td><td style=\"text-align:right\"><input type=\"button\" name=\"longitudinal\" value=\"" . $string['Longitudinal'] . "\" onclick=\"openLongitudinal({$q_id});\" /></td></tr>\n"; echo "</table>\n"; echo "<div style=\"margin:5px; display:block; height:195px; overflow-y:scroll; border:1px solid #295AAD; font-size:100%; background-color:white\">\n<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" style=\"width:100%\">"; echo "<tr><th></th><th>" . $string['papername'] . "</th><th>" . $string['screenno'] . "</th><th>" . $string['examdate'] . "</th><th>" . $string['cohort'] . "</th><th></th><th>" . $string['p'] . "</th><th>" . $string['d'] . "</th></tr>\n"; $performance_array = question_info::question_performance($q_id, $db); foreach ($performance_array as $paper => $performance) { if (!array_key_exists('icon', $performance)) { $performance['icon'] = 'red_flag.png'; } echo "<tr><td><img src=\"../artwork/" . $performance['icon'] . "\" width=\"16\" height=\"16\" border=\"0\" alt=\"0\" /></td>"; if (!array_key_exists('title', $performance)) { $performance['title'] = '?'; } echo "<td><a href=\"\" onclick=\"loadPaper('{$paper}')\">" . $performance['title'] . "</a></td>"; if (!array_key_exists('screen', $performance)) { $performance['screen'] = '?'; } echo "<td class=\"num\">" . $performance['screen'] . "</td>"; if (isset($performance['performance'][1]['taken'])) { echo "<td>" . $performance['performance'][1]['taken'] . "</td><td class=\"num\">" . $performance['performance'][1]['cohort'] . "</td><td style=\"text-align:right\">" . question_info::display_parts($performance['performance'], $q_type) . "</td><td class=\"num\">" . question_info::display_p($performance['performance'], $q_type) . "</td><td class=\"num\">" . question_info::display_d($performance['performance'], $q_type) . "</td>"; } else { echo "<td></td><td></td><td></td><td></td><td></td>"; } echo "</tr>\n"; } echo '</table></div>'; }
/** * Updates the modules on a question removes modules if the user has permission to do so and then adds in the new modules * @param $modules an array of modules keyed on idMod * @param $q_id the id of the question * @param resource $db the database connection. * @param object $userObj the currently authenticated user object. * @return void */ static function update_modules($modules, $q_id, $db, $userObj) { $user_can_delete = ''; if (!$userObj->has_role('SysAdmin')) { // If SysAdmin no restrictions in deleting. $staff_modules = $userObj->get_staff_modules(); if (count($staff_modules) > 0) { $user_can_delete = "AND idMod IN (" . implode(',', array_keys($staff_modules)) . ")"; //users can only remove modules if they are on the team } } $editProperties = $db->prepare("DELETE FROM questions_modules WHERE q_id = ? {$user_can_delete}"); $editProperties->bind_param('i', $q_id); $editProperties->execute(); $editProperties->close(); QuestionUtils::add_modules($modules, $q_id, $db); }
$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");
/** * IMPORT: Take the textual keywords of a question, lookup IDs and then insert into the DB. * @param array $keywords - Array of textual keywords * @param int $q_id - ID of the question the keywords are for. */ private function write_keywords($keywords, $q_id) { if ($this->raf_company == $this->configObj->get('cfg_company')) { // The import file company is the same as the current installation. Use the same IDs. $keywordIDs = $keywords; } else { $keywordIDs = array(); foreach ($keywords as $keyword) { if (isset($this->keywords_lookup[$keyword])) { $tmp_ID = $this->keywords_lookup[$keyword]; $keywordIDs[$tmp_ID] = $tmp_ID; } } } if (count($keywordIDs) > 0) { QuestionUtils::add_keywords($keywordIDs, $q_id, $this->db); } }
require '../include/media.inc'; require_once '../classes/stateutils.class.php'; require_once '../classes/folderutils.class.php'; require_once '../classes/paperproperties.class.php'; require_once '../classes/textboxmarkingutils.class.php'; $state = $stateutil->getState(); $paperID = check_var('paperID', 'GET', true, false, true); $q_id = check_var('q_id', 'GET', true, false, true); $startdate = check_var('startdate', 'GET', true, false, true); $enddate = check_var('enddate', 'GET', true, false, true); $phase = check_var('phase', 'GET', true, false, true); $properties = PaperProperties::get_paper_properties_by_id($paperID, $mysqli, $string); $paper_type = $properties->get_paper_type(); $paper_title = $properties->get_paper_title(); // Check the question exists on the paper. if (!QuestionUtils::question_exists_on_paper($q_id, $paperID, $mysqli)) { $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); } function displayMarks($id, $default, $log_record_id, $log, $halfmarks, $tmp_username, $marks, $string) { $html = '<select id="mark' . $id . '" name="mark' . $id . '" ><option value="NULL"></option>'; $inc = 1; if ($halfmarks == true) { $inc = 0.5; } for ($i = 0; $i <= $marks; $i += $inc) { $display_i = $i; if ($i == 0.5) { $display_i = '½'; } elseif ($i - floor($i) > 0) {
/** * Get details of all the questions that make up a random question block. * @param int $questionID - ID of the random question to look up. * @param object $configObject - Configuration object. * @return array - Array of the questions that make up a random question block. */ function randomDetails($questionID, $configObject, $db) { $question_no = 0; $random_questions = array(); $old_q_id = ''; $old_score_method = ''; $old_q_media_width = ''; $old_q_media_height = ''; $old_correct = array(); $old_option_text = array(); $result = $db->prepare("SELECT theme, options1.option_text, leadin, scenario, q_media_width, q_media_height, options2.correct, options2.marks_correct, options2.option_text, q_type, display_method, score_method, DATE_FORMAT(last_edited,' {$configObject->get('cfg_short_date')}'), status, settings FROM options AS options1, questions LEFT JOIN options AS options2 ON questions.q_id = options2.o_id WHERE options1.option_text=questions.q_id AND options1.o_id=? "); $result->bind_param('i', $questionID); $result->execute(); $result->store_result(); if ($result->num_rows > 0) { $result->bind_result($theme, $q_id, $leadin, $scenario, $q_media_width, $q_media_height, $correct, $marks, $option_text, $q_type, $display_method, $score_method, $display_last_edited, $status, $settings); while ($result->fetch()) { if ($old_q_id != $q_id and $old_q_id != '') { $old_leadin = QuestionUtils::clean_leadin($old_leadin); $random_questions[$question_no]['theme'] = $old_theme; $random_questions[$question_no]['q_id'] = $old_q_id; $random_questions[$question_no]['type'] = $old_q_type; $random_questions[$question_no]['leadin'] = $old_leadin; $random_questions[$question_no]['scenario'] = $old_scenario; $random_questions[$question_no]['scenario'] = $old_scenario; $random_questions[$question_no]['correct'] = $old_correct; $random_questions[$question_no]['status'] = $old_status; $random_questions[$question_no]['settings'] = $old_settings; $random_questions[$question_no]['display_last_edited'] = $display_last_edited; $random_questions[$question_no]['marks'] = qMarks($old_q_type, '', $old_marks, $old_option_text, $old_correct, $old_display_method, $old_score_method); $random_questions[$question_no]['random_mark'] = qRandomMarks($old_q_type, '', $old_marks, $old_option_text, $old_correct, $old_display_method, $old_score_method, $old_q_media_width, $old_q_media_height); $old_correct = array(); $old_option_text = array(); $question_no++; } $old_theme = $theme; $old_q_id = $q_id; $old_q_type = $q_type; $old_leadin = $leadin; $old_scenario = $scenario; $old_status = $status; $old_settings = $settings; $old_marks = $marks; $old_correct[] = $correct; $old_option_text[] = $option_text; $old_display_method = $display_method; $old_score_method = $score_method; $old_q_media_width = $q_media_width; $old_q_media_height = $q_media_height; } // Write out the last question. $old_leadin = QuestionUtils::clean_leadin($old_leadin); $random_questions[$question_no]['theme'] = $old_theme; $random_questions[$question_no]['q_id'] = $old_q_id; $random_questions[$question_no]['type'] = $old_q_type; $random_questions[$question_no]['leadin'] = $old_leadin; $random_questions[$question_no]['scenario'] = $old_scenario; $random_questions[$question_no]['correct'] = $old_correct; $random_questions[$question_no]['status'] = $old_status; $random_questions[$question_no]['settings'] = $old_settings; $random_questions[$question_no]['display_last_edited'] = $display_last_edited; $random_questions[$question_no]['marks'] = qMarks($old_q_type, '', $old_marks, $old_option_text, $old_correct, $old_display_method, $old_score_method); $random_questions[$question_no]['random_mark'] = qRandomMarks($old_q_type, '', $old_marks, $old_option_text, $old_correct, $old_display_method, $old_score_method, $old_q_media_width, $old_q_media_height); } $result->close(); return $random_questions; }
} 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']); $mappings->execute(); $mappings->store_result(); $mappings->bind_result($map_q_id, $obj_id); while ($mappings->fetch()) { if (isset($outcomes[$obj_id])) { $map_guid[$outcomes[$obj_id]] = true;