forked from moevm/gui-1h2017-14
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilm.cpp
44 lines (38 loc) · 871 Bytes
/
film.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "film.h"
Film::Film():QuestCards()
{
type = "films";
}
bool Film::getContent()
{
if (checkUsedSize()){
answerId = getNum();
usedContent.append(answerId);
getRandomAns();
randomId.insert(qrand()%4, answerId);
return true;
}
else
return false;
}
QString Film::getRandomAnsName(int id)
{
QSqlQuery query("SELECT id, name FROM " + type + " WHERE id IS \"" + QString::number(randomId.at(id)) + "\"");
QString id_str;
QString name_str;
while (query.next())
{
id_str = query.value(0).toString();
name_str = query.value(1).toString();
}
return name_str;
}
bool Film::checkUsedSize()
{
QSqlQuery query("SELECT id FROM " + type);
query.last();
N = query.at() + 1;
if (N == usedContent.size())
return false;
return true;
}