diff --git a/DataBaseLMS/databaselms.cpp b/DataBaseLMS/databaselms.cpp index c8dba2a..1a13da2 100644 --- a/DataBaseLMS/databaselms.cpp +++ b/DataBaseLMS/databaselms.cpp @@ -690,13 +690,48 @@ int DataBaseLMS::updateTaskFIM(TaskAmmFim task) int DataBaseLMS::updateStatusTaskFIM(int task_id, QString status) { - QString queryStr = QString("UPDATE public.tasks_fim SET status = '%1' " + QString queryStr; + bool resBool = false; + int id_trainee = 0; + + resBool = db->transaction(); + + queryStr = QString("SELECT trainees.trainee_id " + "FROM public.trainees JOIN public.tasks_fim ON trainees.trainee_id = tasks_fim.trainee_task " + "WHERE tasks_fim.task_id = %1 " + "ORDER BY trainees.trainee_id ASC").arg( + QString::number(task_id)); + + QSqlQuery query = QSqlQuery(*db); + + if(queryExec(queryStr, &query)) + { + if (query.first()) + {//Обучаемый + id_trainee = query.value(0).toInt(); + } + } + if(!id_trainee) + { + resBool = db->rollback(); + return 0; + } + + queryStr = QString("UPDATE public.tasks_fim SET status = '%1' " "WHERE task_id = %2 " "RETURNING tasks_fim.task_id").arg( status, QString::number(task_id) ); - return queryExecInt(queryStr); + QSqlQuery query1 = QSqlQuery(*db); + if(!queryExec(queryStr, &query1)) + { + resBool = db->rollback(); + return 0; + } + + resBool = db->commit(); + return id_trainee; } int DataBaseLMS::deleteTaskFIM(int id_task) diff --git a/DataBaseLMS/interfacedatabaselms.cpp b/DataBaseLMS/interfacedatabaselms.cpp index 31aee2b..c09b77a 100644 --- a/DataBaseLMS/interfacedatabaselms.cpp +++ b/DataBaseLMS/interfacedatabaselms.cpp @@ -338,11 +338,6 @@ int InterfaceDataBaseLMS::editTaskFIM(TaskAmmFim task) return updateTaskFIM(task); } -int InterfaceDataBaseLMS::editStatusTaskFIM(int task_id, QString status) -{ - return updateStatusTaskFIM(task_id, status); -} - int InterfaceDataBaseLMS::replaceReportFIM(TaskAmmFim task) { deleteReportFIM(task.getID()); @@ -356,6 +351,11 @@ int InterfaceDataBaseLMS::replaceReportFIM(TaskAmmFim task) return 0; } +int InterfaceDataBaseLMS::changeStatusTaskFIM(int id_task, QString status) +{ + return updateStatusTaskFIM(id_task, status); +} + int InterfaceDataBaseLMS::newTrainee(int id_group) { return insertTrainee(id_group); diff --git a/DataBaseLMS/interfacedatabaselms.h b/DataBaseLMS/interfacedatabaselms.h index 6747127..7ddb2b9 100644 --- a/DataBaseLMS/interfacedatabaselms.h +++ b/DataBaseLMS/interfacedatabaselms.h @@ -80,8 +80,8 @@ public: int newTaskFIM(TaskAmmFim task, int id_trainee); int delTaskFIM(int id); int editTaskFIM(TaskAmmFim task); - int editStatusTaskFIM(int task_id, QString status); int replaceReportFIM(TaskAmmFim task); + int changeStatusTaskFIM(int id_task, QString status); int newTrainee(int id_group); int delTrainee(int id); diff --git a/InstructorsAndTrainees/instructors/viewerinstructors.ui b/InstructorsAndTrainees/instructors/viewerinstructors.ui index ff7d7da..e8e12bf 100644 --- a/InstructorsAndTrainees/instructors/viewerinstructors.ui +++ b/InstructorsAndTrainees/instructors/viewerinstructors.ui @@ -40,19 +40,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - diff --git a/InstructorsAndTrainees/tasks/dialogchecktask.cpp b/InstructorsAndTrainees/tasks/dialogchecktask.cpp index 5c26828..92b1f06 100644 --- a/InstructorsAndTrainees/tasks/dialogchecktask.cpp +++ b/InstructorsAndTrainees/tasks/dialogchecktask.cpp @@ -84,6 +84,8 @@ void DialogCheckTask::on_btnWrong_clicked() if(QMessageBox::warning(this, tr("Attention!"), tr("Change task status?\nThe status will be set: 'failed'"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_FIM_TO_TRAINEE, id, (void*)&status); + //this->close(); + this->parentWidget()->close(); } } @@ -95,5 +97,7 @@ void DialogCheckTask::on_btnRight_clicked() if(QMessageBox::warning(this, tr("Attention!"), tr("Change task status?\nThe status will be set: 'completed'"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_FIM_TO_TRAINEE, id, (void*)&status); + //this->close(); + this->parentWidget()->close(); } } diff --git a/InstructorsAndTrainees/trainees/viewertrainees.cpp b/InstructorsAndTrainees/trainees/viewertrainees.cpp index 52f7f1a..d34c51b 100644 --- a/InstructorsAndTrainees/trainees/viewertrainees.cpp +++ b/InstructorsAndTrainees/trainees/viewertrainees.cpp @@ -12,7 +12,7 @@ ViewerTrainees::ViewerTrainees(ConnectorToServer* connectorToServer, QWidget *pa connect(treeWidget, &QTreeWidget::currentItemChanged, this, &ViewerTrainees::on_treeWidget_currentItemChanged); - ui->horizontalLayout_1->addWidget(treeWidget); + ui->horizontalLayout_11->addWidget(treeWidget); ammTasksWidget = new AMMtasksWidget(connectorToServer, AMMtasksWidget::TypeList::listForTrainee, this); fimTasksWidget = new FIMtasksWidget(connectorToServer, FIMtasksWidget::TypeList::listForTrainee, this); diff --git a/InstructorsAndTrainees/trainees/viewertrainees.ui b/InstructorsAndTrainees/trainees/viewertrainees.ui index 122e49d..4c44d3c 100644 --- a/InstructorsAndTrainees/trainees/viewertrainees.ui +++ b/InstructorsAndTrainees/trainees/viewertrainees.ui @@ -36,26 +36,23 @@ - + + + + + + + + + + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - diff --git a/ServerLMS/Systems/Parsers/processparser.cpp b/ServerLMS/Systems/Parsers/processparser.cpp index fc789df..531a88b 100644 --- a/ServerLMS/Systems/Parsers/processparser.cpp +++ b/ServerLMS/Systems/Parsers/processparser.cpp @@ -319,6 +319,7 @@ void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, Trainee trainee; Group group; TaskAmmFim task; + QString status = ""; void* data = nullptr; /*Перебираем все атрибуты тега*/ @@ -402,6 +403,11 @@ void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, //if(name == "title") //task.title = value; break; + + case TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_FIM_TO_TRAINEE: + if(name == "status") + status = value; + break; }; } } @@ -424,6 +430,9 @@ void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, case TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_FIM_TO_TRAINEE: data = &task; break; + case TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_FIM_TO_TRAINEE: + data = &status; + break; }; processingSystem->processingClientQueryToDB(client, queryToDB, id, data); diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index b58234a..631f6a06 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -353,6 +353,23 @@ void ProcessingSystem::processingClientQueryToDB(ClientHandler *client, ClientQu } break; } + + case TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_FIM_TO_TRAINEE: + { + QString* status = (QString*)data; + if(int id_trainee = providerDBLMS->changeStatusTaskFIM(id, *status)) + { + //Отправка списка задач FIM клиенту GUI + sendListTasksFIMofTraineetoClient(client, id_trainee); + + //Отправка списка задач FIM клиенту Юнити + if(ClientHandler* clientUnity = getUnityClientById(id_trainee)) + {//Есть такой + sendListTasksFIMofTraineetoClient(clientUnity, id_trainee); + } + } + break; + } } } diff --git a/ServerLMS/providerdblms.cpp b/ServerLMS/providerdblms.cpp index 64666f3..af9ca84 100644 --- a/ServerLMS/providerdblms.cpp +++ b/ServerLMS/providerdblms.cpp @@ -392,16 +392,16 @@ int ProviderDBLMS::editTaskFIM(TaskAmmFim task) return dbLMS->editTaskFIM(task); } -int ProviderDBLMS::editStatusTaskFIM(int task_id, QString status) -{ - return dbLMS->editStatusTaskFIM(task_id, status); -} - int ProviderDBLMS::replaceReportFIM(TaskAmmFim task) { return dbLMS->replaceReportFIM(task); } +int ProviderDBLMS::changeStatusTaskFIM(int id_task, QString status) +{ + return dbLMS->changeStatusTaskFIM(id_task, status); +} + QList ProviderDBLMS::GetListTasksAMMofTrainee(int id_trainee) { QList listTasks; diff --git a/ServerLMS/providerdblms.h b/ServerLMS/providerdblms.h index 2052616..6d86523 100644 --- a/ServerLMS/providerdblms.h +++ b/ServerLMS/providerdblms.h @@ -56,8 +56,8 @@ public: int newTaskFIM(TaskAmmFim task, int id_trainee); int delTaskFIM(int id); int editTaskFIM(TaskAmmFim task); - int editStatusTaskFIM(int task_id, QString status); int replaceReportFIM(TaskAmmFim task); + int changeStatusTaskFIM(int id_task, QString status); QList GetListTasksAMMofTrainee(int id_trainee); QList GetListTasksFIMofTrainee(int id_trainee);