mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
before task parser
This commit is contained in:
@@ -11,6 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt5 COMPONENTS Widgets REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Sql REQUIRED)
|
||||
find_package(Qt5 COMPONENTS LinguistTools REQUIRED)
|
||||
|
||||
add_library(DataBaseLMS SHARED
|
||||
DataBaseLMS_global.h
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.11.1, 2024-11-13T17:15:54. -->
|
||||
<!-- Written by QtCreator 4.11.1, 2024-11-25T15:15:00. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -8,7 +8,7 @@ DataBaseLMS::DataBaseLMS():
|
||||
db(nullptr),
|
||||
transactionBegined(false)
|
||||
{
|
||||
createConnection();
|
||||
|
||||
}
|
||||
|
||||
DataBaseLMS::~DataBaseLMS()
|
||||
@@ -24,12 +24,11 @@ bool DataBaseLMS::createConnection()
|
||||
db->setPassword(dbPassword);
|
||||
if(!db->open())
|
||||
{
|
||||
QMessageBox::critical(nullptr, dbName, "Connection error: " + db->lastError().text());
|
||||
deleteConnection();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(nullptr, dbName, "Connection is successful!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -49,18 +48,34 @@ void DataBaseLMS::deleteConnection()
|
||||
}
|
||||
}
|
||||
|
||||
bool DataBaseLMS::isConnected()
|
||||
{
|
||||
if(db == nullptr)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if(db->isOpen())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBaseLMS::transactionBegin()
|
||||
{
|
||||
/*
|
||||
if(transactionBegined)
|
||||
QSqlDatabase::database().rollback();
|
||||
|
||||
transactionBegined = true;
|
||||
|
||||
return QSqlDatabase::database().transaction();
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataBaseLMS::transactionEnd()
|
||||
{
|
||||
/*
|
||||
if(transactionBegined)
|
||||
{
|
||||
transactionBegined = false;
|
||||
@@ -68,6 +83,8 @@ bool DataBaseLMS::transactionEnd()
|
||||
return QSqlDatabase::database().commit();
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<Instructor> DataBaseLMS::selectAllInstructors()
|
||||
@@ -236,6 +253,27 @@ int DataBaseLMS::selectInstructorID(QString login, QString password)
|
||||
return queryExecInt(queryStr);
|
||||
}
|
||||
|
||||
QString DataBaseLMS::selectInstructorNameByLogin(QString login)
|
||||
{
|
||||
QString queryStr = QString("SELECT instructors.name "
|
||||
"FROM public.instructors "
|
||||
"WHERE instructors.login = '%1' ").arg(
|
||||
login );
|
||||
|
||||
QSqlQuery query = QSqlQuery(*db);
|
||||
|
||||
if(!query.exec(queryStr))
|
||||
{
|
||||
messageWarningErrorQuery(queryStr, &query);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.first())
|
||||
return query.value(0).toString();
|
||||
}
|
||||
return QStringLiteral("");
|
||||
}
|
||||
|
||||
bool DataBaseLMS::selectInstructorIsAdmin(int id_instructor)
|
||||
{
|
||||
QString queryStr = QString("SELECT instructors.is_admin "
|
||||
@@ -251,7 +289,7 @@ bool DataBaseLMS::selectInstructorIsAdmin(int id_instructor)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.next())
|
||||
if(query.first())
|
||||
return query.value(0).toBool();
|
||||
}
|
||||
return false;
|
||||
@@ -272,7 +310,7 @@ bool DataBaseLMS::selectInstructorLoggedIn(int id_instructor)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.next())
|
||||
if(query.first())
|
||||
return query.value(0).toBool();
|
||||
}
|
||||
return false;
|
||||
@@ -293,7 +331,7 @@ bool DataBaseLMS::selectInstructorArchived(int id_instructor)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.next())
|
||||
if(query.first())
|
||||
return query.value(0).toBool();
|
||||
}
|
||||
return false;
|
||||
@@ -311,6 +349,25 @@ int DataBaseLMS::updateInstructorLoggedIn(int id_instructor, bool loggedIn)
|
||||
return queryExecInt(queryStr);
|
||||
}
|
||||
|
||||
bool DataBaseLMS::updateAllInstructorsLoggedIn(bool loggedIn)
|
||||
{
|
||||
QString queryStr = QString("UPDATE public.instructors "
|
||||
"SET logged_in = %1 ").arg(
|
||||
loggedIn ? "true" : "false");
|
||||
|
||||
QSqlQuery query = QSqlQuery(*db);
|
||||
|
||||
if(!query.exec(queryStr))
|
||||
{
|
||||
messageWarningErrorQuery(queryStr, &query);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int DataBaseLMS::updateInstructorArchived(int id_instructor, bool archived)
|
||||
{
|
||||
QString queryStr = QString("UPDATE public.instructors "
|
||||
@@ -560,6 +617,93 @@ int DataBaseLMS::selectTraineeID(QString login, QString password)
|
||||
return queryExecInt(queryStr);
|
||||
}
|
||||
|
||||
QString DataBaseLMS::selectTraineeNameByLogin(QString login)
|
||||
{
|
||||
QString queryStr = QString("SELECT trainees.name "
|
||||
"FROM public.trainees "
|
||||
"WHERE trainees.login = '%1' ").arg(
|
||||
login );
|
||||
|
||||
QSqlQuery query = QSqlQuery(*db);
|
||||
|
||||
if(!query.exec(queryStr))
|
||||
{
|
||||
messageWarningErrorQuery(queryStr, &query);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.first())
|
||||
return query.value(0).toString();
|
||||
}
|
||||
return QStringLiteral("");
|
||||
}
|
||||
|
||||
QString DataBaseLMS::selectTraineeNameOnComputer(QString computer_name)
|
||||
{
|
||||
QString queryStr = QString("SELECT trainees.name "
|
||||
"FROM public.trainees JOIN public.computers ON computers.computer_id = trainees.computer_trainee "
|
||||
"WHERE computers.name = '%1' ").arg(
|
||||
computer_name);
|
||||
|
||||
QSqlQuery query = QSqlQuery(*db);
|
||||
|
||||
if(!query.exec(queryStr))
|
||||
{
|
||||
messageWarningErrorQuery(queryStr, &query);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.first())
|
||||
return query.value(0).toString();
|
||||
}
|
||||
return QStringLiteral("");
|
||||
}
|
||||
|
||||
Trainee DataBaseLMS::selectTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
Trainee trainee;
|
||||
|
||||
QString queryStr = QString("SELECT trainees.trainee_id, trainees.name, trainees.login, trainees.password, trainees.archived, trainees.logged_in, "
|
||||
"groups.group_id, groups.name, "
|
||||
"computers.computer_id, computers.name, computers.ip_address, "
|
||||
"classrooms.classroom_id, classrooms.name "
|
||||
"FROM public.trainees JOIN public.groups ON groups.group_id = trainees.group_trainee "
|
||||
"LEFT OUTER JOIN public.computers ON computers.computer_id = trainees.computer_trainee "
|
||||
"LEFT OUTER JOIN public.classrooms ON classrooms.classroom_id = computers.classroom_computer "
|
||||
"WHERE computers.name = '%1' ").arg(
|
||||
computer_name);
|
||||
|
||||
QSqlQuery query = QSqlQuery(*db);
|
||||
|
||||
if(!query.exec(queryStr))
|
||||
{
|
||||
messageWarningErrorQuery(queryStr, &query);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (query.first())
|
||||
{//Инструктор
|
||||
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.setLoggedIn(query.value(5).toBool());
|
||||
|
||||
Group group = Group(query.value(6).toInt(), query.value(7).toString());
|
||||
trainee.setGroup(group);
|
||||
|
||||
Classroom classroom = Classroom(query.value(11).toInt(), query.value(12).toString());
|
||||
Computer computer = Computer(query.value(8).toInt(), query.value(9).toString(), query.value(10).toString(), classroom);
|
||||
trainee.setComputer(computer);
|
||||
|
||||
trainee.setTasks(selectTasksOfTrainee(trainee.getID()));
|
||||
}
|
||||
}
|
||||
|
||||
return trainee;
|
||||
}
|
||||
|
||||
bool DataBaseLMS::selectTraineeArchived(int id_trainee)
|
||||
{
|
||||
QString queryStr = QString("SELECT trainees.archived "
|
||||
@@ -575,7 +719,7 @@ bool DataBaseLMS::selectTraineeArchived(int id_trainee)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.next())
|
||||
if(query.first())
|
||||
return query.value(0).toBool();
|
||||
}
|
||||
return false;
|
||||
@@ -596,7 +740,7 @@ bool DataBaseLMS::selectTraineeLoggedIn(int id_trainee)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.next())
|
||||
if(query.first())
|
||||
return query.value(0).toBool();
|
||||
}
|
||||
return false;
|
||||
@@ -614,6 +758,25 @@ int DataBaseLMS::updateTraineeLoggedIn(int id_trainee, bool loggedIn)
|
||||
return queryExecInt(queryStr);
|
||||
}
|
||||
|
||||
bool DataBaseLMS::updateAllTraineesLoggedIn(bool loggedIn)
|
||||
{
|
||||
QString queryStr = QString("UPDATE public.trainees "
|
||||
"SET logged_in = %1 ").arg(
|
||||
loggedIn ? "true" : "false");
|
||||
|
||||
QSqlQuery query = QSqlQuery(*db);
|
||||
|
||||
if(!query.exec(queryStr))
|
||||
{
|
||||
messageWarningErrorQuery(queryStr, &query);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int DataBaseLMS::updateTraineeArchived(int id_trainee, bool archived)
|
||||
{
|
||||
QString queryStr = QString("UPDATE public.trainees "
|
||||
@@ -732,24 +895,6 @@ int DataBaseLMS::queryExecInt(QString queryStr)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
bool DataBaseLMS::queryExecBool(QString queryStr)
|
||||
{
|
||||
QSqlQuery query = QSqlQuery(*db);
|
||||
|
||||
if(!query.exec(queryStr))
|
||||
{
|
||||
messageWarningErrorQuery(queryStr, &query);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(query.first())
|
||||
return query.value(0).toBool();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
void DataBaseLMS::messageWarningErrorQuery(QString queryStr, QSqlQuery* query)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ protected:
|
||||
//Подключение
|
||||
bool createConnection();
|
||||
void deleteConnection();
|
||||
bool isConnected();
|
||||
|
||||
//Транзакции
|
||||
bool transactionBegin();
|
||||
@@ -30,10 +31,12 @@ protected:
|
||||
//Инструктор
|
||||
Instructor selectInstructor(int id_instructor);
|
||||
int selectInstructorID(QString login, QString password = QStringLiteral(""));
|
||||
QString selectInstructorNameByLogin(QString login);
|
||||
bool selectInstructorIsAdmin(int id_instructor);
|
||||
bool selectInstructorLoggedIn(int id_instructor);
|
||||
bool selectInstructorArchived(int id_instructor);
|
||||
int updateInstructorLoggedIn(int id_instructor, bool loggedIn);
|
||||
bool updateAllInstructorsLoggedIn(bool loggedIn);
|
||||
int updateInstructorArchived(int id_instructor, bool archived);
|
||||
|
||||
int insertInstructor();
|
||||
@@ -42,22 +45,26 @@ protected:
|
||||
int updateInstructor(Instructor instructor);
|
||||
|
||||
//Группа
|
||||
Group selectGroup(int id_group);//
|
||||
int insertGroup();//
|
||||
Group selectGroup(int id_group);
|
||||
int insertGroup();
|
||||
int insertGroup(Group group);
|
||||
int deleteGroup(int group_id);
|
||||
int updateGroup(Group group);
|
||||
|
||||
//Обучаемый
|
||||
Trainee selectTrainee(int id_trainee);//
|
||||
Trainee selectTrainee(int id_trainee);
|
||||
QList<Trainee> selectAllTraineesInGroup(int id_group);
|
||||
int selectTraineeID(QString login, QString password = QStringLiteral(""));//
|
||||
bool selectTraineeArchived(int id_trainee);//
|
||||
bool selectTraineeLoggedIn(int id_trainee);//
|
||||
int updateTraineeLoggedIn(int id_trainee, bool loggedIn);//
|
||||
int updateTraineeArchived(int id_trainee, bool archived);//
|
||||
int selectTraineeID(QString login, QString password = QStringLiteral(""));
|
||||
QString selectTraineeNameByLogin(QString login);
|
||||
QString selectTraineeNameOnComputer(QString computer_name);
|
||||
Trainee selectTraineeOnComputer(QString computer_name);
|
||||
bool selectTraineeArchived(int id_trainee);
|
||||
bool selectTraineeLoggedIn(int id_trainee);
|
||||
int updateTraineeLoggedIn(int id_trainee, bool loggedIn);
|
||||
bool updateAllTraineesLoggedIn(bool loggedIn);
|
||||
int updateTraineeArchived(int id_trainee, bool archived);
|
||||
|
||||
int insertTrainee(int id_group);//
|
||||
int insertTrainee(int id_group);
|
||||
int insertTrainee(Trainee trainee);
|
||||
int deleteTrainee(int trainee_id);
|
||||
int updateTrainee(Trainee trainee);
|
||||
@@ -66,13 +73,13 @@ protected:
|
||||
|
||||
private:
|
||||
int queryExecInt(QString queryStr);
|
||||
//bool queryExecBool(QString queryStr);
|
||||
void messageWarningErrorQuery(QString queryStr, QSqlQuery* query);
|
||||
|
||||
private:
|
||||
protected:
|
||||
QSqlDatabase* db;
|
||||
bool transactionBegined;
|
||||
const QString dbName = "DataBaseLMS";
|
||||
private:
|
||||
bool transactionBegined;
|
||||
const QString dbUserName = "postgres";
|
||||
const QString dbPassword = "12345678";
|
||||
const QString dbType = "QPSQL";
|
||||
|
||||
@@ -1,12 +1,47 @@
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QSqlError>
|
||||
#include "interfacedatabaselms.h"
|
||||
|
||||
InterfaceDataBaseLMS::InterfaceDataBaseLMS():
|
||||
InterfaceDataBaseLMS::InterfaceDataBaseLMS(QWidget* parent):
|
||||
QWidget(parent),
|
||||
DataBaseLMS()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InterfaceDataBaseLMS::slot_LanguageChanged(QString language)
|
||||
{
|
||||
qtLanguageTranslator.load(QString(QStringLiteral("translations/DataBaseLMS_")) + language, QStringLiteral("."));
|
||||
QCoreApplication::installTranslator(&qtLanguageTranslator);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::ConnectionToDB()
|
||||
{
|
||||
if(!createConnection())
|
||||
{
|
||||
QMessageBox::critical(this, dbName, tr("Connection error: ") + db->lastError().text());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(this, dbName, tr("Connection is successful!"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::DisConnectionFromDB()
|
||||
{
|
||||
deleteConnection();
|
||||
QMessageBox::information(this, dbName, tr("Disconnection is successful!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::DBisConnected()
|
||||
{
|
||||
return isConnected();
|
||||
}
|
||||
|
||||
//Инструкторы
|
||||
|
||||
bool InterfaceDataBaseLMS::AuthorizationInstructor(QString login, QString password)
|
||||
@@ -39,6 +74,16 @@ bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::deAuthorizationAllInstructors()
|
||||
{
|
||||
return updateAllInstructorsLoggedIn(false);
|
||||
}
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameInstructorByLogin(QString login)
|
||||
{
|
||||
return selectInstructorNameByLogin(login);
|
||||
}
|
||||
|
||||
QList<Instructor> InterfaceDataBaseLMS::getListInstructors()
|
||||
{
|
||||
return selectAllInstructors();
|
||||
@@ -67,35 +112,35 @@ int InterfaceDataBaseLMS::editInstructor(Instructor instructor)
|
||||
{
|
||||
if(instructor.getName() == QStringLiteral("<instructor>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(instructor.getLogin() == QStringLiteral("<login>"))
|
||||
{//Логин не корректен!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(instructor.getPassword() == QStringLiteral("<password>"))
|
||||
{//Пароль не корректный!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(instructor.getName() == exist_instructor.getName() && instructor.getID() != exist_instructor.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing instructor name has been entered."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(instructor.getLogin() == exist_instructor.getLogin() && instructor.getID() != exist_instructor.getID())
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing instructor login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
@@ -114,6 +159,11 @@ bool InterfaceDataBaseLMS::isArchivedInstructor(int id)
|
||||
return selectInstructorArchived(id);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isLoggedInInstructor(int id)
|
||||
{
|
||||
return selectInstructorLoggedIn(id);
|
||||
}
|
||||
|
||||
|
||||
//Инструкторы
|
||||
|
||||
@@ -147,6 +197,11 @@ bool InterfaceDataBaseLMS::deAuthorizationTrainee(QString login)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::deAuthorizationAllTrainees()
|
||||
{
|
||||
return updateAllTraineesLoggedIn(false);
|
||||
}
|
||||
|
||||
QList<Task> InterfaceDataBaseLMS::getTasksTrainee(int id)
|
||||
{
|
||||
return selectTasksOfTrainee(id);
|
||||
@@ -154,35 +209,17 @@ QList<Task> InterfaceDataBaseLMS::getTasksTrainee(int id)
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
/*
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getComputer().getName() == computer_name)
|
||||
return trainee.getName();
|
||||
}*/
|
||||
return QString(QStringLiteral(""));
|
||||
return selectTraineeNameOnComputer(computer_name);
|
||||
}
|
||||
|
||||
Trainee InterfaceDataBaseLMS::getTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
/*
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getComputer().getName() == computer_name)
|
||||
return trainee;
|
||||
}*/
|
||||
return Trainee();
|
||||
return selectTraineeOnComputer(computer_name);
|
||||
}
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameTraineeByLogin(QString login)
|
||||
{
|
||||
/*
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getLogin() == login)
|
||||
return trainee.getName();
|
||||
}*/
|
||||
return QString(QStringLiteral(""));
|
||||
return selectTraineeNameByLogin(login);
|
||||
}
|
||||
|
||||
QList<Trainee> InterfaceDataBaseLMS::getListTraineesInGroup(int id)
|
||||
@@ -228,15 +265,15 @@ int InterfaceDataBaseLMS::editGroup(Group group)
|
||||
{
|
||||
if(group.getName() == QStringLiteral("<group>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable group name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
tr("An existing group name has been entered."));
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing group name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -262,35 +299,35 @@ int InterfaceDataBaseLMS::editTrainee(Trainee trainee)
|
||||
{
|
||||
if(trainee.getName() == QStringLiteral("<trainee>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == QStringLiteral("<login>"))
|
||||
{//Логин не корректен!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(trainee.getPassword() == QStringLiteral("<password>"))
|
||||
{//Пароль не корректный!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(trainee.getName() == exist_trainee.getName() && trainee.getID() != exist_trainee.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee name has been entered."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == exist_trainee.getLogin() && trainee.getID() != exist_trainee.getID())
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
@@ -303,3 +340,8 @@ bool InterfaceDataBaseLMS::isArchivedTrainee(int id)
|
||||
{
|
||||
return selectTraineeArchived(id);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isLoggedInTrainee(int id)
|
||||
{
|
||||
return selectTraineeLoggedIn(id);
|
||||
}
|
||||
|
||||
@@ -2,23 +2,35 @@
|
||||
#define INTERFACEDATABASELMS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QTranslator>
|
||||
|
||||
#include "DataBaseLMS_global.h"
|
||||
#include "databaselms.h"
|
||||
|
||||
class DATABASELMS_EXPORT InterfaceDataBaseLMS : public QObject, DataBaseLMS
|
||||
class DATABASELMS_EXPORT InterfaceDataBaseLMS : public /*QObject*/QWidget, DataBaseLMS
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InterfaceDataBaseLMS();
|
||||
InterfaceDataBaseLMS(QWidget* parent = nullptr);
|
||||
|
||||
public Q_SLOTS:
|
||||
void slot_LanguageChanged(QString language);
|
||||
|
||||
public:
|
||||
//Соединение
|
||||
bool ConnectionToDB();
|
||||
bool DisConnectionFromDB();
|
||||
bool DBisConnected();
|
||||
|
||||
//Инструкторы
|
||||
|
||||
bool AuthorizationInstructor(QString login, QString password);
|
||||
bool deAuthorizationInstructor(QString login);
|
||||
bool deAuthorizationAllInstructors();
|
||||
|
||||
QString getNameInstructorByLogin(QString login);
|
||||
|
||||
QList<Instructor> getListInstructors();
|
||||
Instructor getInstructor(int id);
|
||||
@@ -29,12 +41,14 @@ public:
|
||||
|
||||
bool isAdminInstructor(int id);
|
||||
bool isArchivedInstructor(int id);
|
||||
bool isLoggedInInstructor(int id);
|
||||
|
||||
|
||||
//Обучаемые
|
||||
|
||||
bool AuthorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name);
|
||||
bool deAuthorizationTrainee(QString login);
|
||||
bool deAuthorizationAllTrainees();
|
||||
|
||||
//void setTasks(QString login, QStringList tasks);
|
||||
QList<Task> getTasksTrainee(int id);
|
||||
@@ -60,8 +74,10 @@ public:
|
||||
int editTrainee(Trainee trainee);
|
||||
|
||||
bool isArchivedTrainee(int id);
|
||||
bool isLoggedInTrainee(int id);
|
||||
|
||||
|
||||
private:
|
||||
QTranslator qtLanguageTranslator;
|
||||
};
|
||||
|
||||
#endif // INTERFACEDATABASELMS_H
|
||||
|
||||
BIN
DB_LMS/DataBaseLMS/translations/DataBaseLMS_ru_RU.qm
Normal file
BIN
DB_LMS/DataBaseLMS/translations/DataBaseLMS_ru_RU.qm
Normal file
Binary file not shown.
118
DB_LMS/DataBaseLMS/translations/DataBaseLMS_ru_RU.ts
Normal file
118
DB_LMS/DataBaseLMS/translations/DataBaseLMS_ru_RU.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="ru_RU">
|
||||
<context>
|
||||
<name>InterfaceDataBaseLMS</name>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="23"/>
|
||||
<source>Connection error: </source>
|
||||
<translation>Ошибка соединения: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="28"/>
|
||||
<source>Connection is successful!</source>
|
||||
<translation>Соединение успешно!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="36"/>
|
||||
<source>Disconnection is successful!</source>
|
||||
<translation>Отключение успешно!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="109"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="116"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="123"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="130"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="137"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="252"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="259"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="286"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="293"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="300"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="307"/>
|
||||
<location filename="../interfacedatabaselms.cpp" line="314"/>
|
||||
<source>Editing error!</source>
|
||||
<translation>Ошибка редактирования!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="110"/>
|
||||
<source>Unacceptable instructor name has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введено недопустимое имя инструктора.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="117"/>
|
||||
<source>Unacceptable instructor login has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введен недопустимый логин инструктора.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="124"/>
|
||||
<source>Unacceptable instructor password has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введен недопустимый пароль инструктора.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="131"/>
|
||||
<source>An existing instructor name has been entered.</source>
|
||||
<translation>Введено существующее имя инструктора.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="138"/>
|
||||
<source>An existing instructor login has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введен существующий логин инструктора.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="253"/>
|
||||
<source>Unacceptable group name has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введено недопустимое имя группы.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="260"/>
|
||||
<source>An existing group name has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введено существующее имя группы.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="287"/>
|
||||
<source>Unacceptable trainee name has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введено недопустимое имя обучаемого.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="294"/>
|
||||
<source>Unacceptable trainee login has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введен недопустимый логин обучаемого.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="301"/>
|
||||
<source>Unacceptable trainee password has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введен недопустимый пароль обучаемого.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="308"/>
|
||||
<source>An existing trainee name has been entered.</source>
|
||||
<translation>Введено существующее имя обучаемого.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../interfacedatabaselms.cpp" line="315"/>
|
||||
<source>An existing trainee login has been entered.
|
||||
The changes will not be accepted.</source>
|
||||
<translation>Введен существующий логин обучаемого.
|
||||
Изменения не будут приняты.</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
Reference in New Issue
Block a user