Group's tutor can add new assignment see BT#13558

pull/2487/head
jmontoyaa 8 years ago
parent bdd7ad4518
commit e0a8a36229
  1. 2
      main/inc/lib/groupmanager.lib.php
  2. 56
      main/work/work.lib.php
  3. 18
      main/work/work.php

@ -2279,7 +2279,7 @@ class GroupManager
'span',
Display::encrypted_mailto_link(
$tutor['mail'],
$tutor['complete_name']
$tutor['complete_name_with_username']
),
array('title'=>$username)
).', ';

@ -17,57 +17,63 @@ use Chamilo\CourseBundle\Entity\CStudentPublication;
/**
* Displays action links (for admins, authorized groups members and authorized students)
* @param string Current dir
* @param integer Whether to show tool options
* @param integer Whether to show upload form option
* @param bool $isTutor
* @return void
*/
function display_action_links($id, $cur_dir_path, $action)
function displayWorkActionLinks($id, $action, $isTutor)
{
$id = $my_back_id = intval($id);
if ($action == 'list') {
$my_back_id = 0;
}
$display_output = '';
$output = '';
$origin = api_get_origin();
if (!empty($id)) {
$display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_back_id.'">'.
$output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_back_id.'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).
'</a>';
}
if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
if (($isTutor || api_is_allowed_to_edit(null, true)) &&
$origin != 'learnpath'
) {
// Create dir
if (empty($id)) {
$display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=create_dir">';
$display_output .= Display::return_icon(
'new_work.png',
get_lang('CreateAssignment'),
'',
ICON_SIZE_MEDIUM
).
'</a>';
$output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=create_dir">';
$output .= Display::return_icon(
'new_work.png',
get_lang('CreateAssignment'),
'',
ICON_SIZE_MEDIUM
).
'</a>';
}
}
if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
if (empty($id)) {
// Options
$display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=settings">';
$display_output .= Display::return_icon(
$output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=settings">';
$output .= Display::return_icon(
'settings.png',
get_lang('EditToolOptions'),
'',
ICON_SIZE_MEDIUM
).'</a>';
}
$display_output .= '<a id="open-view-list" href="#">'.
Display::return_icon(
'listwork.png',
get_lang('ViewStudents'),
'',
ICON_SIZE_MEDIUM
).
'</a>';
$output .= '<a id="open-view-list" href="#">'.
Display::return_icon(
'listwork.png',
get_lang('ViewStudents'),
'',
ICON_SIZE_MEDIUM
).
'</a>';
}
@ -83,9 +89,9 @@ function display_action_links($id, $cur_dir_path, $action)
}
}
if ($display_output != '') {
if ($output != '') {
echo '<div class="actions">';
echo $display_output;
echo $output;
echo '</div>';
}
}

@ -27,8 +27,6 @@ $curdirpath = '';
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = to_javascript_work();
$_course = api_get_course_info();
/* Constants and variables */
$tool_name = get_lang('StudentPublications');
@ -126,6 +124,16 @@ if (!empty($groupId)) {
// Stats
Event::event_access_tool(TOOL_STUDENTPUBLICATION);
$groupId = api_get_group_id();
$isTutor = false;
if (!empty($groupId)) {
$groupInfo = GroupManager::get_group_properties($groupId);
$isTutor = GroupManager::is_tutor_of_group(
api_get_user_id(),
$groupInfo
);
}
$is_allowed_to_edit = api_is_allowed_to_edit();
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
@ -162,8 +170,8 @@ switch ($action) {
break;
case 'add':
case 'create_dir':
if (!$is_allowed_to_edit) {
api_not_allowed();
if (!($is_allowed_to_edit || $isTutor)) {
api_not_allowed(true);
}
$addUrl = api_get_path(WEB_CODE_PATH).'work/work.php?action=create_dir&'.api_get_cidreq();
$form = new FormValidator(
@ -365,7 +373,7 @@ if ($origin === 'learnpath') {
echo '<div style="height:15px">&nbsp;</div>';
}
display_action_links($work_id, $curdirpath, $action);
displayWorkActionLinks($work_id, $action, $isTutor);
echo $content;
Display::display_footer();

Loading…
Cancel
Save