Пример #1
0
 public static function repopulate_table()
 {
     $sql = "DELETE FROM `TestTemplate`";
     mysql_query($sql);
     $sql = "SELECT * FROM `TestSection`";
     $z = mysql_query($sql);
     while ($r = mysql_fetch_array($z)) {
         set_time_limit(0);
         if ($r['TestSectionType_id'] == DS_TestSectionType::LOAD_HTML_TEMPLATE) {
             $ts = TestSection::from_mysql_id($r['id']);
             $vals = $ts->get_values();
             $template = Template::from_mysql_id($vals[0]);
             if ($template != null) {
                 $html = Template::output_html($template->HTML, $vals, $template->get_outputs(), $template->get_inserts());
                 $test_template = new TestTemplate();
                 $test_template->Test_id = $r['Test_id'];
                 $test_template->TestSection_id = $r['id'];
                 $test_template->Template_id = $vals[0];
                 $test_template->HTML = $html;
                 $test_template->effect_show = $template->effect_show;
                 $test_template->effect_hide = $template->effect_hide;
                 $test_template->effect_show_options = $template->effect_show_options;
                 $test_template->effect_hide_options = $template->effect_hide_options;
                 $test_template->mysql_save();
             }
         }
     }
 }
 public static function get_mapped_variables($TestSection_id)
 {
     $map = array();
     $ts = TestSection::from_mysql_id($TestSection_id);
     if ($ts == null || $ts->TestSectionType_id != DS_TestSectionType::QTI_INITIALIZATION) {
         return null;
     }
     $vals = $ts->get_values();
     for ($i = 1; $i < count($vals); $i = $i + 2) {
         $map[$vals[$i]] = $vals[$i + 1];
     }
     return $map;
 }
*/
if (!isset($ini)) {
    require_once '../../Ini.php';
    $ini = new Ini();
}
$logged_user = User::get_logged_user();
if ($logged_user == null) {
    echo "<script>location.reload();</script>";
    die(Language::string(278));
}
$vals = array();
if (array_key_exists('value', $_POST)) {
    $vals = $_POST['value'];
}
if (array_key_exists('oid', $_POST) && $_POST['oid'] != 0) {
    $section = TestSection::from_mysql_id($_POST['oid']);
    $vals = $section->get_values();
}
?>
  

<div class="divSectionSummary sortableHandle">
    <table class="fullWidth tableSectionHeader">
        <tr>
            <!--<td class="tdSectionColumnIcon"></td>-->
            <td class="ui-widget-header tdSectionColumnCounter" id="tooltipSectionDetail_<?php 
echo $_POST['counter'];
?>
" title=""><?php 
echo $_POST['counter'];
?>
Пример #4
0
 public static function forward($tid, $sid, $hash, $values, $btn_name, $debug, $time, $resume_from_last_template = false)
 {
     $session = null;
     $result = array();
     if ($sid != null && $hash != null) {
         $session = TestSession::authorized_session($sid, $hash);
         if ($session != null) {
             if ($values == null) {
                 $values = array();
             }
             if ($btn_name != null) {
                 array_push($values, json_encode(array("name" => "LAST_PRESSED_BUTTON_NAME", "value" => $btn_name)));
             }
             if (Ini::$timer_tamper_prevention && $session->time_limit > 0 && $time - $session->time_tamper_prevention - Ini::$timer_tamper_prevention_tolerance > $session->time_limit) {
                 if ($session->debug == 1) {
                     TestSession::unregister($session->id);
                 } else {
                     $session->close();
                 }
                 $result = array("data" => array("HASH" => $hash, "TIME_LIMIT" => 0, "HTML" => "", "TEST_ID" => 0, "TEST_SESSION_ID" => $sid, "STATUS" => TestSession::TEST_SESSION_STATUS_TAMPERED, "TEMPLATE_ID" => 0, "HEAD" => "", "FINISHED" => 1));
                 if ($session->debug == 1) {
                     $result["debug"] = array("code" => 0, "return" => "", "output" => "");
                 }
             } else {
                 if (!$resume_from_last_template) {
                     $result = $session->resume($values);
                 } else {
                     $ts = TestSection::from_mysql_id($session->Template_TestSection_id);
                     if ($ts == null) {
                         $result = $session->resume($values);
                     } else {
                         $result = $session->run_Test($ts->counter, $values);
                     }
                 }
             }
         } else {
             $result = array("data" => array("HASH" => $hash, "TIME_LIMIT" => 0, "HTML" => "", "TEST_ID" => 0, "TEST_SESSION_ID" => $sid, "STATUS" => TestSession::TEST_SESSION_STATUS_TAMPERED, "TEMPLATE_ID" => 0, "HEAD" => "", "FINISHED" => 1), "debug" => array("code" => 0, "return" => "", "output" => ""));
         }
     } else {
         if ($tid != null) {
             if ($debug == 1) {
                 $debug = true;
             } else {
                 $debug = false;
             }
             $session = TestSession::start_new($tid, $debug);
             if ($values == null) {
                 $values = array();
             }
             $test = $session->get_Test();
             if ($test != null) {
                 $values = $test->verified_input_values($values);
             } else {
                 $result = array("data" => array("HASH" => $hash, "TIME_LIMIT" => 0, "HTML" => "", "TEST_ID" => $tid, "TEST_SESSION_ID" => $sid, "STATUS" => TestSession::TEST_SESSION_STATUS_TAMPERED, "TEMPLATE_ID" => 0, "HEAD" => "", "FINISHED" => 1), "debug" => array("code" => 0, "return" => "", "output" => ""));
                 return $result;
             }
             $result = $session->run_test(null, $values);
         }
     }
     return $result;
 }
Пример #5
0
 public function mysql_save_from_post($post)
 {
     $lid = parent::mysql_save_from_post($post);
     $obj = static::from_mysql_id($lid);
     if ($obj != null) {
         $xml_hash = $obj->calculate_xml_hash();
         $obj->xml_hash = $xml_hash;
         $obj->mysql_save();
         $tt = TestTemplate::from_property(array("Template_id" => $lid));
         foreach ($tt as $elem) {
             $ts = TestSection::from_mysql_id($elem->TestSection_id);
             $vals = $ts->get_values();
             $html = Template::output_html($obj->HTML, $vals, $obj->get_outputs(), $obj->get_inserts());
             $elem->HTML = $html;
             $elem->mysql_save();
         }
     }
     return $lid;
 }
 public function get_TestSection()
 {
     return TestSection::from_mysql_id($this->TestSection_id);
 }
Пример #7
0
 public function mysql_save_from_post($post)
 {
     $lid = parent::mysql_save_from_post($post);
     $sections = array();
     if (isset($post['sections'])) {
         $sections = json_decode($post["sections"], true);
     }
     if ($this->id != 0) {
         $this->delete_sections();
         $this->delete_templates();
         $this->delete_object_links(TestVariable::get_mysql_table());
         $i = 0;
     } else {
         $found = false;
         foreach ($sections as $section) {
             if ($section['counter'] == 1) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $start_section = new TestSection();
             $start_section->TestSectionType_id = DS_TestSectionType::START;
             $start_section->Test_id = $lid;
             $start_section->counter = 1;
             $start_section->mysql_save();
         }
         $found = false;
         foreach ($sections as $section) {
             if ($section['counter'] == 2) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $end_section = new TestSection();
             $end_section->TestSectionType_id = DS_TestSectionType::END;
             $end_section->Test_id = $lid;
             $end_section->counter = 2;
             $end_section->mysql_save();
         }
     }
     $i = 0;
     if (array_key_exists("parameters", $post)) {
         foreach ($post["parameters"] as $param) {
             $p = json_decode($param);
             $var = new TestVariable();
             $var->description = $p->description;
             $var->name = $p->name;
             $var->index = $i;
             $var->type = 0;
             $var->Test_id = $lid;
             $var->mysql_save();
             $i++;
         }
     }
     if (array_key_exists("returns", $post)) {
         foreach ($post["returns"] as $ret) {
             $r = json_decode($ret);
             $var = new TestVariable();
             $var->description = $r->description;
             $var->name = $r->name;
             $var->index = $i;
             $var->type = 1;
             $var->Test_id = $lid;
             $var->mysql_save();
             $i++;
         }
     }
     foreach ($sections as $section) {
         $s = new TestSection();
         $s->counter = $section['counter'];
         $s->TestSectionType_id = $section['type'];
         $s->end = $section['end'];
         $s->Test_id = $lid;
         $s->parent_counter = $section['parent'];
         $slid = $s->mysql_save();
         $vals = $section['value'];
         foreach ($vals as $k => $v) {
             $index = substr($k, 1);
             $value = $v;
             $sv = new TestSectionValue();
             $sv->TestSection_id = $slid;
             $sv->index = $index;
             $sv->value = $value;
             $sv->mysql_save();
         }
         if ($s->TestSectionType_id == DS_TestSectionType::LOAD_HTML_TEMPLATE) {
             $ts = TestSection::from_mysql_id($slid);
             $vals = $ts->get_values();
             $template = Template::from_mysql_id($vals[0]);
             if ($template != null) {
                 $html = Template::output_html($template->HTML, $vals, $template->get_outputs(), $template->get_inserts());
                 $test_template = new TestTemplate();
                 $test_template->Test_id = $lid;
                 $test_template->TestSection_id = $slid;
                 $test_template->Template_id = $vals[0];
                 $test_template->HTML = $html;
                 $test_template->mysql_save();
             }
         }
     }
     $sql = sprintf("DELETE FROM `%s` WHERE `Test_id`=%d", TestProtectedVariable::get_mysql_table(), $lid);
     mysql_query($sql);
     if (array_key_exists("protected", $post)) {
         foreach ($post['protected'] as $var) {
             $var = json_decode($var);
             $s = new TestProtectedVariable();
             $s->name = $var->name;
             $s->Test_id = $lid;
             $slid = $s->mysql_save();
         }
     }
     $obj = static::from_mysql_id($lid);
     if ($obj != null) {
         $xml_hash = $obj->calculate_xml_hash();
         $obj->xml_hash = $xml_hash;
         $obj->mysql_save();
     }
     return $lid;
 }