Пример #1
0
function enhancedcalc_remark($paper_type, $paper_id, $q_id, $settings, $db, $mode = 'unmarked')
{
    $status = array(-13 => 0, -12 => 0, -11 => 0, -10 => 0, -9 => 0, -8 => 0, -7 => 0, -6 => 0, -5 => 0, -4 => 0, -3 => 0, -2 => 0, -1 => 0, 0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0);
    $configObject = Config::get_instance();
    $enhancedcalc = new EnhancedCalc($configObject);
    $data['settings'] = $settings;
    $data['q_id'] = $q_id;
    $enhancedcalc->load($data);
    $mode_sql = $mode == 'all' ? '' : ' AND mark IS NULL';
    $result = $db->prepare("SELECT log{$paper_type}.id, user_answer FROM log{$paper_type}, log_metadata WHERE log{$paper_type}.metadataID = log_metadata.id AND q_id = ? AND paperID = ? {$mode_sql}");
    $result->bind_param('ii', $q_id, $paper_id);
    $result->execute();
    $result->store_result();
    $result->bind_result($id, $user_answer);
    while ($result->fetch()) {
        $enhancedcalc->set_useranswer($user_answer);
        $returnarray = $enhancedcalc->calculate_user_mark();
        $status[$returnarray]++;
        if ($returnarray !== Q_MARKING_UNMARKED and $returnarray !== Q_MARKING_ERROR) {
            // Save the extra data back into the log record.
            $sql = "UPDATE log{$paper_type} set mark = ?, adjmark = ?, totalpos = ?, user_answer = ? WHERE id = ? LIMIT 1";
            $storemark = $db->prepare($sql);
            $new_useranswerstring = $enhancedcalc->useranswer_to_string();
            $totalpos = $enhancedcalc->calculate_question_mark();
            $storemark->bind_param('dddsi', $enhancedcalc->qmark, $enhancedcalc->qmark, $totalpos, $new_useranswerstring, $id);
            $storemark->execute();
        }
    }
    $result->close();
    return $status;
}
Пример #2
0
 $tmp_questions_array['notes'] = trim($notes);
 $tmp_questions_array['q_type'] = $q_type;
 $tmp_questions_array['q_id'] = $question_id;
 //the newly inserted question ID!
 $tmp_questions_array['score_method'] = $score_method;
 $tmp_questions_array['status'] = $status;
 $tmp_questions_array['display_method'] = $display_method;
 $tmp_questions_array['settings'] = $settings;
 $tmp_questions_array['q_media'] = $q_media;
 $tmp_questions_array['q_media_width'] = $q_media_width;
 $tmp_questions_array['q_media_height'] = $q_media_height;
 $tmp_questions_array['q_option_order'] = $q_option_order;
 $tmp_questions_array['dismiss'] = '';
 $tmp_questions_array['leadin_plain'] = trim($leadin_plain);
 $tmp_questions_array['standards_setting'] = $std;
 $q = new EnhancedCalc($configObj);
 $q->load($tmp_questions_array);
 $vars = $q->get_question_vars();
 $questionChanged = false;
 foreach ($vars as $var_name => $var_data) {
     $linked_q_id = 0;
     if ($q->is_linked_question_var($var_data['min'])) {
         list($linked_var_name, $linked_q_id) = $q->parse_linked_question_var($var_data['min']);
         if (isset($calculation_qid_map[$linked_q_id])) {
             $vars[$var_name]['min'] = 'var' . $linked_var_name . $calculation_qid_map[$linked_q_id];
             $questionChanged = true;
         }
     }
     if ($q->is_linked_question_var($var_data['max'])) {
         list($linked_var_name, $linked_q_id) = $q->parse_linked_question_var($var_data['max']);
         if (isset($calculation_qid_map[$linked_q_id])) {
Пример #3
0
 /**
  * Save 'calculation' question type to QTI XML
  * @param ST_Question_Calculation $question Reference to the question object
  * @author Adam Clarke, Rob Ingram, Simon Atack
  */
 function SaveEnhancedCalc(&$question)
 {
     if (!isset($configObject)) {
         $configObject = Config::get_instance();
     }
     $cfg_web_root = $configObject->get('cfg_web_root');
     require_once $cfg_web_root . '/plugins/questions/enhancedcalc/enhancedcalc.class.php';
     $enhancedcalc = new EnhancedCalc($configObject);
     $enhancedcalc->load($question);
     // replace all variables in leadin with randomly generated values
     $enhancedcalc->generate_variables();
     $real_answer = $enhancedcalc->get_real_answer();
     $enhancedcalc->add_to_useranswer('uans', $real_answer);
     $uansdata = $enhancedcalc->get_uans_data();
     $question->origleadin = $question->leadin;
     // format the text for the question
     $q_text = $enhancedcalc->replace_leadin(false);
     $question->feedback = $enhancedcalc->replace_vars($question->feedback);
     //echo $q_text."<BR>";
     $question->leadin = $q_text;
     list($headertext, $title) = $this->MakeQuestionHeader($question);
     $type = "Calculation";
     $ob = new OB();
     $ob->ClearAndSave();
     include "qti12/tmpl/enhancedcalc.php";
     $this->output .= $ob->GetContent();
     $ob->Restore();
 }
Пример #4
0
<html>
<?php 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$root = str_replace('/plugins/questions/enhancedcalc/tools', '/', str_replace('\\', '/', dirname(__FILE__)));
include_once $root . 'include/load_config.php';
require $configObject->get('cfg_web_root') . '/plugins/questions/enhancedcalc/enhancedcalc.class.php';
$settings = '{"strictdisplay":"on","strictzeros":true,"dp":"2","tolerance_full":"2","fulltoltyp":"%","tolerance_partial":"5","parttoltyp":"#","marks_partial":"0.5","marks_incorrect":"0","marks_correct":"1","marks_unit":0,"show_units":true,"answers":[{"formula":"$A - $B","units":"mm"},{"formula":"($A - $B)\\/1000","units":"m"}],"vars":{"$A":{"min":"1000","max":"2000","inc":"5","dec":"0"},"$B":{"min":"1000","max":"100000","inc":"5","dec":"0"}}}';
$uans[1] = '{"vars":{"$A":"182.0","$B":"88.0"},"uans":"94.00","uansunit":"mm"}';
$uans[2] = '{"vars":{"$A":"182.0","$B":"88.0"},"uans":"92.00","uansunit":"mm"}';
$uans[3] = '{"vars":{"$A":"182.0","$B":"88.0"},"uans":"90.00","uansunit":"mm"}';
$uans[4] = '{"vars":{"$A":"182.0","$B":"88.0"},"uans":"70.00","uansunit":"mm"}';
//$configObj = new Config();
$q = new EnhancedCalc($configObject);
$q->set_settings($settings);
$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
echo "<h1>Marking 500 User answers</h1>";
$i = 0;
while ($i <= 500) {
    $q->set_useranswer($uans[array_rand($uans)]);
    $q->calculate_user_mark();
    echo "<br/> {$i} ::" . $q->qmark . "<br/>";
    $i++;
}
$mtime = microtime();
$mtime = explode(" ", $mtime);