Код программы. Вывод основных уведомлений, страница 7

Label1->Caption = " Тестирование завершено ";

RzBitBtn1->Visible = false;

for (int i = 0; i <= count - 1; i++) {

viewer[i]->Free();

viewert[i]->Free();

check[i]->Free();

}

// Считаем оценку

if (kol_was != 0) {

bl = floor((info.kol_true / info.kol_nado) * 100);

if (bl >= 75) {

info.res_mark_o = 5;

}

if ((bl >= 60) && (bl < 75)) {

info.res_mark_o = 4;

}

if ((bl >= 35) && (bl < 60)) {

info.res_mark_o = 3;

}

if (bl < 35) {

info.res_mark_o = 2;

}

}

else {

info.res_mark_o = 2;

}

Img_q->Free();

Ftest->Hide();

Fresult->Show();

}

}

//--------------------------------------------------------------------------void TFtest::answering()

{

// Отвечаем на вопрос

int n_null = 0;

int count_t_answ = 0;

int cans = 0;

for (int i = 0; i <= count - 1; i++) {

if (!check[i]->Checked) {

cans++;

}

}

if (cans == count) {

Application->MessageBoxA("Необходимо выбрать вариант ответа", "Тестирование", MB_OK + MB_ICONINFORMATION);

return;

}

for (int i = 0; i <= count - 1; i++) {

if (check[i]->Tag == 1) {

n_null++;

}

if ((check[i]->Checked) && (check[i]->Tag == 1)) {

count_t_answ++;

}

}

if (n_null == count_t_answ) {

switch (info.dif_lev) {

case 1: {

info.res_mark += 5;

info.kol_true++;

break;

}

case 2: {

info.res_mark += 10;

info.kol_true++;

break;

}

case 3: {

info.res_mark += 15;

info.kol_true++;

break;

}

default : {

info.kol_true++;

break;

}

}

}

else {

info.f_answ.push_back(testingSh->AsInteger);

info.kol_false++;

}

kol_was++;

if (info.kol_nado == kol_was) {

STOP_ALL();

}

else {

ins_test();

}

}

//--------------------------------------------------------------------------void TFtest::cr_pics()

{

// Заполняем вопрос и варианты ответов

if (sozd == true) {

for (int i = 0; i <= count - 1; i++) {

viewer[i]->Free();

viewert[i]->Free();

check[i]->Free();

}

}

count = 0;

if (sozd == false) {

img = new TJPEGImage;

}

img->Assign(testingTest_q);

Img_q->Picture->Assign(img);

DBGrid1->SelectedIndex = 0;

for (int i =0; i <= 8; i++) {

DBGrid1->SelectedIndex = i;

if (!DBGrid1->SelectedField->IsNull) {

count++;

}

}

int pred = 119;

DBGrid1->SelectedIndex = 0;

for (int i = 0; i <= count - 1; i++) {

DBGrid1->SelectedIndex = i;

viewer[i] = new TJPEGImage;

viewer[i]->Assign(DBGrid1->SelectedField);

viewert[i] = new TImage(this);

viewert[i]->Width = 481;

viewert[i]->Height = 89;

viewert[i]->Left = 1;

viewert[i]->Top = pred + 96;

viewert[i]->Parent = Ftest;

viewert[i]->Picture->Assign(viewer[i]);

check[i] = new TRzCheckBox(this);

check[i]->Parent = Ftest;

check[i]->Width = 41;

check[i]->Height = 17;

check[i]->Left = 488;

check[i]->Top = pred + 96;

check[i]->Caption = "OK";

check[i]->HotTrack = true;

pred = viewert[i]->Top;

}

sozd = true;

}

//--------------------------------------------------------------------------void TFtest::ins_test()

{

// Выбираем  подходящие тесты

randomize();

int dif_lev = info.select_question();

if (dif_lev == 0) {

dif_lev = NULL;

}

testing->Close();

testing->SQL->Clear();

testing->SQL->Add("select * from \"Tests\" where \"Tema\" = "+IntToStr(shablTema->AsInteger)+" and \"Dif_lev\" = "+IntToStr(dif_lev));

testing->Open();

testing->Last();

testing->First();

int povt;

// Выбираем любой из выбранных тестов

L1:      int pos = random(testing->RecordCount + 1);

povt = 0;

if (info.old_quest.size() < testing->RecordCount) {

if (first) {

first = false;

info.old_quest.push_back(pos);

testing->RecNo = pos;

}

else {

for (vector<int>::iterator it = info.old_quest.begin(); it != info.old_quest.end(); it++) {