コード例 #1
0
ファイル: work.lib.php プロジェクト: annickvdp/Chamilo1.9.10
/**
 * @param int $workId
 * @param array $courseInfo
 * @param int $sessionId
 * @param string $format
 * @return bool
 */
function exportAllStudentWorkFromPublication(
    $workId,
    $courseInfo,
    $sessionId,
    $format = 'pdf'
) {
    if (empty($courseInfo)) {
        return false;
    }

    $workData = get_work_data_by_id($workId);

    if (empty($workData)) {
        return false;
    }

    $assignment = get_work_assignment_by_id($workId);

    $courseCode = $courseInfo['code'];
    $header = get_lang('Course').': '.$courseInfo['title'];
    $teachers = CourseManager::get_teacher_list_from_course_code_to_string(
        $courseCode
    );

    if (!empty($sessionId)) {
        $sessionInfo = api_get_session_info($sessionId);
        if (!empty($sessionInfo)) {
            $header .= ' - ' . $sessionInfo['name'];
            $header .= '<br />' . $sessionInfo['description'];
            $teachers = SessionManager::getCoachesByCourseSessionToString(
                $sessionId,
                $courseCode
            );
        }
    }

    $header .= '<br />'.get_lang('Teachers').': '.$teachers.'<br />';
    $header .= '<br />'.get_lang('Date').': '.api_get_local_time().'<br />';
    $header .= '<br />'.get_lang('StudentPublication').': '.$workData['title'].'<br />';

    $content = null;
    $expiresOn = null;

    if (!empty($assignment) && isset($assignment['expires_on'])) {
        $content .= '<br /><strong>' . get_lang('ExpiryDate') . '</strong>: ' . api_get_local_time($assignment['expires_on']);
        $expiresOn = api_get_local_time($assignment['expires_on']);
    }

    if (!empty($workData['description'])) {
        $content .= '<br /><strong>' . get_lang('Description') . '</strong>: ' . $workData['description'];
    }

    $workList = get_work_user_list(null, null, null, null, $workId);

    switch ($format) {
        case 'pdf':
            if (!empty($workList)) {
                require_once api_get_path(LIBRARY_PATH).'pdf.lib.php';

                $table = new HTML_Table(array('class' => 'data_table'));
                $headers = array(
                    get_lang('Name'),
                    get_lang('User'),
                    get_lang('HandOutDateLimit'),
                    get_lang('SentDate'),
                    get_lang('Filename'),
                    get_lang('Score'),
                    get_lang('Feedback')
                );

                $column = 0;
                foreach($headers as $header) {
                    $table->setHeaderContents(0, $column, $header);
                    $column++;
                }

                $row = 1;

                //$pdf->set_custom_header($header);
                foreach ($workList as $work) {
                    $content .= '<hr />';
                    // getWorkComments need c_id
                    $work['c_id'] = $courseInfo['real_id'];

                    //$content .= get_lang('Date').': '.api_get_local_time($work['sent_date_from_db']).'<br />';
                    $score = null;
                    if (!empty($work['qualification_only'])) {
                        $score = $work['qualification_only'];
                    }
                    //$content .= get_lang('Description').': '.$work['description'].'<br />';
                    $comments = getWorkComments($work);

                    $feedback = null;
                    if (!empty($comments)) {
                        $content .= '<h4>'.get_lang('Feedback').': </h4>';
                        foreach ($comments as $comment) {
                            $feedback .= get_lang('User').': '.api_get_person_name(
                                $comment['firstname'],
                                $comment['lastname']
                            ).'<br />';
                            $feedback .= $comment['comment'].'<br />';
                        }
                    }

                    $table->setCellContents($row, 0, strip_tags($workData['title']));
                    $table->setCellContents($row, 1, api_get_person_name(strip_tags($work['firstname']), strip_tags($work['lastname'])));
                    $table->setCellContents($row, 2, $expiresOn);
                    $table->setCellContents($row, 3, api_get_local_time($work['sent_date_from_db']));
                    $table->setCellContents($row, 4, strip_tags($work['title']));
                    $table->setCellContents($row, 5, $score);
                    $table->setCellContents($row, 6, $feedback);

                    $row++;
                }

                $content = $table->toHtml();

                if (!empty($content)) {
                    $params = array(
                        'filename' => $workData['title'] . '_' . api_get_local_time(),
                        'pdf_title' => replace_dangerous_char($workData['title']),
                        'course_code' => $courseInfo['code'],
                        'add_signatures' => false
                    );
                    $pdf = new PDF('A4', null, $params);
                    $pdf->html_to_pdf_with_template($content);
                }
                exit;
            }
            break;
    }
}
コード例 #2
0
ファイル: view.php プロジェクト: secuencia24/chamilo-lms
         if (isset($_FILES["file"])) {
             $_POST['file'] = $_FILES["file"];
         }
         addWorkComment(api_get_course_info(), api_get_user_id(), $my_folder_data, $work, $_POST);
         Display::addFlash(Display::return_message(get_lang('CommentCreated')));
         header('Location: ' . $url);
         exit;
         break;
     case 'delete_attachment':
         deleteCommentFile($_REQUEST['comment_id'], api_get_course_info());
         Display::addFlash(Display::return_message(get_lang('DocDeleted')));
         header('Location: ' . $url);
         exit;
         break;
 }
 $comments = getWorkComments($work);
 $commentForm = getWorkCommentForm($work);
 $tpl = new Template();
 $tpl->assign('work', $work);
 $tpl->assign('comments', $comments);
 $actions = '';
 if (isset($work['contains_file'])) {
     if (isset($work['download_url'])) {
         $actions .= Display::url(Display::return_icon('save.png', get_lang('Download'), null, ICON_SIZE_MEDIUM), $work['download_url']);
         if (isset($work['url_correction'])) {
             $actions .= Display::url(Display::return_icon('check.png', get_lang('Correction'), null, ICON_SIZE_MEDIUM), $work['download_url'] . '&correction=1');
         }
     }
 }
 $tpl->assign('actions', $actions);
 if (api_is_allowed_to_session_edit()) {
コード例 #3
0
ファイル: edit.php プロジェクト: jloguercio/chamilo-lms
    $script = 'work_list.php';
    if ($is_allowed_to_edit) {
        $script = 'work_list_all.php';
    }
    header('Location: ' . api_get_path(WEB_CODE_PATH) . 'work/' . $script . '?' . api_get_cidreq() . '&id=' . $work_id);
    exit;
}
$htmlHeadXtra[] = to_javascript_work();
$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
$content = null;
if (!empty($work_id)) {
    if ($is_allowed_to_edit) {
        if (api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION)) {
            echo Display::display_warning_message(get_lang('ResourceLockedByGradebook'));
        } else {
            $comments = getWorkComments($work_item);
            $tpl->addGlobal('comments', $comments);
            $commentForm = getWorkCommentForm($work_item, 'edit');
            $tpl->addGlobal('form', '');
            if (api_is_allowed_to_session_edit()) {
                $tpl->addGlobal('form', $commentForm);
            }
            $commentContent = $tpl->render('@template_style/work/comments.html.twig');
            $content .= $form->returnForm();
            $content .= $commentContent;
        }
    } elseif ($is_author) {
        if (empty($work_item['qualificator_id']) || $work_item['qualificator_id'] == 0) {
            $content .= $form->returnForm();
        } else {
            $content .= Display::return_message(get_lang('ActionNotAllowed'), 'error');