Exemplo n.º 1
0
 /**
  * Output HTML for mid-exam announcements for the current paper.
  */
 public function display_student_announcements()
 {
     $exam_announcements = $this->get_announcements();
     $maxscreen = Paper_utils::get_num_screens($this->paperID, $this->db);
     if (count($exam_announcements) == 0) {
         return '';
     }
     $html = '';
     $html .= "<table class=\"exam_announcement_box\">\n";
     $html .= "<tr><td rowspan=\"" . (count($exam_announcements) + 1) . "\" class=\"exam_announce_icon\" ><img src=\"../artwork/comment_48.png\" width=\"48\" height=\"48\" /></td><td class=\"exam_announce_title\">" . $this->string['questionclarification'] . "</td></tr>\n";
     foreach ($exam_announcements as $exam_announcement) {
         $html .= "<tr><td><ul><li><strong>" . $this->string['question'] . " " . $exam_announcement['q_number'] . "</strong> (" . sprintf($this->string['clarificationscreen'], $exam_announcement['screen'], $maxscreen) . ")<br />" . $exam_announcement['msg'] . "</li></ul></td></tr>\n";
     }
     $html .= '</table>';
     return $html;
 }
Exemplo n.º 2
0
}
$option_no = 1;
// Work out if any negative marking is used
$neg_marking = false;
$result = $mysqli->prepare("SELECT marks_incorrect FROM papers, questions, options WHERE papers.question = questions.q_id AND questions.q_id = options.o_id AND paper = ?");
$result->bind_param('i', $paperID);
$result->execute();
$result->bind_result($marks_incorrect);
while ($result->fetch()) {
    if ($marks_incorrect < 0) {
        $neg_marking = true;
    }
}
$result->close();
// Load textual feedback
$textual_feedback = Paper_utils::get_textual_feedback($paperID, $mysqli);
$local_time = new DateTimeZone($configObject->get('cfg_timezone'));
$target_timezone = new DateTimeZone($properties->get_timezone());
if ($properties->get_start_date() != '') {
    $start_date = DateTime::createFromFormat('U', $properties->get_start_date(), $local_time);
    $start_date->setTimezone($target_timezone);
} else {
    $start_date = '';
}
if ($properties->get_end_date() != '') {
    $end_date = DateTime::createFromFormat('U', $properties->get_end_date(), $local_time);
    $end_date->setTimezone($target_timezone);
} else {
    $end_date = '';
}
if ($configObject->get('cfg_summative_mgmt') and $properties->get_paper_type() == '2' and !$userObject->has_role(array('SysAdmin', 'Admin'))) {
Exemplo n.º 3
0
// Is it a self-enrol module.
if (isset($module_details['selfenroll']) and $module_details['selfenroll'] == 1) {
    $selfenrol_url = NetworkUtils::get_protocol() . $_SERVER['HTTP_HOST'] . $configObject->get('cfg_root_path') . '/self_enrol.php?moduleid=' . $module_details['moduleid'];
    echo "<br /><div style=\"margin-left:auto; margin-right:auto; width:500px\"><img src=\"../artwork/self_enrol.png\" width=\"48\" height=\"48\" alt=\"modules\" style=\"float:left; margin-right:10px\" /> <div style=\"color:#F18103; font-weight:bold; line-height:200%\">" . $string['selfenrolmodule'] . "</div>" . $string['studenturl'] . ": <a href=\"{$selfenrol_url}\" style=\"color:#316ac5\">{$selfenrol_url}</a></div>\n";
}
// Paper type folders
echo "<div class=\"subsect_table\" style=\"clear:both\"><div class=\"subsect_title\">" . $string['papers'] . "</div><div class=\"subsect_hr\"><hr noshade=\"noshade\" /></div></div>\n";
$state = $stateutil->getState($configObject->get('cfg_root_path') . '/paper/type.php');
if (isset($state['showretired']) and $state['showretired'] == 'true') {
    $types_used = module_utils::paper_types($module, true, $mysqli);
} else {
    $types_used = module_utils::paper_types($module, false, $mysqli);
}
foreach ($types_used as $type => $no_papers) {
    $url = '../paper/type.php?module=' . $module . '&type=' . $type;
    echo "<div class=\"f2\"><div class=\"f_icon\"><a href=\"{$url}\"><img src=\"../artwork/yellow_folder.png\" alt=\"Folder\" /></a></div><div class=\"f_details\"><a href=\"{$url}\">" . Paper_utils::type_to_name($type, $string) . "</a><br /><span class=\"grey\">" . number_format($no_papers) . " " . strtolower($string['papers']) . "</span></div></div>\n";
}
echo "<br clear=\"left\">\n";
echo "<div class=\"f2\"><div class=\"f_icon\"><a href=\"../paper/search.php?module={$module}\"><img src=\"../artwork/search_48.png\" alt=\"Folder\" /></a></div><div class=\"f_details\"><a href=\"../paper/search.php?module={$module}\">" . $string['search'] . "</a><br /><span class=\"grey\">" . $string['forpapers'] . "</span></div></div>\n";
if ($module != 0) {
    // Don't want new papers created from the Unassigned folder.
    echo "<div class=\"f2\"><div class=\"f_icon\"><a href=\"\" onclick=\"newPaper({$module}); return false;\"><img src=\"../artwork/new_paper_48.png\" alt=\"" . $string['newpaper'] . "\" /></a></div><div class=\"f_details\"><a href=\"\" onclick=\"newPaper({$module}); return false;\">" . $string['newpaper'] . "</a></div></div>\n";
}
// Question bank section
echo "<br clear=\"left\">\n";
echo "<div class=\"subsect_table\" style=\"clear:both\"><div class=\"subsect_title\"><nobr>" . $string['questionbank'] . "</nobr></div><div class=\"subsect_hr\"><hr noshade=\"noshade\" /></div></div>\n";
$qbank = new QuestionBank($module, $module_details['moduleid'], $string, $notice, $mysqli);
$qbank->get_categories('all');
$stats = $qbank->get_stats('all');
$question_no = 0;
foreach ($stats as $stat_name => $stat_no) {
Exemplo n.º 4
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
Exemplo n.º 5
0
// You should have received a copy of the GNU General Public License
// along with Rogō.  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/staff_auth.inc';
require '../../include/errors.inc';
require '../../include/question_types.inc';
require_once '../../classes/questionutils.class.php';
require_once '../../classes/question_status.class.php';
$question_paper = check_var('question_paper', 'GET', true, false, true);
if (!Paper_utils::paper_exists($question_paper, $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);
}
// Get question statuses
$status_array = QuestionStatus::get_all_statuses($mysqli, $string, true);
?>
<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>by Paper</title>
Exemplo n.º 6
0
// Rogō is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rogō.  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/invigilator_auth.inc';
require_once '../../include/errors.inc';
require_once '../../classes/paperutils.class.php';
require_once '../../classes/userutils.class.php';
require_once '../../classes/toiletbreakutils.class.php';
$userID = check_var('userID', 'POST', true, false, true);
$paperID = check_var('paperID', 'POST', true, false, true);
// Does the paper exist?
if (!Paper_utils::paper_exists($paperID, $mysqli)) {
    exit;
}
// Does the student exist?
if (!UserUtils::userid_exists($userID, $mysqli)) {
    exit;
}
ToiletBreaks::add_toilet_break($userID, $paperID, $mysqli);
$mysqli->close();
Exemplo n.º 7
0
?>
<div style="padding-top:6px; padding-left:6px; padding-right:14px">
<?php 
// Check for any news/announcements
foreach ($announcements as $announcement) {
    if (!isset($_SESSION['announcement' . $announcement['id']])) {
        echo "<div class=\"announcement\" id=\"announcement" . $announcement['id'] . "\"><img src=\"./artwork/close_note.png\" style=\"display:block; float:right\" onclick=\"hideAnnouncement(" . $announcement['id'] . ")\" /><div style=\"min-height:64px; padding-left:80px; padding-top:5px; background: transparent url('./artwork/" . $announcement['icon'] . "') no-repeat 5px 5px;\"><strong>" . $announcement['title'] . "</strong><br />\n<br />\n" . $announcement['msg'] . "</div></div>\n";
    }
}
// -- Display any papers for review ---------------------------------
$review_papers = get_review_papers($userObject->get_user_ID(), $mysqli);
if (count($review_papers) > 0) {
    echo "<div class=\"subsect_table\" style=\"clear:both\"><div class=\"subsect_title\"><nobr>" . $string['papersforreview'] . "</nobr></div><div class=\"subsect_hr\"><hr noshade=\"noshade\" /></div></div>\n";
}
foreach ($review_papers as $review_paper) {
    echo "<div class=\"f\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"width:60px\" align=\"center\"><a href=\"#\" onclick=\"startPaper('" . $review_paper['crypt_name'] . "'," . $review_paper['fullscreen'] . "); return false;\">" . Paper_utils::displayIcon($review_paper['type'], '', '', '', '', '') . "</a></td>\n";
    echo "  <td><a href=\"#\" onclick=\"startPaper('" . $review_paper['crypt_name'] . "'," . $review_paper['fullscreen'] . "); return false;\">" . $review_paper['paper_title'] . "</a><br /><div style=\"color:#C00000\">" . $string['deadline'] . " " . $review_paper['internal_review_deadline'] . "</div>";
    if ($review_paper['reviewed'] == '') {
        echo "<span style=\"color:white; background-color:#FF4040\">&nbsp;" . $string['notreviewed'] . "&nbsp;</span>";
    } else {
        echo "<span style=\"color:#808080\">" . $string['reviewed'] . ": {$review_paper['reviewed']}</span>";
    }
    echo "</td></tr></table></div>\n";
}
if (count($review_papers) > 0) {
    echo '<br clear="left" />';
}
// -- Display personal folders --------------------------------------
$module_sql = '';
if (count($userObject->get_staff_modules()) > 0) {
    $module_sql = " OR idMod IN (" . implode(',', array_keys($userObject->get_staff_modules())) . ")";
Exemplo n.º 8
0
/**
* 
* @author Simon Wilkinson
* @version 1.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'];
}
Exemplo n.º 9
0
 /**
  * IMPORT: Decode the data file and add questions one by one to the current paper.
  */
 private function load_raf_data()
 {
     $data_array = json_decode($this->data, true);
     $display_pos = 1;
     $this->raf_company = $data_array['metadata']['company'];
     foreach ($data_array['items'] as $item) {
         $q_id = $this->write_question($item['question']);
         $this->write_keywords($item['keywords'], $q_id);
         foreach ($item['options'] as $options) {
             $this->write_option($options, $q_id);
         }
         if (is_object($this->properties)) {
             $paperID = $this->properties->get_property_id();
             $screen_no = $item['question']['screen'];
             Paper_utils::add_question($paperID, $q_id, $screen_no, $display_pos, $this->db);
         }
         $display_pos++;
     }
 }
Exemplo n.º 10
0
$result->bind_result($paper_type, $paper_title, $property_id, $bidirectional, $fullscreen, $max_screen, $external_review_deadline, $crypt_name);
while ($result->fetch()) {
    $reviewed = '';
    if ($fullscreen == '') {
        $fullscreen = 0;
    }
    $log_results = $mysqli->prepare("SELECT UNIX_TIMESTAMP(MAX(started)) AS started FROM review_metadata WHERE reviewerID = ? and paperID = ?");
    $log_results->bind_param('ii', $userObject->get_user_ID(), $property_id);
    $log_results->execute();
    $log_results->store_result();
    $log_results->bind_result($reviewed);
    $log_results->fetch();
    $log_results->close();
    $restartdate = '';
    $display_deadline = date($configObject->get('cfg_long_date_php'), $external_review_deadline);
    echo "<tr><td align=\"center\"><a href=\"../paper/user_index.php?id={$crypt_name}\">" . Paper_utils::displayIcon($paper_type, $paper_title, '', '', '', '') . "</a></td>\n";
    echo "  <td><a href=\"../paper/user_index.php?id={$crypt_name}\">{$paper_title}</a><br /><div style=\"color:#C00000\">" . $string['deadline'] . " ";
    if ($start_of_day_ts > $external_review_deadline) {
        printf($string['expired'], $configObject->get('cfg_company'));
    } else {
        if ($display_deadline == '00/00/0000') {
            echo $string['notset'];
        } else {
            echo $display_deadline;
        }
    }
    echo '</div>';
    if ($reviewed == '') {
        echo '<span style="color:white; background-color:#FF4040; padding-left:5px; padding-right:5px">' . $string['notreviewed'] . '</span>';
    } else {
        echo '<span style="color:#808080">' . sprintf($string['reviewed'], date($configObject->get('cfg_short_date_php') . ' ' . $configObject->get('cfg_short_time_php'), $reviewed)) . '</span>';
Exemplo n.º 11
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++;
             }
         }
     }
 }
Exemplo n.º 12
0
}
// Process the posted modules
$modules = array();
$first = true;
for ($i = 0; $i < $_POST['module_no']; $i++) {
    if (isset($_POST['mod' . $i])) {
        $module_code = module_utils::get_moduleid_from_id($_POST['mod' . $i], $mysqli);
        if ($first == true) {
            $first_module = $_POST['mod' . $i];
            $first = false;
        }
        $modules[$_POST['mod' . $i]] = $module_code;
    }
}
//add the modules to the paper
Paper_utils::add_modules($modules, $property_id, $mysqli);
$stmt = $mysqli->prepare("SELECT UNIX_TIMESTAMP(created), paper_ownerID FROM properties WHERE property_id = ?");
$stmt->bind_param('i', $property_id);
$stmt->execute();
$stmt->bind_result($created, $paper_ownerID);
$stmt->fetch();
$stmt->close();
$hash = $property_id . $created . $paper_ownerID;
// Generate the encrypted name of the paper.
if ($configObject->get('cfg_summative_mgmt') and $_POST['paper_type'] == 'summative') {
    $duration = 0;
    if (isset($_POST['duration_hours'])) {
        $duration += $_POST['duration_hours'] * 60;
    }
    if (isset($_POST['duration_mins'])) {
        $duration += $_POST['duration_mins'];
Exemplo n.º 13
0
if ($properties->get_summative_lock()) {
    echo "<tr><td colspan=\"2\"><div class=\"yellowwarn\"><img src=\"../artwork/paper_locked_padlock.png\" width=\"32\" height=\"32\" alt=\"Locked\" /></div></td><td colspan=\"4\" style=\"vertical-align:middle\"><div class=\"yellowwarn\">" . $string['paperlockedwarning'] . " <a href=\"#\" class=\"blacklink\" onclick=\"launchHelp(189); return false;\">" . $string['paperlockedclick'] . "</a></div></td></tr>\n";
} elseif ($properties->get_paper_type() == '2' and $properties->get_start_date() !== null) {
    $tmp_hour = date("G", $properties->get_start_date());
    if (date("Y", $properties->get_start_date()) > date("Y") + 1) {
        echo "<tr><td colspan=\"2\" style=\"width:40px; line-height:0\" class=\"redwarn\"><img src=\"../artwork/late_warning_icon.png\" width=\"32\" height=\"32\" alt=\"Warning\" /></td><td colspan=\"4\" class=\"redwarn\">";
        printf($string['farfuturewarning'], $properties->get_display_start_date());
        echo "</td></tr>\n";
    } elseif ($tmp_hour < $configObject->get('cfg_hour_warning')) {
        echo "<tr><td colspan=\"2\" style=\"width:40px; line-height:0\" class=\"redwarn\"><img src=\"../artwork/late_warning_icon.png\" width=\"32\" height=\"32\" alt=\"Warning\" /></td><td colspan=\"4\" class=\"redwarn\">";
        printf($string['earlywarning'], $configObject->get('cfg_hour_warning'));
        echo "</td></tr>\n";
    }
}
if ($properties->get_calendar_year() !== null) {
    $tmp_match = Paper_utils::academic_year_from_title($properties->get_paper_title());
    if ($tmp_match !== false and $tmp_match != $properties->get_calendar_year()) {
        echo "<tr><td colspan=\"6\" style=\"padding: 0\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:100%; font-size:100%\">\n";
        echo "<tr><td class=\"redwarn\" style=\"width:40px; line-height:0\"><img src=\"../artwork/exclamation_red_bg.png\" width=\"32\" height=\"32\" alt=\"Warning\" /></td><td colspan=\"7\" class=\"redwarn\"><strong>" . $string['warning'] . "</strong>&nbsp;&nbsp;";
        printf($string['nomatchsession'], $tmp_match, $properties->get_calendar_year());
        echo "</td></tr>\n</table>\n</td></tr>\n";
    }
}
$q_screen = array();
$screen_marks = 0;
$old_screen = 0;
$question_number = 0;
$marks_incorrect_error = false;
$paper_warnings = array();
for ($x = 1; $x <= $row_no; $x++) {
    $status = $status_array[$temp_array[$x]['status']];
Exemplo n.º 14
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();
     }
 }
Exemplo n.º 15
0
            $remaining_available = has_time_remaining($propertyObj, $remaining_time);
            break;
    }
}
echo '<tr><td style="text-align:center" colspan="4"><br />';
if ($start_available === false) {
    echo "<div style=\"color:#C00000;font-size:90%\">" . $string['papernotavailable'] . "</div>\n";
} elseif ($remaining_available === false) {
    echo "<div style=\"color:#C00000;font-size:90%\">" . $string['timeexpired'] . "</div>\n";
} elseif ($metadata_security === false) {
    echo "<div style=\"color:#C00000;font-size:90%\">{$metadata_msg}</div>\n";
} elseif ($test_type == '2' and !$userObject->has_role('External Examiner')) {
    echo "<div style=\"color:#C00000;font-size:90%\">" . $string['donotstart'] . "</div>\n";
}
if ($test_type == 2) {
    $paper_utils = Paper_utils::get_instance();
    $paper_display = array();
    $paper_no = $paper_utils->get_active_papers($paper_display, array('1', '2'), $userObject, $mysqli, $property_id);
    if ($paper_no > 0) {
        echo "<input class=\"ok\" type=\"button\" style=\"margin-right:20px; width:" . $button_width . "px\" value=\"" . $string['switchpapers'] . "\" name=\"switch\" onclick=\"window.location='index.php'\" />";
    }
}
$display_date = '';
if ($start_available and $remaining_available and $metadata_security) {
    echo "<input type=\"button\" class=\"ok\" style=\"width:" . $button_width . "px; font-weight:bold\" value=\"{$start_label}\" name=\"start\" id=\"start\" onclick=\"startPaper();\" onkeypress=\"startPaper();\" />\n";
} else {
    echo "<input type=\"button\" class=\"notok\" style=\"width:" . $button_width . "px\" value=\"" . $string['start'] . "\" name=\"start\" disabled />\n";
}
echo '<br />&nbsp;';
if ($test_type != '2') {
    // Display previous attempts
Exemplo n.º 16
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);
Exemplo n.º 17
0
 // Get the maximum display position for an existing paper.
 $result = $mysqli->prepare("SELECT MAX(display_pos), MAX(screen) FROM papers WHERE paper = ?");
 $result->bind_param('i', $property_id);
 $result->execute();
 $result->bind_result($display_pos, $screen);
 $result->fetch();
 $result->close();
 if ($screen == '') {
     $screen = 1;
 }
 $display_pos++;
 // Add one to put new question right at the end.
 $q_IDs = explode(',', $q_id);
 for ($i = 1; $i < count($q_IDs); $i++) {
     $map_guid = array();
     Paper_utils::add_question($property_id, $q_IDs[$i], $screen, $display_pos, $mysqli);
     $display_pos++;
     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 = ?");
                 $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;
Exemplo n.º 18
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);
}
Exemplo n.º 19
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']))) {
Exemplo n.º 20
0
     echo '<img src="../artwork/breadcrumb_arrow.png" class="breadcrumb_arrow" alt="-" /><a href="../module/index.php?module=' . $_REQUEST['module'] . '">' . module_utils::get_moduleid_from_id($_REQUEST['module'], $mysqli) . '</a>';
 }
 echo "</div><div class=\"page_title\">" . $string['papersearch'] . " (" . number_format($results->num_rows) . "):&nbsp;<span style=\"font-weight: normal\">'" . $_POST['searchterm'] . "'</span></div>";
 echo "</div>\n";
 if ($results->num_rows > 0) {
     echo '<br />';
     while ($results->fetch()) {
         echo '<div class="f">';
         echo '<table cellpadding="0" cellspacing="0" border="0"><tr><td style="width:60px; text-align:center">';
         $type = $paper_type;
         if ($start_date != '' and date("YmdHis", time()) >= $start_date) {
             $locked = '_locked';
         } else {
             $locked = '';
         }
         echo "<a href=\"../paper/details.php?paperID={$property_id}\">" . Paper_utils::displayIcon($type, $title, $initials, $surname, $locked, $retired) . "</a></td>\n";
         echo "</td><td><a href=\"../paper/details.php?paperID={$property_id}\">{$paper_title}</a><br />";
         echo '  <span style="color:#808080">' . $screens;
         if ($screens == 1) {
             echo ' ' . $string['screen'] . ', ';
         } else {
             echo ' ' . $string['screens'] . ', ';
         }
         echo $moduleID . '<br />';
         echo '  ' . $display_start_date . ' ' . $string['to'] . ' ' . $display_end_date . '</td></tr></table>';
         echo "</div>\n";
     }
 } else {
     $msg = $string['nothingfound'] . ' "' . $_POST['searchterm'] . '"';
     echo $notice->info_strip($msg, 100);
 }
Exemplo n.º 21
0
//
// Rogō is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Rogō is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rogō.  If not, see <http://www.gnu.org/licenses/>.
/**
*
* Check that a paper name has not already been used elsewhere.
*
* @author Simon Wilkinson
* @version 1.0
* @copyright Copyright (c) 2014 The University of Nottingham
* @package
*/
require '../../include/staff_auth.inc';
require_once '../../include/errors.inc';
require_once '../../classes/paperutils.class.php';
$name = check_var('name', 'POST', true, false, true);
if (Paper_utils::is_paper_title_unique($name, $mysqli)) {
    echo 'unique';
} else {
    echo 'duplicate';
}
Exemplo n.º 22
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;
}
Exemplo n.º 23
0
<body>
<?php 
    echo draw_toprightmenu();
    if ($paper_no > 1) {
        echo displayHead($string);
        echo "<div style=\"margin:16px\">";
        echo "<h1>" . $string['multipleExams'] . "</h1>\n";
        echo "<p>" . $string['selectOne'] . "</p>\n";
    }
    echo "<table cellpadding=\"0\" cellspacing=\"4\" border=\"0\">\n";
    for ($i = 0; $i < $paper_no; $i++) {
        if ($paper_display[$i]['password'] == '') {
            echo "<tr><td width=\"66\" style=\"text-align:right\"><a href=\"user_index.php?id=" . $paper_display[$i]['crypt_name'] . "\">" . Paper_utils::displayIcon($paper_display[$i]['paper_type'], '', '', '', '', '') . "</a></td>\n";
            echo "<td><a href=\"user_index.php?id=" . $paper_display[$i]['crypt_name'] . "\">" . $paper_display[$i]['paper_title'] . "</a>";
        } else {
            echo "<tr><td width=\"66\" style=\"text-align:right\"><a href=\"user_index.php?id=" . $paper_display[$i]['crypt_name'] . "\">" . Paper_utils::displayIcon($paper_display[$i]['paper_type'], '', '', '', '', '') . "</a></td>\n";
            echo "<td><a href=\"user_index.php?id=" . $paper_display[$i]['crypt_name'] . "\">" . $paper_display[$i]['paper_title'] . "</a>";
            echo ' <img src="../artwork/key.png" width="16" height="16" alt="Key" /> <span style="color:#C88607; font-weight:bold; font-size:80%">' . $string['passwordRequired'] . '</span>';
        }
        if ($paper_display[$i]['completed'] == '') {
            echo '<br /><span style="color:#808080; font-size:80%">(' . $paper_display[$i]['max_screen'];
            if ($paper_display[$i]['max_screen'] == 1) {
                echo ' ' . $string['screen'] . ', ';
            } else {
                echo ' ' . $string['screens'] . ', ';
            }
            if ($paper_display[$i]['bidirectional'] == 1) {
                echo $string['Bidirectional'];
            } else {
                echo $string['Unidirectional'];
            }
Exemplo n.º 24
0
    $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");
Exemplo n.º 25
0
if (count($reference_materials) > 0) {
    $css .= "#maincontent {position:fixed; right:" . ($max_ref_width + 1) . "px}\n";
    $css .= ".framecontent {width:" . ($max_ref_width - 12) . "px}\n";
    $css .= ".refhead {width:" . ($max_ref_width - 12) . "px;}\n";
}
if ($css != '') {
    echo "<style type=\"text/css\">\n{$css}\n</style>\n";
}
?>
<script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
<?php 
if ($propertyObj->get_latex_needed() == 1) {
    echo "<script type=\"text/javascript\" src=\"../js/jquery-migrate-1.2.1.min.js\"></script>\n";
    echo "<script type=\"text/javascript\" src=\"../tools/mee/mee/js/mee_src.js\"></script>\n";
}
if (Paper_utils::need_interactiveQ($screen_data, $current_screen, $mysqli)) {
    if ($configObject->get('cfg_interactive_qs') == 'html5') {
        echo "<script type=\"text/javascript\">\nvar lang_string = " . json_encode($jstring) . "\n</script>\n";
        echo "<script type=\"text/javascript\" src=\"../js/html5.images.js\"></script>\n";
        echo "<script type=\"text/javascript\" src=\"../js/qsharedf.js\"></script>\n";
        echo "<script type=\"text/javascript\" src=\"../js/qlabelling.js\"></script>\n";
        echo "<script type=\"text/javascript\" src=\"../js/qhotspot.js\"></script>\n";
        echo "<script type=\"text/javascript\" src=\"../js/qarea.js\"></script>\n";
    } else {
        echo "<script type=\"text/javascript\" src=\"../js/ie_fix.js\"></script>\n";
        echo "<script type=\"text/javascript\" src=\"../js/flash_include.js\"></script>\n";
        echo "<script type=\"text/javascript\" src=\"../js/jquery.flash_q.js\"></script>\n";
    }
}
echo $configObject->get('cfg_js_root');
?>
Exemplo n.º 26
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;
 }
Exemplo n.º 27
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
Exemplo n.º 28
0
  <meta http-equiv="content-type" content="text/html;charset=<?php 
echo $configObject->get('cfg_page_charset');
?>
" />

  <title><?php 
echo $string['createnewpaper'] . $configObject->get('cfg_install_type');
?>
</title>
<?php 
// Delete any half completed papers owned by current user.
$result = $mysqli->prepare("DELETE FROM properties WHERE deleted='0000-00-00 00:00:00' AND paper_ownerID = ?");
$result->bind_param('i', $userObject->get_user_ID());
$result->execute();
// Check that the new paper name is not already used by any other paper (i.e. unique).
$unique = Paper_utils::is_paper_title_unique($_POST['paper_name'], $mysqli);
if (!$unique) {
    ?>
  <link rel="stylesheet" type="text/css" href="../css/body.css" />
  <link rel="stylesheet" type="text/css" href="../css/new_paper.css" />

  <script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
  <script>
    function over(id) {
      if (id != $('#paper_type').val()) {
				$('#' + id).css('background-color', '#FFE7A2');
      }
      switch (id) {
        case 'formative':
          $('#description').html("<?php 
    echo $string['description0'];
Exemplo n.º 29
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')) {