PSQL 02.11.2024

This commit is contained in:
krivoshein
2024-11-02 13:43:57 +03:00
parent 9422c5e257
commit 0f1fa71c33
76 changed files with 576 additions and 493 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2024-11-01T11:44:20. -->
<!-- Written by QtCreator 4.11.1, 2024-11-02T13:43:21. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@@ -47,7 +47,7 @@ QList<Instructor> DataBaseLMS::selectAllInstructors()
{
QList<Instructor> listInstructors;
QString queryStr = QString("SELECT instructor_id, name, login, password, is_admin, archived "
QString queryStr = QString("SELECT instructor_id, name, login, password, is_admin, archived, logged_in "
"FROM public.instructors "
"ORDER BY instructor_id ASC");
@@ -67,7 +67,7 @@ QList<Instructor> DataBaseLMS::selectAllInstructors()
instructor.setPassword(query.value(3).toString());
instructor.setIsAdmin(query.value(4).toBool());
instructor.setArchived(query.value(5).toBool());
instructor.setLoggedIn(false);
instructor.setLoggedIn(query.value(6).toBool());
listInstructors.append(instructor);
}
@@ -80,9 +80,13 @@ QList<Trainee> DataBaseLMS::selectAllTrainees()
{
QList<Trainee> listTrainees;
QString queryStr = QString("SELECT trainees.trainee_id, trainees.name, trainees.login, trainees.password, trainees.archived, "
"groups_of_trainees.name "
QString queryStr = QString("SELECT trainees.trainee_id, trainees.name, trainees.login, trainees.password, trainees.archived, trainees.logged_in, "
"groups_of_trainees.name, "
"educational_classes.name, "
"computers.name, computers.ip_address "
"FROM public.trainees JOIN public.groups_of_trainees ON groups_of_trainees.group_id = trainees.group_trainees "
"LEFT OUTER JOIN public.computers ON computers.computer_id = trainees.computer "
"LEFT OUTER JOIN public.educational_classes ON educational_classes.class_id = computers.class "
"ORDER BY groups_of_trainees.name ASC");
QSqlQuery query(*db);
@@ -95,16 +99,20 @@ QList<Trainee> DataBaseLMS::selectAllTrainees()
while (query.next())
{//Обучаемый
Trainee trainee;
trainee.setID(query.value(0).toInt());
trainee.setName(query.value(1).toString());
trainee.setLogin(query.value(2).toString());
trainee.setPassword(query.value(3).toString());
trainee.setArchived(query.value(4).toBool());
trainee.setGroup(query.value(5).toString());
trainee.setWhatItDoes(QStringLiteral(""));
trainee.setLoggedIn(false);
trainee.setLearnClass(QStringLiteral(""));
trainee.setComputer(QStringLiteral(""));
trainee.setArchived(query.value(4).toBool());
trainee.setLoggedIn(query.value(5).toBool());
trainee.setGroup(query.value(6).toString());
trainee.setLearnClass(query.value(7).toString());
trainee.setComputer(query.value(8).toString());
trainee.setIpAddress(query.value(9).toString());
trainee.setTasks(selectTasksOfTrainee(trainee.getID()));
listTrainees.append(trainee);
}
@@ -144,13 +152,14 @@ QList<Group> DataBaseLMS::selectAllGroups()
bool DataBaseLMS::insertInstructor(Instructor instructor)
{
QString queryStr = QString("INSERT INTO public.instructors (name, login, password, is_admin, archived) "
"VALUES ('%1', '%2', '%3', %4, %5)").arg(
QString queryStr = QString("INSERT INTO public.instructors (name, login, password, is_admin, archived, logged_in) "
"VALUES ('%1', '%2', '%3', %4, %5, %6)").arg(
instructor.getName(),
instructor.getLogin(),
instructor.getPassword(),
instructor.getIsAdmin() ? "true" : "false",
instructor.getArchived() ? "true" : "false");
instructor.getArchived() ? "true" : "false",
instructor.getLoggedIn() ? "true" : "false");
return queryExec(queryStr);
}
@@ -165,13 +174,14 @@ bool DataBaseLMS::deleteInstructor(int instructor_id)
bool DataBaseLMS::updateInstructor(Instructor instructor)
{
QString queryStr = QString("UPDATE public.instructors "
"SET name = '%1', login = '%2', password = '%3', is_admin = %4, archived = %5 "
"WHERE instructor_id = %6").arg(
"SET name = '%1', login = '%2', password = '%3', is_admin = %4, archived = %5, logged_in = %6 "
"WHERE instructor_id = %7").arg(
instructor.getName(),
instructor.getLogin(),
instructor.getPassword(),
instructor.getIsAdmin() ? "true" : "false",
instructor.getArchived() ? "true" : "false",
instructor.getLoggedIn() ? "true" : "false",
QString::number(instructor.getID()) );
return queryExec(queryStr);
@@ -206,15 +216,18 @@ bool DataBaseLMS::updateGroup(Group group)
bool DataBaseLMS::insertTrainee(Trainee trainee)
{
QString queryStr = QString("INSERT INTO public.trainees (name, login, password, archived, group_trainees) "
"VALUES ('%1', '%2', '%3', %4, "
"(SELECT group_id FROM public.groups_of_trainees WHERE name = '%5') "
QString queryStr = QString("INSERT INTO public.trainees (name, login, password, archived, logged_in, group_trainees, computer) "
"VALUES ('%1', '%2', '%3', %4, %5, "
"(SELECT group_id FROM public.groups_of_trainees WHERE name = '%6'), "
"(SELECT computer_id FROM public.computers WHERE name = '%7') "
")").arg(
trainee.getName(),
trainee.getLogin(),
trainee.getPassword(),
trainee.getArchived() ? "true" : "false",
trainee.getGroup());
trainee.getLoggedIn() ? "true" : "false",
trainee.getGroup(),
trainee.getComputer());
return queryExec(queryStr);
}
@@ -229,19 +242,52 @@ bool DataBaseLMS::deleteTrainee(int trainee_id)
bool DataBaseLMS::updateTrainee(Trainee trainee)
{
QString queryStr = QString("UPDATE public.trainees "
"SET name = '%1', login = '%2', password = '%3', archived = %4, group_trainees = "
"(SELECT group_id FROM public.groups_of_trainees WHERE name = '%5') "
"WHERE trainee_id = %6").arg(
"SET name = '%1', login = '%2', password = '%3', archived = %4, logged_in = %5, "
"group_trainees = "
"(SELECT group_id FROM public.groups_of_trainees WHERE name = '%6'), "
"computer = "
"(SELECT computer_id FROM public.computers WHERE name = '%7') "
"WHERE trainee_id = %8").arg(
trainee.getName(),
trainee.getLogin(),
trainee.getPassword(),
trainee.getArchived() ? "true" : "false",
trainee.getLoggedIn() ? "true" : "false",
trainee.getGroup(),
trainee.getComputer(),
QString::number(trainee.getID()) );
return queryExec(queryStr);
}
QStringList DataBaseLMS::selectTasksOfTrainee(int trainee_id)
{
QStringList tasks;
QString queryStr = QString("SELECT tasks.task_id, tasks.name "
"FROM public.trainees "
"JOIN public.trainee_tasks ON trainee_tasks.trainee_id = trainees.trainee_id "
"JOIN public.tasks ON tasks.task_id = trainee_tasks.task_id "
"WHERE trainees.trainee_id = %1 "
"ORDER BY tasks.name ASC").arg(
trainee_id);
QSqlQuery query(*db);
if(!query.exec(queryStr))
{
messageWarningErrorQuery(queryStr);
}
else
{
while (query.next())
{//Задача
tasks.append(query.value(1).toString());
}
}
return tasks;
}
bool DataBaseLMS::queryExec(QString queryStr)
{
QSqlQuery query(*db);

View File

@@ -35,6 +35,8 @@ public:
bool deleteTrainee(int trainee_id);
bool updateTrainee(Trainee trainee);
QStringList selectTasksOfTrainee(int trainee_id);
private:
bool queryExec(QString queryStr);
void messageWarningErrorQuery(QString queryStr);

View File

@@ -4,13 +4,13 @@ Trainee::Trainee():
trainee_id(),
name(),
login(),
password(),
password(),
archived(false),
loggedIn(false),
group(),
learnClass(),
computer(),
group(),
archived(false),
whatItDoes(),
loggedIn(false)
tasks()
{
}

View File

@@ -2,6 +2,7 @@
#define TRAINEE_H
#include <QString>
#include <QList>
#include "DataBaseLMS_global.h"
class DATABASELMS_EXPORT Trainee
@@ -27,6 +28,9 @@ public:
void setComputer(QString computer){this->computer = computer;}
QString getComputer(){return computer;}
void setIpAddress(QString ipAddress){this->ipAddress = ipAddress;}
QString getIpAddress(){return ipAddress;}
void setGroup(QString group){this->group = group;}
QString getGroup(){return group;}
@@ -36,22 +40,23 @@ public:
void setLoggedIn(bool loggedIn){this->loggedIn = loggedIn;}
bool getLoggedIn(){return loggedIn;}
void setWhatItDoes(QString whatItDoes){this->whatItDoes = whatItDoes;}
QString getWhatItDoes(){return whatItDoes;}
void setTasks(QStringList tasks){this->tasks = tasks;}
QStringList getTasks(){return tasks;}
private:
int trainee_id;
QString name;
QString login;
QString password;
QString password;
bool archived;
bool loggedIn;
QString group;
QString learnClass;
QString computer;
QString group;
bool archived;
QString ipAddress;
QString whatItDoes;
bool loggedIn;
QStringList tasks;
};
#endif // TRAINEE_H

View File

@@ -175,7 +175,7 @@
},
{
"name" : "HELPSTRING",
"value" : "CXX compiler"
"value" : "No help, variable specified on the command line."
}
],
"type" : "STRING",

View File

@@ -35,7 +35,7 @@
}
},
{
"jsonFile" : "cache-v2-87ff728da30d5c1b46b4.json",
"jsonFile" : "cache-v2-8fba00a0d0b5ca55fe65.json",
"kind" : "cache",
"version" :
{
@@ -57,7 +57,7 @@
{
"cache-v2" :
{
"jsonFile" : "cache-v2-87ff728da30d5c1b46b4.json",
"jsonFile" : "cache-v2-8fba00a0d0b5ca55fe65.json",
"kind" : "cache",
"version" :
{

Binary file not shown.

View File

@@ -1,38 +1,40 @@
# ninja log v5
19 65 0 CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
19 65 0 DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
19 65 0 D:/LMS/DB_LMS/Debug64/CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
19 65 0 D:/LMS/DB_LMS/Debug64/DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
73 114 7519953979924905 CMakeFiles/DataBaseLMS.dir/DataBaseLMS_autogen/mocs_compilation.cpp.obj d9dc0a262f9d4ccd
76 2021 7519953998963985 CMakeFiles/DataBaseLMS.dir/databaselms.cpp.obj 202016fcb2dffc59
81 528 7519953984053864 CMakeFiles/DataBaseLMS.dir/trainee.cpp.obj 4ac35fd8ef58e9f
78 530 7519953984073811 CMakeFiles/DataBaseLMS.dir/instructor.cpp.obj fb68571e9d220198
83 659 7519953985360369 CMakeFiles/DataBaseLMS.dir/group.cpp.obj 70fefc8893e4cb77
2022 2151 7519954000271671 libDataBaseLMS.dll ff7ea32bf6d01e45
2022 2151 7519954000271671 libDataBaseLMS.dll.a ff7ea32bf6d01e45
13 38 0 CMakeFiles/clean.additional 7155004b3956b606
38 45 0 clean 9c4b4372737ab8da
11 88 0 CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
11 88 0 DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
11 88 0 D:/LMS/DB_LMS/Debug64/CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
11 88 0 D:/LMS/DB_LMS/Debug64/DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
89 131 7520878398625762 CMakeFiles/DataBaseLMS.dir/DataBaseLMS_autogen/mocs_compilation.cpp.obj d9dc0a262f9d4ccd
96 543 7520878402734775 CMakeFiles/DataBaseLMS.dir/trainee.cpp.obj 4ac35fd8ef58e9f
94 543 7520878402734775 CMakeFiles/DataBaseLMS.dir/instructor.cpp.obj fb68571e9d220198
99 674 7520878404051256 CMakeFiles/DataBaseLMS.dir/group.cpp.obj 70fefc8893e4cb77
91 2052 7520878417814781 CMakeFiles/DataBaseLMS.dir/databaselms.cpp.obj 202016fcb2dffc59
2052 2189 7520878419182806 libDataBaseLMS.dll ff7ea32bf6d01e45
2052 2189 7520878419182806 libDataBaseLMS.dll.a ff7ea32bf6d01e45
22 47 0 CMakeFiles/clean.additional 7155004b3956b606
47 55 0 clean 9c4b4372737ab8da
11 94 0 CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
11 94 0 DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
11 94 0 D:/LMS/DB_LMS/Debug64/CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
11 94 0 D:/LMS/DB_LMS/Debug64/DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
94 551 7521537133322796 CMakeFiles/DataBaseLMS.dir/DataBaseLMS_autogen/mocs_compilation.cpp.obj d9dc0a262f9d4ccd
101 560 7521537133402973 CMakeFiles/DataBaseLMS.dir/trainee.cpp.obj 4ac35fd8ef58e9f
99 560 7521537133402973 CMakeFiles/DataBaseLMS.dir/instructor.cpp.obj fb68571e9d220198
1951 2080 7522348242331840 libDataBaseLMS.dll.a ff7ea32bf6d01e45
1951 2080 7522348242331840 libDataBaseLMS.dll ff7ea32bf6d01e45
22 47 0 CMakeFiles/clean.additional 7155004b3956b606
104 671 7521537134517871 CMakeFiles/DataBaseLMS.dir/group.cpp.obj 70fefc8893e4cb77
96 2083 7521537148634640 CMakeFiles/DataBaseLMS.dir/databaselms.cpp.obj 202016fcb2dffc59
2084 2362 7521537151402412 libDataBaseLMS.dll ff7ea32bf6d01e45
2084 2362 7521537151402412 libDataBaseLMS.dll.a ff7ea32bf6d01e45
99 560 7521537133402973 CMakeFiles/DataBaseLMS.dir/instructor.cpp.obj fb68571e9d220198
53 590 7522403839711265 CMakeFiles/DataBaseLMS.dir/trainee.cpp.obj 4ac35fd8ef58e9f
50 1951 7522348241036252 CMakeFiles/DataBaseLMS.dir/databaselms.cpp.obj 202016fcb2dffc59
94 551 7521537133322796 CMakeFiles/DataBaseLMS.dir/DataBaseLMS_autogen/mocs_compilation.cpp.obj d9dc0a262f9d4ccd
15 50 0 D:/LMS/DB_LMS/Debug64/DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
15 50 0 D:/LMS/DB_LMS/Debug64/CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
15 50 0 DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
15 50 0 CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
15 48 0 CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
15 48 0 DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
15 48 0 D:/LMS/DB_LMS/Debug64/CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
15 48 0 D:/LMS/DB_LMS/Debug64/DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
48 1982 7522404428246470 CMakeFiles/DataBaseLMS.dir/databaselms.cpp.obj 202016fcb2dffc59
1982 2122 7522404429643912 libDataBaseLMS.dll ff7ea32bf6d01e45
1982 2122 7522404429643912 libDataBaseLMS.dll.a ff7ea32bf6d01e45
14 51 0 CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
14 51 0 DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
14 51 0 D:/LMS/DB_LMS/Debug64/CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
14 51 0 D:/LMS/DB_LMS/Debug64/DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
55 602 7522435661437638 CMakeFiles/DataBaseLMS.dir/trainee.cpp.obj 4ac35fd8ef58e9f
52 2052 7522435675931417 CMakeFiles/DataBaseLMS.dir/databaselms.cpp.obj 202016fcb2dffc59
2052 2186 7522435677257822 libDataBaseLMS.dll ff7ea32bf6d01e45
2052 2186 7522435677257822 libDataBaseLMS.dll.a ff7ea32bf6d01e45
15 47 0 CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
15 47 0 DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
15 47 0 D:/LMS/DB_LMS/Debug64/CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
15 47 0 D:/LMS/DB_LMS/Debug64/DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
48 1966 7522449510503097 CMakeFiles/DataBaseLMS.dir/databaselms.cpp.obj 202016fcb2dffc59
1966 2101 7522449511856355 libDataBaseLMS.dll ff7ea32bf6d01e45
1966 2101 7522449511856355 libDataBaseLMS.dll.a ff7ea32bf6d01e45
15 48 0 CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
15 48 0 DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20
15 48 0 D:/LMS/DB_LMS/Debug64/CMakeFiles/DataBaseLMS_autogen b8e538c54fdbce20
15 48 0 D:/LMS/DB_LMS/Debug64/DataBaseLMS_autogen/mocs_compilation.cpp b8e538c54fdbce20

View File

@@ -34,7 +34,7 @@ CMAKE_CODEBLOCKS_EXECUTABLE:FILEPATH=CMAKE_CODEBLOCKS_EXECUTABLE-NOTFOUND
// Enter e.g. -j<some_number> to get parallel builds
CMAKE_CODEBLOCKS_MAKE_ARGUMENTS:STRING=
//CXX compiler
//No help, variable specified on the command line.
CMAKE_CXX_COMPILER:STRING=C:/Qt/Qt5.14.2/Tools/mingw730_64/bin/g++.exe
//A wrapper around 'ar' adding the appropriate '--plugin' option

View File

@@ -1,10 +1,10 @@
# Generated by CMake. Changes will be overwritten.
D:/LMS/DB_LMS/DataBaseLMS/trainee.cpp
D:/LMS/DB_LMS/DataBaseLMS/instructor.cpp
D:/LMS/DB_LMS/DataBaseLMS/group.cpp
D:/LMS/DB_LMS/DataBaseLMS/databaselms.cpp
D:/LMS/DB_LMS/DataBaseLMS/trainee.h
D:/LMS/DB_LMS/DataBaseLMS/instructor.h
D:/LMS/DB_LMS/DataBaseLMS/group.h
D:/LMS/DB_LMS/DataBaseLMS/databaselms.h
D:/LMS/DB_LMS/DataBaseLMS/DataBaseLMS_global.h
D:/LMS/DB_LMS/DataBaseLMS/databaselms.h
D:/LMS/DB_LMS/DataBaseLMS/group.h
D:/LMS/DB_LMS/DataBaseLMS/instructor.h
D:/LMS/DB_LMS/DataBaseLMS/trainee.h
D:/LMS/DB_LMS/DataBaseLMS/databaselms.cpp
D:/LMS/DB_LMS/DataBaseLMS/group.cpp
D:/LMS/DB_LMS/DataBaseLMS/instructor.cpp
D:/LMS/DB_LMS/DataBaseLMS/trainee.cpp

Binary file not shown.

Binary file not shown.