Student publication: Fix downdload all, fix delete correction.

pull/3741/head
Julio Montoya 4 years ago
parent 848f15b3cf
commit 4085839d35
  1. 4
      public/main/work/upload_corrections.php
  2. 50
      public/main/work/work_list_all.php
  3. 11
      src/CoreBundle/Controller/ResourceController.php
  4. 10
      src/CourseBundle/Entity/CStudentPublicationComment.php

@ -2,8 +2,6 @@
/* For licensing terms, see /license.txt */
use Symfony\Component\Finder\Finder;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
@ -38,7 +36,7 @@ if (empty($workInfo)) {
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
$homework = get_work_assignment_by_id($workInfo['id']);
$homework = get_work_assignment_by_id($workInfo['iid']);
$validationStatus = getWorkDateValidationStatus($homework);
$interbreadcrumb[] = [

@ -2,6 +2,9 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CStudentPublication;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
@ -25,6 +28,7 @@ if (empty($my_folder_data)) {
$work_data = get_work_assignment_by_id($workId);
$studentPublicationRepo = Container::getStudentPublicationRepository();
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
@ -113,8 +117,11 @@ switch ($action) {
$result = get_work_user_list(null, null, null, null, $workId);
if ($result) {
foreach ($result as $item) {
$workToDelete = get_work_data_by_id($item['id']);
deleteCorrection($courseInfo, $workToDelete);
/** @var CStudentPublication $work */
$work = $studentPublicationRepo->find($item['id']);
if ($work) {
deleteCorrection( $work);
}
}
Display::addFlash(
Display::return_message(get_lang('Deleted'), 'confirmation')
@ -172,19 +179,22 @@ $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
$blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
if (!$blockAddDocuments) {
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= '<a
href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('new_document.png', get_lang('Add document'), '', ICON_SIZE_MEDIUM).'</a>';
}
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= '<a
href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('addworkuser.png', get_lang('Add a user'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
$actionsLeft .= '<a
href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
$actionsLeft .= Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
$display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
$displayOutput = '<a
href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&id='.$workId.'&list=without">'.
Display::return_icon('exercice_uncheck.png', get_lang('View missing assignments'), '', ICON_SIZE_MEDIUM).'</a>';
$editLink = '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
@ -198,7 +208,19 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfC
$count = get_count_work($workId);
if ($count > 0) {
$display_output .= '<a class="btn-toolbar" href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
$router = Container::getRouter();
/** @var CStudentPublication $studentPublication */
$studentPublication = $studentPublicationRepo->find($workId);
$downloadUrl = $router->generate(
'chamilo_core_resource_download',
[
'id' => $studentPublication->getResourceNode()->getId(),
'tool' => 'student_publication',
'type' => 'student_publications',
]
);
$displayOutput .= '<a class="btn-toolbar" href="'.$downloadUrl.'?'.api_get_cidreq().'">'.
Display::return_icon(
'save_pack.png',
get_lang('Download assignments package'),
@ -206,8 +228,10 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfC
ICON_SIZE_MEDIUM
).' '.get_lang('Download assignments package').'</a>';
}
$actionsLeft .= $display_output;
$url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
$actionsLeft .= $displayOutput;
// @todo fix upload corrections.
/*$url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
$actionsLeft .= '<a class="btn-toolbar" href="'.$url.'">'.
Display::return_icon(
'upload_package.png',
@ -215,9 +239,9 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfC
'',
ICON_SIZE_MEDIUM
).' '.get_lang('Upload corrections package').'</a>';
$url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq(
).'&id='.$workId.'&action=delete_correction';
*/
$url = api_get_path(WEB_CODE_PATH).
'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=delete_correction';
$actionsLeft .= Display::toolbarButton(get_lang('Delete all corrections'), $url, 'trash', 'danger');
}

@ -589,7 +589,6 @@ class ResourceController extends AbstractResourceController implements CourseCon
{
$id = (int) $request->get('id');
$em = $this->getDoctrine();
/** @var ResourceNode $resourceNode */
$resourceNode = $this->getResourceNodeRepository()->find($id);
@ -614,10 +613,11 @@ class ResourceController extends AbstractResourceController implements CourseCon
$zipName = $resourceNode->getSlug().'.zip';
$rootNodePath = $resourceNode->getPathForDisplay();
$resourceNodeRepo = $repo->getResourceNodeRepository();
$type = $repo->getResourceType();
$criteria = Criteria::create()
->where(Criteria::expr()->neq('resourceFile', null)) // must have a file
// ->andWhere(Criteria::expr()->eq('resourceType', $type))
->andWhere(Criteria::expr()->eq('resourceType', $type)) // only download same type
;
/** @var ArrayCollection|ResourceNode[] $children */
@ -646,8 +646,11 @@ class ResourceController extends AbstractResourceController implements CourseCon
/** @var ResourceNode $node */
foreach ($children as $node) {
$stream = $repo->getResourceNodeFileStream($node);
$fileToDisplay = str_replace($rootNodePath, '', $node->getPathForDisplay());
$zip->addFileFromStream($fileToDisplay, $stream);
$fileName = $node->getResourceFile()->getOriginalName();
//$fileToDisplay = basename($node->getPathForDisplay());
//$fileToDisplay = str_replace($rootNodePath, '', $node->getPathForDisplay());
//error_log($fileToDisplay);
$zip->addFileFromStream($fileName, $stream);
}
$zip->finish();
}

@ -7,6 +7,7 @@ namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Doctrine\ORM\Mapping as ORM;
use Cocur\Slugify\Slugify;
/**
* CStudentPublicationComment.
@ -233,9 +234,6 @@ class CStudentPublicationComment extends AbstractResource implements ResourceInt
return $this->sentAt;
}
/**
* Resource identifier.
*/
public function getResourceIdentifier(): int
{
return $this->getIid();
@ -243,7 +241,11 @@ class CStudentPublicationComment extends AbstractResource implements ResourceInt
public function getResourceName(): string
{
return (string) substr(str_replace('/', '-', strip_tags($this->getComment())), 0, 40);
$text = strip_tags($this->getComment());
$slugify = new Slugify();
$text = $slugify->slugify($text);
return (string) substr($text, 0, 40);
}
public function setResourceName(string $name): self

Loading…
Cancel
Save