Example #1
0
 function LoadQuestion($q_id)
 {
     global $REPLACEMEuserIDold, $show_debug;
     $userObj = UserObject::get_instance();
     // storage for question data
     $q_row = array();
     $o_rows = array();
     // retrieve question row from database
     $db = new Database();
     $db->SetTable('questions');
     $db->AddField('*');
     $db->AddWhere('q_id', $q_id, 'i');
     $q_row = $db->GetSingleRow();
     // retrieve array of options from database
     $db = new Database();
     $db->SetTable('options');
     $db->AddField('*');
     $db->AddWhere('o_id', $q_id, 'i');
     $db->AddOrder('id_num');
     $o_rows = $db->GetMultiRow();
     // determine q type and create a storage class for correct type
     $q_type = $q_row['q_type'];
     $q_storage = 'ST_Question_' . $q_type;
     $store = new $q_storage();
     $store->type = $q_type;
     // populate base storage fields
     $this->LoadQuestionBase($store, $q_row, $o_rows);
     // populate class specific storage fields
     $funcname = 'LoadQuestion' . $q_type;
     call_user_func(array($this, $funcname), $store, $q_row, $o_rows);
     // display some debug data
     print_p($q_row);
     print_p($o_rows, true, 100);
     // insert track changes record
     if ($show_debug != true) {
         $track = array();
         $track['type'] = "QTI Export";
         $track['typeID'] = $q_row['q_id'];
         $track['editor'] = $userObj->get_user_ID();
         $track['new'] = "Exported to QTI file";
         $track['part'] = "all";
         $track['changed'] = date("Y-m-d H:i:s");
         $db->InsertRow("track_changes", "id", $track);
     }
     // return question
     return $store;
 }