2021-10-11 23:37:14 +02:00
|
|
|
|
// swad_project_database.c: projects (final degree projects, thesis), operations with database
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
|
2021-10-11 23:37:14 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
|
|
|
|
#include <stdio.h> // For asprintf
|
2021-10-15 16:46:57 +02:00
|
|
|
|
#include <stdlib.h> // For free
|
2021-10-11 23:37:14 +02:00
|
|
|
|
|
|
|
|
|
#include "swad_database.h"
|
|
|
|
|
#include "swad_error.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_project.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Public constants and types ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-05-03 11:02:06 +02:00
|
|
|
|
/***** Enum field in database for type of rubric *****/
|
2023-05-17 15:28:15 +02:00
|
|
|
|
const char *Prj_DB_RubricType[PrjCfg_NUM_RUBRIC_TYPES] =
|
2023-05-03 11:02:06 +02:00
|
|
|
|
{
|
|
|
|
|
[PrjCfg_RUBRIC_TUT] = "tut",
|
|
|
|
|
[PrjCfg_RUBRIC_EVL] = "evl",
|
|
|
|
|
[PrjCfg_RUBRIC_GBL] = "gbl",
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-11 23:37:14 +02:00
|
|
|
|
/***** Enum field in database for types of proposal *****/
|
2023-05-03 11:02:06 +02:00
|
|
|
|
const char *Prj_DB_Proposal[Prj_NUM_PROPOSAL_TYPES] =
|
2021-10-11 23:37:14 +02:00
|
|
|
|
{
|
|
|
|
|
[Prj_PROPOSAL_NEW ] = "new",
|
|
|
|
|
[Prj_PROPOSAL_MODIFIED ] = "modified",
|
|
|
|
|
[Prj_PROPOSAL_UNMODIFIED] = "unmodified",
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-11 23:30:47 +02:00
|
|
|
|
/***** Enum field in database for review status *****/
|
2023-05-03 11:02:06 +02:00
|
|
|
|
const char *Prj_DB_ReviewStatus[Prj_NUM_REVIEW_STATUS] =
|
2022-10-11 23:30:47 +02:00
|
|
|
|
{
|
|
|
|
|
[Prj_UNREVIEWED] = "unreviewed",
|
|
|
|
|
[Prj_UNAPPROVED] = "unapproved",
|
|
|
|
|
[Prj_APPROVED ] = "approved",
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-11 23:37:14 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Lock project edition ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_LockProjectEdition (long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryUPDATE ("can not lock project edition",
|
|
|
|
|
"UPDATE prj_projects"
|
|
|
|
|
" SET Locked='Y'"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld",
|
|
|
|
|
PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Unlock project edition ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_UnlockProjectEdition (long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryUPDATE ("can not lock project edition",
|
|
|
|
|
"UPDATE prj_projects"
|
|
|
|
|
" SET Locked='N'"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
|
|
|
|
PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Create a new project *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
long Prj_DB_CreateProject (const struct Prj_Project *Prj)
|
|
|
|
|
{
|
2023-09-11 17:41:31 +02:00
|
|
|
|
extern const char HidVis_YN[HidVis_NUM_HIDDEN_VISIBLE];
|
|
|
|
|
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return
|
|
|
|
|
DB_QueryINSERTandReturnCode ("can not create new project",
|
|
|
|
|
"INSERT INTO prj_projects"
|
|
|
|
|
" (CrsCod,DptCod,Hidden,Assigned,NumStds,Proposal,"
|
|
|
|
|
"CreatTime,ModifTime,"
|
2022-10-11 23:30:47 +02:00
|
|
|
|
"Title,Description,Knowledge,Materials,URL,"
|
|
|
|
|
"ReviewStatus,ReviewTime,ReviewTxt)"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%ld,'%c','%c',%u,'%s',"
|
|
|
|
|
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
2022-10-11 23:30:47 +02:00
|
|
|
|
"'%s','%s','%s','%s','%s',"
|
|
|
|
|
"'%s',FROM_UNIXTIME(%ld),'%s')",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
Prj->DptCod,
|
2023-09-11 17:41:31 +02:00
|
|
|
|
HidVis_YN[Prj->Hidden],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
Prj->Assigned == Prj_ASSIGNED ? 'Y' :
|
|
|
|
|
'N',
|
|
|
|
|
Prj->NumStds,
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_Proposal[Prj->Proposal],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
Prj->CreatTime,
|
|
|
|
|
Prj->ModifTime,
|
|
|
|
|
Prj->Title,
|
|
|
|
|
Prj->Description,
|
|
|
|
|
Prj->Knowledge,
|
|
|
|
|
Prj->Materials,
|
2022-10-11 23:30:47 +02:00
|
|
|
|
Prj->URL,
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj->Review.Status],
|
2022-10-12 16:50:18 +02:00
|
|
|
|
Prj->Review.Time,
|
|
|
|
|
Prj->Review.Txt);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Update an existing project **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_UpdateProject (const struct Prj_Project *Prj)
|
|
|
|
|
{
|
2023-09-11 17:41:31 +02:00
|
|
|
|
extern const char HidVis_YN[HidVis_NUM_HIDDEN_VISIBLE];
|
|
|
|
|
|
2021-10-11 23:37:14 +02:00
|
|
|
|
DB_QueryUPDATE ("can not update project",
|
|
|
|
|
"UPDATE prj_projects"
|
|
|
|
|
" SET DptCod=%ld,"
|
|
|
|
|
"Hidden='%c',"
|
|
|
|
|
"Assigned='%c',"
|
|
|
|
|
"NumStds=%u,"
|
|
|
|
|
"Proposal='%s',"
|
|
|
|
|
"ModifTime=FROM_UNIXTIME(%ld),"
|
|
|
|
|
"Title='%s',"
|
|
|
|
|
"Description='%s',"
|
|
|
|
|
"Knowledge='%s',"
|
|
|
|
|
"Materials='%s',"
|
|
|
|
|
"URL='%s'"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
|
|
|
|
Prj->DptCod,
|
2023-09-11 17:41:31 +02:00
|
|
|
|
HidVis_YN[Prj->Hidden],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
Prj->Assigned == Prj_ASSIGNED ? 'Y' :
|
|
|
|
|
'N',
|
|
|
|
|
Prj->NumStds,
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_Proposal[Prj->Proposal],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
Prj->ModifTime,
|
|
|
|
|
Prj->Title,
|
|
|
|
|
Prj->Description,
|
|
|
|
|
Prj->Knowledge,
|
|
|
|
|
Prj->Materials,
|
|
|
|
|
Prj->URL,
|
|
|
|
|
Prj->PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Add user to project **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_AddUsrToPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryREPLACE ("can not add user to project",
|
|
|
|
|
"REPLACE INTO prj_users"
|
|
|
|
|
" (PrjCod,RoleInProject,UsrCod)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%u,%ld)",
|
|
|
|
|
PrjCod,
|
|
|
|
|
(unsigned) RoleInProject,
|
|
|
|
|
UsrCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Hide a project *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-09-10 15:20:25 +02:00
|
|
|
|
void Prj_DB_HideOrUnhideProject (long PrjCod,
|
|
|
|
|
HidVis_HiddenOrVisible_t HiddenOrVisible)
|
2021-10-11 23:37:14 +02:00
|
|
|
|
{
|
2023-09-11 17:41:31 +02:00
|
|
|
|
extern const char HidVis_YN[HidVis_NUM_HIDDEN_VISIBLE];
|
|
|
|
|
|
2021-10-24 16:55:47 +02:00
|
|
|
|
DB_QueryUPDATE ("can not hide/unhide project",
|
2021-10-11 23:37:14 +02:00
|
|
|
|
"UPDATE prj_projects"
|
|
|
|
|
" SET Hidden='%c'"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
2023-09-11 17:41:31 +02:00
|
|
|
|
HidVis_YN[HiddenOrVisible],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-13 16:49:55 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Update review of an existing project ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_UpdateReview (const struct Prj_Project *Prj)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryUPDATE ("can not update project review",
|
|
|
|
|
"UPDATE prj_projects"
|
|
|
|
|
" SET ReviewStatus='%s',"
|
|
|
|
|
"ReviewTime=NOW(),"
|
|
|
|
|
"ReviewTxt='%s'"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj->Review.Status],
|
2022-10-13 16:49:55 +02:00
|
|
|
|
Prj->Review.Txt,
|
|
|
|
|
Prj->PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2022-10-13 16:49:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 23:37:14 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Get projects *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Prj_DB_GetListProjects (MYSQL_RES **mysql_res,
|
|
|
|
|
const struct Prj_Projects *Projects,
|
|
|
|
|
const char *UsrsSubQuery) // NULL if no users
|
|
|
|
|
{
|
2024-07-15 14:37:03 +02:00
|
|
|
|
/* Role in project subquery */
|
|
|
|
|
static const char *RolPrjSubQuery[16] = // EVL TUT STD UNK
|
|
|
|
|
{ // 3 2 1 0
|
|
|
|
|
[0b0000] = "", // <20> <20> <20> <20>
|
|
|
|
|
[0b0001] = " AND (" "prj_users.RoleInProject IS NULL)", // <20> <20> <20> 1
|
|
|
|
|
[0b0010] = " AND (prj_users.RoleInProject IN " "(1)" ")", // <20> <20> 1 <20>
|
|
|
|
|
[0b0011] = " AND (prj_users.RoleInProject IN " "(1)" " OR prj_users.RoleInProject IS NULL)", // <20> <20> 1 1
|
|
|
|
|
[0b0100] = " AND (prj_users.RoleInProject IN " "(2)" ")", // <20> 1 <20> <20>
|
|
|
|
|
[0b0101] = " AND (prj_users.RoleInProject IN " "(2)" " OR prj_users.RoleInProject IS NULL)", // <20> 1 <20> 1
|
|
|
|
|
[0b0110] = " AND (prj_users.RoleInProject IN " "(1,2)" ")", // <20> 1 1 <20>
|
|
|
|
|
[0b0111] = " AND (prj_users.RoleInProject IN " "(1,2)" " OR prj_users.RoleInProject IS NULL)", // <20> 1 1 1
|
|
|
|
|
[0b1000] = " AND (prj_users.RoleInProject IN " "(3)" ")", // 1 <20> <20> <20>
|
|
|
|
|
[0b1001] = " AND (prj_users.RoleInProject IN " "(3)" " OR prj_users.RoleInProject IS NULL)", // 1 <20> <20> 1
|
|
|
|
|
[0b1010] = " AND (prj_users.RoleInProject IN " "(1,""3)" ")", // 1 <20> 1 <20>
|
|
|
|
|
[0b1011] = " AND (prj_users.RoleInProject IN " "(1,""3)" " OR prj_users.RoleInProject IS NULL)", // 1 <20> 1 1
|
|
|
|
|
[0b1100] = " AND (prj_users.RoleInProject IN " "(2,3)" ")", // 1 1 <20> <20>
|
|
|
|
|
[0b1101] = " AND (prj_users.RoleInProject IN " "(2,3)" " OR prj_users.RoleInProject IS NULL)", // 1 1 <20> 1
|
|
|
|
|
[0b1110] = " AND (prj_users.RoleInProject IN " "(1,2,3)" ")", // 1 1 1 <20>
|
|
|
|
|
[0b1111] = "", // 1 1 1 1
|
|
|
|
|
};
|
2021-10-11 23:37:14 +02:00
|
|
|
|
char *AssignSubQuery;
|
|
|
|
|
char *HidVisSubQuery;
|
2022-10-17 10:47:15 +02:00
|
|
|
|
char *ReviewSubQuery;
|
2021-10-11 23:37:14 +02:00
|
|
|
|
char *DptCodSubQuery;
|
|
|
|
|
static const char *OrderBySubQuery[Prj_NUM_ORDERS] =
|
|
|
|
|
{
|
|
|
|
|
[Prj_ORDER_START_TIME] = "prj_projects.CreatTime DESC,"
|
|
|
|
|
"prj_projects.ModifTime DESC,"
|
|
|
|
|
"prj_projects.Title",
|
|
|
|
|
[Prj_ORDER_END_TIME ] = "prj_projects.ModifTime DESC,"
|
|
|
|
|
"prj_projects.CreatTime DESC,"
|
|
|
|
|
"prj_projects.Title",
|
|
|
|
|
[Prj_ORDER_TITLE ] = "prj_projects.Title,"
|
|
|
|
|
"prj_projects.CreatTime DESC,"
|
|
|
|
|
"prj_projects.ModifTime DESC",
|
|
|
|
|
[Prj_ORDER_DEPARTMENT] = "dpt_departments.FullName,"
|
|
|
|
|
"prj_projects.CreatTime DESC,"
|
|
|
|
|
"prj_projects.ModifTime DESC,"
|
|
|
|
|
"prj_projects.Title",
|
|
|
|
|
};
|
|
|
|
|
unsigned NumPrjsFromDB = 0;
|
|
|
|
|
|
|
|
|
|
/* Assigned subquery */
|
|
|
|
|
switch (Projects->Filter.Assign)
|
|
|
|
|
{
|
|
|
|
|
case (1 << Prj_NONASSIG): // Non-assigned projects
|
|
|
|
|
if (asprintf (&AssignSubQuery," AND prj_projects.Assigned='N'") < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
2024-07-15 14:37:03 +02:00
|
|
|
|
case (1 << Prj_ASSIGNED): // Assigned projects
|
|
|
|
|
if (asprintf (&AssignSubQuery," AND prj_projects.Assigned='Y'") < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
2021-10-11 23:37:14 +02:00
|
|
|
|
default: // All projects
|
|
|
|
|
if (asprintf (&AssignSubQuery,"%s","") < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Hidden subquery */
|
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
|
|
|
|
{
|
|
|
|
|
case Rol_STD: // Students can view only visible projects
|
|
|
|
|
if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='N'") < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_SYS_ADM:
|
|
|
|
|
switch (Projects->Filter.Hidden)
|
|
|
|
|
{
|
2023-09-10 16:55:23 +02:00
|
|
|
|
case (1 << HidVis_HIDDEN): // Hidden projects
|
2021-10-11 23:37:14 +02:00
|
|
|
|
if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='Y'") < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
2023-09-10 16:55:23 +02:00
|
|
|
|
case (1 << HidVis_VISIBLE): // Visible projects
|
2021-10-11 23:37:14 +02:00
|
|
|
|
if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='N'") < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
|
|
|
|
default: // All projects
|
|
|
|
|
if (asprintf (&HidVisSubQuery,"%s","") < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongRoleExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-11 21:36:37 +02:00
|
|
|
|
/* Review status subquery */
|
|
|
|
|
switch (Projects->Filter.Review)
|
|
|
|
|
{
|
|
|
|
|
case (1 << Prj_UNREVIEWED): // Unreviewed projects
|
2022-10-17 10:47:15 +02:00
|
|
|
|
if (asprintf (&ReviewSubQuery," AND prj_projects.ReviewStatus='%s'",
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj_UNREVIEWED]) < 0)
|
2022-10-11 21:36:37 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
|
|
|
|
case (1 << Prj_UNAPPROVED): // Unapproved projects
|
2022-10-17 10:47:15 +02:00
|
|
|
|
if (asprintf (&ReviewSubQuery," AND prj_projects.ReviewStatus='%s'",
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj_UNAPPROVED]) < 0)
|
2022-10-11 21:36:37 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
|
|
|
|
case (1 << Prj_APPROVED): // Approved projects
|
2022-10-17 10:47:15 +02:00
|
|
|
|
if (asprintf (&ReviewSubQuery," AND prj_projects.ReviewStatus='%s'",
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj_APPROVED ]) < 0)
|
2022-10-11 21:36:37 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
2022-10-11 23:30:47 +02:00
|
|
|
|
case (1 << Prj_UNREVIEWED |
|
|
|
|
|
1 << Prj_UNAPPROVED): // Unreviewed and unapproved projects
|
2022-10-17 10:47:15 +02:00
|
|
|
|
if (asprintf (&ReviewSubQuery," AND prj_projects.ReviewStatus IN ('%s','%s')",
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj_UNREVIEWED],
|
|
|
|
|
Prj_DB_ReviewStatus[Prj_UNAPPROVED]) < 0)
|
2022-10-11 21:36:37 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
2022-10-11 23:30:47 +02:00
|
|
|
|
case (1 << Prj_UNREVIEWED |
|
|
|
|
|
1 << Prj_APPROVED): // Unreviewed and approved projects
|
2022-10-17 10:47:15 +02:00
|
|
|
|
if (asprintf (&ReviewSubQuery," AND prj_projects.ReviewStatus IN ('%s','%s')",
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj_UNREVIEWED],
|
|
|
|
|
Prj_DB_ReviewStatus[Prj_APPROVED ]) < 0)
|
2022-10-11 21:36:37 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
2022-10-11 23:30:47 +02:00
|
|
|
|
case (1 << Prj_UNAPPROVED |
|
|
|
|
|
1 << Prj_APPROVED): // Unapproved and approved projects
|
2022-10-17 10:47:15 +02:00
|
|
|
|
if (asprintf (&ReviewSubQuery," AND prj_projects.ReviewStatus IN ('%s','%s')",
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj_UNAPPROVED],
|
|
|
|
|
Prj_DB_ReviewStatus[Prj_APPROVED ]) < 0)
|
2022-10-11 21:36:37 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
2022-10-11 23:30:47 +02:00
|
|
|
|
default: // All projects
|
2022-10-17 10:47:15 +02:00
|
|
|
|
if (asprintf (&ReviewSubQuery,"%s","") < 0)
|
2022-10-11 21:36:37 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 23:37:14 +02:00
|
|
|
|
/* Department subquery */
|
|
|
|
|
if (Projects->Filter.DptCod >= 0)
|
|
|
|
|
{
|
|
|
|
|
if (asprintf (&DptCodSubQuery," AND prj_projects.DptCod=%ld",
|
|
|
|
|
Projects->Filter.DptCod) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
|
|
|
|
else // Any department
|
|
|
|
|
{
|
|
|
|
|
if (asprintf (&DptCodSubQuery,"%s","") < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Query */
|
|
|
|
|
switch (Projects->Filter.Who)
|
|
|
|
|
{
|
|
|
|
|
case Usr_WHO_ME:
|
|
|
|
|
/* Get list of projects */
|
|
|
|
|
switch (Projects->SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
case Prj_ORDER_START_TIME:
|
|
|
|
|
case Prj_ORDER_END_TIME:
|
|
|
|
|
case Prj_ORDER_TITLE:
|
|
|
|
|
NumPrjsFromDB = (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get projects",
|
|
|
|
|
"SELECT prj_projects.PrjCod"
|
|
|
|
|
" FROM prj_projects,"
|
|
|
|
|
"prj_users"
|
|
|
|
|
" WHERE prj_projects.CrsCod=%ld"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
2022-10-17 10:47:15 +02:00
|
|
|
|
"%s"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" AND prj_projects.PrjCod=prj_users.PrjCod"
|
|
|
|
|
" AND prj_users.UsrCod=%ld"
|
2024-07-15 14:37:03 +02:00
|
|
|
|
"%s"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
" GROUP BY prj_projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
|
|
|
|
" ORDER BY %s",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
AssignSubQuery,
|
|
|
|
|
HidVisSubQuery,
|
2022-10-17 10:47:15 +02:00
|
|
|
|
ReviewSubQuery,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
DptCodSubQuery,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
2024-07-15 14:37:03 +02:00
|
|
|
|
RolPrjSubQuery[Projects->Filter.RolPrj],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
OrderBySubQuery[Projects->SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
case Prj_ORDER_DEPARTMENT:
|
|
|
|
|
NumPrjsFromDB = (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get projects",
|
|
|
|
|
"SELECT prj_projects.PrjCod"
|
2022-01-02 15:17:30 +01:00
|
|
|
|
" FROM prj_projects LEFT JOIN dpt_departments"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" ON prj_projects.DptCod=dpt_departments.DptCod"
|
2022-01-02 15:17:30 +01:00
|
|
|
|
" LEFT JOIN prj_users"
|
|
|
|
|
" ON prj_projects.PrjCod=prj_users.PrjCod"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" WHERE prj_projects.CrsCod=%ld"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
2022-10-17 10:47:15 +02:00
|
|
|
|
"%s"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" AND prj_projects.PrjCod=prj_users.PrjCod"
|
|
|
|
|
" AND prj_users.UsrCod=%ld"
|
2024-07-15 14:37:03 +02:00
|
|
|
|
"%s"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
" GROUP BY prj_projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
|
|
|
|
" ORDER BY %s",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
AssignSubQuery,
|
|
|
|
|
HidVisSubQuery,
|
2022-10-17 10:47:15 +02:00
|
|
|
|
ReviewSubQuery,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
DptCodSubQuery,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
2024-07-15 14:37:03 +02:00
|
|
|
|
RolPrjSubQuery[Projects->Filter.RolPrj],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
OrderBySubQuery[Projects->SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Usr_WHO_SELECTED:
|
|
|
|
|
if (UsrsSubQuery)
|
|
|
|
|
{
|
|
|
|
|
/* Get list of projects */
|
|
|
|
|
switch (Projects->SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
case Prj_ORDER_START_TIME:
|
|
|
|
|
case Prj_ORDER_END_TIME:
|
|
|
|
|
case Prj_ORDER_TITLE:
|
|
|
|
|
NumPrjsFromDB = (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get projects",
|
|
|
|
|
"SELECT prj_projects.PrjCod"
|
|
|
|
|
" FROM prj_projects,"
|
|
|
|
|
"prj_users"
|
|
|
|
|
" WHERE prj_projects.CrsCod=%ld"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
2022-10-17 10:47:15 +02:00
|
|
|
|
"%s"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" AND prj_projects.PrjCod=prj_users.PrjCod"
|
|
|
|
|
" AND prj_users.UsrCod IN (%s)"
|
2024-07-15 14:37:03 +02:00
|
|
|
|
"%s"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
" GROUP BY prj_projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
|
|
|
|
" ORDER BY %s",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
AssignSubQuery,
|
|
|
|
|
HidVisSubQuery,
|
2022-10-17 10:47:15 +02:00
|
|
|
|
ReviewSubQuery,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
DptCodSubQuery,
|
|
|
|
|
UsrsSubQuery,
|
2024-07-15 14:37:03 +02:00
|
|
|
|
RolPrjSubQuery[Projects->Filter.RolPrj],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
OrderBySubQuery[Projects->SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
case Prj_ORDER_DEPARTMENT:
|
|
|
|
|
NumPrjsFromDB = (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get projects",
|
|
|
|
|
"SELECT prj_projects.PrjCod"
|
2022-01-02 15:17:30 +01:00
|
|
|
|
" FROM prj_projects LEFT JOIN dpt_departments"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" ON prj_projects.DptCod=dpt_departments.DptCod"
|
2022-01-02 15:17:30 +01:00
|
|
|
|
" LEFT JOIN prj_users"
|
|
|
|
|
" ON prj_projects.PrjCod=prj_users.PrjCod"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" WHERE prj_projects.CrsCod=%ld"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" AND prj_projects.PrjCod=prj_users.PrjCod"
|
|
|
|
|
" AND prj_users.UsrCod IN (%s)"
|
2024-07-15 14:37:03 +02:00
|
|
|
|
"%s"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
" GROUP BY prj_projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
|
|
|
|
" ORDER BY %s",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
AssignSubQuery,
|
|
|
|
|
HidVisSubQuery,
|
2022-10-17 10:47:15 +02:00
|
|
|
|
ReviewSubQuery,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
DptCodSubQuery,
|
|
|
|
|
UsrsSubQuery,
|
2024-07-15 14:37:03 +02:00
|
|
|
|
RolPrjSubQuery[Projects->Filter.RolPrj],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
OrderBySubQuery[Projects->SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Usr_WHO_ALL:
|
|
|
|
|
/* Get list of projects */
|
|
|
|
|
switch (Projects->SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
case Prj_ORDER_START_TIME:
|
|
|
|
|
case Prj_ORDER_END_TIME:
|
|
|
|
|
case Prj_ORDER_TITLE:
|
|
|
|
|
NumPrjsFromDB = (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get projects",
|
|
|
|
|
"SELECT prj_projects.PrjCod"
|
2024-07-15 14:37:03 +02:00
|
|
|
|
" FROM prj_projects LEFT JOIN prj_users"
|
|
|
|
|
" ON prj_projects.PrjCod=prj_users.PrjCod"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" WHERE prj_projects.CrsCod=%ld"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
2024-07-15 14:37:03 +02:00
|
|
|
|
"%s"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
" ORDER BY %s",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
AssignSubQuery,
|
|
|
|
|
HidVisSubQuery,
|
2022-10-17 10:47:15 +02:00
|
|
|
|
ReviewSubQuery,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
DptCodSubQuery,
|
2024-07-15 14:37:03 +02:00
|
|
|
|
RolPrjSubQuery[Projects->Filter.RolPrj],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
OrderBySubQuery[Projects->SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
case Prj_ORDER_DEPARTMENT:
|
|
|
|
|
NumPrjsFromDB = (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get projects",
|
|
|
|
|
"SELECT prj_projects.PrjCod"
|
|
|
|
|
" FROM prj_projects LEFT JOIN dpt_departments"
|
|
|
|
|
" ON prj_projects.DptCod=dpt_departments.DptCod"
|
2024-07-15 14:37:03 +02:00
|
|
|
|
" LEFT JOIN prj_users"
|
|
|
|
|
" ON prj_projects.PrjCod=prj_users.PrjCod"
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" WHERE prj_projects.CrsCod=%ld"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
|
|
|
|
"%s"
|
2024-07-15 14:37:03 +02:00
|
|
|
|
"%s"
|
2023-03-03 00:28:27 +01:00
|
|
|
|
" ORDER BY %s",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
AssignSubQuery,
|
|
|
|
|
HidVisSubQuery,
|
2022-10-17 10:47:15 +02:00
|
|
|
|
ReviewSubQuery,
|
2021-10-11 23:37:14 +02:00
|
|
|
|
DptCodSubQuery,
|
2024-07-15 14:37:03 +02:00
|
|
|
|
RolPrjSubQuery[Projects->Filter.RolPrj],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
OrderBySubQuery[Projects->SelectedOrder]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongWhoExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free allocated memory for subqueries */
|
|
|
|
|
free (DptCodSubQuery);
|
2022-10-17 10:47:15 +02:00
|
|
|
|
free (ReviewSubQuery);
|
|
|
|
|
free (HidVisSubQuery);
|
|
|
|
|
free (AssignSubQuery);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
|
|
|
|
|
return NumPrjsFromDB;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get project data using its code ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-23 09:35:20 +01:00
|
|
|
|
unsigned Prj_DB_GetProjectDataByCod (MYSQL_RES **mysql_res,long PrjCod)
|
2021-10-11 23:37:14 +02:00
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get project data",
|
|
|
|
|
"SELECT PrjCod," // row[ 0]
|
|
|
|
|
"CrsCod," // row[ 1]
|
|
|
|
|
"DptCod," // row[ 2]
|
|
|
|
|
"Locked," // row[ 3]
|
|
|
|
|
"Hidden," // row[ 4]
|
|
|
|
|
"Assigned," // row[ 5]
|
|
|
|
|
"NumStds," // row[ 6]
|
|
|
|
|
"Proposal," // row[ 7]
|
|
|
|
|
"UNIX_TIMESTAMP(CreatTime)," // row[ 8]
|
|
|
|
|
"UNIX_TIMESTAMP(ModifTime)," // row[ 9]
|
|
|
|
|
"Title," // row[10]
|
|
|
|
|
"Description," // row[11]
|
|
|
|
|
"Knowledge," // row[12]
|
|
|
|
|
"Materials," // row[13]
|
2022-10-11 23:30:47 +02:00
|
|
|
|
"URL," // row[14]
|
|
|
|
|
"ReviewStatus," // row[15]
|
|
|
|
|
"UNIX_TIMESTAMP(ReviewTime)," // row[16]
|
|
|
|
|
"ReviewTxt" // row[17]
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" FROM prj_projects"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
|
|
|
|
PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2022-09-28 01:07:54 +02:00
|
|
|
|
/********************* Get project title from database ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-06 22:39:26 +02:00
|
|
|
|
void Prj_DB_GetProjectTitle (long PrjCod,char *Title,size_t TitleSize)
|
2022-09-28 01:07:54 +02:00
|
|
|
|
{
|
2023-04-06 22:39:26 +02:00
|
|
|
|
DB_QuerySELECTString (Title,TitleSize,"can not get project title",
|
2022-09-28 01:07:54 +02:00
|
|
|
|
"SELECT Title" // row[0]
|
|
|
|
|
" FROM prj_projects"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
|
|
|
|
PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2022-09-28 01:07:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-11 23:37:14 +02:00
|
|
|
|
/******************* Get some project data to check faults *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Prj_DB_GetPrjDataToCheckFaults (MYSQL_RES **mysql_res,long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get project data",
|
2022-10-13 22:30:01 +02:00
|
|
|
|
"SELECT Assigned='Y'," // row[0] = 0 / 1
|
|
|
|
|
"NumStds," // row[1] =
|
|
|
|
|
"Title<>''," // row[2] = 0 / 1
|
|
|
|
|
"Description<>''," // row[3] = 0 / 1
|
|
|
|
|
"ReviewStatus='%s'," // row[4] = 0 / 1
|
|
|
|
|
"ReviewStatus<>'%s' AND ModifTime>ReviewTime" // row[5] = 0 / 1
|
2021-10-11 23:37:14 +02:00
|
|
|
|
" FROM prj_projects"
|
|
|
|
|
" WHERE PrjCod=%ld",
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Prj_DB_ReviewStatus[Prj_UNAPPROVED],
|
|
|
|
|
Prj_DB_ReviewStatus[Prj_UNREVIEWED],
|
2021-10-11 23:37:14 +02:00
|
|
|
|
PrjCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get number of users with a role in a project ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Prj_DB_GetNumUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject)
|
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of users in project",
|
|
|
|
|
"SELECT COUNT(UsrCod)"
|
|
|
|
|
" FROM prj_users"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND RoleInProject=%u",
|
|
|
|
|
PrjCod,
|
|
|
|
|
(unsigned) RoleInProject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Get users with a role in a project *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Prj_DB_GetUsrsInPrj (MYSQL_RES **mysql_res,
|
|
|
|
|
long PrjCod,Prj_RoleInProject_t RoleInProject)
|
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get users in project",
|
|
|
|
|
"SELECT prj_users.UsrCod," // row[0]
|
|
|
|
|
"usr_data.Surname1 AS S1," // row[1]
|
|
|
|
|
"usr_data.Surname2 AS S2," // row[2]
|
|
|
|
|
"usr_data.FirstName AS FN" // row[3]
|
|
|
|
|
" FROM prj_users,"
|
|
|
|
|
"usr_data"
|
|
|
|
|
" WHERE prj_users.PrjCod=%ld"
|
|
|
|
|
" AND prj_users.RoleInProject=%u"
|
|
|
|
|
" AND prj_users.UsrCod=usr_data.UsrCod"
|
|
|
|
|
" ORDER BY S1,"
|
|
|
|
|
"S2,"
|
|
|
|
|
"FN",
|
|
|
|
|
PrjCod,
|
|
|
|
|
(unsigned) RoleInProject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Get my roles in a project **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Prj_DB_GetMyRolesInPrj (MYSQL_RES **mysql_res,long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get my roles in project",
|
|
|
|
|
"SELECT RoleInProject" // row[0]
|
|
|
|
|
" FROM prj_users"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND UsrCod=%ld",
|
|
|
|
|
PrjCod,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Get course of a project **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
long Prj_DB_GetCrsOfPrj (long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Trivial check: project code should be > 0 *****/
|
|
|
|
|
if (PrjCod <= 0)
|
|
|
|
|
return -1L;
|
|
|
|
|
|
|
|
|
|
/***** Get course code from database *****/
|
|
|
|
|
return DB_QuerySELECTCode ("can not get project course",
|
|
|
|
|
"SELECT CrsCod" // row[0]
|
|
|
|
|
" FROM prj_projects"
|
|
|
|
|
" WHERE PrjCod=%ld",
|
|
|
|
|
PrjCod); // Project found...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Get number of courses with projects ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of courses with projects
|
|
|
|
|
// in this location (all the platform, current degree or current course)
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
unsigned Prj_DB_GetNumCoursesWithProjects (Hie_Level_t Level)
|
2021-10-11 23:37:14 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Get number of courses with projects from database *****/
|
2023-07-11 19:12:24 +02:00
|
|
|
|
switch (Level)
|
2021-10-11 23:37:14 +02:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_SYS:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT CrsCod)"
|
|
|
|
|
" FROM prj_projects"
|
|
|
|
|
" WHERE CrsCod>0");
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_CTY:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT prj_projects.CrsCod)"
|
|
|
|
|
" FROM ins_instits,"
|
|
|
|
|
"ctr_centers,"
|
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"prj_projects"
|
|
|
|
|
" WHERE ins_instits.CtyCod=%ld"
|
|
|
|
|
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=prj_projects.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].HieCod);
|
|
|
|
|
case Hie_INS:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT prj_projects.CrsCod)"
|
|
|
|
|
" FROM ctr_centers,"
|
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"prj_projects"
|
|
|
|
|
" WHERE ctr_centers.InsCod=%ld"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=prj_projects.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_INS].HieCod);
|
|
|
|
|
case Hie_CTR:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT prj_projects.CrsCod)"
|
|
|
|
|
" FROM deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"prj_projects"
|
|
|
|
|
" WHERE deg_degrees.CtrCod=%ld"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=prj_projects.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTR].HieCod);
|
|
|
|
|
case Hie_DEG:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT prj_projects.CrsCod)"
|
|
|
|
|
" FROM crs_courses,"
|
|
|
|
|
"prj_projects"
|
|
|
|
|
" WHERE crs_courses.DegCod=%ld"
|
|
|
|
|
" AND crs_courses.CrsCod=prj_projects.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_DEG].HieCod);
|
|
|
|
|
case Hie_CRS:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of courses with projects",
|
|
|
|
|
"SELECT COUNT(DISTINCT CrsCod)"
|
|
|
|
|
" FROM prj_projects"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
default:
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Err_WrongHierarchyLevelExit ();
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return 0; // Not reached
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Get number of projects ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of projects in this location
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
unsigned Prj_DB_GetNumProjects (Hie_Level_t Level)
|
2021-10-11 23:37:14 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Get number of projects from database *****/
|
2023-07-11 19:12:24 +02:00
|
|
|
|
switch (Level)
|
2021-10-11 23:37:14 +02:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_SYS:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM prj_projects"
|
|
|
|
|
" WHERE CrsCod>0");
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_CTY:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM ins_instits,"
|
|
|
|
|
"ctr_centers,"
|
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"prj_projects"
|
|
|
|
|
" WHERE ins_instits.CtyCod=%ld"
|
|
|
|
|
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=prj_projects.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].HieCod);
|
|
|
|
|
case Hie_INS:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM ctr_centers,"
|
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"prj_projects"
|
|
|
|
|
" WHERE ctr_centers.InsCod=%ld"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=prj_projects.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_INS].HieCod);
|
|
|
|
|
case Hie_CTR:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"prj_projects"
|
|
|
|
|
" WHERE deg_degrees.CtrCod=%ld"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=prj_projects.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTR].HieCod);
|
|
|
|
|
case Hie_DEG:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM crs_courses,"
|
|
|
|
|
"prj_projects"
|
|
|
|
|
" WHERE crs_courses.DegCod=%ld"
|
|
|
|
|
" AND crs_courses.CrsCod=prj_projects.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_DEG].HieCod);
|
|
|
|
|
case Hie_CRS:
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QueryCOUNT ("can not get number of projects",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM prj_projects"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
default:
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Err_WrongHierarchyLevelExit ();
|
2021-10-11 23:37:14 +02:00
|
|
|
|
return 0; // Not reached
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Remove user from a project *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_RemoveUsrFromPrj (long PrjCod,Prj_RoleInProject_t RoleInPrj,long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryDELETE ("can not remove a user from a project",
|
|
|
|
|
"DELETE FROM prj_users"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND RoleInProject=%u"
|
|
|
|
|
" AND UsrCod=%ld",
|
|
|
|
|
PrjCod,
|
|
|
|
|
(unsigned) RoleInPrj,
|
|
|
|
|
UsrCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Remove user from all his/her projects *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_RemoveUsrFromProjects (long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryDELETE ("can not remove user from projects",
|
|
|
|
|
"DELETE FROM prj_users"
|
|
|
|
|
" WHERE UsrCod=%ld",
|
|
|
|
|
UsrCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Remove all users from a project ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_RemoveUsrsFromPrj (long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryDELETE ("can not remove project",
|
|
|
|
|
"DELETE FROM prj_users"
|
|
|
|
|
" USING prj_projects,"
|
|
|
|
|
"prj_users"
|
|
|
|
|
" WHERE prj_projects.PrjCod=%ld"
|
|
|
|
|
" AND prj_projects.CrsCod=%ld" // Extra check
|
|
|
|
|
" AND prj_projects.PrjCod=prj_users.PrjCod",
|
|
|
|
|
PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Remove all users from all projects in a course ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_RemoveUsrsFromCrsPrjs (long CrsCod)
|
|
|
|
|
{
|
2021-10-30 13:28:48 +02:00
|
|
|
|
DB_QueryDELETE ("can not remove all projects in a course",
|
2021-10-11 23:37:14 +02:00
|
|
|
|
"DELETE FROM prj_users"
|
|
|
|
|
" USING prj_projects,"
|
|
|
|
|
"prj_users"
|
|
|
|
|
" WHERE prj_projects.CrsCod=%ld"
|
|
|
|
|
" AND prj_projects.PrjCod=prj_users.PrjCod",
|
|
|
|
|
CrsCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Remove configuration of projects in the course **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_RemoveConfigOfCrsPrjs (long CrsCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryDELETE ("can not remove configuration of projects in a course",
|
|
|
|
|
"DELETE FROM prj_config"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
|
|
|
|
CrsCod);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-03 11:02:06 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Remove associations of rubrics to projects in the course *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_RemoveRubricsOfCrsPrjs (long CrsCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryDELETE ("can not remove rubrics of projects in a course",
|
|
|
|
|
"DELETE FROM prj_rubrics"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
|
|
|
|
CrsCod);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 23:37:14 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Remove project ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_RemovePrj (long PrjCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryDELETE ("can not remove project",
|
|
|
|
|
"DELETE FROM prj_projects"
|
|
|
|
|
" WHERE PrjCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
|
|
|
|
PrjCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-10-11 23:37:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Remove all projects in a course ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prj_DB_RemoveCrsPrjs (long CrsCod)
|
|
|
|
|
{
|
2021-10-30 13:28:48 +02:00
|
|
|
|
DB_QueryDELETE ("can not remove all projects of a course",
|
2021-10-11 23:37:14 +02:00
|
|
|
|
"DELETE FROM prj_projects"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
|
|
|
|
CrsCod);
|
|
|
|
|
}
|
2023-04-13 14:25:52 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/********** Update whether non-editing teachers can create projects **********/
|
2023-04-13 14:25:52 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
void Prj_DB_UpdateNETCanCreate (const struct Prj_Projects *Projects)
|
2023-04-13 14:25:52 +02:00
|
|
|
|
{
|
|
|
|
|
DB_QueryREPLACE ("can not save configuration of projects",
|
|
|
|
|
"REPLACE INTO prj_config"
|
2023-05-03 11:02:06 +02:00
|
|
|
|
" (CrsCod,NETCanCreate)"
|
2023-04-13 14:25:52 +02:00
|
|
|
|
" VALUES"
|
2023-05-03 11:02:06 +02:00
|
|
|
|
" (%ld,'%c')",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2023-04-13 14:25:52 +02:00
|
|
|
|
Projects->Config.NETCanCreate ? 'Y' :
|
|
|
|
|
'N');
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-03 11:02:06 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Update rubrics associated to projects for current course **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-05-19 23:00:30 +02:00
|
|
|
|
void Prj_DB_UpdateRubrics (PrjCfg_RubricType_t RubricType,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
const struct PrgCfg_ListRubCods *ListRubCods)
|
2023-05-03 11:02:06 +02:00
|
|
|
|
{
|
2023-05-17 15:28:15 +02:00
|
|
|
|
unsigned RubCod;
|
2023-05-03 11:02:06 +02:00
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/***** Delete all rubric codes of this type *****/
|
|
|
|
|
DB_QueryDELETE ("can not save configuration of projects",
|
|
|
|
|
"DELETE FROM prj_rubrics"
|
|
|
|
|
" WHERE CrsCod=%ld"
|
|
|
|
|
" AND Type='%s'",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
Prj_DB_RubricType[RubricType]);
|
|
|
|
|
|
|
|
|
|
/***** Insert specified rubric codes of this type *****/
|
|
|
|
|
for (RubCod = 0;
|
|
|
|
|
RubCod <= ListRubCods->NumRubrics;
|
|
|
|
|
RubCod++)
|
2023-05-03 11:02:06 +02:00
|
|
|
|
DB_QueryREPLACE ("can not save configuration of projects",
|
|
|
|
|
"REPLACE INTO prj_rubrics"
|
|
|
|
|
" (CrsCod,Type,RubCod)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,'%s',%ld)",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
Prj_DB_RubricType[RubricType],
|
|
|
|
|
ListRubCods->RubCods[RubCod]);
|
2023-05-03 11:02:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 14:25:52 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Get configuration of projects for current course *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Prj_DB_GetConfig (MYSQL_RES **mysql_res)
|
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get project configuration",
|
2023-05-03 11:02:06 +02:00
|
|
|
|
"SELECT NETCanCreate" // row[0]
|
2023-04-13 14:25:52 +02:00
|
|
|
|
" FROM prj_config"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2023-04-13 14:25:52 +02:00
|
|
|
|
}
|
2023-05-03 11:02:06 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get project rubrics for current course ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
unsigned Prj_DB_GetRubricsOfType (MYSQL_RES **mysql_res,
|
|
|
|
|
PrjCfg_RubricType_t RubricType)
|
2023-05-03 11:02:06 +02:00
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get project rubrics",
|
2023-05-17 15:28:15 +02:00
|
|
|
|
"SELECT prj_rubrics.RubCod" // row[0]
|
|
|
|
|
" FROM prj_rubrics,"
|
|
|
|
|
"rub_rubrics"
|
|
|
|
|
" WHERE prj_rubrics.CrsCod=%ld"
|
|
|
|
|
" AND prj_rubrics.Type='%s'"
|
|
|
|
|
" AND prj_rubrics.RubCod=rub_rubrics.RubCod"
|
|
|
|
|
" ORDER BY rub_rubrics.Title",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
Prj_DB_RubricType[RubricType]);
|
2023-05-03 11:02:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*** Get type of project rubric in the current course given a rubric code ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
PrjCfg_RubricType_t Prj_DB_GetWichRubricFromRubCod (long RubCod)
|
2023-05-03 11:02:06 +02:00
|
|
|
|
{
|
|
|
|
|
char StrTypeDB[32];
|
|
|
|
|
|
|
|
|
|
DB_QuerySELECTString (StrTypeDB,sizeof (StrTypeDB) - 1,
|
|
|
|
|
"can not get which rubric",
|
|
|
|
|
"SELECT Type" // row[0]
|
|
|
|
|
" FROM prj_rubrics"
|
|
|
|
|
" WHERE CrsCod=%ld"
|
|
|
|
|
" AND RubCod=%ld",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2023-05-03 11:02:06 +02:00
|
|
|
|
RubCod);
|
|
|
|
|
return PrjCfg_GetRubricFromString (StrTypeDB);
|
|
|
|
|
}
|