You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.6 KiB

// swad_program_database.h: course program, operations with database
#ifndef _SWAD_PRG_DB
#define _SWAD_PRG_DB
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-2023 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
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 <>.
/********************************* Headers ***********************************/
#include "swad_hierarchy_level.h"
#include "swad_program.h"
#include "swad_program_resource.h"
/***************************** Public prototypes *****************************/
//--------------------------------- Items -------------------------------------
long Prg_DB_InsertItem (const struct Prg_Item *Item,const char *Txt);
void Prg_DB_UpdateItem (const struct Prg_Item *Item,const char *Txt);
void Prg_DB_HideOrUnhideItem (long ItmCod,bool Hide);
void Prg_DB_UpdateIndexRange (long Diff,long Begin,long End);
void Prg_DB_LockTableItems (void);
void Prg_DB_MoveDownItems (unsigned Index);
void Prg_DB_MoveLeftRightItemRange (const struct Prg_ItemRange *ToMove,
Prg_MoveLeftRight_t LeftRight);
unsigned Prg_DB_GetListItems (MYSQL_RES **mysql_res);
unsigned Prg_DB_GetItemDataByCod (MYSQL_RES **mysql_res,long ItmCod);
void Prg_DB_GetItemTxt (long ItmCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
unsigned Prg_DB_GetNumCoursesWithItems (HieLvl_Level_t Scope);
unsigned Prg_DB_GetNumItems (HieLvl_Level_t Scope);
void Prg_DB_RemoveItemRange (const struct Prg_ItemRange *ToRemove);
void Prg_DB_RemoveCrsItems (long CrsCod);
//------------------------------ Resources ------------------------------------
long Prg_DB_CreateResource (const struct Prg_Item *Item);
void Prg_DB_UpdateResourceTitle (long ItmCod,long RscCod,
const char NewTitle[Rsc_MAX_BYTES_RESOURCE_TITLE + 1]);
unsigned Prg_DB_GetListResources (MYSQL_RES **mysql_res,long ItmCod,
bool ShowHiddenResources);
unsigned Prg_DB_GetResourceDataByCod (MYSQL_RES **mysql_res,long RscCod);
unsigned Prg_DB_GetRscIndBefore (long ItmCod,unsigned RscInd);
unsigned Prg_DB_GetRscIndAfter (long ItmCod,unsigned RscInd);
long Prg_DB_GetRscCodFromRscInd (long ItmCod,unsigned RscInd);
void Prg_DB_RemoveResource (const struct Prg_Item *Item);
void Prg_DB_HideOrUnhideResource (long RscCod,bool Hide);
void Prg_DB_LockTableResources (void);
void Prg_DB_UpdateRscInd (long RscCod,int RscInd);
void Prg_DB_UpdateRscLink (const struct Prg_Item *Item);
void Prg_DB_InsertItemInExpandedItems (long ItmCod);
bool Prg_DB_GetIfExpandedItem (long ItmCod);
void Prg_DB_RemoveItemFromExpandedItems (long ItmCod);