swad-core/swad_assignment.c

1735 lines
60 KiB
C
Raw Normal View History

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.
Copyright (C) 1999-2023 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
#include "swad_action_list.h"
2014-12-01 23:55:08 +01:00
#include "swad_assignment.h"
#include "swad_assignment_database.h"
#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"
#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"
#include "swad_group_database.h"
#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"
#include "swad_notification_database.h"
2014-12-01 23:55:08 +01:00
#include "swad_pagination.h"
#include "swad_parameter_code.h"
2014-12-01 23:55:08 +01:00
#include "swad_photo.h"
#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"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static void Asg_PutHead (struct Asg_Assignments *Assignments,
bool OnlyOneAssignment,
bool PrintView);
2016-11-07 01:44:50 +01:00
static bool 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);
static void Asg_ParsWhichGroupsToShow (void *Assignments);
static void Asg_PutIconsOneAsg (void *Assignments);
static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments,
bool OnlyOneAssignment,
bool PrintView);
2020-04-08 03:06:45 +02:00
static void Asg_WriteAsgAuthor (struct Asg_Assignment *Asg);
static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView);
2015-04-02 18:39:49 +02:00
static void Asg_PutIconsToRemEditOneAsg (struct Asg_Assignments *Assignments,
2019-04-20 22:06:18 +02:00
const char *Anchor);
static void Asg_PutPars (void *Assignments);
2020-04-05 22:53:58 +02:00
static void Asg_GetListAssignments (struct Asg_Assignments *Assignments);
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);
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);
static void Asg_CreateGroups (long AsgCod);
2020-04-08 03:06:45 +02:00
static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Asg_Assignment *Asg);
2015-11-10 02:23:55 +01:00
static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod);
2014-12-01 23:55:08 +01:00
2020-04-05 22:53:58 +02:00
/*****************************************************************************/
/*************************** Reset assignments *******************************/
/*****************************************************************************/
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->AsgCod = -1L; // Used as parameter in contextual links
2020-04-05 22:53:58 +02:00
Assignments->CurrentPage = 0;
Asg_ResetAssignment (&Assignments->Asg);
2020-04-05 22:53:58 +02:00
}
2014-12-01 23:55:08 +01: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 *****/
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
}
/*****************************************************************************/
/**************************** Show all assignments ***************************/
2014-12-01 23:55:08 +01: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;
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 *****/
2020-03-26 02:54:30 +01:00
Box_BoxBegin ("100%",Txt_Assignments,
2020-04-05 22:53:58 +02:00
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
/***** Select whether show only my groups or all groups *****/
if (Gbl.Crs.Grps.NumGrps)
{
Set_BeginSettingsHead ();
Grp_ShowFormToSelWhichGrps (ActSeeAllAsg,
Asg_ParsWhichGroupsToShow,Assignments);
Set_EndSettingsHead ();
}
2014-12-01 23:55:08 +01:00
/***** Write links to pages *****/
Pag_WriteLinksToPagesCentered (Pag_ASSIGNMENTS,&Pagination,
Assignments,-1L);
2019-12-06 22:18:05 +01:00
if (Assignments->Num)
{
/***** Begin table *****/
HTM_TABLE_BeginWideMarginPadding (2);
/***** Table head *****/
Asg_PutHead (Assignments,
false, // Not only this assignment in table
false); // Not print view
/***** Write all assignments *****/
for (NumAsg = Pagination.FirstItemVisible, The_ResetRowColor ();
NumAsg <= Pagination.LastItemVisible;
NumAsg++, The_ChangeRowColor ())
{
Assignments->Asg.AsgCod = Assignments->LstAsgCods[NumAsg - 1];
Asg_GetAssignmentDataByCod (&Assignments->Asg);
Asg_ShowAssignmentRow (Assignments,
false, // Not only this assignment in table
false); // Not print view
}
/***** End table *****/
HTM_TABLE_End ();
}
else // No assignments created
Ale_ShowAlert (Ale_INFO,Txt_No_assignments);
2016-03-19 19:22:13 +01: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 *****************/
/*****************************************************************************/
static void Asg_PutHead (struct Asg_Assignments *Assignments,
bool OnlyOneAssignment,
bool PrintView)
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
if (!OnlyOneAssignment)
HTM_TH_Span (NULL,HTM_HEAD_CENTER,1,1,"CONTEXT_COL"); // Column for contextual icons
for (Order = (Dat_StartEndTime_t) 0;
Order <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
Order++)
2017-05-02 13:02:43 +02:00
{
/* Begin head cell */
HTM_TH_Begin (HTM_HEAD_LEFT);
if (!PrintView)
{
/* Begin form */
Frm_BeginForm (ActSeeAllAsg);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
Pag_PutParPagNum (Pag_ASSIGNMENTS,Assignments->CurrentPage);
Par_PutParOrder ((unsigned) Order);
/* Begin link to select order */
HTM_BUTTON_Submit_Begin (Txt_START_END_TIME_HELP[Order],
"class=\"BT_LINK\"");
if (Order == Assignments->SelectedOrder)
HTM_U_Begin ();
}
/* Start / end text */
HTM_Txt (Txt_START_END_TIME[Order]);
if (!PrintView)
{
/* 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
}
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 **********************/
/*****************************************************************************/
static bool Asg_CheckIfICanCreateAssignments (void)
{
return Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM;
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)
{
2020-03-26 02:54:30 +01:00
if (Asg_CheckIfICanCreateAssignments ())
Asg_PutIconToCreateNewAsg (Assignments);
2016-11-07 01:44:50 +01:00
/***** Link to get resource link *****/
if (Rsc_CheckIfICanGetLink ())
{
((struct Asg_Assignments *) Assignments)->Asg.AsgCod = -1L;
Ico_PutContextualIconToGetLink (ActReqLnkAsg,NULL,
Asg_PutPars,Assignments);
}
}
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)
{
((struct Asg_Assignments *) Assignments)->Asg.AsgCod = -1L;
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
/*****************************************************************************/
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
{
Par_PutParOrder ((unsigned) ((struct Asg_Assignments *) Assignments)->SelectedOrder);
Pag_PutParPagNum (Pag_ASSIGNMENTS,
2020-04-05 22:53:58 +02:00
((struct Asg_Assignments *) Assignments)->CurrentPage);
2020-03-26 02:54:30 +01:00
}
2014-12-01 23:55:08 +01: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 *****/
Assignments.SelectedOrder = Asg_GetParAsgOrder ();
Grp_GetParWhichGroups ();
Assignments.CurrentPage = Pag_GetParPagNum (Pag_ASSIGNMENTS);
/***** Get the code of the assignment *****/
Assignments.Asg.AsgCod = ParCod_GetAndCheckPar (ParCod_Asg);
/***** Get data of this assignment *****/
Asg_GetAssignmentDataByCod (&Assignments.Asg);
/***** Show selected assignment in a box *****/
Asg_ShowOneAssignmentInBox (&Assignments);
/***** Show current assignments, if any *****/
// TODO: The page should be that corresponding to the selected assignment.
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 *****/
Assignments.Asg.AsgCod = ParCod_GetAndCheckPar (ParCod_Asg);
2017-05-02 10:24:47 +02:00
/***** Get data of this assignment *****/
Asg_GetAssignmentDataByCod (&Assignments.Asg);
2017-06-12 14:16:33 +02:00
/***** Write header *****/
2017-05-02 10:24:47 +02:00
Lay_WriteHeaderClassPhoto (true,false,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Deg.DegCod,
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod);
2017-05-02 10:24:47 +02:00
/***** Begin table *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_BeginWideMarginPadding (2);
2017-05-02 10:24:47 +02:00
/***** Table head *****/
Asg_PutHead (&Assignments,
true, // Only this assignment in table
true); // Print view
/***** Write assignment *****/
Asg_ShowAssignmentRow (&Assignments,
true, // Only this assignment in table
true); // Print view
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
}
/*****************************************************************************/
/************************* Show an assignment in a box ***********************/
/*****************************************************************************/
void Asg_ShowOneAssignmentInBox (struct Asg_Assignments *Assignments)
{
extern const char *Hlp_ASSESSMENT_Assignments;
extern const char *Txt_Assignment;
/***** Begin box and table *****/
Box_BoxTableBegin (NULL,Assignments->Asg.Title[0] ? Assignments->Asg.Title :
Txt_Assignment,
Asg_PutIconsOneAsg,Assignments,
Hlp_ASSESSMENT_Assignments,Box_NOT_CLOSABLE,2);
/***** Table head *****/
Asg_PutHead (Assignments,
true, // Only this assignment in table
false); // Not print view
/***** Write assignment *****/
Asg_ShowAssignmentRow (Assignments,
true, // Only this assignment in table
false); // Not print view
/***** End table and end box *****/
Box_BoxTableEnd ();
}
/*****************************************************************************/
/****************** Put contextual icons in an assignment ********************/
/*****************************************************************************/
static void Asg_PutIconsOneAsg (void *Assignments)
{
char *Anchor = NULL;
if (Assignments)
{
/***** Set anchor string *****/
Frm_SetAnchorStr (((struct Asg_Assignments *) Assignments)->Asg.AsgCod,&Anchor);
/***** Icons to remove/edit this assignment *****/
Asg_PutIconsToRemEditOneAsg (Assignments,Anchor);
/***** Free anchor string *****/
Frm_FreeAnchorStr (&Anchor);
}
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********************* Show assignment row in a table ************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments,
bool OnlyOneAssignment,
bool PrintView)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Actions[ActLst_NUM_ACTIONS];
extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE];
extern const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE];
extern const char *HidVis_TitleClass[HidVis_NUM_HIDDEN_VISIBLE];
extern const char *HidVis_DataClass[HidVis_NUM_HIDDEN_VISIBLE];
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 *****/
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
/* Forms to remove/edit this assignment */
if (!OnlyOneAssignment)
{
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL %s\"",
The_GetColorRows ());
Asg_PutIconsToRemEditOneAsg (Assignments,Anchor);
HTM_TD_End ();
}
2017-05-02 11:39:17 +02:00
/* Start/end date/time */
UniqueId++;
2019-09-27 00:46:02 +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 ();
if (PrintView)
HTM_TD_Begin ("id=\"%s\" class=\"LB %s_%s\"",
Id,
Assignments->Asg.Open == HidVis_HIDDEN ? HidVis_DateGreenClass[Assignments->Asg.HiddenOrVisible] :
HidVis_DateRedClass[Assignments->Asg.HiddenOrVisible],
The_GetSuffix ());
else
HTM_TD_Begin ("id=\"%s\" class=\"LB %s_%s %s\"",
Id,
Assignments->Asg.Open == HidVis_HIDDEN ? HidVis_DateGreenClass[Assignments->Asg.HiddenOrVisible] :
HidVis_DateRedClass[Assignments->Asg.HiddenOrVisible],
The_GetSuffix (),
The_GetColorRows ());
Dat_WriteLocalDateHMSFromUTC (Id,Assignments->Asg.TimeUTC[StartEndTime],
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
true,true,true,0x7);
HTM_TD_End ();
free (Id);
}
/* Assignment title */
2019-10-07 22:28:16 +02:00
if (PrintView)
HTM_TD_Begin ("class=\"LT\"");
2019-10-07 22:28:16 +02:00
else
HTM_TD_Begin ("class=\"LT %s\"",The_GetColorRows ());
HTM_ARTICLE_Begin (Anchor);
Frm_BeginForm (ActSeeOneAsg);
Asg_PutPars (Assignments);
HTM_BUTTON_Submit_Begin (Txt_Actions[ActSeeOneAsg],
"class=\"LT BT_LINK %s_%s\"",
HidVis_TitleClass[Assignments->Asg.HiddenOrVisible],
The_GetSuffix ());
HTM_Txt (Assignments->Asg.Title);
HTM_BUTTON_End ();
Frm_EndForm ();
HTM_ARTICLE_End ();
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2014-12-01 23:55:08 +01:00
/* Assignment folder */
if (PrintView)
HTM_TD_Begin ("class=\"LT DAT_%s\"",
The_GetSuffix ());
else
HTM_TD_Begin ("class=\"LT DAT_%s %s\"",
The_GetSuffix (),
The_GetColorRows ());
if (Assignments->Asg.SendWork == Asg_SEND_WORK)
Asg_WriteAssignmentFolder (&Assignments->Asg,PrintView);
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
/* Author of the assignment */
if (PrintView)
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
else
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
The_GetColorRows ());
Asg_WriteAsgAuthor (&Assignments->Asg);
HTM_TD_End ();
2014-12-01 23:55:08 +01:00
/* Text of the assignment */
Asg_DB_GetAssignmentTxtByCod (Assignments->Asg.AsgCod,Txt);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES);
ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
if (PrintView)
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
else
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",The_GetColorRows ());
if (Gbl.Crs.Grps.NumGrps)
Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (&Assignments->Asg);
HTM_DIV_Begin ("class=\"PAR %s_%s\"",
HidVis_DataClass[Assignments->Asg.HiddenOrVisible],
The_GetSuffix ());
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 *****/
Frm_FreeAnchorStr (&Anchor);
2019-04-20 22:06:18 +02:00
2014-12-01 23:55:08 +01:00
/***** Mark possible notification as seen *****/
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
{
Usr_WriteAuthor1Line (Asg->UsrCod,Asg->HiddenOrVisible);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* Write the folder of an assignment *********************/
/*****************************************************************************/
2020-04-08 03:06:45 +02:00
static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView)
2014-12-01 23:55:08 +01:00
{
2015-07-21 17:24:52 +02:00
extern const char *Txt_Folder;
Act_Action_t NextAction;
bool ICanSendFiles = Asg->HiddenOrVisible == HidVis_VISIBLE && // It's visible (not hidden)