Skip to content

Commit

Permalink
Certificate Generation: Add checkbox conditional on certificate gener…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
tonyidbeeznest committed Jul 30, 2021
1 parent 915d679 commit e3577f0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 14 deletions.
33 changes: 33 additions & 0 deletions main/inc/ajax/myspace.ajax.php
Expand Up @@ -201,5 +201,38 @@
header('Cache-Control: no-cache');
echo json_encode($result);
break;
case 'show_conditional_to_export_pdf':

$studentId = (int) $_REQUEST['student'];
$sId = (int) $_REQUEST['session_to_export'];

$form = new FormValidator(
'conditional_to_export_pdf',
'post',
api_get_path(WEB_CODE_PATH).'mySpace/session.php?'
.http_build_query(
[
'student' => $studentId,
'action' => 'export_to_pdf',
'type' => 'achievement',
'session_to_export' => $sId,
]
)
);

$message = get_lang('HideConnectionTime', true);
if (empty($message)) {
$message = "¿Hide connection time?";
}
$form->addCheckBox('hide_connection_time', null, $message);

$messageBtn = get_lang('GenerateCertificate', true);
if (empty($messageBtn)) {
$messageBtn = 'Generate Certificate';
}
$form->addButtonSave($messageBtn, 'submitLink');
$content = $form->returnForm();
echo $content;
break;
}
exit;
9 changes: 5 additions & 4 deletions main/mySpace/myStudents.php
Expand Up @@ -1284,15 +1284,16 @@
);
$sessionAction .= Display::url(
Display::return_icon('pdf.png', get_lang('CertificateOfAchievement'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'mySpace/session.php?'
api_get_path(WEB_CODE_PATH).'inc/ajax/myspace.ajax.php?'
.http_build_query(
[
'a' => 'show_conditional_to_export_pdf',
'student' => $student_id,
'action' => 'export_to_pdf',
'type' => 'achievement',
'session_to_export' => $sId,
'type' => 'achievement',
]
)
),
['class' => "ajax", 'data-size' => 'sm']
);
}
echo $sessionAction;
Expand Down
28 changes: 18 additions & 10 deletions main/mySpace/session.php
Expand Up @@ -28,6 +28,7 @@

$studentId = isset($_GET['student']) ? (int) $_GET['student'] : 0;
$sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : 0;
$hideConnectionTime = isset($_REQUEST['hide_connection_time']) ? (int) $_REQUEST['hide_connection_time'] : 0;
$currentUrl = api_get_self().'?student='.$studentId.'&sid='.$sessionId;

switch ($action) {
Expand Down Expand Up @@ -118,9 +119,13 @@
$courseTable .= '<table class="table table-hover table-striped data_table">';
$courseTable .= '<thead>';
$courseTable .= '<tr>
<th>'.get_lang('FormationUnit').'</th>
<th>'.get_lang('ConnectionTime').'</th>
<th>'.get_lang('Progress').'</th>';
<th>'.get_lang('FormationUnit').'</th>';

if (!$hideConnectionTime) {
$courseTable .= '<th>'.get_lang('ConnectionTime').'</th>';
}

$courseTable .= '<th>'.get_lang('Progress').'</th>';

if ('attendance' === $type) {
$courseTable .= '<th>'.get_lang('Score').'</th>';
Expand Down Expand Up @@ -177,9 +182,11 @@
<td>
<a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sessionToExport.'">'.
$courseInfoItem['title'].'</a>
</td>
<td >'.$time_spent_on_course.'</td>
<td >'.$progress.'</td>';
</td>';
if (!$hideConnectionTime) {
$courseTable .= '<td >'.$time_spent_on_course.'</td>';
}
$courseTable .= '<td >'.$progress.'</td>';
if ('attendance' === $type) {
$courseTable .= '<td >'.$score.'</td>';
}
Expand All @@ -197,10 +204,11 @@
$totalTimeFormatted = api_time_to_hms($totalCourseTime);
$courseTable .= '
<tr>
<th>'.get_lang('Total').'</th>
<th>'.$totalTimeFormatted.'</th>
<th>'.$totalProgressFormatted.'</th>
';
<th>'.get_lang('Total').'</th>';
if (!$hideConnectionTime) {
$courseTable .= '<th>'.$totalTimeFormatted.'</th>';
}
$courseTable .= '<th>'.$totalProgressFormatted.'</th>';
if ('attendance' === $type) {
$courseTable .= '<th>'.$totalScoreFormatted.'</th>';
}
Expand Down

0 comments on commit e3577f0

Please sign in to comment.