Конференция "Игры" » Исходник для создания Теста
 
  • Iran_dv © (22.11.08 14:47) [0]
    Здравствуйте, скажите как написать (или есть исходник, то где он находится) программу по созданию теста на Delphi, так чтобы в вопросе постоянно менялись варианты ответов  и всегда был правильный ответ
  • Сергей М. © (22.11.08 18:57) [1]
    И сколько ты готов заплатить за эту "Игру" ?
  • Iran_dv © (23.11.08 10:11) [2]
    А сколько ты хочешь
  • Сергей М. © (24.11.08 16:45) [3]
    Хочу штуку WMZ)
  • AIK © (25.11.08 12:57) [4]
    Предлагаю за 900WMZ + Возможности тестера жульничества, форматирование дисков и с возможностью отправки спамов на почтовые ящики )))
  • Denis__ © (27.11.08 17:47) [5]
    850 WMZ + спам нa LovePlanet, "Мой мир", vkontakte, etc.
  • tButton © (28.12.08 10:51) [6]
    форма

    unit uMain;

    interface

    uses
     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
     StdCtrls, ExtCtrls, Menus, IniFiles;

    type
     TForm1 = class(TForm)
       MainMenu1: TMainMenu;
       Test1: TMenuItem;
       Restart1: TMenuItem;
       Quit1: TMenuItem;
       ListBox1: TListBox;
       Panel2: TPanel;
       Label1: TLabel;
       ListBox2: TListBox;
       procedure ListBox1Click(Sender: TObject);
       procedure FormCreate(Sender: TObject);
     private
       { Private declarations }
       qs: TIniFile;
       order: tStringList;
       current_question: integer;
       procedure AddValue(name: string; value: integer);
       procedure ProcessAnswer(answer: string);
       function GetAnswerText(answer: string): string;
       procedure PrepareQuestions;
       procedure AskQuestion(n: integer);
       procedure ProcessResults;
     public
       { Public declarations }
     end;

    var
     Form1: TForm1;

    implementation

    {$R *.DFM}

    { TForm1 }

    procedure TForm1.AddValue(name: string; value: integer);
    var
     v: integer;
    begin
     v := StrToIntDef(ListBox2.Items.Values[name], 0);
     ListBox2.Items.Values[name] := IntToStr(v + value);
    end;

    procedure TForm1.AskQuestion(n: integer);
    var
     i, j: integer;
    begin
     Label1.Caption := qs.ReadString(order[n], 'question', '???');
     j := qs.ReadInteger(order[n], 'answers', 0);
     ListBox1.Clear;
     if j > 0 then
       for i := 1 to j do
         ListBox1.Items.Add(GetAnswerText(qs.ReadString(order[n], 'answer' + intToStr(i), '???')));
     ListBox1.ItemIndex := -1;
    end;

    function TForm1.GetAnswerText(answer: string): string;
    var
     n: integer;
    begin
     n := Pos('^', answer);
     result := Copy(answer, 1, n - 1);
    end;

    procedure TForm1.PrepareQuestions;
    var
     i, n: integer;
     s: string;
    begin
     if qs = nil
       then qs := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'test.ini');
     if order = nil
       then order := TStringList.Create;
     qs.UpdateFile;
     {order.CommaText}s := qs.ReadString('index', 'questions', '');
     order.CommaText := s;
     n := order.Count;
     if n > 0 then
       for i := 0 to n * 2 do
         order.Exchange(random(n), random(n));
     current_question := 0;
     AskQuestion(current_question);
    end;

    procedure TForm1.ProcessAnswer(answer: string);
    var
     l: TStringList;
     i, n: integer;
    begin
     l := TStringList.Create;
     n := Pos('^', answer);
     l.CommaText := Copy(answer, n + 1, Length(answer));
     n := l.Count - 1;
     for i := 0 to n do begin
       AddValue(l.Names[i], StrToIntDef(l.Values[l.Names[i]], 0));
     end;
    end;

    procedure TForm1.ProcessResults;
    begin
     ShowMessage('Done');
     ListBox2.Clear;
    end;

    procedure TForm1.ListBox1Click(Sender: TObject);
    var
     a: string;
     n: integer;
    begin
     // picking an answer
     n := ListBox1.ItemIndex + 1;
     a := qs.ReadString(order[current_question], 'answer' + IntToStr(n), '^');
     ProcessAnswer(a);
     if current_question < (order.Count - 1)
       then begin
         current_question := current_question + 1;
         AskQuestion(current_question);
         end
       else begin
         ProcessResults;
         PrepareQuestions;
         end;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
     PrepareQuestions;
    end;

    initialization
     Randomize;

    end.



    пример теста(test.ini)

    [index]
    questions = q_1 q_2 q_3 q_4

    [q_1]
    question=You are coming from family of...
    answers=7
    answer1=Forester.^axe=+10 herblore=+10
    answer2=Hunter.^archery=+10 skining=+10
    answer3=Farmer.^herblore=+10 cooking=+5
    answer4=Merchant.^barter=+10 persuation =+10
    answer5=Guardian.^blades=+10 parry=+5 shield=+5
    answer6=Craftsman.^crafting=+10 unarmed=+10
    answer7=I have no family...^persuation=+10 perfomance=+10

    [q_2]
    question=If you have plenty of money you will...
    answers=5
    answer1=buy myself new equipment.^blades=+5 axes=+5 maces=+5 pikes=+5 archery=+5 shield=+5
    answer2=spent them all with my friends in nearest inn.^persuation=+5 intimidation=+5 perfomance=+10
    answer3=will try to gamble and make even more.^gambling=+25
    answer4=will go to neighbord village and by some goods to sell them else where.^barter=+20 persuation=+5
    answer5=have nothing to worry about and finaly can spent some time learning ancient manuscripts.^magery=+5 spellcraft=+5 enchanting=+5 alchemy=+5

    [q_3]
    question=You are walking through the dark forest. Accidently you see campfire behind the trees.
    answers=3
    answer1=I'll go there maybe it's another strangers.^perfomance=+5 persuation=+5 barter=+5
    answer2=I'll sneak there with my weapon ready, it might be dangerous.^stealth=+5 archery=+5 blades=+5
    answer3=I'
    ll continue my way trying to stay as far as possible.^crafting=+5 gambling=+5

    [q_4]
    question=You are going to fight on the duel. Choose your weapon.
    answers=8
    answer1=Sword! Weapon of honor.^blades=+10
    answer2=Axe! I'm going to cut this bustard into two halves!^axes=+10
    answer3=Morning star! I'
    m going to splash his brains all over the place.^maces=+10
    answer4=My hands, and my skill, ohm mane padme hung...^unarmed=+15
    answer5=I'll take bow, most safe and reliable weapon.^archery=+10
    answer6=I'
    ll take the rifle, this new technologies is great thing indeed.^marksmanship=+10
    answer7=I'll crush my opponent with my mystical powers! Muhahahaha!^magery=+5 spellcrafting=+5
    answer8=Do we realy need to fight? To the death?^persuation=+10 perfomance=+5

  • VirusO4eK © (31.12.08 08:20) [7]
    Подойдет?
    http://ifolder.ru/9824871
 
Конференция "Игры" » Исходник для создания Теста
Есть новые Нет новых   [134430   +4][b:0][p:0.004]