2022-09-22 00:21:23 +02:00
|
|
|
|
// swad_assignment_resource.c: links to assignments as program resources
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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-2022 Antonio Ca<EFBFBD>as Vargas
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "swad_alert.h"
|
|
|
|
|
#include "swad_assignment.h"
|
|
|
|
|
#include "swad_assignment_database.h"
|
2022-09-28 15:19:17 +02:00
|
|
|
|
#include "swad_assignment_resource.h"
|
2022-09-22 00:21:23 +02:00
|
|
|
|
#include "swad_error.h"
|
|
|
|
|
#include "swad_form.h"
|
|
|
|
|
#include "swad_pagination.h"
|
|
|
|
|
#include "swad_program_database.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Get link to assignment ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void AsgRsc_GetLinkToAssignment (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Link_to_resource_X_copied_into_clipboard;
|
|
|
|
|
struct Asg_Assignments Assignments;
|
|
|
|
|
char Title[Asg_MAX_BYTES_ASSIGNMENT_TITLE + 1];
|
|
|
|
|
|
|
|
|
|
/***** Reset assignments *****/
|
|
|
|
|
Asg_ResetAssignments (&Assignments);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Assignments.SelectedOrder = Asg_GetParamAsgOrder ();
|
|
|
|
|
Grp_GetParamWhichGroups ();
|
|
|
|
|
Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS);
|
|
|
|
|
|
|
|
|
|
/***** Get assignment code *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Assignments.Asg.AsgCod = Asg_GetParamAsgCod ();
|
2022-09-22 00:21:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Get assignment title *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
AsgRsc_GetTitleFromAsgCod (Assignments.Asg.AsgCod,Title,sizeof (Title) - 1);
|
2022-09-22 00:21:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Copy link to assignment into resource clipboard *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
Prg_DB_CopyToClipboard (PrgRsc_ASSIGNMENT,Assignments.Asg.AsgCod);
|
2022-09-22 00:21:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Write sucess message *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard,
|
|
|
|
|
Title);
|
|
|
|
|
|
|
|
|
|
/***** Show selected assignment in a box *****/
|
2022-09-29 21:35:08 +02:00
|
|
|
|
if (Assignments.Asg.AsgCod > 0)
|
2022-09-29 00:04:41 +02:00
|
|
|
|
Asg_ShowOneAssignmentInBox (&Assignments);
|
2022-09-22 00:21:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Show current assignments, if any *****/
|
|
|
|
|
Asg_ShowAllAssignments (&Assignments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Write assignment in course program ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void AsgRsc_WriteAssignmentInCrsProgram (long AsgCod,bool PutFormToGo,
|
|
|
|
|
const char *Icon,const char *IconTitle)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Actions[Act_NUM_ACTIONS];
|
2022-09-28 15:19:17 +02:00
|
|
|
|
Act_Action_t NextAction;
|
2022-09-22 00:21:23 +02:00
|
|
|
|
char Title[Asg_MAX_BYTES_ASSIGNMENT_TITLE + 1];
|
|
|
|
|
|
|
|
|
|
/***** Get assignment title *****/
|
2022-09-28 15:19:17 +02:00
|
|
|
|
AsgRsc_GetTitleFromAsgCod (AsgCod,Title,sizeof (Title) - 1);
|
2022-09-22 00:21:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Begin form to go to assignment *****/
|
|
|
|
|
if (PutFormToGo)
|
|
|
|
|
{
|
2022-09-28 15:19:17 +02:00
|
|
|
|
NextAction = (AsgCod > 0) ? ActSeeOneAsg : // Assignment specified
|
|
|
|
|
ActSeeAsg; // All assignments
|
|
|
|
|
Frm_BeginForm (NextAction);
|
2022-09-22 00:21:23 +02:00
|
|
|
|
Asg_PutParamAsgCod (AsgCod);
|
|
|
|
|
// TODO: In the listing of assignments, the page is always the first.
|
|
|
|
|
// The page should be that corresponding to the selected assignment.
|
2022-09-28 15:19:17 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction],
|
2022-09-23 00:13:10 +02:00
|
|
|
|
"class=\"LM BT_LINK PRG_LNK_%s\"",
|
2022-09-22 00:21:23 +02:00
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Icon depending on type ******/
|
|
|
|
|
if (PutFormToGo)
|
2022-09-28 15:19:17 +02:00
|
|
|
|
Ico_PutIconLink (Icon,Ico_BLACK,NextAction);
|
2022-09-22 00:21:23 +02:00
|
|
|
|
else
|
|
|
|
|
Ico_PutIconOn (Icon,Ico_BLACK,IconTitle);
|
|
|
|
|
|
|
|
|
|
/***** Write assignment title of exam *****/
|
|
|
|
|
HTM_Txt (Title);
|
|
|
|
|
|
|
|
|
|
/***** End form to download file *****/
|
|
|
|
|
if (PutFormToGo)
|
|
|
|
|
{
|
|
|
|
|
/* End form */
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Get assignment title from assignment code ******************/
|
|
|
|
|
/*****************************************************************************/
|
2022-09-29 17:25:27 +02:00
|
|
|
|
// The trailing null character is not counted in TitleSize
|
2022-09-22 00:21:23 +02:00
|
|
|
|
|
|
|
|
|
void AsgRsc_GetTitleFromAsgCod (long AsgCod,char *Title,size_t TitleSize)
|
|
|
|
|
{
|
2022-09-29 00:04:41 +02:00
|
|
|
|
extern const char *Txt_Assignments;
|
2022-09-22 00:21:23 +02:00
|
|
|
|
char TitleFromDB[Asg_MAX_BYTES_ASSIGNMENT_TITLE + 1];
|
|
|
|
|
|
2022-09-28 15:19:17 +02:00
|
|
|
|
if (AsgCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Get assignment title *****/
|
|
|
|
|
Asg_DB_GetAssignmentTitleByCod (AsgCod,TitleFromDB);
|
|
|
|
|
Str_Copy (Title,TitleFromDB,TitleSize);
|
|
|
|
|
}
|
|
|
|
|
else
|
2022-09-29 00:04:41 +02:00
|
|
|
|
/***** Generic title for all assignments *****/
|
|
|
|
|
Str_Copy (Title,Txt_Assignments,TitleSize);
|
2022-09-22 00:21:23 +02:00
|
|
|
|
}
|