mirror of https://github.com/acanas/swad-core.git
Version 20.100.1: Sep 10, 2021 Queries moved to module swad_institution_database.
This commit is contained in:
parent
7468bf70cd
commit
2c8264ae0b
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
|||
|
||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.100 (2021-09-10)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.100.1 (2021-09-10)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.69.1.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 20.100.1: Sep 10, 2021 Queries moved to module swad_institution_database. (314941 lines)
|
||||
Version 20.100: Sep 10, 2021 New module swad_figure_database for database queries related to figures. (314940 lines)
|
||||
Version 20.99: Sep 10, 2021 Queries moved to module swad_institution_database. (314758 lines)
|
||||
Version 20.98: Sep 10, 2021 New module swad_institution_database for database queries related to institutions. (314663 lines)
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
// swad_figure_database.c: figures (global stats) 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.
|
||||
Copyright (C) 1999-2021 Antonio Cañas Vargas
|
||||
|
||||
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 ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// #include <stdio.h> // For sscanf
|
||||
|
||||
#include "swad_database.h"
|
||||
// #include "swad_figure_cache.h"
|
||||
#include "swad_figure_database.h"
|
||||
// #include "swad_scope.h"
|
||||
// #include "swad_string.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Private types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private variables *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Private prototypes ***************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Update unsigned figure value into cache ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Fig_DB_UpdateUnsignedFigureIntoCache (FigCch_FigureCached_t Figure,
|
||||
HieLvl_Level_t Scope,long Cod,
|
||||
unsigned Value)
|
||||
{
|
||||
DB_QueryREPLACE ("can not update cached figure value",
|
||||
"REPLACE INTO fig_figures"
|
||||
" (Figure,Scope,Cod,ValueInt,ValueDouble)"
|
||||
" VALUES"
|
||||
" (%u,'%s',%ld,%u,'0.0')",
|
||||
(unsigned) Figure,
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod,
|
||||
Value);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Update double figure value into cache *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Fig_DB_UpdateDoubleFigureIntoCache (FigCch_FigureCached_t Figure,
|
||||
HieLvl_Level_t Scope,long Cod,
|
||||
double Value)
|
||||
{
|
||||
Str_SetDecimalPointToUS (); // To write the decimal point as a dot
|
||||
DB_QueryREPLACE ("can not update cached figure value",
|
||||
"REPLACE INTO fig_figures"
|
||||
" (Figure,Scope,Cod,ValueInt,ValueDouble)"
|
||||
" VALUES"
|
||||
" (%u,'%s',%ld,0,'%.15lg')",
|
||||
(unsigned) Figure,
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod,
|
||||
Value);
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
|
||||
/***** Get figure's value if cached and recent *****/
|
||||
/*****************************************************************************/
|
||||
/************************** Get figure from cache ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Fig_DB_GetFigureFromCache (MYSQL_RES **mysql_res,
|
||||
FigCch_FigureCached_t Figure,
|
||||
HieLvl_Level_t Scope,long Cod,
|
||||
FigCch_Type_t Type,time_t TimeCached)
|
||||
{
|
||||
static const char *Field[FigCch_NUM_TYPES] =
|
||||
{
|
||||
[FigCch_UNSIGNED] = "ValueInt",
|
||||
[FigCch_DOUBLE ] = "ValueDouble",
|
||||
};
|
||||
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get cached figure value",
|
||||
"SELECT %s" // row[0]
|
||||
" FROM fig_figures"
|
||||
" WHERE Figure=%u"
|
||||
" AND Scope='%s'"
|
||||
" AND Cod=%ld"
|
||||
" AND LastUpdate>FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
Field[Type],
|
||||
(unsigned) Figure,Sco_GetDBStrFromScope (Scope),Cod,
|
||||
TimeCached);
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
// swad_figure_database.h: figures (global stats) operations with database
|
||||
|
||||
#ifndef _SWAD_FIG_DB
|
||||
#define _SWAD_FIG_DB
|
||||
/*
|
||||
SWAD (Shared Workspace At a Distance in Spanish),
|
||||
is a web platform developed at the University of Granada (Spain),
|
||||
and used to support university teaching.
|
||||
|
||||
This file is part of SWAD core.
|
||||
Copyright (C) 1999-2021 Antonio Cañas Vargas
|
||||
|
||||
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 ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <mysql/mysql.h> // To access MySQL databases
|
||||
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_hierarchy_level.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Public types and constants ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Fig_DB_UpdateUnsignedFigureIntoCache (FigCch_FigureCached_t Figure,
|
||||
HieLvl_Level_t Scope,long Cod,
|
||||
unsigned Value);
|
||||
void Fig_DB_UpdateDoubleFigureIntoCache (FigCch_FigureCached_t Figure,
|
||||
HieLvl_Level_t Scope,long Cod,
|
||||
double Value);
|
||||
|
||||
unsigned Fig_DB_GetFigureFromCache (MYSQL_RES **mysql_res,
|
||||
FigCch_FigureCached_t Figure,
|
||||
HieLvl_Level_t Scope,long Cod,
|
||||
FigCch_Type_t Type,time_t TimeCached);
|
||||
|
||||
#endif
|
|
@ -481,7 +481,7 @@ unsigned Ins_DB_GetInssInCurrentInsOrderedByNumberOfDegs (MYSQL_RES **mysql_res)
|
|||
unsigned Ins_DB_GetInssInCurrentInsOrderedByNumberOfCrss (MYSQL_RES **mysql_res)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
DB_QuerySELECT (mysql_res,"can not get institutions",
|
||||
"SELECT ctr_centers.InsCod," // row[0]
|
||||
"COUNT(*) AS N" // row[1]
|
||||
" FROM ctr_centers,"
|
||||
|
|
Loading…
Reference in New Issue