Version 20.83: May 27, 2021 New module swad_course_database for database queries related to courses.

This commit is contained in:
acanas 2021-05-27 00:30:06 +02:00
parent ac0070c318
commit 41a08ee001
25 changed files with 2078 additions and 1698 deletions

View File

@ -37,7 +37,7 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \
swad_connected.o swad_connected_database.o swad_cookie.o \
swad_cookie_database.o swad_country.o swad_country_config.o \
swad_country_database.o swad_course.o swad_course_config.o \
swad_cryptography.o \
swad_course_database.o swad_cryptography.o \
swad_database.o swad_date.o swad_degree.o swad_degree_config.o \
swad_degree_type.o swad_department.o swad_duplicate.o \
swad_enrolment.o swad_error.o swad_exam.o swad_exam_log.o \

View File

@ -1174,470 +1174,470 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams,
Cfe_PutHiddenParamExaCod (ExaCod);
}
/***** Begin table *****/
HTM_TABLE_Begin ("%s CELLS_PAD_2",
ClassCallForExam[TypeViewCallForExam][CallsForExams->CallForExam.Status]);
/***** Begin table *****/
HTM_TABLE_Begin ("%s CELLS_PAD_2",
ClassCallForExam[TypeViewCallForExam][CallsForExams->CallForExam.Status]);
/***** Institution logo *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("colspan=\"2\" class=\"CM\"");
if (TypeViewCallForExam == Cfe_PRINT_VIEW)
HTM_SPAN_Begin ("class=\"EXAM_TIT\"");
else
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"EXAM_TIT\"",
Ins.WWW);
Lgo_DrawLogo (Hie_Lvl_INS,Ins.InsCod,Ins.FullName,64,NULL,true);
HTM_BR ();
HTM_Txt (Ins.FullName);
if (TypeViewCallForExam == Cfe_PRINT_VIEW)
HTM_SPAN_End ();
else
HTM_A_End ();
HTM_TD_End ();
HTM_TR_End ();
/***** Institution logo *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("colspan=\"2\" class=\"CM\"");
if (TypeViewCallForExam == Cfe_PRINT_VIEW)
HTM_SPAN_Begin ("class=\"EXAM_TIT\"");
else
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"EXAM_TIT\"",
Ins.WWW);
Lgo_DrawLogo (Hie_Lvl_INS,Ins.InsCod,Ins.FullName,64,NULL,true);
HTM_BR ();
HTM_Txt (Ins.FullName);
if (TypeViewCallForExam == Cfe_PRINT_VIEW)
HTM_SPAN_End ();
else
HTM_A_End ();
HTM_TD_End ();
HTM_TR_End ();
/***** Degree *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("colspan=\"2\" class=\"EXAM_TIT CM\"");
if (TypeViewCallForExam == Cfe_NORMAL_VIEW)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"EXAM_TIT\"",
Gbl.Hierarchy.Deg.WWW);
HTM_Txt (Gbl.Hierarchy.Deg.FullName);
if (TypeViewCallForExam == Cfe_NORMAL_VIEW)
HTM_A_End ();
HTM_TD_End ();
HTM_TR_End ();
/***** Degree *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("colspan=\"2\" class=\"EXAM_TIT CM\"");
if (TypeViewCallForExam == Cfe_NORMAL_VIEW)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"EXAM_TIT\"",
Gbl.Hierarchy.Deg.WWW);
HTM_Txt (Gbl.Hierarchy.Deg.FullName);
if (TypeViewCallForExam == Cfe_NORMAL_VIEW)
HTM_A_End ();
HTM_TD_End ();
HTM_TR_End ();
/***** Title *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("colspan=\"2\" class=\"EXAM CM\"");
HTM_NBSP ();
HTM_BR ();
HTM_STRONG_Begin ();
HTM_Txt (Txt_CALL_FOR_EXAM);
HTM_STRONG_End ();
HTM_TD_End ();
HTM_TR_End ();
/***** Title *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("colspan=\"2\" class=\"EXAM CM\"");
HTM_NBSP ();
HTM_BR ();
HTM_STRONG_Begin ();
HTM_Txt (Txt_CALL_FOR_EXAM);
HTM_STRONG_End ();
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_Begin (NULL);
HTM_TD_Begin ("colspan=\"2\" class=\"EXAM LM\"");
HTM_NBSP ();
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_Begin (NULL);
HTM_TD_Begin ("colspan=\"2\" class=\"EXAM LM\"");
HTM_NBSP ();
HTM_TD_End ();
HTM_TR_End ();
/***** Name of the course *****/
HTM_TR_Begin (NULL);
/***** Name of the course *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "CrsName" :
NULL,
Txt_CALL_FOR_EXAM_Course);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "CrsName" :
NULL,
Txt_CALL_FOR_EXAM_Course);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
HTM_INPUT_TEXT ("CrsName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,CallsForExams->CallForExam.CrsFullName,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"CrsName\" size=\"30\"");
else
{
HTM_STRONG_Begin ();
HTM_Txt (CallsForExams->CallForExam.CrsFullName);
HTM_STRONG_End ();
}
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
HTM_INPUT_TEXT ("CrsName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,CallsForExams->CallForExam.CrsFullName,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"CrsName\" size=\"30\"");
else
{
HTM_STRONG_Begin ();
HTM_Txt (CallsForExams->CallForExam.CrsFullName);
HTM_STRONG_End ();
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Year/semester (N.A., 1º, 2º, 3º, 4º, 5º...) *****/
HTM_TR_Begin (NULL);
/***** Year/semester (N.A., 1º, 2º, 3º, 4º, 5º...) *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "Year" :
NULL,
Txt_CALL_FOR_EXAM_Year_or_semester);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "Year" :
NULL,
Txt_CALL_FOR_EXAM_Year_or_semester);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Year\" name=\"Year\"");
for (Year = 0;
Year <= Deg_MAX_YEARS_PER_DEGREE;
Year++)
HTM_OPTION (HTM_Type_UNSIGNED,&Year,
CallsForExams->CallForExam.Year == Year,false,
"%s",Txt_YEAR_OF_DEGREE[Year]);
HTM_SELECT_End ();
}
else
HTM_Txt (Txt_YEAR_OF_DEGREE[CallsForExams->CallForExam.Year]);
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Year\" name=\"Year\"");
for (Year = 0;
Year <= Deg_MAX_YEARS_PER_DEGREE;
Year++)
HTM_OPTION (HTM_Type_UNSIGNED,&Year,
CallsForExams->CallForExam.Year == Year,false,
"%s",Txt_YEAR_OF_DEGREE[Year]);
HTM_SELECT_End ();
}
else
HTM_Txt (Txt_YEAR_OF_DEGREE[CallsForExams->CallForExam.Year]);
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Exam session *****/
HTM_TR_Begin (NULL);
/***** Exam session *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "ExamSession" :
NULL,
Txt_CALL_FOR_EXAM_Session);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "ExamSession" :
NULL,
Txt_CALL_FOR_EXAM_Session);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
HTM_INPUT_TEXT ("ExamSession",Cfe_MAX_CHARS_SESSION,CallsForExams->CallForExam.Session,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"ExamSession\" size=\"30\"");
else
HTM_Txt (CallsForExams->CallForExam.Session);
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
HTM_INPUT_TEXT ("ExamSession",Cfe_MAX_CHARS_SESSION,CallsForExams->CallForExam.Session,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"ExamSession\" size=\"30\"");
else
HTM_Txt (CallsForExams->CallForExam.Session);
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Date of the exam *****/
HTM_TR_Begin (NULL);
/***** Date of the exam *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "ExamYear" :
NULL,
Txt_CALL_FOR_EXAM_Exam_date);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "ExamYear" :
NULL,
Txt_CALL_FOR_EXAM_Exam_date);
/* Data */
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TD_Begin ("class=\"LB\"");
Dat_WriteFormDate (CallsForExams->CallForExam.ExamDate.Year < Gbl.Now.Date.Year ? CallsForExams->CallForExam.ExamDate.Year :
Gbl.Now.Date.Year,
Gbl.Now.Date.Year + 1,"Exam",
&(CallsForExams->CallForExam.ExamDate),
false,false);
HTM_TD_End ();
}
else
{
Dat_ConvDateToDateStr (&CallsForExams->CallForExam.ExamDate,
StrExamDate);
HTM_TD_Begin ("class=\"EXAM LB\"");
HTM_Txt (StrExamDate);
HTM_TD_End ();
}
HTM_TR_End ();
/* Data */
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TD_Begin ("class=\"LB\"");
Dat_WriteFormDate (CallsForExams->CallForExam.ExamDate.Year < Gbl.Now.Date.Year ? CallsForExams->CallForExam.ExamDate.Year :
Gbl.Now.Date.Year,
Gbl.Now.Date.Year + 1,"Exam",
&(CallsForExams->CallForExam.ExamDate),
false,false);
HTM_TD_End ();
}
else
{
Dat_ConvDateToDateStr (&CallsForExams->CallForExam.ExamDate,
StrExamDate);
HTM_TD_Begin ("class=\"EXAM LB\"");
HTM_Txt (StrExamDate);
HTM_TD_End ();
}
HTM_TR_End ();
/***** Start time *****/
HTM_TR_Begin (NULL);
/***** Start time *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "ExamHour" :
NULL,
Txt_CALL_FOR_EXAM_Start_time);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "ExamHour" :
NULL,
Txt_CALL_FOR_EXAM_Start_time);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"ExamHour\" name=\"ExamHour\"");
HTM_OPTION (HTM_Type_STRING,"0",
CallsForExams->CallForExam.StartTime.Hour == 0,false,
"-");
for (Hour = 7;
Hour <= 22;
Hour++)
HTM_OPTION (HTM_Type_UNSIGNED,&Hour,
CallsForExams->CallForExam.StartTime.Hour == Hour,false,
"%02u %s",Hour,Txt_hours_ABBREVIATION);
HTM_SELECT_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"ExamHour\" name=\"ExamHour\"");
HTM_OPTION (HTM_Type_STRING,"0",
CallsForExams->CallForExam.StartTime.Hour == 0,false,
"-");
for (Hour = 7;
Hour <= 22;
Hour++)
HTM_OPTION (HTM_Type_UNSIGNED,&Hour,
CallsForExams->CallForExam.StartTime.Hour == Hour,false,
"%02u %s",Hour,Txt_hours_ABBREVIATION);
HTM_SELECT_End ();
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"name=\"ExamMinute\"");
for (Minute = 0;
Minute <= 59;
Minute++)
HTM_OPTION (HTM_Type_UNSIGNED,&Minute,
CallsForExams->CallForExam.StartTime.Minute == Minute,false,
"%02u &prime;",Minute);
HTM_SELECT_End ();
}
else if (CallsForExams->CallForExam.StartTime.Hour)
HTM_TxtF ("%2u:%02u",CallsForExams->CallForExam.StartTime.Hour,
CallsForExams->CallForExam.StartTime.Minute);
HTM_TD_End ();
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"name=\"ExamMinute\"");
for (Minute = 0;
Minute <= 59;
Minute++)
HTM_OPTION (HTM_Type_UNSIGNED,&Minute,
CallsForExams->CallForExam.StartTime.Minute == Minute,false,
"%02u &prime;",Minute);
HTM_SELECT_End ();
}
else if (CallsForExams->CallForExam.StartTime.Hour)
HTM_TxtF ("%2u:%02u",CallsForExams->CallForExam.StartTime.Hour,
CallsForExams->CallForExam.StartTime.Minute);
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Approximate duration of the exam *****/
HTM_TR_Begin (NULL);
/***** Approximate duration of the exam *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "DurationHour" :
NULL,
Txt_CALL_FOR_EXAM_Approximate_duration);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "DurationHour" :
NULL,
Txt_CALL_FOR_EXAM_Approximate_duration);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"DurationHour\" name=\"DurationHour\"");
for (Hour = 0;
Hour <= 8;
Hour++)
HTM_OPTION (HTM_Type_UNSIGNED,&Hour,
CallsForExams->CallForExam.Duration.Hour == Hour,false,
"%02u %s",Hour,Txt_hours_ABBREVIATION);
HTM_SELECT_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"DurationHour\" name=\"DurationHour\"");
for (Hour = 0;
Hour <= 8;
Hour++)
HTM_OPTION (HTM_Type_UNSIGNED,&Hour,
CallsForExams->CallForExam.Duration.Hour == Hour,false,
"%02u %s",Hour,Txt_hours_ABBREVIATION);
HTM_SELECT_End ();
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"name=\"DurationMinute\"");
for (Minute = 0;
Minute <= 59;
Minute++)
HTM_OPTION (HTM_Type_UNSIGNED,&Minute,
CallsForExams->CallForExam.Duration.Minute == Minute,false,
"%02u &prime;",Minute);
HTM_SELECT_End ();
}
else if (CallsForExams->CallForExam.Duration.Hour ||
CallsForExams->CallForExam.Duration.Minute)
{
if (CallsForExams->CallForExam.Duration.Hour)
{
if (CallsForExams->CallForExam.Duration.Minute)
HTM_TxtF ("%u%s %u&prime;",CallsForExams->CallForExam.Duration.Hour,
Txt_hours_ABBREVIATION,
CallsForExams->CallForExam.Duration.Minute);
else
HTM_TxtF ("%u&nbsp;%s",CallsForExams->CallForExam.Duration.Hour,
CallsForExams->CallForExam.Duration.Hour == 1 ? Txt_hour :
Txt_hours);
}
else if (CallsForExams->CallForExam.Duration.Minute)
{
HTM_TxtF ("%u&nbsp;%s",CallsForExams->CallForExam.Duration.Minute,
CallsForExams->CallForExam.Duration.Minute == 1 ? Txt_minute :
Txt_minutes);
}
}
HTM_TD_End ();
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
"name=\"DurationMinute\"");
for (Minute = 0;
Minute <= 59;
Minute++)
HTM_OPTION (HTM_Type_UNSIGNED,&Minute,
CallsForExams->CallForExam.Duration.Minute == Minute,false,
"%02u &prime;",Minute);
HTM_SELECT_End ();
}
else if (CallsForExams->CallForExam.Duration.Hour ||
CallsForExams->CallForExam.Duration.Minute)
{
if (CallsForExams->CallForExam.Duration.Hour)
{
if (CallsForExams->CallForExam.Duration.Minute)
HTM_TxtF ("%u%s %u&prime;",CallsForExams->CallForExam.Duration.Hour,
Txt_hours_ABBREVIATION,
CallsForExams->CallForExam.Duration.Minute);
else
HTM_TxtF ("%u&nbsp;%s",CallsForExams->CallForExam.Duration.Hour,
CallsForExams->CallForExam.Duration.Hour == 1 ? Txt_hour :
Txt_hours);
}
else if (CallsForExams->CallForExam.Duration.Minute)
{
HTM_TxtF ("%u&nbsp;%s",CallsForExams->CallForExam.Duration.Minute,
CallsForExams->CallForExam.Duration.Minute == 1 ? Txt_minute :
Txt_minutes);
}
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Place where the exam will be made *****/
HTM_TR_Begin (NULL);
/***** Place where the exam will be made *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "Place" :
NULL,
Txt_CALL_FOR_EXAM_Place_of_exam);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "Place" :
NULL,
Txt_CALL_FOR_EXAM_Place_of_exam);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"Place\" name=\"Place\" cols=\"40\" rows=\"4\"");
HTM_Txt (CallsForExams->CallForExam.Place);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.Place,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.Place);
}
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"Place\" name=\"Place\" cols=\"40\" rows=\"4\"");
HTM_Txt (CallsForExams->CallForExam.Place);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.Place,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.Place);
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Exam mode *****/
HTM_TR_Begin (NULL);
/***** Exam mode *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "ExamMode" :
NULL,
Txt_CALL_FOR_EXAM_Mode);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "ExamMode" :
NULL,
Txt_CALL_FOR_EXAM_Mode);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"ExamMode\" name=\"ExamMode\" cols=\"40\" rows=\"2\"");
HTM_Txt (CallsForExams->CallForExam.Mode);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.Mode,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.Mode);
}
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"ExamMode\" name=\"ExamMode\" cols=\"40\" rows=\"2\"");
HTM_Txt (CallsForExams->CallForExam.Mode);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.Mode,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.Mode);
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Structure of the exam *****/
HTM_TR_Begin (NULL);
/***** Structure of the exam *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "Structure" :
NULL,
Txt_CALL_FOR_EXAM_Structure_of_the_exam);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "Structure" :
NULL,
Txt_CALL_FOR_EXAM_Structure_of_the_exam);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"Structure\" name=\"Structure\" cols=\"40\" rows=\"8\"");
HTM_Txt (CallsForExams->CallForExam.Structure);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.Structure,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.Structure);
}
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"Structure\" name=\"Structure\" cols=\"40\" rows=\"8\"");
HTM_Txt (CallsForExams->CallForExam.Structure);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.Structure,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.Structure);
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Documentation required *****/
HTM_TR_Begin (NULL);
/***** Documentation required *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "DocRequired" :
NULL,
Txt_CALL_FOR_EXAM_Documentation_required);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "DocRequired" :
NULL,
Txt_CALL_FOR_EXAM_Documentation_required);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"DocRequired\" name=\"DocRequired\" cols=\"40\" rows=\"2\"");
HTM_Txt (CallsForExams->CallForExam.DocRequired);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.DocRequired,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.DocRequired);
}
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"DocRequired\" name=\"DocRequired\" cols=\"40\" rows=\"2\"");
HTM_Txt (CallsForExams->CallForExam.DocRequired);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.DocRequired,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.DocRequired);
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Material required *****/
HTM_TR_Begin (NULL);
/***** Material required *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "MatRequired" :
NULL,
Txt_CALL_FOR_EXAM_Material_required);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "MatRequired" :
NULL,
Txt_CALL_FOR_EXAM_Material_required);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"MatRequired\" name=\"MatRequired\" cols=\"40\" rows=\"4\"");
HTM_Txt (CallsForExams->CallForExam.MatRequired);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.MatRequired,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.MatRequired);
}
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"MatRequired\" name=\"MatRequired\" cols=\"40\" rows=\"4\"");
HTM_Txt (CallsForExams->CallForExam.MatRequired);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.MatRequired,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.MatRequired);
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Material allowed *****/
HTM_TR_Begin (NULL);
/***** Material allowed *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "MatAllowed" :
NULL,
Txt_CALL_FOR_EXAM_Material_allowed);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "MatAllowed" :
NULL,
Txt_CALL_FOR_EXAM_Material_allowed);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"MatAllowed\" name=\"MatAllowed\" cols=\"40\" rows=\"4\"");
HTM_Txt (CallsForExams->CallForExam.MatAllowed);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.MatAllowed,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.MatAllowed);
}
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"MatAllowed\" name=\"MatAllowed\" cols=\"40\" rows=\"4\"");
HTM_Txt (CallsForExams->CallForExam.MatAllowed);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.MatAllowed,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.MatAllowed);
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** Other information to students *****/
HTM_TR_Begin (NULL);
/***** Other information to students *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "OtherInfo" :
NULL,
Txt_CALL_FOR_EXAM_Other_information);
/* Label */
Frm_LabelColumn ("RT",
TypeViewCallForExam == Cfe_FORM_VIEW ? "OtherInfo" :
NULL,
Txt_CALL_FOR_EXAM_Other_information);
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"OtherInfo\" name=\"OtherInfo\" cols=\"40\" rows=\"5\"");
HTM_Txt (CallsForExams->CallForExam.OtherInfo);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.OtherInfo,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.OtherInfo);
}
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"EXAM LB\"");
if (TypeViewCallForExam == Cfe_FORM_VIEW)
{
HTM_TEXTAREA_Begin ("id=\"OtherInfo\" name=\"OtherInfo\" cols=\"40\" rows=\"5\"");
HTM_Txt (CallsForExams->CallForExam.OtherInfo);
HTM_TEXTAREA_End ();
}
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CallsForExams->CallForExam.OtherInfo,
Cns_MAX_BYTES_TEXT,false);
HTM_Txt (CallsForExams->CallForExam.OtherInfo);
}
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** End table, send button and end box *****/
if (TypeViewCallForExam == Cfe_FORM_VIEW)
Box_BoxTableWithButtonEnd ((ExaCod > 0) ? Btn_CONFIRM_BUTTON :
Btn_CREATE_BUTTON,
Txt_Publish_call_FOR_EXAM);
else
Box_BoxTableEnd ();
/***** End table, send button and end box *****/
if (TypeViewCallForExam == Cfe_FORM_VIEW)
Box_BoxTableWithButtonEnd ((ExaCod > 0) ? Btn_CONFIRM_BUTTON :
Btn_CREATE_BUTTON,
Txt_Publish_call_FOR_EXAM);
else
Box_BoxTableEnd ();
/***** Show QR code *****/
if (TypeViewCallForExam == Cfe_PRINT_VIEW)
QR_ExamAnnnouncement ();
/***** Show QR code *****/
if (TypeViewCallForExam == Cfe_PRINT_VIEW)
QR_ExamAnnnouncement ();
/***** End article *****/
if (TypeViewCallForExam == Cfe_NORMAL_VIEW)
@ -1840,3 +1840,17 @@ static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *Call
Txt_CALL_FOR_EXAM_Other_information,CallsForExams->CallForExam.OtherInfo) < 0)
Err_NotEnoughMemoryExit ();
}
/*****************************************************************************/
/*********** Mark all exam announcements in the course as deleted ************/
/*****************************************************************************/
void Cfe_DB_MarkCallForExamsInCrsAsDeleted (long CrsCod)
{
DB_QueryUPDATE ("can not remove calls for exams of a course",
"UPDATE cfe_exams"
" SET Status=%u"
" WHERE CrsCod=%ld",
(unsigned) Cfe_DELETED_CALL_FOR_EXAM,
CrsCod);
}

View File

@ -126,4 +126,6 @@ void Cfe_GetSummaryAndContentCallForExam (char SummaryStr[Ntf_MAX_BYTES_SUMMARY
char **ContentStr,
long ExaCod,bool GetContent);
void Cfe_DB_MarkCallForExamsInCrsAsDeleted (long CrsCod);
#endif

View File

@ -1232,7 +1232,7 @@ void Ctr_RemoveCenter (void)
Svy_RemoveSurveys (Hie_Lvl_CTR,Ctr_EditingCtr->CtrCod);
/***** Remove information related to files in center *****/
Brw_RemoveCtrFilesFromDB (Ctr_EditingCtr->CtrCod);
Brw_DB_RemoveCtrFiles (Ctr_EditingCtr->CtrCod);
/***** Remove all rooms in center *****/
Roo_RemoveAllRoomsInCtr (Ctr_EditingCtr->CtrCod);

View File

@ -602,14 +602,15 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/
#define Log_PLATFORM_VERSION "SWAD 20.82 (2021-05-23)"
#define Log_PLATFORM_VERSION "SWAD 20.83 (2021-05-27)"
#define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js"
/*
TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.82: May 22, 2021 Queries moved to module swad_country_database. (311702 lines)
Version 20.83: May 27, 2021 New module swad_course_database for database queries related to courses. (311982 lines)
Version 20.82: May 23, 2021 Queries moved to module swad_country_database. (311702 lines)
Version 20.81: May 22, 2021 New module swad_country_database for database queries related to countries. (311632 lines)
Version 20.80: May 20, 2021 New module swad_cookie_database for database queries related to cookies. (311497 lines)
Version 20.79: May 20, 2021 New module swad_connected_database for database queries related to connected users. (311415 lines)

View File

@ -126,7 +126,7 @@ void Cty_SeeCtyWithPendingInss (void)
}
/***** Get countries with pending institutions *****/
if ((NumCtys = Cty_DB_GetListOfCountriesWithPendingInss (&mysql_res)))
if ((NumCtys = Cty_DB_GetCtysWithPendingInss (&mysql_res)))
{
/***** Begin box and table *****/
Box_BoxTableBegin (NULL,Txt_Countries_with_pending_institutions,
@ -748,7 +748,7 @@ void Cty_GetBasicListOfCountries (void)
return;
/***** Get countries from database *****/
if ((Gbl.Hierarchy.Ctys.Num = Cty_DB_GetBasicListOfCountries (&mysql_res))) // Countries found...
if ((Gbl.Hierarchy.Ctys.Num = Cty_DB_GetCtysBasic (&mysql_res))) // Countries found...
{
/***** Create list with countries *****/
if ((Gbl.Hierarchy.Ctys.Lst = calloc ((size_t) Gbl.Hierarchy.Ctys.Num,
@ -809,7 +809,7 @@ void Cty_GetFullListOfCountries (void)
return;
/***** Get countries from database *****/
if ((Gbl.Hierarchy.Ctys.Num = Cty_DB_GetFullListOfCountries (&mysql_res))) // Countries found...
if ((Gbl.Hierarchy.Ctys.Num = Cty_DB_GetCtysFull (&mysql_res))) // Countries found...
{
/***** Create list with countries *****/
if ((Gbl.Hierarchy.Ctys.Lst = calloc ((size_t) Gbl.Hierarchy.Ctys.Num,
@ -871,15 +871,15 @@ void Cty_WriteSelectorOfCountry (void)
/***** Begin form *****/
Frm_BeginFormGoTo (ActSeeIns);
/* Begin selector of country */
/***** Begin selector of country *****/
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
"id=\"cty\" name=\"cty\" class=\"HIE_SEL\"");
/* Initial disabled option */
/***** Initial disabled option *****/
HTM_OPTION (HTM_Type_STRING,"",Gbl.Hierarchy.Cty.CtyCod < 0,true,
"[%s]",Txt_Country);
/* List countries */
/***** List countries *****/
for (NumCty = 0;
NumCty < Gbl.Hierarchy.Ctys.Num;
NumCty++)
@ -887,7 +887,7 @@ void Cty_WriteSelectorOfCountry (void)
Gbl.Hierarchy.Ctys.Lst[NumCty].CtyCod == Gbl.Hierarchy.Cty.CtyCod,false,
"%s",Gbl.Hierarchy.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]);
/* End selector of country */
/***** End selector of country *****/
HTM_SELECT_End ();
/***** End form *****/

View File

@ -113,7 +113,7 @@ void Cty_DB_CreateCountry (const struct Cty_Countr *Cty)
/********** Get basic list of countries ordered by name of country ***********/
/*****************************************************************************/
unsigned Cty_DB_GetBasicListOfCountries (MYSQL_RES **mysql_res)
unsigned Cty_DB_GetCtysBasic (MYSQL_RES **mysql_res)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
@ -131,7 +131,7 @@ unsigned Cty_DB_GetBasicListOfCountries (MYSQL_RES **mysql_res)
/******************* Get countries with pending institutions *****************/
/*****************************************************************************/
unsigned Cty_DB_GetListOfCountriesWithPendingInss (MYSQL_RES **mysql_res)
unsigned Cty_DB_GetCtysWithPendingInss (MYSQL_RES **mysql_res)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
@ -155,7 +155,7 @@ unsigned Cty_DB_GetListOfCountriesWithPendingInss (MYSQL_RES **mysql_res)
/********** and number of users who claim to belong to them ***********/
/*****************************************************************************/
unsigned Cty_DB_GetFullListOfCountries (MYSQL_RES **mysql_res)
unsigned Cty_DB_GetCtysFull (MYSQL_RES **mysql_res)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
char StrField[32];

View File

@ -43,9 +43,9 @@
void Cty_DB_CreateCountry (const struct Cty_Countr *Cty);
unsigned Cty_DB_GetBasicListOfCountries (MYSQL_RES **mysql_res);
unsigned Cty_DB_GetListOfCountriesWithPendingInss (MYSQL_RES **mysql_res);
unsigned Cty_DB_GetFullListOfCountries (MYSQL_RES **mysql_res);
unsigned Cty_DB_GetCtysBasic (MYSQL_RES **mysql_res);
unsigned Cty_DB_GetCtysWithPendingInss (MYSQL_RES **mysql_res);
unsigned Cty_DB_GetCtysFull (MYSQL_RES **mysql_res);
unsigned Cty_DB_GetDataOfCountryByCod (MYSQL_RES **mysql_res,long CtyCod);
void Cty_DB_GetCountryName (long CtyCod,Lan_Language_t Language,
char CtyName[Cty_MAX_BYTES_NAME + 1]);

File diff suppressed because it is too large Load Diff

View File

@ -71,12 +71,6 @@ typedef enum
Crs_STATUS_REMOVED = 3, // 1- (Status & Crs_STATUS_BIT_REMOVED)
} Crs_StatusTxt_t;
typedef enum
{
Crs_ACTIVE_COURSES = 0, // Courses with all Status bits == 0
Crs_ALL_COURSES_EXCEPT_REMOVED = 1, // Courses with Status bit Crs_STATUS_BIT_REMOVED == 0
} Crs_WhatCourses_t;
struct Crs_Course
{
long CrsCod;
@ -137,13 +131,15 @@ bool Crs_GetDataOfCourseByCod (struct Crs_Course *Crs);
void Crs_RemoveCourseCompletely (long CrsCod);
void Crs_ChangeInsCrsCod (void);
void Crs_ChangeCrsYear (void);
void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,
const char *NewInstitutionalCrsCod);
void Crs_UpdateCrsYear (struct Crs_Course *Crs,unsigned NewYear);
void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,const char *NewInstitutionalCrsCod);
void Crs_RenameCourseShort (void);
void Crs_RenameCourseFull (void);
void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName);
bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
long DegCod,unsigned Year);
void Crs_ChangeCrsStatus (void);
void Crs_ContEditAfterChgCrs (void);

View File

@ -32,6 +32,7 @@
#include <stdlib.h> // For free
#include <string.h> // For string functions
#include "swad_course_database.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_form.h"
@ -77,8 +78,6 @@ static void CrsCfg_Shortcut (bool PrintView);
static void CrsCfg_QR (void);
static void CrsCfg_Indicators (void);
static void CrsCfg_UpdateCrsDegDB (long CrsCod,long DegCod);
/*****************************************************************************/
/***************** Configuration of the current course ***********************/
/*****************************************************************************/
@ -129,48 +128,48 @@ void CrsCfg_Configuration (bool PrintView)
/**************************** Left part ***********************************/
HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\"");
/***** Begin table *****/
HTM_TABLE_BeginWidePadding (2);
/***** Begin table *****/
HTM_TABLE_BeginWidePadding (2);
/***** Degree *****/
CrsCfg_Degree (PrintView,PutFormDeg);
/***** Degree *****/
CrsCfg_Degree (PrintView,PutFormDeg);
/***** Course name *****/
CrsCfg_FullName (PutFormName);
CrsCfg_ShrtName (PutFormName);
/***** Course name *****/
CrsCfg_FullName (PutFormName);
CrsCfg_ShrtName (PutFormName);
/***** Course year *****/
CrsCfg_Year (PutFormYear);
/***** Course year *****/
CrsCfg_Year (PutFormYear);
if (!PrintView)
{
/***** Institutional code of the course *****/
CrsCfg_InstitutionalCode (PutFormInsCod);
if (!PrintView)
{
/***** Institutional code of the course *****/
CrsCfg_InstitutionalCode (PutFormInsCod);
/***** Internal code of the course *****/
CrsCfg_InternalCode ();
}
/***** Internal code of the course *****/
CrsCfg_InternalCode ();
}
/***** Shortcut to the couse *****/
CrsCfg_Shortcut (PrintView);
/***** Shortcut to the couse *****/
CrsCfg_Shortcut (PrintView);
if (PrintView)
/***** QR code with link to the course *****/
CrsCfg_QR ();
else
{
/***** Number of users *****/
HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_TCH);
HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_NET);
HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_STD);
HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_UNK);
if (PrintView)
/***** QR code with link to the course *****/
CrsCfg_QR ();
else
{
/***** Number of users *****/
HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_TCH);
HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_NET);
HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_STD);
HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_UNK);
/***** Indicators *****/
CrsCfg_Indicators ();
}
/***** Indicators *****/
CrsCfg_Indicators ();
}
/***** End table *****/
HTM_TABLE_End ();
/***** End table *****/
HTM_TABLE_End ();
/***** End of left part *****/
HTM_DIV_End ();
@ -205,12 +204,12 @@ void CrsCfg_PrintConfiguration (void)
static void CrsCfg_Title (bool PutLink)
{
HieCfg_Title (PutLink,
Hie_Lvl_DEG, // Logo scope
Gbl.Hierarchy.Deg.DegCod, // Logo code
Gbl.Hierarchy.Deg.ShrtName, // Logo short name
Gbl.Hierarchy.Deg.FullName, // Logo full name
Gbl.Hierarchy.Deg.WWW, // Logo www
Gbl.Hierarchy.Crs.FullName); // Text full name
Hie_Lvl_DEG, // Logo scope
Gbl.Hierarchy.Deg.DegCod, // Logo code
Gbl.Hierarchy.Deg.ShrtName, // Logo short name
Gbl.Hierarchy.Deg.FullName, // Logo full name
Gbl.Hierarchy.Deg.WWW, // Logo www
Gbl.Hierarchy.Crs.FullName); // Text full name
}
/*****************************************************************************/
@ -225,56 +224,56 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm)
/***** Degree *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "OthDegCod" :
NULL,
Txt_Degree);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "OthDegCod" :
NULL,
Txt_Degree);
/* Data */
HTM_TD_Begin ("class=\"DAT LB\"");
if (PutForm)
{
/* Get list of degrees of the current center */
Deg_GetListDegsInCurrentCtr ();
/* Data */
HTM_TD_Begin ("class=\"DAT LB\"");
if (PutForm)
{
/* Get list of degrees of the current center */
Deg_GetListDegsInCurrentCtr ();
/* Put form to select degree */
Frm_BeginForm (ActChgCrsDegCfg);
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
"id=\"OthDegCod\" name=\"OthDegCod\""
" class=\"INPUT_SHORT_NAME\"");
for (NumDeg = 0;
NumDeg < Gbl.Hierarchy.Degs.Num;
NumDeg++)
HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Degs.Lst[NumDeg].DegCod,
Gbl.Hierarchy.Degs.Lst[NumDeg].DegCod == Gbl.Hierarchy.Deg.DegCod,false,
"%s",Gbl.Hierarchy.Degs.Lst[NumDeg].ShrtName);
HTM_SELECT_End ();
Frm_EndForm ();
/* Put form to select degree */
Frm_BeginForm (ActChgCrsDegCfg);
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
"id=\"OthDegCod\" name=\"OthDegCod\""
" class=\"INPUT_SHORT_NAME\"");
for (NumDeg = 0;
NumDeg < Gbl.Hierarchy.Degs.Num;
NumDeg++)
HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Degs.Lst[NumDeg].DegCod,
Gbl.Hierarchy.Degs.Lst[NumDeg].DegCod == Gbl.Hierarchy.Deg.DegCod,false,
"%s",Gbl.Hierarchy.Degs.Lst[NumDeg].ShrtName);
HTM_SELECT_End ();
Frm_EndForm ();
/* Free list of degrees of the current center */
Deg_FreeListDegs (&Gbl.Hierarchy.Degs);
}
else // I can not move course to another degree
{
if (!PrintView)
{
Frm_BeginFormGoTo (ActSeeDegInf);
Deg_PutParamDegCod (Gbl.Hierarchy.Deg.DegCod);
HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Gbl.Hierarchy.Deg.ShrtName),
"BT_LINK LT DAT",NULL);
Hie_FreeGoToMsg ();
}
Lgo_DrawLogo (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.ShrtName,
20,"LM",true);
HTM_NBSP ();
HTM_Txt (Gbl.Hierarchy.Deg.FullName);
if (!PrintView)
{
HTM_BUTTON_End ();
Frm_EndForm ();
}
}
HTM_TD_End ();
/* Free list of degrees of the current center */
Deg_FreeListDegs (&Gbl.Hierarchy.Degs);
}
else // I can not move course to another degree
{
if (!PrintView)
{
Frm_BeginFormGoTo (ActSeeDegInf);
Deg_PutParamDegCod (Gbl.Hierarchy.Deg.DegCod);
HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Gbl.Hierarchy.Deg.ShrtName),
"BT_LINK LT DAT",NULL);
Hie_FreeGoToMsg ();
}
Lgo_DrawLogo (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.ShrtName,
20,"LM",true);
HTM_NBSP ();
HTM_Txt (Gbl.Hierarchy.Deg.FullName);
if (!PrintView)
{
HTM_BUTTON_End ();
Frm_EndForm ();
}
}
HTM_TD_End ();
HTM_TR_End ();
}
@ -314,31 +313,31 @@ static void CrsCfg_Year (bool PutForm)
/***** Academic year *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "OthCrsYear" :
NULL,
Txt_Year_OF_A_DEGREE);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "OthCrsYear" :
NULL,
Txt_Year_OF_A_DEGREE);
/* Data */
HTM_TD_Begin ("class=\"DAT LB\"");
if (PutForm)
{
Frm_BeginForm (ActChgCrsYeaCfg);
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
"id=\"OthCrsYear\" name=\"OthCrsYear\"");
for (Year = 0;
Year <= Deg_MAX_YEARS_PER_DEGREE;
Year++)
HTM_OPTION (HTM_Type_UNSIGNED,&Year,
Year == Gbl.Hierarchy.Crs.Year,false,
"%s",Txt_YEAR_OF_DEGREE[Year]);
HTM_SELECT_End ();
Frm_EndForm ();
}
else
HTM_Txt (Gbl.Hierarchy.Crs.Year ? Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year] :
Txt_Not_applicable);
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"DAT LB\"");
if (PutForm)
{
Frm_BeginForm (ActChgCrsYeaCfg);
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
"id=\"OthCrsYear\" name=\"OthCrsYear\"");
for (Year = 0;
Year <= Deg_MAX_YEARS_PER_DEGREE;
Year++)
HTM_OPTION (HTM_Type_UNSIGNED,&Year,
Year == Gbl.Hierarchy.Crs.Year,false,
"%s",Txt_YEAR_OF_DEGREE[Year]);
HTM_SELECT_End ();
Frm_EndForm ();
}
else
HTM_Txt (Gbl.Hierarchy.Crs.Year ? Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year] :
Txt_Not_applicable);
HTM_TD_End ();
HTM_TR_End ();
}
@ -354,26 +353,26 @@ static void CrsCfg_InstitutionalCode (bool PutForm)
/***** Institutional course code *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "InsCrsCod" :
NULL,
Txt_Institutional_code);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "InsCrsCod" :
NULL,
Txt_Institutional_code);
/* Data */
HTM_TD_Begin ("class=\"DAT LB\"");
if (PutForm)
{
Frm_BeginForm (ActChgInsCrsCodCfg);
HTM_INPUT_TEXT ("InsCrsCod",Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD,
Gbl.Hierarchy.Crs.InstitutionalCrsCod,
HTM_SUBMIT_ON_CHANGE,
"id=\"InsCrsCod\" size=\"%u\" class=\"INPUT_INS_CODE\"",
Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD);
Frm_EndForm ();
}
else
HTM_Txt (Gbl.Hierarchy.Crs.InstitutionalCrsCod);
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"DAT LB\"");
if (PutForm)
{
Frm_BeginForm (ActChgInsCrsCodCfg);
HTM_INPUT_TEXT ("InsCrsCod",Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD,
Gbl.Hierarchy.Crs.InstitutionalCrsCod,
HTM_SUBMIT_ON_CHANGE,
"id=\"InsCrsCod\" size=\"%u\" class=\"INPUT_INS_CODE\"",
Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD);
Frm_EndForm ();
}
else
HTM_Txt (Gbl.Hierarchy.Crs.InstitutionalCrsCod);
HTM_TD_End ();
HTM_TR_End ();
}
@ -389,13 +388,13 @@ static void CrsCfg_InternalCode (void)
/***** Internal course code *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",NULL,Txt_Internal_code);
/* Label */
Frm_LabelColumn ("RT",NULL,Txt_Internal_code);
/* Data */
HTM_TD_Begin ("class=\"DAT LB\"");
HTM_Long (Gbl.Hierarchy.Crs.CrsCod);
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"DAT LB\"");
HTM_Long (Gbl.Hierarchy.Crs.CrsCod);
HTM_TD_End ();
HTM_TR_End ();
}
@ -437,25 +436,25 @@ static void CrsCfg_Indicators (void)
/***** Number of indicators *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",NULL,Txt_Indicators);
/* Label */
Frm_LabelColumn ("RT",NULL,Txt_Indicators);
/* Data */
HTM_TD_Begin ("class=\"LB\"");
Frm_BeginForm (ActReqStaCrs);
if (asprintf (&Title,"%u %s %u",
IndicatorsCrs.NumIndicators,
Txt_of_PART_OF_A_TOTAL,Ind_NUM_INDICATORS) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_SUBMIT_Begin (Title,"BT_LINK DAT",NULL);
HTM_TxtF ("%s&nbsp;",Title);
Ico_PutIcon ((IndicatorsCrs.NumIndicators == Ind_NUM_INDICATORS) ? "check-circle.svg" :
"exclamation-triangle.svg",
Title,"ICO16x16");
HTM_BUTTON_End ();
free (Title);
Frm_EndForm ();
HTM_TD_End ();
/* Data */
HTM_TD_Begin ("class=\"LB\"");
Frm_BeginForm (ActReqStaCrs);
if (asprintf (&Title,"%u %s %u",
IndicatorsCrs.NumIndicators,
Txt_of_PART_OF_A_TOTAL,Ind_NUM_INDICATORS) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_SUBMIT_Begin (Title,"BT_LINK DAT",NULL);
HTM_TxtF ("%s&nbsp;",Title);
Ico_PutIcon ((IndicatorsCrs.NumIndicators == Ind_NUM_INDICATORS) ? "check-circle.svg" :
"exclamation-triangle.svg",
Title,"ICO16x16");
HTM_BUTTON_End ();
free (Title);
Frm_EndForm ();
HTM_TD_End ();
HTM_TR_End ();
}
@ -481,15 +480,15 @@ void CrsCfg_ChangeCrsDeg (void)
Deg_GetDataOfDegreeByCod (&NewDeg);
/***** If name of course was in database in the new degree... *****/
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L,
NewDeg.DegCod,Gbl.Hierarchy.Crs.Year))
if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L,
NewDeg.DegCod,Gbl.Hierarchy.Crs.Year))
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z,
Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year],
NewDeg.FullName,
Gbl.Hierarchy.Crs.ShrtName);
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L,
NewDeg.DegCod,Gbl.Hierarchy.Crs.Year))
else if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L,
NewDeg.DegCod,Gbl.Hierarchy.Crs.Year))
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z,
Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year],
@ -498,7 +497,7 @@ void CrsCfg_ChangeCrsDeg (void)
else // Update degree in database
{
/***** Update degree in table of courses *****/
CrsCfg_UpdateCrsDegDB (Gbl.Hierarchy.Crs.CrsCod,NewDeg.DegCod);
Crs_DB_UpdateCrsDeg (Gbl.Hierarchy.Crs.CrsCod,NewDeg.DegCod);
Gbl.Hierarchy.Crs.DegCod =
Gbl.Hierarchy.Deg.DegCod = NewDeg.DegCod;
@ -514,21 +513,6 @@ void CrsCfg_ChangeCrsDeg (void)
}
}
/*****************************************************************************/
/********************** Update degree in table of courses ********************/
/*****************************************************************************/
static void CrsCfg_UpdateCrsDegDB (long CrsCod,long DegCod)
{
/***** Update degree in table of courses *****/
DB_QueryUPDATE ("can not move course to another degree",
"UPDATE crs_courses"
" SET DegCod=%ld"
" WHERE CrsCod=%ld",
DegCod,
CrsCod);
}
/*****************************************************************************/
/*************** Change the name of a course in configuration ****************/
/*****************************************************************************/
@ -563,14 +547,14 @@ void CrsCfg_ChangeCrsYear (void)
if (NewYear <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid
{
/***** If name of course was in database in the new year... *****/
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L,
Gbl.Hierarchy.Crs.DegCod,NewYear))
if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L,
Gbl.Hierarchy.Crs.DegCod,NewYear))
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_course_X_already_exists_in_year_Y,
Gbl.Hierarchy.Crs.ShrtName,
Txt_YEAR_OF_DEGREE[NewYear]);
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L,
Gbl.Hierarchy.Crs.DegCod,NewYear))
else if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L,
Gbl.Hierarchy.Crs.DegCod,NewYear))
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_course_X_already_exists_in_year_Y,
Gbl.Hierarchy.Crs.FullName,

501
swad_course_database.c Normal file
View File

@ -0,0 +1,501 @@
// swad_course_database.c: edition of courses operations with database
/*
SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2021 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include "swad_course.h"
#include "swad_course_config.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_global.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/*************************** Public constants ********************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private types *********************************/
/*****************************************************************************/
/*****************************************************************************/
/**************************** Private variables ******************************/
/*****************************************************************************/
/*****************************************************************************/
/**************************** Private prototypes *****************************/
/*****************************************************************************/
/*****************************************************************************/
/************* Add a new requested course to pending requests ****************/
/*****************************************************************************/
void Crs_DB_CreateCourse (struct Crs_Course *Crs,unsigned Status)
{
/***** Insert new course into pending requests *****/
Crs->CrsCod =
DB_QueryINSERTandReturnCode ("can not create a new course",
"INSERT INTO crs_courses"
" (DegCod,Year,InsCrsCod,Status,RequesterUsrCod,"
"ShortName,FullName)"
" VALUES"
" (%ld,%u,'%s',%u,%ld,"
"'%s','%s')",
Crs->DegCod,
Crs->Year,
Crs->InstitutionalCrsCod,
Status,
Gbl.Usrs.Me.UsrDat.UsrCod,
Crs->ShrtName,
Crs->FullName);
}
/*****************************************************************************/
/******************** Get courses in current degree *********************/
/*****************************************************************************/
unsigned Crs_DB_GetCrssInCurrentDegBasic (MYSQL_RES **mysql_res)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get courses of a degree",
"SELECT CrsCod," // row[0]
"ShortName" // row[1]
" FROM crs_courses"
" WHERE DegCod=%ld"
" ORDER BY ShortName",
Gbl.Hierarchy.Deg.DegCod);
}
/*****************************************************************************/
/******************** Get courses in current degree *********************/
/*****************************************************************************/
unsigned Crs_DB_GetCrssInCurrentDegFull (MYSQL_RES **mysql_res)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get courses of a degree",
"SELECT CrsCod," // row[0]
"DegCod," // row[1]
"Year," // row[2]
"InsCrsCod," // row[3]
"Status," // row[4]
"RequesterUsrCod," // row[5]
"ShortName," // row[6]
"FullName" // row[7]
" FROM crs_courses"
" WHERE DegCod=%ld"
" AND (Status & %u)=0"
" ORDER BY Year,"
"ShortName",
Gbl.Hierarchy.Deg.DegCod,
(unsigned) Crs_STATUS_BIT_REMOVED); // All courses except those removed
}
/*****************************************************************************/
/********************* Get data of a course from its code ********************/
/*****************************************************************************/
unsigned Crs_DB_GetDataOfCourseByCod (MYSQL_RES **mysql_res,long CrsCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get data of a course",
"SELECT CrsCod," // row[0]
"DegCod," // row[1]
"Year," // row[2]
"InsCrsCod," // row[3]
"Status," // row[4]
"RequesterUsrCod," // row[5]
"ShortName," // row[6]
"FullName" // row[7]
" FROM crs_courses"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/
/******* Get the short names of degree and course from a course code *********/
/*****************************************************************************/
void Crs_DB_GetShortNamesByCod (long CrsCod,
char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1])
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
DegShortName[0] = CrsShortName[0] = '\0';
/***** Trivial check: course code should be > 0 *****/
if (CrsCod <= 0)
return;
/***** Get the short name of a degree from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a course",
"SELECT crs_courses.ShortName," // row[0]
"deg_degrees.ShortName" // row[1]
" FROM crs_courses,"
"deg_degrees"
" WHERE crs_courses.CrsCod=%ld"
" AND crs_courses.DegCod=deg_degrees.DegCod",
CrsCod) == 1)
{
/***** Get the course short name and degree short name *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (CrsShortName,row[0],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (DegShortName,row[1],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/********** Check if the name of course exists in existing courses ***********/
/*****************************************************************************/
bool Crs_DB_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
long DegCod,unsigned Year)
{
/***** Get number of courses in a year of a degree and with a name from database *****/
return (DB_QueryCOUNT ("can not check if the name"
" of a course already existed",
"SELECT COUNT(*)"
" FROM crs_courses"
" WHERE DegCod=%ld"
" AND Year=%u"
" AND %s='%s'"
" AND CrsCod<>%ld",
DegCod,
Year,
FieldName,
Name,
CrsCod) != 0);
}
/*****************************************************************************/
/************************** Write courses of a user **************************/
/*****************************************************************************/
unsigned Crs_DB_GetCrssOfAUsr (MYSQL_RES **mysql_res,long UsrCod,Rol_Role_t Role)
{
char *SubQuery;
unsigned NumCrss;
/***** Get courses of a user from database *****/
if (Role == Rol_UNK) // Role == Rol_UNK ==> any role
{
if (asprintf (&SubQuery,"%s","") < 0)
Err_NotEnoughMemoryExit ();
}
else
{
if (asprintf (&SubQuery," AND crs_users.Role=%u",(unsigned) Role) < 0)
Err_NotEnoughMemoryExit ();
}
NumCrss = (unsigned)
DB_QuerySELECT (mysql_res,"can not get courses of a user",
"SELECT deg_degrees.DegCod," // row[0]
"crs_courses.CrsCod," // row[1]
"deg_degrees.ShortName," // row[2]
"deg_degrees.FullName," // row[3]
"crs_courses.Year," // row[4]
"crs_courses.FullName," // row[5]
"ctr_centers.ShortName," // row[6]
"crs_users.Accepted" // row[7]
" FROM crs_users,"
"crs_courses,"
"deg_degrees,"
"ctr_centers"
" WHERE crs_users.UsrCod=%ld%s"
" AND crs_users.CrsCod=crs_courses.CrsCod"
" AND crs_courses.DegCod=deg_degrees.DegCod"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" ORDER BY deg_degrees.FullName,"
"crs_courses.Year,"
"crs_courses.FullName",
UsrCod,SubQuery);
/***** Free allocated memory for subquery *****/
free (SubQuery);
return NumCrss;
}
/*****************************************************************************/
/************************** Get old courses from database ********************/
/*****************************************************************************/
unsigned Crs_DB_GetOldCrss (MYSQL_RES **mysql_res,unsigned long SecondsWithoutAccess)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get old courses",
"SELECT CrsCod"
" FROM crs_last"
" WHERE LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
" AND CrsCod NOT IN"
" (SELECT DISTINCT CrsCod"
" FROM crs_users)",
SecondsWithoutAccess);
}
/*****************************************************************************/
/******************** Get number of courses in a country *********************/
/*****************************************************************************/
unsigned Crs_DB_GetNumCrssInCty (long CtyCod)
{
return (unsigned)
DB_QueryCOUNT ("can not get the number of courses in a country",
"SELECT COUNT(*)"
" FROM ins_instits,"
"ctr_centers,"
"deg_degrees,"
"crs_courses"
" WHERE ins_instits.CtyCod=%ld"
" AND ins_instits.InsCod=ctr_centers.InsCod"
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
" AND deg_degrees.DegCod=crs_courses.DegCod",
CtyCod);
}
/*****************************************************************************/
/****************** Get number of courses in an institution ******************/
/*****************************************************************************/
unsigned Crs_DB_GetNumCrssInIns (long InsCod)
{
return (unsigned)
DB_QueryCOUNT ("can not get the number of courses in an institution",
"SELECT COUNT(*)"
" FROM ctr_centers,"
"deg_degrees,"
"crs_courses"
" WHERE ctr_centers.InsCod=%ld"
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
" AND deg_degrees.DegCod=crs_courses.DegCod",
InsCod);
}
/*****************************************************************************/
/********************* Get number of courses in a center *********************/
/*****************************************************************************/
unsigned Crs_DB_GetNumCrssInCtr (long CtrCod)
{
return (unsigned)
DB_QueryCOUNT ("can not get the number of courses in a center",
"SELECT COUNT(*)"
" FROM deg_degrees,"
"crs_courses"
" WHERE deg_degrees.CtrCod=%ld"
" AND deg_degrees.DegCod=crs_courses.DegCod",
CtrCod);
}
/*****************************************************************************/
/********************* Get number of courses in a degree *********************/
/*****************************************************************************/
unsigned Crs_DB_GetNumCrssInDeg (long DegCod)
{
return (unsigned)
DB_QueryCOUNT ("can not get the number of courses in a degree",
"SELECT COUNT(*)"
" FROM crs_courses"
" WHERE DegCod=%ld",
DegCod);
}
/*****************************************************************************/
/******************** Get number of courses with users ***********************/
/*****************************************************************************/
unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of courses with users",
"SELECT COUNT(DISTINCT crs_courses.CrsCod)"
" FROM ins_instits,"
"ctr_centers,"
"deg_degrees,"
"crs_courses,"
"crs_users"
" WHERE %s"
"institutions.InsCod=ctr_centers.InsCod"
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
" AND deg_degrees.DegCod=crs_courses.DegCod"
" AND crs_courses.CrsCod=crs_users.CrsCod"
" AND crs_users.Role=%u",
SubQuery,
(unsigned) Role);
}
/*****************************************************************************/
/************* Change the institutional course code of a course **************/
/*****************************************************************************/
void Crs_DB_UpdateInstitutionalCrsCod (long CrsCod,const char *NewInstitutionalCrsCod)
{
DB_QueryUPDATE ("can not update the institutional code of a course",
"UPDATE crs_courses"
" SET InsCrsCod='%s'"
" WHERE CrsCod=%ld",
NewInstitutionalCrsCod,
CrsCod);
}
/*****************************************************************************/
/****************** Change the year/semester of a course *********************/
/*****************************************************************************/
void Crs_DB_UpdateCrsYear (long CrsCod,unsigned NewYear)
{
DB_QueryUPDATE ("can not update the year of a course",
"UPDATE crs_courses"
" SET Year=%u"
" WHERE CrsCod=%ld",
NewYear,
CrsCod);
}
/*****************************************************************************/
/********************** Change the status of a course ************************/
/*****************************************************************************/
void Crs_DB_UpdateCrsStatus (long CrsCod,Crs_Status_t Status)
{
DB_QueryUPDATE ("can not update the status of a course",
"UPDATE crs_courses"
" SET Status=%u"
" WHERE CrsCod=%ld",
(unsigned) Status,
CrsCod);
}
/*****************************************************************************/
/***************** Update course name in table of courses ********************/
/*****************************************************************************/
void Crs_DB_UpdateCrsName (long CrsCod,const char *FieldName,const char *NewCrsName)
{
DB_QueryUPDATE ("can not update the name of a course",
"UPDATE crs_courses"
" SET %s='%s'"
" WHERE CrsCod=%ld",
FieldName,NewCrsName,
CrsCod);
}
/*****************************************************************************/
/********************** Update degree in table of courses ********************/
/*****************************************************************************/
void Crs_DB_UpdateCrsDeg (long CrsCod,long DegCod)
{
DB_QueryUPDATE ("can not move course to another degree",
"UPDATE crs_courses"
" SET DegCod=%ld"
" WHERE CrsCod=%ld",
DegCod,
CrsCod);
}
/*****************************************************************************/
/***************** Update my last click in current course ********************/
/*****************************************************************************/
void Crs_DB_UpdateCrsLastClick (void)
{
/***** Update last access to current course *****/
DB_QueryREPLACE ("can not update last access to current course",
"REPLACE INTO crs_last"
" (CrsCod,LastTime)"
" VALUES"
" (%ld,NOW())",
Gbl.Hierarchy.Crs.CrsCod);
}
/*****************************************************************************/
/******************** Remove information about a course **********************/
/*****************************************************************************/
void Crs_DB_RemoveCrsInfo (long CrsCod)
{
/* Remove information source of the course */
DB_QueryDELETE ("can not remove info sources of a course",
"DELETE FROM crs_info_src"
" WHERE CrsCod=%ld",
CrsCod);
/* Remove information text of the course */
DB_QueryDELETE ("can not remove info of a course",
"DELETE FROM crs_info_txt"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/
/********************** Remove timetable of a course *************************/
/*****************************************************************************/
void Crs_DB_RemoveCrsTimetable (long CrsCod)
{
DB_QueryDELETE ("can not remove the timetable of a course",
"DELETE FROM tmt_courses"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/
/***** Remove course from table of last accesses to courses in database ******/
/*****************************************************************************/
void Crs_DB_RemoveCrsLast (long CrsCod)
{
DB_QueryDELETE ("can not remove a course",
"DELETE FROM crs_last"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/
/************* Remove course from table of courses in database ***************/
/*****************************************************************************/
void Crs_DB_RemoveCrs (long CrsCod)
{
DB_QueryDELETE ("can not remove a course",
"DELETE FROM crs_courses"
" WHERE CrsCod=%ld",
CrsCod);
}

78
swad_course_database.h Normal file
View File

@ -0,0 +1,78 @@
// swad_course_database.c: edition of courses operations with database
#ifndef _SWAD_CRS_DB
#define _SWAD_CRS_DB
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2021 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#include "swad_constant.h"
#include "swad_course.h"
#include "swad_role.h"
/*****************************************************************************/
/***************************** Public constants ******************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Public types ********************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
void Crs_DB_CreateCourse (struct Crs_Course *Crs,unsigned Status);
unsigned Crs_DB_GetCrssInCurrentDegBasic (MYSQL_RES **mysql_res);
unsigned Crs_DB_GetCrssInCurrentDegFull (MYSQL_RES **mysql_res);
unsigned Crs_DB_GetDataOfCourseByCod (MYSQL_RES **mysql_res,long CrsCod);
void Crs_DB_GetShortNamesByCod (long CrsCod,
char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]);
bool Crs_DB_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
long DegCod,unsigned Year);
unsigned Crs_DB_GetCrssOfAUsr (MYSQL_RES **mysql_res,long UsrCod,Rol_Role_t Role);
unsigned Crs_DB_GetOldCrss (MYSQL_RES **mysql_res,unsigned long SecondsWithoutAccess);
unsigned Crs_DB_GetNumCrssInCty (long CtyCod);
unsigned Crs_DB_GetNumCrssInIns (long InsCod);
unsigned Crs_DB_GetNumCrssInCtr (long CtrCod);
unsigned Crs_DB_GetNumCrssInDeg (long DegCod);
unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery);
void Crs_DB_UpdateInstitutionalCrsCod (long CrsCod,const char *NewInstitutionalCrsCod);
void Crs_DB_UpdateCrsStatus (long CrsCod,Crs_Status_t Status);
void Crs_DB_UpdateCrsYear (long CrsCod,unsigned NewYear);
void Crs_DB_UpdateCrsName (long CrsCod,const char *FieldName,const char *NewCrsName);
void Crs_DB_UpdateCrsDeg (long CrsCod,long DegCod);
void Crs_DB_UpdateCrsLastClick (void);
void Crs_DB_RemoveCrsInfo (long CrsCod);
void Crs_DB_RemoveCrsTimetable (long CrsCod);
void Crs_DB_RemoveCrsLast (long CrsCod);
void Crs_DB_RemoveCrs (long CrsCod);
#endif

View File

@ -1529,7 +1529,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
Svy_RemoveSurveys (Hie_Lvl_DEG,DegCod);
/***** Remove information related to files in degree *****/
Brw_RemoveDegFilesFromDB (DegCod);
Brw_DB_RemoveDegFiles (DegCod);
/***** Remove directories of the degree *****/
snprintf (PathDeg,sizeof (PathDeg),"%s/%02u/%u",

View File

@ -4309,7 +4309,19 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
}
/*****************************************************************************/
/************************ Remove a user from a course ************************/
/*********** Remove all users' requests for inscription in a course **********/
/*****************************************************************************/
void Enr_DB_RemCrsRequests (long CrsCod)
{
DB_QueryDELETE ("can not remove requests for inscription to a course",
"DELETE FROM crs_requests"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/
/************ Remove user's requests for inscription from a course ***********/
/*****************************************************************************/
void Enr_DB_RemUsrRequests (long UsrCod)
@ -4320,6 +4332,30 @@ void Enr_DB_RemUsrRequests (long UsrCod)
UsrCod);
}
/*****************************************************************************/
/*************** Remove all users from settings in a course ******************/
/*****************************************************************************/
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod)
{
DB_QueryDELETE ("can not remove users from a course settings",
"DELETE FROM crs_user_settings"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/
/*************** Remove all users from settings in a course ******************/
/*****************************************************************************/
void Enr_DB_RemAllUsrsFromCrs (long CrsCod)
{
DB_QueryDELETE ("can not remove users from a course",
"DELETE FROM crs_users"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/
/************************ Remove a user from a course ************************/
/*****************************************************************************/

View File

@ -145,7 +145,10 @@ void Enr_ModifyUsr2 (void);
void Enr_AcceptUsrInCrs (long UsrCod);
void Enr_DB_RemCrsRequests (long CrsCod);
void Enr_DB_RemUsrRequests (long UsrCod);
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod);
void Enr_DB_RemAllUsrsFromCrs (long CrsCod);
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
void Enr_DB_RemUsrAsAdmin (long UsrCod);

View File

@ -4173,7 +4173,7 @@ static void Brw_StoreSizeOfFileTreeInDB (void)
/******** Remove files related to an institution from the database ***********/
/*****************************************************************************/
void Brw_RemoveInsFilesFromDB (long InsCod)
void Brw_DB_RemoveInsFiles (long InsCod)
{
/***** Remove from database the entries that store the file views *****/
DB_QueryDELETE ("can not remove file views to files of an institution",
@ -4241,7 +4241,7 @@ void Brw_RemoveInsFilesFromDB (long InsCod)
/************ Remove files related to a center from the database *************/
/*****************************************************************************/
void Brw_RemoveCtrFilesFromDB (long CtrCod)
void Brw_DB_RemoveCtrFiles (long CtrCod)
{
/***** Remove from database the entries that store the file views *****/
DB_QueryDELETE ("can not remove file views to files of a center",
@ -4305,7 +4305,7 @@ void Brw_RemoveCtrFilesFromDB (long CtrCod)
/************ Remove files related to a degree from the database *************/
/*****************************************************************************/
void Brw_RemoveDegFilesFromDB (long DegCod)
void Brw_DB_RemoveDegFiles (long DegCod)
{
/***** Remove from database the entries that store the file views *****/
DB_QueryDELETE ("can not remove file views to files of a degree",
@ -4373,7 +4373,7 @@ void Brw_RemoveDegFilesFromDB (long DegCod)
so this function must be called
before removing groups and projects */
void Brw_RemoveCrsFilesFromDB (long CrsCod)
void Brw_DB_RemoveCrsFiles (long CrsCod)
{
char SubqueryGrp[256];
char SubqueryPrj[128];

View File

@ -185,10 +185,10 @@ void Brw_GetSelectedUsrsAndShowWorks (void);
void Brw_ShowFileBrowserOrWorks (void);
void Brw_ShowAgainFileBrowserOrWorks (void);
void Brw_RemoveInsFilesFromDB (long InsCod);
void Brw_RemoveCtrFilesFromDB (long CtrCod);
void Brw_RemoveDegFilesFromDB (long DegCod);
void Brw_RemoveCrsFilesFromDB (long CrsCod);
void Brw_DB_RemoveInsFiles (long InsCod);
void Brw_DB_RemoveCtrFiles (long CtrCod);
void Brw_DB_RemoveDegFiles (long DegCod);
void Brw_DB_RemoveCrsFiles (long CrsCod);
void Brw_RemoveGrpFilesFromDB (long GrpCod);
void Brw_RemovePrjFilesFromDB (long PrjCod);
void Brw_RemoveSomeInfoAboutCrsUsrFilesFromDB (long UsrCod,long CrsCod);

View File

@ -5147,3 +5147,36 @@ Grp_WhichGroups_t Grp_GetParamWhichGroups (void)
return Gbl.Crs.Grps.WhichGrps;
}
/*****************************************************************************/
/************************** Remove groups in a course ************************/
/*****************************************************************************/
void Grp_DB_RemoveCrsGrps (long CrsCod)
{
/***** Remove all the users in groups in the course *****/
DB_QueryDELETE ("can not remove users from groups of a course",
"DELETE FROM grp_users"
" USING grp_types,"
"grp_groups,"
"grp_users"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
" AND grp_groups.GrpCod=grp_users.GrpCod",
CrsCod);
/***** Remove all the groups in the course *****/
DB_QueryDELETE ("can not remove groups of a course",
"DELETE FROM grp_groups"
" USING grp_types,"
"grp_groups"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod",
CrsCod);
/***** Remove all the group types in the course *****/
DB_QueryDELETE ("can not remove types of group of a course",
"DELETE FROM grp_types"
" WHERE CrsCod=%ld",
CrsCod);
}

View File

@ -242,4 +242,6 @@ void Grp_ShowFormToSelWhichGrps (Act_Action_t Action,
void (*FuncParams) (void *Args),void *Args);
Grp_WhichGroups_t Grp_GetParamWhichGroups (void);
void Grp_DB_RemoveCrsGrps (long CrsCod);
#endif

View File

@ -1372,7 +1372,7 @@ void Ins_RemoveInstitution (void)
Svy_RemoveSurveys (Hie_Lvl_INS,Ins_EditingIns->InsCod);
/***** Remove information related to files in institution *****/
Brw_RemoveInsFilesFromDB (Ins_EditingIns->InsCod);
Brw_DB_RemoveInsFiles (Ins_EditingIns->InsCod);
/***** Remove directories of the institution *****/
snprintf (PathIns,sizeof (PathIns),"%s/%02u/%u",

View File

@ -1087,3 +1087,30 @@ static long Not_GetParamNotCod (void)
/***** Get notice code *****/
return Par_GetParToLong ("NotCod");
}
/*****************************************************************************/
/************************* Remove notices in a course ************************/
/*****************************************************************************/
void Not_DB_RemoveCrsNotices (long CrsCod)
{
/***** Copy all notices from the course to table of deleted notices *****/
DB_QueryINSERT ("can not remove notices in a course",
"INSERT INTO not_deleted"
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
" SELECT NotCod,"
"CrsCod,"
"UsrCod,"
"CreatTime,"
"Content,"
"NumNotif"
" FROM not_notices"
" WHERE CrsCod=%ld",
CrsCod);
/***** Remove all notices from the course *****/
DB_QueryDELETE ("can not remove notices in a course",
"DELETE FROM not_notices"
" WHERE CrsCod=%ld",
CrsCod);
}

View File

@ -77,4 +77,6 @@ unsigned Not_GetNumNoticesDeleted (Hie_Lvl_Level_t Scope,unsigned *NumNotif);
void Not_PutHiddenParamNotCod (long NotCod);
void Not_DB_RemoveCrsNotices (long CrsCod);
#endif

View File

@ -4236,3 +4236,30 @@ void Rec_UpdateMyOfficePhone (void)
/***** Show form again *****/
Rec_ShowMySharedRecordAndMore ();
}
/*****************************************************************************/
/******************** Remove content of course record cards ******************/
/*****************************************************************************/
void Rec_DB_RemoveCrsRecordContents (long CrsCod)
{
DB_QueryDELETE ("can not remove content of cards in a course",
"DELETE FROM crs_records"
" USING crs_record_fields,"
"crs_records"
" WHERE crs_record_fields.CrsCod=%ld"
" AND crs_record_fields.FieldCod=crs_records.FieldCod",
CrsCod);
}
/*****************************************************************************/
/************ Remove definition of fields in course record cards *************/
/*****************************************************************************/
void Rec_DB_RemoveCrsRecordFields (long CrsCod)
{
DB_QueryDELETE ("can not remove fields of cards in a course",
"DELETE FROM crs_record_fields"
" WHERE CrsCod=%ld",
CrsCod);
}

View File

@ -180,4 +180,7 @@ void Rec_UpdateMyDepartment (void);
void Rec_UpdateMyOffice (void);
void Rec_UpdateMyOfficePhone (void);
void Rec_DB_RemoveCrsRecordContents (long CrsCod);
void Rec_DB_RemoveCrsRecordFields (long CrsCod);
#endif