2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_assignment.c: assignments
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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
|
2014-12-01 23:55:08 +01: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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-01 22:53:39 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2019-11-01 22:53:39 +01:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_assignment.h"
|
2021-05-11 18:22:00 +02:00
|
|
|
|
#include "swad_assignment_database.h"
|
2021-11-28 00:49:23 +01:00
|
|
|
|
#include "swad_autolink.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2019-02-12 14:46:14 +01:00
|
|
|
|
#include "swad_figure.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_group.h"
|
2021-06-17 13:55:45 +02:00
|
|
|
|
#include "swad_group_database.h"
|
2023-06-06 22:18:31 +02:00
|
|
|
|
#include "swad_hidden_visible.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_notification.h"
|
2021-10-01 09:11:58 +02:00
|
|
|
|
#include "swad_notification_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_pagination.h"
|
2023-03-10 17:21:04 +01:00
|
|
|
|
#include "swad_parameter_code.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_photo.h"
|
2023-03-26 20:46:28 +02:00
|
|
|
|
#include "swad_resource.h"
|
2019-09-28 15:03:22 +02:00
|
|
|
|
#include "swad_role.h"
|
2019-03-26 11:53:21 +01:00
|
|
|
|
#include "swad_setting.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_string.h"
|
|
|
|
|
|
2024-04-01 17:59:51 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Private types *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Asg_ONE_ASSIGMENT,
|
|
|
|
|
Asg_MULTIPLE_ASSIGMENTS
|
|
|
|
|
} Asg_OneOrMultiple_t;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-29 21:35:08 +02:00
|
|
|
|
static void Asg_PutHead (struct Asg_Assignments *Assignments,
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_OneOrMultiple_t OneOrMultiple,
|
|
|
|
|
Vie_ViewType_t ViewType);
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Asg_CheckIfICanCreateAssignments (void);
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_PutIconsListAssignments (void *Assignments);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
static void Asg_PutIconToCreateNewAsg (void *Assignments);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Asg_ParsWhichGroupsToShow (void *Assignments);
|
2022-09-21 02:33:40 +02:00
|
|
|
|
static void Asg_PutIconsOneAsg (void *Assignments);
|
2022-09-29 21:35:08 +02:00
|
|
|
|
static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments,
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_OneOrMultiple_t OneOrMultiple,
|
2023-10-29 12:32:08 +01:00
|
|
|
|
Vie_ViewType_t ViewType);
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_WriteAsgAuthor (struct Asg_Assignment *Asg);
|
2023-10-29 12:32:08 +01:00
|
|
|
|
static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,
|
|
|
|
|
Vie_ViewType_t ViewType);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
|
2022-09-29 21:35:08 +02:00
|
|
|
|
static void Asg_PutIconsToRemEditOneAsg (struct Asg_Assignments *Assignments,
|
2019-04-20 22:06:18 +02:00
|
|
|
|
const char *Anchor);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Asg_PutPars (void *Assignments);
|
2020-04-05 22:53:58 +02:00
|
|
|
|
static void Asg_GetListAssignments (struct Asg_Assignments *Assignments);
|
2023-03-22 11:34:06 +01:00
|
|
|
|
static void Asg_GetAssignmentDataFromRow (MYSQL_RES **mysql_res,
|
|
|
|
|
struct Asg_Assignment *Asg,
|
|
|
|
|
unsigned NumAsgs);
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_ResetAssignment (struct Asg_Assignment *Asg);
|
2020-04-05 22:53:58 +02:00
|
|
|
|
static void Asg_FreeListAssignments (struct Asg_Assignments *Assignments);
|
2023-09-09 15:47:37 +02:00
|
|
|
|
static void Asg_HideUnhideAssignment (HidVis_HiddenOrVisible_t HiddenOrVisible);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Asg_ShowLstGrpsToEditAssignment (long AsgCod);
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_CreateAssignment (struct Asg_Assignment *Asg,const char *Txt);
|
|
|
|
|
static void Asg_UpdateAssignment (struct Asg_Assignment *Asg,const char *Txt);
|
2021-05-13 12:50:36 +02:00
|
|
|
|
static void Asg_CreateGroups (long AsgCod);
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Asg_Assignment *Asg);
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Asg_CheckIfICanDoAsgBasedOnGroups (long AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Reset assignments *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-21 10:46:14 +02:00
|
|
|
|
void Asg_ResetAssignments (struct Asg_Assignments *Assignments)
|
2020-04-05 22:53:58 +02:00
|
|
|
|
{
|
|
|
|
|
Assignments->LstIsRead = false; // List is not read
|
|
|
|
|
Assignments->Num = 0;
|
|
|
|
|
Assignments->LstAsgCods = NULL;
|
|
|
|
|
Assignments->SelectedOrder = Asg_ORDER_DEFAULT;
|
|
|
|
|
Assignments->CurrentPage = 0;
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Assignments->Asg.AsgCod = -1L; // Used as parameter in contextual links
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_ResetAssignment (&Assignments->Asg);
|
2020-04-05 22:53:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/**************************** List all assignments ***************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_SeeAssignments (void)
|
|
|
|
|
{
|
2020-04-05 22:53:58 +02:00
|
|
|
|
struct Asg_Assignments Assignments;
|
|
|
|
|
|
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Assignments.SelectedOrder = Asg_GetParAsgOrder ();
|
|
|
|
|
Gbl.Crs.Grps.WhichGrps = Grp_GetParWhichGroups ();
|
|
|
|
|
Assignments.CurrentPage = Pag_GetParPagNum (Pag_ASSIGNMENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Show all assignments *****/
|
|
|
|
|
Asg_ShowAllAssignments (&Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/**************************** Show all assignments ***************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-21 10:46:14 +02:00
|
|
|
|
void Asg_ShowAllAssignments (struct Asg_Assignments *Assignments)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-27 21:41:17 +01:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Assignments;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
extern const char *Txt_Assignments;
|
2016-03-19 19:22:13 +01:00
|
|
|
|
extern const char *Txt_No_assignments;
|
2023-03-02 22:40:41 +01:00
|
|
|
|
struct Pag_Pagination Pagination;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumAsg;
|
|
|
|
|
|
2016-03-19 19:34:22 +01:00
|
|
|
|
/***** Get list of assignments *****/
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Asg_GetListAssignments (Assignments);
|
2016-03-19 19:34:22 +01:00
|
|
|
|
|
2015-01-02 12:57:26 +01:00
|
|
|
|
/***** Compute variables related to pagination *****/
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Pagination.NumItems = Assignments->Num;
|
|
|
|
|
Pagination.CurrentPage = (int) Assignments->CurrentPage;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
Pag_CalculatePagination (&Pagination);
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Assignments->CurrentPage = (unsigned) Pagination.CurrentPage;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_Assignments,Asg_PutIconsListAssignments,Assignments,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_ASSESSMENT_Assignments,Box_NOT_CLOSABLE);
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2022-09-21 02:33:40 +02:00
|
|
|
|
/***** Select whether show only my groups or all groups *****/
|
|
|
|
|
if (Gbl.Crs.Grps.NumGrps)
|
|
|
|
|
{
|
|
|
|
|
Set_BeginSettingsHead ();
|
2023-04-06 21:43:41 +02:00
|
|
|
|
Grp_ShowFormToSelWhichGrps (ActSeeAllAsg,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Asg_ParsWhichGroupsToShow,Assignments);
|
2022-09-21 02:33:40 +02:00
|
|
|
|
Set_EndSettingsHead ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2022-09-21 02:33:40 +02:00
|
|
|
|
/***** Write links to pages *****/
|
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_ASSIGNMENTS,&Pagination,
|
|
|
|
|
Assignments,-1L);
|
2019-12-06 22:18:05 +01:00
|
|
|
|
|
2022-09-21 02:33:40 +02:00
|
|
|
|
if (Assignments->Num)
|
|
|
|
|
{
|
|
|
|
|
/***** Begin table *****/
|
2023-12-18 14:27:33 +01:00
|
|
|
|
HTM_TABLE_Begin ("TBL_SCROLL");
|
2022-09-21 02:33:40 +02:00
|
|
|
|
|
|
|
|
|
/***** Table head *****/
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_PutHead (Assignments,Asg_MULTIPLE_ASSIGMENTS,Vie_VIEW);
|
2022-09-21 02:33:40 +02:00
|
|
|
|
|
|
|
|
|
/***** Write all assignments *****/
|
|
|
|
|
for (NumAsg = Pagination.FirstItemVisible, The_ResetRowColor ();
|
|
|
|
|
NumAsg <= Pagination.LastItemVisible;
|
|
|
|
|
NumAsg++, The_ChangeRowColor ())
|
2022-09-29 21:35:08 +02:00
|
|
|
|
{
|
|
|
|
|
Assignments->Asg.AsgCod = Assignments->LstAsgCods[NumAsg - 1];
|
2023-04-18 22:13:37 +02:00
|
|
|
|
Asg_GetAssignmentDataByCod (&Assignments->Asg);
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_ShowAssignmentRow (Assignments,Asg_MULTIPLE_ASSIGMENTS,Vie_VIEW);
|
2022-09-29 21:35:08 +02:00
|
|
|
|
}
|
2022-09-21 02:33:40 +02:00
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
}
|
|
|
|
|
else // No assignments created
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_assignments);
|
2016-03-19 19:22:13 +01:00
|
|
|
|
|
2022-09-21 02:33:40 +02:00
|
|
|
|
/***** Write again links to pages *****/
|
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_ASSIGNMENTS,&Pagination,
|
|
|
|
|
Assignments,-1L);
|
2019-12-06 22:18:05 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free list of assignments *****/
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Asg_FreeListAssignments (Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 10:24:47 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Write header with fields of an assignment *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-29 21:35:08 +02:00
|
|
|
|
static void Asg_PutHead (struct Asg_Assignments *Assignments,
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_OneOrMultiple_t OneOrMultiple,
|
|
|
|
|
Vie_ViewType_t ViewType)
|
2017-05-02 10:24:47 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_START_END_TIME_HELP[Dat_NUM_START_END_TIME];
|
|
|
|
|
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
|
|
|
|
|
extern const char *Txt_Assignment;
|
|
|
|
|
extern const char *Txt_Folder;
|
|
|
|
|
Dat_StartEndTime_t Order;
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2024-04-01 17:59:51 +02:00
|
|
|
|
if (OneOrMultiple == Asg_MULTIPLE_ASSIGMENTS)
|
2022-09-29 21:35:08 +02:00
|
|
|
|
HTM_TH_Span (NULL,HTM_HEAD_CENTER,1,1,"CONTEXT_COL"); // Column for contextual icons
|
|
|
|
|
|
2022-01-02 00:39:26 +01:00
|
|
|
|
for (Order = (Dat_StartEndTime_t) 0;
|
|
|
|
|
Order <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
Order++)
|
2017-05-02 13:02:43 +02:00
|
|
|
|
{
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/* Begin head cell */
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH_Begin (HTM_HEAD_LEFT);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
if (ViewType == Vie_VIEW)
|
2021-05-11 18:22:00 +02:00
|
|
|
|
{
|
|
|
|
|
/* Begin form */
|
2023-04-06 21:43:41 +02:00
|
|
|
|
Frm_BeginForm (ActSeeAllAsg);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
WhichGroups = Grp_GetParWhichGroups ();
|
|
|
|
|
Grp_PutParWhichGroups (&WhichGroups);
|
|
|
|
|
Pag_PutParPagNum (Pag_ASSIGNMENTS,Assignments->CurrentPage);
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_PutParOrder ((unsigned) Order);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
|
|
|
|
|
/* Begin link to select order */
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_START_END_TIME_HELP[Order],
|
|
|
|
|
"class=\"BT_LINK\"");
|
2021-05-11 18:22:00 +02:00
|
|
|
|
if (Order == Assignments->SelectedOrder)
|
|
|
|
|
HTM_U_Begin ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Start / end text */
|
|
|
|
|
HTM_Txt (Txt_START_END_TIME[Order]);
|
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
if (ViewType == Vie_VIEW)
|
2021-05-11 18:22:00 +02:00
|
|
|
|
{
|
|
|
|
|
/* End link to select order */
|
|
|
|
|
if (Order == Assignments->SelectedOrder)
|
|
|
|
|
HTM_U_End ();
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
|
|
|
|
|
/* End form */
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* End head cell */
|
|
|
|
|
HTM_TH_End ();
|
2017-05-02 13:02:43 +02:00
|
|
|
|
}
|
2022-09-29 21:35:08 +02:00
|
|
|
|
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH (Txt_Assignment,HTM_HEAD_LEFT);
|
|
|
|
|
HTM_TH (Txt_Folder ,HTM_HEAD_LEFT);
|
2019-10-12 19:10:32 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2017-05-02 10:24:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 01:44:50 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Check if I can create assignments **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Asg_CheckIfICanCreateAssignments (void)
|
2016-11-07 01:44:50 +01:00
|
|
|
|
{
|
2024-04-01 17:59:51 +02:00
|
|
|
|
return (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_CAN :
|
|
|
|
|
Usr_CAN_NOT;
|
2016-11-07 01:44:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Put contextual icons in list of assignments *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
static void Asg_PutIconsListAssignments (void *Assignments)
|
2016-11-07 01:44:50 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Put icon to create a new assignment *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
if (Assignments)
|
2022-09-29 00:04:41 +02:00
|
|
|
|
{
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Asg_CheckIfICanCreateAssignments () == Usr_CAN)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Asg_PutIconToCreateNewAsg (Assignments);
|
2016-11-07 01:44:50 +01:00
|
|
|
|
|
2022-09-29 00:04:41 +02:00
|
|
|
|
/***** Link to get resource link *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Rsc_CheckIfICanGetLink () == Usr_CAN)
|
2022-09-29 00:04:41 +02:00
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
((struct Asg_Assignments *) Assignments)->Asg.AsgCod = -1L;
|
2022-09-29 00:04:41 +02:00
|
|
|
|
Ico_PutContextualIconToGetLink (ActReqLnkAsg,NULL,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Asg_PutPars,Assignments);
|
2022-09-29 00:04:41 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 01:44:50 +01:00
|
|
|
|
/***** Put icon to show a figure *****/
|
2020-04-06 23:18:02 +02:00
|
|
|
|
Fig_PutIconToShowFigure (Fig_ASSIGNMENTS);
|
2016-11-07 01:44:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-19 19:22:13 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Put icon to create a new assignment *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
static void Asg_PutIconToCreateNewAsg (void *Assignments)
|
2016-03-19 19:22:13 +01:00
|
|
|
|
{
|
2020-03-26 02:54:30 +01:00
|
|
|
|
if (Assignments)
|
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
((struct Asg_Assignments *) Assignments)->Asg.AsgCod = -1L;
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Ico_PutContextualIconToAdd (ActFrmNewAsg,NULL,Asg_PutPars,Assignments);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2016-03-19 19:22:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2019-02-25 15:14:28 +01:00
|
|
|
|
/**************** Put params to select which groups to show ******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Asg_ParsWhichGroupsToShow (void *Assignments)
|
2016-12-04 23:09:28 +01:00
|
|
|
|
{
|
2020-04-05 22:53:58 +02:00
|
|
|
|
if (Assignments)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2024-03-08 10:33:08 +01:00
|
|
|
|
Par_PutParOrder ((unsigned)
|
|
|
|
|
((struct Asg_Assignments *) Assignments)->SelectedOrder);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Pag_PutParPagNum (Pag_ASSIGNMENTS,
|
2024-03-08 10:33:08 +01:00
|
|
|
|
((struct Asg_Assignments *) Assignments)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-21 00:48:44 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Show one assignment ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_SeeOneAssignment (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Assignments;
|
|
|
|
|
struct Asg_Assignments Assignments;
|
|
|
|
|
|
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Assignments.SelectedOrder = Asg_GetParAsgOrder ();
|
|
|
|
|
Grp_GetParWhichGroups ();
|
|
|
|
|
Assignments.CurrentPage = Pag_GetParPagNum (Pag_ASSIGNMENTS);
|
2022-09-21 00:48:44 +02:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the assignment *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Assignments.Asg.AsgCod = ParCod_GetAndCheckPar (ParCod_Asg);
|
2022-09-21 00:48:44 +02:00
|
|
|
|
|
2023-04-18 22:13:37 +02:00
|
|
|
|
/***** Get data of this assignment *****/
|
|
|
|
|
Asg_GetAssignmentDataByCod (&Assignments.Asg);
|
|
|
|
|
|
2022-09-21 02:33:40 +02:00
|
|
|
|
/***** Show selected assignment in a box *****/
|
|
|
|
|
Asg_ShowOneAssignmentInBox (&Assignments);
|
2022-09-21 00:48:44 +02:00
|
|
|
|
|
|
|
|
|
/***** Show current assignments, if any *****/
|
2023-04-06 12:39:13 +02:00
|
|
|
|
// TODO: The page should be that corresponding to the selected assignment.
|
2022-09-21 00:48:44 +02:00
|
|
|
|
Asg_ShowAllAssignments (&Assignments);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 10:24:47 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Show print view of one assignment **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_PrintOneAssignment (void)
|
|
|
|
|
{
|
2020-04-05 22:53:58 +02:00
|
|
|
|
struct Asg_Assignments Assignments;
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
2017-05-02 10:24:47 +02:00
|
|
|
|
/***** Get the code of the assignment *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Assignments.Asg.AsgCod = ParCod_GetAndCheckPar (ParCod_Asg);
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
2023-04-18 22:13:37 +02:00
|
|
|
|
/***** Get data of this assignment *****/
|
|
|
|
|
Asg_GetAssignmentDataByCod (&Assignments.Asg);
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Write header *****/
|
2023-10-29 20:34:03 +01:00
|
|
|
|
Lay_WriteHeaderClassPhoto (Vie_PRINT);
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/***** Table head *****/
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_PutHead (&Assignments,Asg_ONE_ASSIGMENT,Vie_PRINT);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
|
|
|
|
|
/***** Write assignment *****/
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_ShowAssignmentRow (&Assignments,Asg_ONE_ASSIGMENT,Vie_PRINT);
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2017-05-02 10:24:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-21 02:33:40 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Show an assignment in a box ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-21 10:46:14 +02:00
|
|
|
|
void Asg_ShowOneAssignmentInBox (struct Asg_Assignments *Assignments)
|
2022-09-21 02:33:40 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Assignments;
|
|
|
|
|
extern const char *Txt_Assignment;
|
|
|
|
|
|
2023-12-18 14:27:33 +01:00
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Assignments->Asg.Title[0] ? Assignments->Asg.Title :
|
|
|
|
|
Txt_Assignment,
|
2023-12-18 14:27:33 +01:00
|
|
|
|
Asg_PutIconsOneAsg,Assignments,
|
|
|
|
|
Hlp_ASSESSMENT_Assignments,Box_NOT_CLOSABLE);
|
2022-09-21 02:33:40 +02:00
|
|
|
|
|
2023-12-18 14:27:33 +01:00
|
|
|
|
/***** Begin table *****/
|
|
|
|
|
HTM_TABLE_Begin ("TBL_SCROLL");
|
2022-09-21 02:33:40 +02:00
|
|
|
|
|
2023-12-18 14:27:33 +01:00
|
|
|
|
/***** Table head *****/
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_PutHead (Assignments,Asg_ONE_ASSIGMENT,Vie_VIEW);
|
2023-12-18 14:27:33 +01:00
|
|
|
|
|
|
|
|
|
/***** Write assignment *****/
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_ShowAssignmentRow (Assignments,Asg_ONE_ASSIGMENT,Vie_VIEW);
|
2022-09-21 02:33:40 +02:00
|
|
|
|
|
2023-12-18 14:27:33 +01:00
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
2022-09-21 02:33:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Put contextual icons in an assignment ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Asg_PutIconsOneAsg (void *Assignments)
|
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
char *Anchor = NULL;
|
|
|
|
|
|
|
|
|
|
if (Assignments)
|
|
|
|
|
{
|
|
|
|
|
/***** Set anchor string *****/
|
|
|
|
|
Frm_SetAnchorStr (((struct Asg_Assignments *) Assignments)->Asg.AsgCod,&Anchor);
|
|
|
|
|
|
2022-09-30 00:19:57 +02:00
|
|
|
|
/***** Icons to remove/edit this assignment *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_PutIconsToRemEditOneAsg (Assignments,Anchor);
|
|
|
|
|
|
|
|
|
|
/***** Free anchor string *****/
|
2023-04-06 19:59:33 +02:00
|
|
|
|
Frm_FreeAnchorStr (&Anchor);
|
2022-09-29 21:35:08 +02:00
|
|
|
|
}
|
2022-09-21 02:33:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
/********************* Show assignment row in a table ************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-29 21:35:08 +02:00
|
|
|
|
static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments,
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Asg_OneOrMultiple_t OneOrMultiple,
|
2023-10-29 12:32:08 +01:00
|
|
|
|
Vie_ViewType_t ViewType)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2024-04-13 21:33:16 +02:00
|
|
|
|
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
2023-06-06 22:18:31 +02:00
|
|
|
|
extern const char *HidVis_TitleClass[HidVis_NUM_HIDDEN_VISIBLE];
|
|
|
|
|
extern const char *HidVis_DataClass[HidVis_NUM_HIDDEN_VISIBLE];
|
2024-04-13 21:33:16 +02:00
|
|
|
|
extern const char *Txt_Actions[ActLst_NUM_ACTIONS];
|
2019-04-20 22:06:18 +02:00
|
|
|
|
char *Anchor = NULL;
|
2015-10-22 01:24:43 +02:00
|
|
|
|
static unsigned UniqueId = 0;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2019-09-27 00:46:02 +02:00
|
|
|
|
Dat_StartEndTime_t StartEndTime;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-20 22:06:18 +02:00
|
|
|
|
/***** Set anchor string *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Frm_SetAnchorStr (Assignments->Asg.AsgCod,&Anchor);
|
2019-04-20 22:06:18 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Write first row of data of this assignment *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/* Forms to remove/edit this assignment */
|
2024-04-01 17:59:51 +02:00
|
|
|
|
if (OneOrMultiple == Asg_MULTIPLE_ASSIGMENTS)
|
2021-05-11 18:22:00 +02:00
|
|
|
|
{
|
2021-12-20 22:43:32 +01:00
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL %s\"",
|
2022-03-19 02:05:53 +01:00
|
|
|
|
The_GetColorRows ());
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_PutIconsToRemEditOneAsg (Assignments,Anchor);
|
|
|
|
|
HTM_TD_End ();
|
2021-05-11 18:22:00 +02:00
|
|
|
|
}
|
2017-05-02 11:39:17 +02:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/* Start/end date/time */
|
|
|
|
|
UniqueId++;
|
2019-09-27 00:46:02 +02:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
for (StartEndTime = (Dat_StartEndTime_t) 0;
|
|
|
|
|
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
|
|
|
|
StartEndTime++)
|
|
|
|
|
{
|
|
|
|
|
if (asprintf (&Id,"asg_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2023-10-29 12:32:08 +01:00
|
|
|
|
switch (ViewType)
|
|
|
|
|
{
|
|
|
|
|
case Vie_VIEW:
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
|
|
|
|
Id,
|
2024-04-13 21:33:16 +02:00
|
|
|
|
CloOpe_Class[Assignments->Asg.ClosedOrOpen][Assignments->Asg.HiddenOrVisible],
|
2023-10-29 12:32:08 +01:00
|
|
|
|
The_GetSuffix (),
|
|
|
|
|
The_GetColorRows ());
|
|
|
|
|
break;
|
|
|
|
|
case Vie_PRINT:
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"",
|
|
|
|
|
Id,
|
2024-04-13 21:33:16 +02:00
|
|
|
|
CloOpe_Class[Assignments->Asg.ClosedOrOpen][Assignments->Asg.HiddenOrVisible],
|
2023-10-29 12:32:08 +01:00
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongTypeExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Assignments->Asg.TimeUTC[StartEndTime],
|
2021-05-11 18:22:00 +02:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
2024-04-24 13:47:19 +02:00
|
|
|
|
Dat_WRITE_TODAY |
|
|
|
|
|
Dat_WRITE_DATE_ON_SAME_DAY |
|
|
|
|
|
Dat_WRITE_WEEK_DAY |
|
|
|
|
|
Dat_WRITE_HOUR |
|
|
|
|
|
Dat_WRITE_MINUTE |
|
|
|
|
|
Dat_WRITE_SECOND);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
free (Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Assignment title */
|
2023-10-29 12:32:08 +01:00
|
|
|
|
switch (ViewType)
|
|
|
|
|
{
|
|
|
|
|
case Vie_VIEW:
|
|
|
|
|
HTM_TD_Begin ("class=\"LT %s\"",The_GetColorRows ());
|
|
|
|
|
break;
|
|
|
|
|
case Vie_PRINT:
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongTypeExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-09-21 00:48:44 +02:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_ARTICLE_Begin (Anchor);
|
2022-09-21 00:48:44 +02:00
|
|
|
|
Frm_BeginForm (ActSeeOneAsg);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Asg_PutPars (Assignments);
|
2022-09-21 00:48:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_Actions[ActSeeOneAsg],
|
|
|
|
|
"class=\"LT BT_LINK %s_%s\"",
|
2023-06-06 22:18:31 +02:00
|
|
|
|
HidVis_TitleClass[Assignments->Asg.HiddenOrVisible],
|
2022-09-21 00:48:44 +02:00
|
|
|
|
The_GetSuffix ());
|
2022-09-29 21:35:08 +02:00
|
|
|
|
HTM_Txt (Assignments->Asg.Title);
|
2022-09-21 00:48:44 +02:00
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_ARTICLE_End ();
|
2022-09-21 00:48:44 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/* Assignment folder */
|
2023-10-29 12:32:08 +01:00
|
|
|
|
switch (ViewType)
|
|
|
|
|
{
|
|
|
|
|
case Vie_VIEW:
|
|
|
|
|
HTM_TD_Begin ("class=\"LT DAT_%s %s\"",
|
|
|
|
|
The_GetSuffix (),The_GetColorRows ());
|
|
|
|
|
break;
|
|
|
|
|
case Vie_PRINT:
|
|
|
|
|
HTM_TD_Begin ("class=\"LT DAT_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongTypeExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Assignments->Asg.SendWork == Asg_SEND_WORK)
|
2023-10-29 12:32:08 +01:00
|
|
|
|
Asg_WriteAssignmentFolder (&Assignments->Asg,ViewType);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write second row of data of this assignment *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/* Author of the assignment */
|
2023-10-29 12:32:08 +01:00
|
|
|
|
switch (ViewType)
|
|
|
|
|
{
|
|
|
|
|
case Vie_VIEW:
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",The_GetColorRows ());
|
|
|
|
|
break;
|
|
|
|
|
case Vie_PRINT:
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongTypeExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_WriteAsgAuthor (&Assignments->Asg);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/* Text of the assignment */
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_DB_GetAssignmentTxtByCod (Assignments->Asg.AsgCod,Txt);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
2023-05-30 23:18:59 +02:00
|
|
|
|
Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES);
|
2021-11-28 00:49:23 +01:00
|
|
|
|
ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
|
2023-10-29 12:32:08 +01:00
|
|
|
|
switch (ViewType)
|
|
|
|
|
{
|
|
|
|
|
case Vie_VIEW:
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",The_GetColorRows ());
|
|
|
|
|
break;
|
|
|
|
|
case Vie_PRINT:
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongTypeExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-05-11 18:22:00 +02:00
|
|
|
|
if (Gbl.Crs.Grps.NumGrps)
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (&Assignments->Asg);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
|
2022-03-25 11:09:51 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"PAR %s_%s\"",
|
2023-06-06 22:18:31 +02:00
|
|
|
|
HidVis_DataClass[Assignments->Asg.HiddenOrVisible],
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_Txt (Txt);
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-20 22:06:18 +02:00
|
|
|
|
/***** Free anchor string *****/
|
2023-04-06 19:59:33 +02:00
|
|
|
|
Frm_FreeAnchorStr (&Anchor);
|
2019-04-20 22:06:18 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Mark possible notification as seen *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Ntf_DB_MarkNotifAsSeenUsingCod (Ntf_EVENT_ASSIGNMENT,Assignments->Asg.AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Write the author of an assignment *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_WriteAsgAuthor (struct Asg_Assignment *Asg)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-06-06 15:16:57 +02:00
|
|
|
|
Usr_WriteAuthor1Line (Asg->UsrCod,Asg->HiddenOrVisible);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Write the folder of an assignment *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,
|
|
|
|
|
Vie_ViewType_t ViewType)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-07-21 17:24:52 +02:00
|
|
|
|
extern const char *Txt_Folder;
|
2022-06-28 18:11:31 +02:00
|
|
|
|
Act_Action_t NextAction;
|
2023-06-06 22:18:31 +02:00
|
|
|
|
bool ICanSendFiles = Asg->HiddenOrVisible == HidVis_VISIBLE && // It's visible (not hidden)
|
2024-04-13 21:33:16 +02:00
|
|
|
|
Asg->ClosedOrOpen == CloOpe_OPEN && // It's open (inside dates)
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Asg->ICanDo == Usr_CAN; // I can do (I belong to course/group)
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
|
|
|
|
/***** Folder icon *****/
|
2023-10-29 12:32:08 +01:00
|
|
|
|
if (ViewType == Vie_VIEW && // Not print view
|
|
|
|
|
ICanSendFiles) // I can send files to this assignment folder
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-02 10:24:47 +02:00
|
|
|
|
/* Form to create a new file or folder */
|
2019-04-25 02:58:42 +02:00
|
|
|
|
Gbl.FileBrowser.FullTree = true; // By default, show all files
|
2019-12-19 14:47:14 +01:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2019-04-25 02:58:42 +02:00
|
|
|
|
{
|
|
|
|
|
case Rol_STD:
|
|
|
|
|
Gbl.FileBrowser.Type = Brw_ADMI_ASG_USR; // User assignments
|
2022-06-28 18:11:31 +02:00
|
|
|
|
NextAction = ActFrmCreAsgUsr;
|
2019-04-25 02:58:42 +02:00
|
|
|
|
break;
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
2019-12-19 14:47:14 +01:00
|
|
|
|
case Rol_SYS_ADM:
|
2019-04-25 02:58:42 +02:00
|
|
|
|
Gbl.FileBrowser.Type = Brw_ADMI_ASG_CRS; // Course assignments
|
2021-02-15 22:49:44 +01:00
|
|
|
|
Str_Copy (Gbl.Usrs.Other.UsrDat.EnUsrCod,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Gbl.Usrs.Other.UsrDat.EnUsrCod) - 1);
|
2019-12-19 14:47:14 +01:00
|
|
|
|
Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr (&Gbl.Usrs.Selected);
|
2022-06-28 18:11:31 +02:00
|
|
|
|
NextAction = ActFrmCreAsgCrs;
|
2019-04-25 02:58:42 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongRoleExit ();
|
2022-06-28 18:11:31 +02:00
|
|
|
|
NextAction = ActUnk;
|
2019-04-25 02:58:42 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2022-06-28 18:11:31 +02:00
|
|
|
|
Frm_BeginForm (NextAction);
|
2022-03-19 02:05:53 +01:00
|
|
|
|
|
|
|
|
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
|
|
|
|
|
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
|
|
|
|
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,Asg->Folder,
|
|
|
|
|
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
|
|
|
|
|
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_FOLDER;
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Brw_PutImplicitParsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
|
2022-06-30 13:39:57 +02:00
|
|
|
|
Ico_PutIconLink ("folder-open-yellow-plus.png",Ico_UNCHANGED,NextAction);
|
2022-03-19 02:05:53 +01:00
|
|
|
|
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2022-03-19 02:05:53 +01:00
|
|
|
|
|
2019-12-19 14:47:14 +01:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2019-04-25 02:58:42 +02:00
|
|
|
|
{
|
|
|
|
|
case Rol_STD:
|
|
|
|
|
break;
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
2019-12-19 14:47:14 +01:00
|
|
|
|
case Rol_SYS_ADM:
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_FreeListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
|
2019-04-25 02:58:42 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-01-12 03:00:59 +01:00
|
|
|
|
else // Sending of files disabled
|
2021-12-22 00:20:06 +01:00
|
|
|
|
{
|
|
|
|
|
if (ICanSendFiles)
|
|
|
|
|
Ico_PutIconOff ("folder-open.svg",Ico_GREEN,Txt_Folder);
|
|
|
|
|
else
|
|
|
|
|
Ico_PutIconOff ("folder.svg" ,Ico_RED ,Txt_Folder);
|
|
|
|
|
}
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
|
|
|
|
/***** Folder name *****/
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Asg->Folder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******* Get parameter with the type or order in list of assignments *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Dat_StartEndTime_t Asg_GetParAsgOrder (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-05 22:53:58 +02:00
|
|
|
|
return (Dat_StartEndTime_t)
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParUnsignedLong ("Order",
|
2023-03-10 00:13:55 +01:00
|
|
|
|
0,
|
|
|
|
|
Dat_NUM_START_END_TIME - 1,
|
|
|
|
|
(unsigned long) Asg_ORDER_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
/******************** Put icons to edit one assignment ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-29 21:35:08 +02:00
|
|
|
|
static void Asg_PutIconsToRemEditOneAsg (struct Asg_Assignments *Assignments,
|
2019-04-20 22:06:18 +02:00
|
|
|
|
const char *Anchor)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2024-03-20 09:39:04 +01:00
|
|
|
|
static Act_Action_t ActionHideUnhide[HidVis_NUM_HIDDEN_VISIBLE] =
|
2022-07-21 19:30:03 +02:00
|
|
|
|
{
|
2023-06-06 22:18:31 +02:00
|
|
|
|
[HidVis_HIDDEN ] = ActUnhAsg, // Hidden ==> action to unhide
|
|
|
|
|
[HidVis_VISIBLE] = ActHidAsg, // Visible ==> action to hide
|
2022-07-21 19:30:03 +02:00
|
|
|
|
};
|
|
|
|
|
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2017-05-02 10:24:47 +02:00
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_TCH:
|
2017-05-02 10:24:47 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to remove assignment *****/
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemAsg,NULL,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Asg_PutPars,Assignments);
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to hide/unhide assignment *****/
|
|
|
|
|
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,Anchor,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Asg_PutPars,Assignments,
|
2023-06-06 15:16:57 +02:00
|
|
|
|
Assignments->Asg.HiddenOrVisible);
|
2017-05-02 10:24:47 +02:00
|
|
|
|
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to edit assignment *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiOneAsg,NULL,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Asg_PutPars,Assignments);
|
2022-09-29 21:35:08 +02:00
|
|
|
|
|
|
|
|
|
/***** Link to get resource link *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Rsc_CheckIfICanGetLink () == Usr_CAN)
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Ico_PutContextualIconToGetLink (ActReqLnkAsg,NULL,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Asg_PutPars,Assignments);
|
2018-10-04 21:57:25 +02:00
|
|
|
|
/* falls through */
|
|
|
|
|
/* no break */
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_STD:
|
2017-05-21 21:23:13 +02:00
|
|
|
|
case Rol_NET:
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to print assignment *****/
|
2024-02-11 23:29:50 +01:00
|
|
|
|
Ico_PutContextualIconToPrint (ActPrnOneAsg,Asg_PutPars,Assignments);
|
2017-05-02 10:24:47 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-12-13 19:17:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2015-12-13 19:37:08 +01:00
|
|
|
|
/******************** Params used to edit an assignment **********************/
|
2015-12-13 19:17:09 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Asg_PutPars (void *Assignments)
|
2015-12-13 19:17:09 +01:00
|
|
|
|
{
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
if (Assignments)
|
|
|
|
|
{
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Asg,((struct Asg_Assignments *) Assignments)->Asg.AsgCod);
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_PutParOrder ((unsigned) ((struct Asg_Assignments *) Assignments)->SelectedOrder);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
WhichGroups = Grp_GetParWhichGroups ();
|
|
|
|
|
Grp_PutParWhichGroups (&WhichGroups);
|
|
|
|
|
Pag_PutParPagNum (Pag_ASSIGNMENTS,((struct Asg_Assignments *) Assignments)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/*************************** List all assignments ****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-05-13 12:50:36 +02:00
|
|
|
|
extern unsigned (*Asg_DB_GetListAssignments[Grp_NUM_WHICH_GROUPS]) (MYSQL_RES **mysql_res,
|
|
|
|
|
Dat_StartEndTime_t SelectedOrder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumAsg;
|
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
if (Assignments->LstIsRead)
|
|
|
|
|
Asg_FreeListAssignments (Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of assignments from database *****/
|
2021-05-13 12:50:36 +02:00
|
|
|
|
Assignments->Num = Asg_DB_GetListAssignments[Gbl.Crs.Grps.WhichGrps] (&mysql_res,Assignments->SelectedOrder);
|
|
|
|
|
if (Assignments->Num) // Assignments found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create list of assignments *****/
|
2021-05-13 12:50:36 +02:00
|
|
|
|
if ((Assignments->LstAsgCods = calloc ((size_t) Assignments->Num,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (*Assignments->LstAsgCods))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the assignments codes *****/
|
|
|
|
|
for (NumAsg = 0;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
NumAsg < Assignments->Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumAsg++)
|
|
|
|
|
/* Get next assignment code */
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Assignments->LstAsgCods[NumAsg] = DB_GetNextCode (mysql_res)) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongAssignmentExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Assignments->LstIsRead = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get assignment data using its code **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-23 09:35:20 +01:00
|
|
|
|
void Asg_GetAssignmentDataByCod (struct Asg_Assignment *Asg)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2018-10-30 09:02:14 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
2021-04-16 13:51:12 +02:00
|
|
|
|
unsigned NumAsgs;
|
2018-10-30 09:02:14 +01:00
|
|
|
|
|
2016-12-28 17:45:53 +01:00
|
|
|
|
if (Asg->AsgCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Build query *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
NumAsgs = Asg_DB_GetAssignmentDataByCod (&mysql_res,Asg->AsgCod);
|
2016-12-28 17:45:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of assignment *****/
|
2023-03-22 11:34:06 +01:00
|
|
|
|
Asg_GetAssignmentDataFromRow (&mysql_res,Asg,NumAsgs);
|
2016-12-28 17:45:53 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2016-12-29 23:33:01 +01:00
|
|
|
|
{
|
2016-12-28 17:45:53 +01:00
|
|
|
|
/***** Clear all assignment data *****/
|
2016-12-29 23:33:01 +01:00
|
|
|
|
Asg->AsgCod = -1L;
|
2016-12-28 17:45:53 +01:00
|
|
|
|
Asg_ResetAssignment (Asg);
|
2016-12-29 23:33:01 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get assignment data using its folder name *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-23 09:35:20 +01:00
|
|
|
|
void Asg_GetAssignmentDataByFolder (struct Asg_Assignment *Asg)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2018-10-30 09:02:14 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
2021-04-16 13:51:12 +02:00
|
|
|
|
unsigned NumAsgs;
|
2018-10-30 09:02:14 +01:00
|
|
|
|
|
2016-12-28 17:45:53 +01:00
|
|
|
|
if (Asg->Folder[0])
|
|
|
|
|
{
|
|
|
|
|
/***** Query database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
NumAsgs = Asg_DB_GetAssignmentDataByFolder (&mysql_res,Asg->Folder);
|
2016-12-28 17:45:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of assignment *****/
|
2023-03-22 11:34:06 +01:00
|
|
|
|
Asg_GetAssignmentDataFromRow (&mysql_res,Asg,NumAsgs);
|
2016-12-28 17:45:53 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2016-12-29 23:33:01 +01:00
|
|
|
|
{
|
2016-12-28 17:45:53 +01:00
|
|
|
|
/***** Clear all assignment data *****/
|
2016-12-29 23:33:01 +01:00
|
|
|
|
Asg->AsgCod = -1L;
|
2016-12-28 17:45:53 +01:00
|
|
|
|
Asg_ResetAssignment (Asg);
|
2016-12-29 23:33:01 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Get assignment data *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-22 11:34:06 +01:00
|
|
|
|
static void Asg_GetAssignmentDataFromRow (MYSQL_RES **mysql_res,
|
|
|
|
|
struct Asg_Assignment *Asg,
|
|
|
|
|
unsigned NumAsgs)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2016-11-14 11:57:42 +01:00
|
|
|
|
/***** Clear all assignment data *****/
|
2016-12-28 17:45:53 +01:00
|
|
|
|
Asg_ResetAssignment (Asg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of assignment from database *****/
|
2021-04-16 13:51:12 +02:00
|
|
|
|
if (NumAsgs) // Assignment found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-03-23 19:56:18 +01:00
|
|
|
|
/* Get next row from result */
|
2018-10-30 09:02:14 +01:00
|
|
|
|
row = mysql_fetch_row (*mysql_res);
|
2020-05-07 01:14:50 +02:00
|
|
|
|
/*
|
|
|
|
|
row[0] AsgCod
|
|
|
|
|
row[1] Hidden
|
|
|
|
|
row[2] UsrCod
|
|
|
|
|
row[3] UNIX_TIMESTAMP(StartTime)
|
|
|
|
|
row[4] UNIX_TIMESTAMP(EndTime)
|
|
|
|
|
row[5] NOW() BETWEEN StartTime AND EndTime
|
|
|
|
|
row[6] Title
|
|
|
|
|
row[7] Folder
|
|
|
|
|
*/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get code of the assignment (row[0]) */
|
|
|
|
|
Asg->AsgCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
2016-09-07 18:02:25 +02:00
|
|
|
|
/* Get whether the assignment is hidden or not (row[1]) */
|
2023-09-11 22:28:56 +02:00
|
|
|
|
Asg->HiddenOrVisible = HidVid_GetHiddenOrVisible (row[1][0]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get author of the assignment (row[2]) */
|
|
|
|
|
Asg->UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/* Get start and end dates (row[3] and row[4] hold the start UTC time) */
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Asg->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[3]);
|
|
|
|
|
Asg->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[4]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get whether the assignment is open or closed (row(5)) */
|
2024-04-13 21:33:16 +02:00
|
|
|
|
Asg->ClosedOrOpen = CloOpe_GetClosedOrOpenFrom01 (row[5][0]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-02-15 22:49:44 +01:00
|
|
|
|
/* Get the title (row[6]) and the folder (row[7]) of the assignment */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Asg->Title ,row[6],sizeof (Asg->Title ) - 1);
|
|
|
|
|
Str_Copy (Asg->Folder,row[7],sizeof (Asg->Folder) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Asg->SendWork = (Asg->Folder[0] != '\0');
|
|
|
|
|
|
|
|
|
|
/* Can I do this assignment? */
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Asg->ICanDo = Asg_CheckIfICanDoAsgBasedOnGroups (Asg->AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
2018-10-30 09:02:14 +01:00
|
|
|
|
DB_FreeMySQLResult (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-28 17:45:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Clear all assignment data **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_ResetAssignment (struct Asg_Assignment *Asg)
|
2016-12-28 17:45:53 +01:00
|
|
|
|
{
|
2016-12-29 23:33:01 +01:00
|
|
|
|
if (Asg->AsgCod <= 0) // If > 0 ==> keep value
|
|
|
|
|
Asg->AsgCod = -1L;
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Asg->HiddenOrVisible = HidVis_VISIBLE;
|
|
|
|
|
Asg->UsrCod = -1L;
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Asg->TimeUTC[Dat_STR_TIME] =
|
|
|
|
|
Asg->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Asg->ClosedOrOpen = CloOpe_CLOSED;
|
|
|
|
|
Asg->Title[0] = '\0';
|
|
|
|
|
Asg->SendWork = Asg_DONT_SEND_WORK;
|
|
|
|
|
Asg->Folder[0] = '\0';
|
|
|
|
|
Asg->ICanDo = Usr_CAN_NOT;
|
2016-12-28 17:45:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Free list of assignments **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
static void Asg_FreeListAssignments (struct Asg_Assignments *Assignments)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-05 22:53:58 +02:00
|
|
|
|
if (Assignments->LstIsRead &&
|
|
|
|
|
Assignments->LstAsgCods)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of assignments *****/
|
2020-04-05 22:53:58 +02:00
|
|
|
|
free (Assignments->LstAsgCods);
|
|
|
|
|
Assignments->LstAsgCods = NULL;
|
|
|
|
|
Assignments->Num = 0;
|
|
|
|
|
Assignments->LstIsRead = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get summary and content of an assignment *****************/
|
|
|
|
|
/*****************************************************************************/
|
2015-10-22 01:24:43 +02:00
|
|
|
|
// This function may be called inside a web service
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
2017-03-06 13:01:16 +01:00
|
|
|
|
char **ContentStr,
|
2023-11-05 19:44:03 +01:00
|
|
|
|
long AsgCod,Ntf_GetContent_t GetContent)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2017-01-17 03:10:43 +01:00
|
|
|
|
size_t Length;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
SummaryStr[0] = '\0'; // Return nothing on error
|
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/***** Query database. Result should have a unique row *****/
|
|
|
|
|
if (Asg_DB_GetAssignmentTitleAndTxtByCod (&mysql_res,AsgCod) == 1)
|
2018-10-18 23:38:06 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Get row *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-10-18 23:38:06 +02:00
|
|
|
|
/***** Get summary *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
2018-10-18 23:38:06 +02:00
|
|
|
|
|
|
|
|
|
/***** Get content *****/
|
2023-11-05 19:44:03 +01:00
|
|
|
|
if (GetContent == Ntf_GET_CONTENT)
|
2018-10-18 23:38:06 +02:00
|
|
|
|
{
|
|
|
|
|
Length = strlen (row[1]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (*ContentStr,row[1],Length);
|
2018-10-18 23:38:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-11 21:02:22 +01:00
|
|
|
|
/************* Ask for confirmation of removing an assignment ****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-11 21:02:22 +01:00
|
|
|
|
void Asg_ReqRemAssignment (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_assignment_X;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
struct Asg_Assignments Assignments;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Assignments.SelectedOrder = Asg_GetParAsgOrder ();
|
|
|
|
|
Gbl.Crs.Grps.WhichGrps = Grp_GetParWhichGroups ();
|
|
|
|
|
Assignments.CurrentPage = Pag_GetParPagNum (Pag_ASSIGNMENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get assignment code *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Assignments.Asg.AsgCod = ParCod_GetAndCheckPar (ParCod_Asg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the assignment from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Asg_GetAssignmentDataByCod (&Assignments.Asg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-28 10:20:29 +02:00
|
|
|
|
/***** Show question and button to remove the assignment *****/
|
2023-05-12 23:03:05 +02:00
|
|
|
|
Ale_ShowAlertRemove (ActRemAsg,NULL,
|
|
|
|
|
Asg_PutPars,&Assignments,
|
|
|
|
|
Txt_Do_you_really_want_to_remove_the_assignment_X,
|
|
|
|
|
Assignments.Asg.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Show all assignments again *****/
|
|
|
|
|
Asg_ShowAllAssignments (&Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Remove an assignment ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_RemoveAssignment (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Assignment_X_removed;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
struct Asg_Assignments Assignments;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
2020-11-26 00:28:21 +01:00
|
|
|
|
/***** Get parameters *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Assignments.SelectedOrder = Asg_GetParAsgOrder ();
|
|
|
|
|
Gbl.Crs.Grps.WhichGrps = Grp_GetParWhichGroups ();
|
|
|
|
|
Assignments.CurrentPage = Pag_GetParPagNum (Pag_ASSIGNMENTS);
|
2020-11-26 00:28:21 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get assignment code *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Assignments.Asg.AsgCod = ParCod_GetAndCheckPar (ParCod_Asg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the assignment from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Asg_GetAssignmentDataByCod (&Assignments.Asg); // Inside this function, the course is checked to be the current one
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Remove all folders associated to this assignment *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Assignments.Asg.Folder[0])
|
|
|
|
|
Brw_RemoveFoldersAssignmentsIfExistForAllUsrs (Assignments.Asg.Folder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Remove all groups of this assignment *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_DB_RemoveGrpsAssociatedToAnAssignment (Assignments.Asg.AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove assignment *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_DB_RemoveAssignment (Assignments.Asg.AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications as removed *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_ASSIGNMENT,Assignments.Asg.AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Assignment_X_removed,
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Assignments.Asg.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Show all assignments again *****/
|
|
|
|
|
Asg_ShowAllAssignments (&Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2023-09-09 15:47:37 +02:00
|
|
|
|
/************************* Hide/unhide an assignment *************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_HideAssignment (void)
|
|
|
|
|
{
|
2023-09-09 15:47:37 +02:00
|
|
|
|
Asg_HideUnhideAssignment (HidVis_HIDDEN);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
void Asg_UnhideAssignment (void)
|
2023-09-09 15:47:37 +02:00
|
|
|
|
{
|
|
|
|
|
Asg_HideUnhideAssignment (HidVis_VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Asg_HideUnhideAssignment (HidVis_HiddenOrVisible_t HiddenOrVisible)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-05 22:53:58 +02:00
|
|
|
|
struct Asg_Assignments Assignments;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
2020-11-26 00:28:21 +01:00
|
|
|
|
/***** Get parameters *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Assignments.SelectedOrder = Asg_GetParAsgOrder ();
|
|
|
|
|
Gbl.Crs.Grps.WhichGrps = Grp_GetParWhichGroups ();
|
|
|
|
|
Assignments.CurrentPage = Pag_GetParPagNum (Pag_ASSIGNMENTS);
|
2020-11-26 00:28:21 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get assignment code *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Assignments.Asg.AsgCod = ParCod_GetAndCheckPar (ParCod_Asg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the assignment from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Asg_GetAssignmentDataByCod (&Assignments.Asg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/***** Unhide assignment *****/
|
2023-09-09 15:47:37 +02:00
|
|
|
|
Asg_DB_HideOrUnhideAssignment (Assignments.Asg.AsgCod,HiddenOrVisible);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Show all assignments again *****/
|
|
|
|
|
Asg_ShowAllAssignments (&Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Put a form to create a new assignment ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-17 12:51:11 +01:00
|
|
|
|
void Asg_ReqCreatOrEditAsg (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-27 21:41:17 +01:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Assignments_edit_assignment;
|
2023-04-20 01:22:07 +02:00
|
|
|
|
extern const char *Txt_Assignment;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Title;
|
2024-01-24 13:36:17 +01:00
|
|
|
|
extern const char *Folder_to_upload_files;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Description;
|
2023-05-09 00:00:29 +02:00
|
|
|
|
extern const char *Txt_Create;
|
2019-02-18 18:27:45 +01:00
|
|
|
|
extern const char *Txt_Save_changes;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
struct Asg_Assignments Assignments;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ItsANewAssignment;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2020-04-13 16:39:15 +02:00
|
|
|
|
static const Dat_SetHMS SetHMSDontSet[Dat_NUM_START_END_TIME] =
|
2020-02-26 19:35:33 +01:00
|
|
|
|
{
|
2021-09-18 18:22:26 +02:00
|
|
|
|
[Dat_STR_TIME] = Dat_HMS_DO_NOT_SET,
|
|
|
|
|
[Dat_END_TIME] = Dat_HMS_DO_NOT_SET
|
2020-04-13 16:39:15 +02:00
|
|
|
|
};
|
|
|
|
|
static const Dat_SetHMS SetHMSAllDay[Dat_NUM_START_END_TIME] =
|
|
|
|
|
{
|
2021-09-18 18:22:26 +02:00
|
|
|
|
[Dat_STR_TIME] = Dat_HMS_TO_000000,
|
|
|
|
|
[Dat_END_TIME] = Dat_HMS_TO_235959
|
2020-02-26 19:35:33 +01:00
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Assignments.SelectedOrder = Asg_GetParAsgOrder ();
|
|
|
|
|
Grp_GetParWhichGroups ();
|
|
|
|
|
Assignments.CurrentPage = Pag_GetParPagNum (Pag_ASSIGNMENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the assignment *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ItsANewAssignment = ((Assignments.Asg.AsgCod = ParCod_GetPar (ParCod_Asg)) <= 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the data of the assignment *****/
|
|
|
|
|
if (ItsANewAssignment)
|
|
|
|
|
{
|
|
|
|
|
/* Initialize to empty assignment */
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Assignments.Asg.AsgCod = -1L;
|
2022-10-19 01:04:19 +02:00
|
|
|
|
Assignments.Asg.TimeUTC[Dat_STR_TIME] = Dat_GetStartExecutionTimeUTC ();
|
|
|
|
|
Assignments.Asg.TimeUTC[Dat_END_TIME] = Assignments.Asg.TimeUTC[Dat_STR_TIME] + (2 * 60 * 60); // +2 hours
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Assignments.Asg.ClosedOrOpen = CloOpe_OPEN;
|
|
|
|
|
Assignments.Asg.Title[0] = '\0';
|
|
|
|
|
Assignments.Asg.SendWork = Asg_DONT_SEND_WORK;
|
|
|
|
|
Assignments.Asg.Folder[0] = '\0';
|
|
|
|
|
Assignments.Asg.ICanDo = Usr_CAN_NOT;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Get data of the assignment from database */
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Asg_GetAssignmentDataByCod (&Assignments.Asg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get text of the assignment from database */
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_DB_GetAssignmentTxtByCod (Assignments.Asg.AsgCod,Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (ItsANewAssignment)
|
2017-04-28 10:20:29 +02:00
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActNewAsg);
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Assignments.Asg.AsgCod = -1L;
|
2017-04-28 10:20:29 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActChgAsg);
|
2022-09-29 21:35:08 +02:00
|
|
|
|
// Assignments.Asg.AsgCod = Asg.AsgCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Asg_PutPars (&Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-12-15 00:47:29 +01:00
|
|
|
|
/***** Begin box and table *****/
|
2024-01-29 08:47:21 +01:00
|
|
|
|
Box_BoxTableBegin (Assignments.Asg.Title[0] ? Assignments.Asg.Title :
|
2023-04-20 01:22:07 +02:00
|
|
|
|
Txt_Assignment,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Assignments_edit_assignment,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-20 01:22:07 +02:00
|
|
|
|
/***** Assignment title *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-20 01:22:07 +02:00
|
|
|
|
/* Label */
|
2024-01-30 15:08:53 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RM","Title",Txt_Title);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2023-04-20 01:22:07 +02:00
|
|
|
|
/* Data */
|
2024-01-30 15:08:53 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LM\"");
|
2023-04-20 01:22:07 +02:00
|
|
|
|
HTM_INPUT_TEXT ("Title",Asg_MAX_CHARS_ASSIGNMENT_TITLE,Assignments.Asg.Title,
|
2024-06-07 10:44:31 +02:00
|
|
|
|
HTM_REQUIRED,
|
2024-05-14 10:19:48 +02:00
|
|
|
|
"id=\"Title\" class=\"Frm_C2_INPUT INPUT_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2023-04-20 01:22:07 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Assignment start and end dates *****/
|
|
|
|
|
Dat_PutFormStartEndClientLocalDateTimes (Assignments.Asg.TimeUTC,
|
|
|
|
|
Dat_FORM_SECONDS_ON,
|
|
|
|
|
Gbl.Action.Act == ActFrmNewAsg ? SetHMSAllDay :
|
|
|
|
|
SetHMSDontSet);
|
|
|
|
|
|
|
|
|
|
/***** Send work? *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Label */
|
2024-01-30 15:08:53 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RM","Folder",Folder_to_upload_files);
|
2023-04-20 01:22:07 +02:00
|
|
|
|
|
|
|
|
|
/* Data */
|
2024-01-30 15:08:53 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LM\"");
|
2023-04-20 01:22:07 +02:00
|
|
|
|
HTM_LABEL_Begin ("class=\"DAT_%s\"",The_GetSuffix ());
|
|
|
|
|
HTM_INPUT_TEXT ("Folder",Brw_MAX_CHARS_FOLDER,Assignments.Asg.Folder,
|
2024-06-07 10:44:31 +02:00
|
|
|
|
HTM_NO_ATTR,
|
2024-05-09 19:11:16 +02:00
|
|
|
|
"id=\"Folder\" class=\"Frm_C2_INPUT INPUT_%s\"",
|
2023-04-20 01:22:07 +02:00
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Assignment text *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Label */
|
2024-01-30 15:08:53 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RT","Txt",Txt_Description);
|
2023-04-20 01:22:07 +02:00
|
|
|
|
|
|
|
|
|
/* Data */
|
2024-01-30 15:08:53 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LT\"");
|
2024-06-07 10:44:31 +02:00
|
|
|
|
HTM_TEXTAREA_Begin (HTM_NO_ATTR,
|
2024-05-09 19:11:16 +02:00
|
|
|
|
"id=\"Txt\" name=\"Txt\" rows=\"10\""
|
2024-01-30 15:08:53 +01:00
|
|
|
|
" class=\"Frm_C2_INPUT INPUT_%s\"",
|
2023-04-20 01:22:07 +02:00
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
if (!ItsANewAssignment)
|
|
|
|
|
HTM_Txt (Txt);
|
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Groups *****/
|
|
|
|
|
Asg_ShowLstGrpsToEditAssignment (Assignments.Asg.AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-12-15 00:47:29 +01:00
|
|
|
|
/***** End table, send button and end box *****/
|
|
|
|
|
if (ItsANewAssignment)
|
2023-05-09 00:00:29 +02:00
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create);
|
2021-12-15 00:47:29 +01:00
|
|
|
|
else
|
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-03-19 19:22:13 +01:00
|
|
|
|
/***** Show current assignments, if any *****/
|
2024-01-26 10:47:38 +01:00
|
|
|
|
HTM_BR ();
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Asg_ShowAllAssignments (&Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Show list of groups to edit and assignment *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Asg_ShowLstGrpsToEditAssignment (long AsgCod)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Groups;
|
|
|
|
|
unsigned NumGrpTyp;
|
2024-09-12 14:38:16 +02:00
|
|
|
|
struct GroupType *GrpTyp;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of groups types and groups in this course *****/
|
|
|
|
|
Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);
|
|
|
|
|
|
2021-06-28 12:54:09 +02:00
|
|
|
|
if (Gbl.Crs.Grps.GrpTypes.NumGrpTypes)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2024-01-24 13:36:17 +01:00
|
|
|
|
/***** Begin row *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
|
2024-01-24 13:36:17 +01:00
|
|
|
|
/* Label */
|
2024-01-30 15:08:53 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RT","",Txt_Groups);
|
2024-01-24 13:36:17 +01:00
|
|
|
|
|
|
|
|
|
/* Groups */
|
2024-01-30 15:08:53 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LT\"");
|
2024-01-24 13:36:17 +01:00
|
|
|
|
HTM_TABLE_Begin (NULL);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
|
|
|
|
|
/***** First row: checkbox to select the whole course *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2024-06-07 10:44:31 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"7\" class=\"LM DAT_%s\"",The_GetSuffix ());
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_LABEL_Begin (NULL);
|
2024-06-07 10:44:31 +02:00
|
|
|
|
HTM_INPUT_CHECKBOX ("WholeCrs",
|
|
|
|
|
Grp_DB_CheckIfAssociatedToGrps ("asg_groups",
|
|
|
|
|
"AsgCod",
|
|
|
|
|
AsgCod) ? HTM_NO_ATTR :
|
|
|
|
|
HTM_CHECKED,
|
2024-04-30 11:00:46 +02:00
|
|
|
|
"id=\"WholeCrs\" value=\"Y\""
|
|
|
|
|
" onclick=\"uncheckChildren(this,'GrpCods')\"");
|
2024-01-26 10:47:38 +01:00
|
|
|
|
Grp_WriteTheWholeCourse ();
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** List the groups for each group type *****/
|
|
|
|
|
for (NumGrpTyp = 0;
|
2021-06-28 12:54:09 +02:00
|
|
|
|
NumGrpTyp < Gbl.Crs.Grps.GrpTypes.NumGrpTypes;
|
2021-05-11 18:22:00 +02:00
|
|
|
|
NumGrpTyp++)
|
2024-09-12 14:38:16 +02:00
|
|
|
|
{
|
|
|
|
|
GrpTyp = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp];
|
|
|
|
|
|
|
|
|
|
if (GrpTyp->NumGrps)
|
|
|
|
|
Grp_ListGrpsToEditAsgAttSvyEvtMch (GrpTyp,Grp_ASSIGNMENT,AsgCod);
|
|
|
|
|
}
|
2021-05-11 18:22:00 +02:00
|
|
|
|
|
2024-01-24 13:36:17 +01:00
|
|
|
|
HTM_TABLE_End ();
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free list of groups types and groups in this course *****/
|
|
|
|
|
Grp_FreeListGrpTypesAndGrps ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Receive form to create a new assignment ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-03-20 09:39:04 +01:00
|
|
|
|
void Asg_ReceiveAssignment (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Already_existed_an_assignment_with_the_title_X;
|
|
|
|
|
extern const char *Txt_Already_existed_an_assignment_with_the_folder_X;
|
2015-10-23 13:20:42 +02:00
|
|
|
|
extern const char *Txt_Created_new_assignment_X;
|
|
|
|
|
extern const char *Txt_The_assignment_has_been_modified;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_You_can_not_disable_file_uploading_once_folders_have_been_created;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
struct Asg_Assignments Assignments;
|
2020-04-08 03:06:45 +02:00
|
|
|
|
struct Asg_Assignment OldAsg; // Current assigment data in database
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ItsANewAssignment;
|
|
|
|
|
bool NewAssignmentIsCorrect = true;
|
|
|
|
|
unsigned NumUsrsToBeNotifiedByEMail;
|
2019-02-15 21:09:18 +01:00
|
|
|
|
char Description[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
2020-11-26 00:28:21 +01:00
|
|
|
|
/***** Get parameters *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Assignments.SelectedOrder = Asg_GetParAsgOrder ();
|
|
|
|
|
Grp_GetParWhichGroups ();
|
|
|
|
|
Assignments.CurrentPage = Pag_GetParPagNum (Pag_ASSIGNMENTS);
|
2020-11-26 00:28:21 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get the code of the assignment *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ItsANewAssignment = ((Assignments.Asg.AsgCod = ParCod_GetPar (ParCod_Asg)) <= 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-28 17:45:53 +01:00
|
|
|
|
if (ItsANewAssignment)
|
2016-12-29 23:33:01 +01:00
|
|
|
|
{
|
2016-12-28 17:45:53 +01:00
|
|
|
|
/***** Reset old (current, not existing) assignment data *****/
|
2016-12-29 23:33:01 +01:00
|
|
|
|
OldAsg.AsgCod = -1L;
|
2016-12-28 17:45:53 +01:00
|
|
|
|
Asg_ResetAssignment (&OldAsg);
|
2016-12-29 23:33:01 +01:00
|
|
|
|
}
|
2016-12-28 17:45:53 +01:00
|
|
|
|
else
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-12-28 17:45:53 +01:00
|
|
|
|
/***** Get data of the old (current) assignment from database *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
OldAsg.AsgCod = Assignments.Asg.AsgCod;
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Asg_GetAssignmentDataByCod (&OldAsg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-22 14:49:48 +02:00
|
|
|
|
/***** Get start/end date-times *****/
|
2023-03-06 09:14:38 +01:00
|
|
|
|
Assignments.Asg.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm (Dat_STR_TIME);
|
|
|
|
|
Assignments.Asg.TimeUTC[Dat_END_TIME] = Dat_GetTimeUTCFromForm (Dat_END_TIME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get assignment title *****/
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParText ("Title",Assignments.Asg.Title,Asg_MAX_BYTES_ASSIGNMENT_TITLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get folder name where to send works of the assignment *****/
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParText ("Folder",Assignments.Asg.Folder,Brw_MAX_BYTES_FOLDER);
|
2024-04-19 12:49:42 +02:00
|
|
|
|
Assignments.Asg.SendWork = Assignments.Asg.Folder[0] ? Asg_SEND_WORK :
|
|
|
|
|
Asg_DONT_SEND_WORK;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get assignment text *****/
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParHTML ("Txt",Description,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Adjust dates *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Assignments.Asg.TimeUTC[Dat_STR_TIME] == 0)
|
2022-10-19 01:04:19 +02:00
|
|
|
|
Assignments.Asg.TimeUTC[Dat_STR_TIME] = Dat_GetStartExecutionTimeUTC ();
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Assignments.Asg.TimeUTC[Dat_END_TIME] == 0)
|
|
|
|
|
Assignments.Asg.TimeUTC[Dat_END_TIME] = Assignments.Asg.TimeUTC[Dat_STR_TIME] + 2 * 60 * 60; // +2 hours
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if title is correct *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Assignments.Asg.Title[0]) // If there's an assignment title
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* If title of assignment was in database... */
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Asg_DB_CheckIfSimilarAssignmentExists ("Title",Assignments.Asg.Title,Assignments.Asg.AsgCod))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
NewAssignmentIsCorrect = false;
|
2019-02-15 21:09:18 +01:00
|
|
|
|
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_an_assignment_with_the_title_X,
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Assignments.Asg.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // Title is correct
|
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Assignments.Asg.SendWork == Asg_SEND_WORK)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Str_ConvertFilFolLnkNameToValid (Assignments.Asg.Folder)) // If folder name is valid...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Asg_DB_CheckIfSimilarAssignmentExists ("Folder",Assignments.Asg.Folder,Assignments.Asg.AsgCod)) // If folder of assignment was in database...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
NewAssignmentIsCorrect = false;
|
2019-02-15 23:38:44 +01:00
|
|
|
|
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_an_assignment_with_the_folder_X,
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Assignments.Asg.Folder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Folder name not valid
|
|
|
|
|
{
|
|
|
|
|
NewAssignmentIsCorrect = false;
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlerts (NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // NewAsg.SendWork == Asg_DO_NOT_SEND_WORK
|
|
|
|
|
{
|
|
|
|
|
if (OldAsg.SendWork == Asg_SEND_WORK)
|
|
|
|
|
{
|
|
|
|
|
if (Brw_CheckIfExistsFolderAssigmentForAnyUsr (OldAsg.Folder))
|
|
|
|
|
{
|
|
|
|
|
NewAssignmentIsCorrect = false;
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_disable_file_uploading_once_folders_have_been_created);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // If there is not an assignment title
|
|
|
|
|
{
|
|
|
|
|
NewAssignmentIsCorrect = false;
|
2023-04-17 23:55:22 +02:00
|
|
|
|
Ale_CreateAlertYouMustSpecifyTheTitle ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Create a new assignment or update an existing one *****/
|
|
|
|
|
if (NewAssignmentIsCorrect)
|
|
|
|
|
{
|
|
|
|
|
/* Get groups for this assignments */
|
2017-01-19 20:55:31 +01:00
|
|
|
|
Grp_GetParCodsSeveralGrps ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (ItsANewAssignment)
|
2015-10-23 13:20:42 +02:00
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_CreateAssignment (&Assignments.Asg,Description); // Add new assignment to database
|
2015-10-23 13:20:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_assignment_X,
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Assignments.Asg.Title);
|
2015-10-23 13:20:42 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (OldAsg.Folder[0] && Assignments.Asg.Folder[0])
|
|
|
|
|
if (strcmp (OldAsg.Folder,Assignments.Asg.Folder)) // Folder name has changed
|
|
|
|
|
NewAssignmentIsCorrect = Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (OldAsg.Folder,
|
|
|
|
|
Assignments.Asg.Folder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (NewAssignmentIsCorrect)
|
2015-10-23 13:20:42 +02:00
|
|
|
|
{
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Asg_UpdateAssignment (&Assignments.Asg,Description);
|
2015-10-23 13:20:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_assignment_has_been_modified);
|
2015-10-23 13:20:42 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free memory for list of selected groups */
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
2016-03-19 19:34:22 +01:00
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** Notify by email about the new assignment *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_ASSIGNMENT,Assignments.Asg.AsgCod)))
|
|
|
|
|
Asg_DB_UpdateNumUsrsNotifiedByEMailAboutAssignment (Assignments.Asg.AsgCod,
|
2021-05-11 18:22:00 +02:00
|
|
|
|
NumUsrsToBeNotifiedByEMail);
|
2016-03-19 19:34:22 +01:00
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
/***** Show all assignments again *****/
|
2020-11-26 00:28:21 +01:00
|
|
|
|
Asg_ShowAllAssignments (&Assignments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2015-10-23 01:06:32 +02:00
|
|
|
|
// TODO: The form should be filled with partial data, now is always empty
|
2023-03-17 12:51:11 +01:00
|
|
|
|
Asg_ReqCreatOrEditAsg ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Create a new assignment ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_CreateAssignment (struct Asg_Assignment *Asg,const char *Txt)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create a new assignment *****/
|
2021-05-11 18:22:00 +02:00
|
|
|
|
Asg->AsgCod = Asg_DB_CreateAssignment (Asg,Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create groups *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps)
|
2021-05-13 12:50:36 +02:00
|
|
|
|
Asg_CreateGroups (Asg->AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Update an existing assignment *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_UpdateAssignment (struct Asg_Assignment *Asg,const char *Txt)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Update the data of the assignment *****/
|
2021-05-11 18:22:00 +02:00
|
|
|
|
Asg_DB_UpdateAssignment (Asg,Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update groups *****/
|
|
|
|
|
/* Remove old groups */
|
2021-05-13 12:50:36 +02:00
|
|
|
|
Asg_DB_RemoveGrpsAssociatedToAnAssignment (Asg->AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Create new groups */
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps)
|
2021-05-13 12:50:36 +02:00
|
|
|
|
Asg_CreateGroups (Asg->AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Create groups of an assignment ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-05-13 12:50:36 +02:00
|
|
|
|
static void Asg_CreateGroups (long AsgCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-05-13 12:50:36 +02:00
|
|
|
|
unsigned NumGrp;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create groups of the assignment *****/
|
2021-05-13 12:50:36 +02:00
|
|
|
|
for (NumGrp = 0;
|
|
|
|
|
NumGrp < Gbl.Crs.Grps.LstGrpsSel.NumGrps;
|
|
|
|
|
NumGrp++)
|
|
|
|
|
Asg_DB_CreateGroup (AsgCod,Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrp]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Get and write the names of the groups of an assignment ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Asg_Assignment *Asg)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Group;
|
|
|
|
|
extern const char *Txt_Groups;
|
|
|
|
|
extern const char *Txt_and;
|
2023-06-06 22:18:31 +02:00
|
|
|
|
extern const char *HidVis_GroupClass[HidVis_NUM_HIDDEN_VISIBLE];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-04-16 13:51:12 +02:00
|
|
|
|
unsigned NumGrps;
|
|
|
|
|
unsigned NumGrp;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get groups associated to an assignment from database *****/
|
2021-05-11 18:22:00 +02:00
|
|
|
|
NumGrps = Asg_DB_GetGrps (&mysql_res,Asg->AsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2022-04-22 22:22:14 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s_%s\"",
|
2023-06-06 22:18:31 +02:00
|
|
|
|
HidVis_GroupClass[Asg->HiddenOrVisible],The_GetSuffix ());
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group :
|
|
|
|
|
Txt_Groups);
|
|
|
|
|
|
|
|
|
|
/***** Write groups *****/
|
|
|
|
|
if (NumGrps) // Groups found...
|
|
|
|
|
/* Get and write the group types and names */
|
|
|
|
|
for (NumGrp = 0;
|
|
|
|
|
NumGrp < NumGrps;
|
|
|
|
|
NumGrp++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next group */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Write group type name and group name */
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_TxtF ("%s %s",row[0],row[1]);
|
2021-05-11 18:22:00 +02:00
|
|
|
|
|
|
|
|
|
if (NumGrps >= 2)
|
|
|
|
|
{
|
|
|
|
|
if (NumGrp == NumGrps - 2)
|
|
|
|
|
HTM_TxtF (" %s ",Txt_and);
|
|
|
|
|
if (NumGrps >= 3)
|
|
|
|
|
if (NumGrp < NumGrps - 2)
|
|
|
|
|
HTM_Txt (", ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-01-26 10:47:38 +01:00
|
|
|
|
Grp_WriteTheWholeCourse ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/******************** Remove all assignments from a course *******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_RemoveCrsAssignments (long CrsCod)
|
|
|
|
|
{
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/***** Remove groups associated to assignments in course *****/
|
|
|
|
|
Asg_DB_RemoveGrpsAssociatedToAsgsInCrs (CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove assignments *****/
|
2021-05-11 18:22:00 +02:00
|
|
|
|
Asg_DB_RemoveCrsAssignments (CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
/*********************** Check if I can do an assignment *********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Asg_CheckIfICanDoAsgBasedOnGroups (long AsgCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2015-04-02 19:25:44 +02:00
|
|
|
|
{
|
2017-05-20 12:04:12 +02:00
|
|
|
|
case Rol_STD:
|
2017-05-21 21:23:13 +02:00
|
|
|
|
case Rol_NET:
|
2017-05-20 12:04:12 +02:00
|
|
|
|
case Rol_TCH:
|
|
|
|
|
// Students and teachers can do assignments depending on groups
|
|
|
|
|
/***** Get if I can do an assignment from database *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
return Asg_DB_CheckIfICanDoAsgBasedOnGroups (AsgCod);
|
2017-05-20 12:04:12 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2024-04-19 12:00:30 +02:00
|
|
|
|
return Usr_CAN;
|
2017-05-20 12:04:12 +02:00
|
|
|
|
default:
|
2024-04-19 12:00:30 +02:00
|
|
|
|
return Usr_CAN_NOT;
|
2015-04-02 19:25:44 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-29 14:28:36 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Write start and end dates of a folder of assignment ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_WriteDatesAssignment (const struct Asg_Assignment *Asg)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_unknown_assignment;
|
2024-04-13 21:33:16 +02:00
|
|
|
|
static const char *DateClass[CloOpe_NUM_CLOSED_OPEN] =
|
|
|
|
|
{
|
|
|
|
|
[CloOpe_CLOSED] = "ASG_LST_DATE_RED",
|
|
|
|
|
[CloOpe_OPEN ] = "ASG_LST_DATE_GREEN",
|
|
|
|
|
};
|
2023-09-29 14:28:36 +02:00
|
|
|
|
static unsigned UniqueId = 0;
|
|
|
|
|
char *Id;
|
|
|
|
|
|
|
|
|
|
/***** Begin table cell *****/
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RM %s_%s %s\"",
|
2024-04-13 21:33:16 +02:00
|
|
|
|
DateClass[Asg->ClosedOrOpen],The_GetSuffix (),
|
|
|
|
|
The_GetColorRows ());
|
2023-09-29 14:28:36 +02:00
|
|
|
|
|
|
|
|
|
if (Asg->AsgCod > 0)
|
|
|
|
|
{
|
|
|
|
|
UniqueId++;
|
|
|
|
|
|
|
|
|
|
/***** Write start date *****/
|
|
|
|
|
if (asprintf (&Id,"asg_start_date_%u",UniqueId) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Asg->TimeUTC[Dat_STR_TIME],
|
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
2024-04-24 13:47:19 +02:00
|
|
|
|
Dat_WRITE_TODAY |
|
|
|
|
|
Dat_WRITE_DATE_ON_SAME_DAY |
|
|
|
|
|
Dat_WRITE_HOUR |
|
|
|
|
|
Dat_WRITE_MINUTE |
|
|
|
|
|
Dat_WRITE_SECOND);
|
2023-09-29 14:28:36 +02:00
|
|
|
|
HTM_SPAN_End ();
|
|
|
|
|
free (Id);
|
|
|
|
|
|
|
|
|
|
/***** Arrow *****/
|
|
|
|
|
HTM_Txt ("→");
|
|
|
|
|
|
|
|
|
|
/***** Write end date *****/
|
|
|
|
|
if (asprintf (&Id,"asg_end_date_%u",UniqueId) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Asg->TimeUTC[Dat_END_TIME],
|
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
2024-04-24 13:47:19 +02:00
|
|
|
|
Dat_WRITE_TODAY |
|
|
|
|
|
Dat_WRITE_DATE_ON_SAME_DAY |
|
|
|
|
|
Dat_WRITE_HOUR |
|
|
|
|
|
Dat_WRITE_MINUTE |
|
|
|
|
|
Dat_WRITE_SECOND);
|
2023-09-29 14:28:36 +02:00
|
|
|
|
HTM_SPAN_End ();
|
|
|
|
|
free (Id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
HTM_TxtF (" (%s)",Txt_unknown_assignment);
|
|
|
|
|
|
|
|
|
|
/***** End table cell *****/
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Check if I have permission to create a file or folder into an assignment **/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Usr_Can_t Asg_CheckIfICanCreateIntoAssigment (const struct Asg_Assignment *Asg)
|
2023-09-29 14:28:36 +02:00
|
|
|
|
{
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t CloOpe_ICanCreate[CloOpe_NUM_CLOSED_OPEN] =
|
2024-04-13 21:33:16 +02:00
|
|
|
|
{
|
2024-04-19 12:00:30 +02:00
|
|
|
|
[CloOpe_CLOSED] = Usr_CAN_NOT,
|
|
|
|
|
[CloOpe_OPEN ] = Usr_CAN,
|
2024-04-13 21:33:16 +02:00
|
|
|
|
};
|
|
|
|
|
|
2023-09-29 14:28:36 +02:00
|
|
|
|
/***** Trivial check 1: assignment is valid *****/
|
|
|
|
|
if (Asg->AsgCod <= 0)
|
2024-04-19 12:00:30 +02:00
|
|
|
|
return Usr_CAN_NOT;
|
2023-09-29 14:28:36 +02:00
|
|
|
|
|
|
|
|
|
/***** Check 2: Do not create anything in hidden assigments *****/
|
|
|
|
|
if (Asg->HiddenOrVisible == HidVis_HIDDEN)
|
2024-04-19 12:00:30 +02:00
|
|
|
|
return Usr_CAN_NOT;
|
2023-09-29 14:28:36 +02:00
|
|
|
|
|
|
|
|
|
/***** Check 3: If I do not belong to course / groups of this assignment,
|
|
|
|
|
I can not create anything inside this assignment *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Asg->ICanDo == Usr_CAN_NOT)
|
|
|
|
|
return Usr_CAN_NOT;
|
2023-09-29 14:28:36 +02:00
|
|
|
|
|
|
|
|
|
/***** Check 4: Depending on my role in this course... *****/
|
|
|
|
|
switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs)
|
|
|
|
|
{
|
2024-04-13 21:33:16 +02:00
|
|
|
|
case Rol_STD: // Students...
|
|
|
|
|
case Rol_NET: // ...and non-editing teachers...
|
|
|
|
|
// ...can create only inside open assignments
|
|
|
|
|
return CloOpe_ICanCreate[Asg->ClosedOrOpen];
|
|
|
|
|
case Rol_TCH: // Teachers...
|
2024-04-19 12:00:30 +02:00
|
|
|
|
return Usr_CAN; // ...can create inside any assignment
|
2023-09-29 14:28:36 +02:00
|
|
|
|
default:
|
2024-04-19 12:00:30 +02:00
|
|
|
|
return Usr_CAN_NOT;
|
2023-09-29 14:28:36 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-29 14:42:04 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Set assignment folder ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_SetFolder (struct Asg_Assignment *Asg,unsigned Level)
|
|
|
|
|
{
|
|
|
|
|
const char *Ptr;
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
if (Level == 1)
|
|
|
|
|
// We are in this case: assignments/assignment-folder
|
|
|
|
|
Str_Copy (Asg->Folder,Gbl.FileBrowser.FilFolLnk.Name,
|
|
|
|
|
sizeof (Asg->Folder) - 1);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// We are in this case: assignments/assignment-folder/rest-of-path
|
|
|
|
|
for (Ptr = Gbl.FileBrowser.FilFolLnk.Path;
|
|
|
|
|
*Ptr && *Ptr != '/';
|
|
|
|
|
Ptr++); // Go to first '/'
|
|
|
|
|
if (*Ptr == '/')
|
|
|
|
|
Ptr++; // Skip '/'
|
|
|
|
|
for (i = 0;
|
|
|
|
|
i < Brw_MAX_BYTES_FOLDER && *Ptr && *Ptr != '/';
|
|
|
|
|
i++, Ptr++)
|
|
|
|
|
Asg->Folder[i] = *Ptr; // Copy assignment folder
|
|
|
|
|
Asg->Folder[i] = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Get number of assignments **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of assignments
|
2021-10-30 13:28:48 +02:00
|
|
|
|
// in this location (all the platform, the current degree or the current course)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
unsigned Asg_GetNumAssignments (Hie_Level_t Level,unsigned *NumNotif)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumAssignments;
|
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/***** Default values *****/
|
|
|
|
|
NumAssignments = 0;
|
|
|
|
|
*NumNotif = 0;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get number of assignments from database *****/
|
2023-07-11 19:12:24 +02:00
|
|
|
|
if (Asg_DB_GetNumAssignments (&mysql_res,Level))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/***** Get number of assignments *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%u",&NumAssignments) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of assignments.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 18:22:00 +02:00
|
|
|
|
/***** Get number of notifications by email *****/
|
|
|
|
|
if (row[1])
|
|
|
|
|
if (sscanf (row[1],"%u",NumNotif) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of notifications of assignments.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumAssignments;
|
|
|
|
|
}
|
2022-01-03 02:47:16 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Show stats about assignments ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Asg_GetAndShowAssignmentsStats (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ANALYTICS_Figures_assignments;
|
|
|
|
|
extern const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES];
|
|
|
|
|
extern const char *Txt_Number_of_BR_assignments;
|
|
|
|
|
extern const char *Txt_Number_of_BR_courses_with_BR_assignments;
|
|
|
|
|
extern const char *Txt_Average_number_BR_of_ASSIG_BR_per_course;
|
|
|
|
|
extern const char *Txt_Number_of_BR_notifications;
|
|
|
|
|
unsigned NumAssignments;
|
|
|
|
|
unsigned NumNotif;
|
2023-10-11 22:45:34 +02:00
|
|
|
|
unsigned NumCoursesWithAssignments;
|
2022-01-03 02:47:16 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the number of assignments from this location *****/
|
|
|
|
|
if ((NumAssignments = Asg_GetNumAssignments (Gbl.Scope.Current,&NumNotif)))
|
2023-10-11 22:45:34 +02:00
|
|
|
|
NumCoursesWithAssignments = Asg_DB_GetNumCoursesWithAssignments (Gbl.Scope.Current);
|
|
|
|
|
else
|
|
|
|
|
NumCoursesWithAssignments = 0;
|
2022-01-03 02:47:16 +01:00
|
|
|
|
|
|
|
|
|
/***** Begin box and table *****/
|
2024-01-29 08:47:21 +01:00
|
|
|
|
Box_BoxTableBegin (Txt_FIGURE_TYPES[Fig_ASSIGNMENTS],NULL,NULL,
|
2022-01-03 02:47:16 +01:00
|
|
|
|
Hlp_ANALYTICS_Figures_assignments,Box_NOT_CLOSABLE,2);
|
|
|
|
|
|
|
|
|
|
/***** Write table heading *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TH (Txt_Number_of_BR_assignments ,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_Number_of_BR_courses_with_BR_assignments,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_Average_number_BR_of_ASSIG_BR_per_course,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_Number_of_BR_notifications ,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write number of assignments *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2023-10-11 22:45:34 +02:00
|
|
|
|
HTM_TD_Unsigned (NumAssignments);
|
|
|
|
|
HTM_TD_Unsigned (NumCoursesWithAssignments);
|
|
|
|
|
HTM_TD_Ratio (NumAssignments,NumCoursesWithAssignments);
|
|
|
|
|
HTM_TD_Unsigned (NumNotif);
|
2022-01-03 02:47:16 +01:00
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** End table and box *****/
|
|
|
|
|
Box_BoxTableEnd ();
|
|
|
|
|
}
|