Ejemplo n.º 1
0
    }
    $old_marks = $marks_correct;
    if (!empty($option_text) or !empty($correct) and in_array($q_type, array('labelling', 'hotspot', 'area', 'true_false')) or in_array($q_type, array('info', 'likert', 'flash', 'enhancedcalc'))) {
        $options++;
    }
}
$result->close();
if (!$properties->get_summative_lock()) {
    $q_mod_check = array_unique($q_mod_check);
    if (count($q_mod_check) > 0) {
        $q_mod_found = QuestionUtils::multi_get_modules($q_mod_check, $mysqli);
        $paper_modules = Paper_utils::get_modules($paperID, $mysqli);
        foreach ($q_mod_check as $tmp_q_id) {
            foreach ($paper_modules as $p_mod_id => $mod) {
                if (!isset($q_mod_found[$tmp_q_id][$p_mod_id])) {
                    QuestionUtils::add_modules($paper_modules, $tmp_q_id, $mysqli);
                    // Question is not on a module that the paper is assigned to so add.
                    break;
                }
            }
        }
    }
}
if ($row_no > 0) {
    $temp_array[$row_no]['options'] = $options;
    $temp_array[$row_no]['o_media'] = $old_o_media;
    $tmp_exclude = $exclusions->get_exclusions_by_qid($old_q_id);
    // Check for status that's excluded from marking
    $do_marking = ($row_no2 > 0 and !$status_array[$temp_array[$row_no2]['status']]->get_exclude_marking());
    if ($old_q_type == 'random') {
        $temp_array[$row_no2]['original_marks'] = random_qMarks($temp_array[$row_no2]['random']);
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 } 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;