Skip to content

Commit

Permalink
WebServices: get work students without publications
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Aug 25, 2021
1 parent 5ab7fe0 commit 475fde3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main/inc/lib/webservices/Rest.php
Expand Up @@ -61,6 +61,7 @@ class Rest extends WebService
const SET_THREAD_NOTIFY = 'set_thread_notify';

const GET_WORK_LIST = 'get_work_list';
const GET_WORK_STUDENTS_WITHOUT_PUBLICATIONS = 'get_work_students_without_publications';
const PUT_WORK_STUDENT_ITEM_VISIBILITY = 'put_course_work_visibility';
const DELETE_WORK_STUDENT_ITEM = 'delete_work_student_item';
const DELETE_WORK_CORRECTIONS = 'delete_work_corrections';
Expand Down Expand Up @@ -2717,6 +2718,15 @@ function (array $work) use ($courseInfo, $webPath) {
);
}

public function getWorkStudentsWithoutPublications(int $workId): array
{
Event::event_access_tool(TOOL_STUDENTPUBLICATION);

require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';

return get_list_users_without_publication($workId);
}

public static function isAllowedByRequest(bool $inpersonate = false): bool
{
$username = $_GET['username'] ?? null;
Expand Down
13 changes: 13 additions & 0 deletions main/webservices/api/v2.php
Expand Up @@ -305,6 +305,19 @@
$restApi->getWorkList((int) $_GET['work'])
);
break;
case Rest::GET_WORK_STUDENTS_WITHOUT_PUBLICATIONS:
if (!isset($_GET['work'])) {
throw new Exception(get_lang('ActionNotAllowed'));
}

if (!api_is_allowed_to_edit(false, true)) {
throw new Exception(get_lang('NotAllowed'));
}

$restResponse->setData(
$restApi->getWorkStudentsWithoutPublications((int) $_GET['work'])
);
break;
case Rest::PUT_WORK_STUDENT_ITEM_VISIBILITY:
if (!isset($_POST['status'], $_POST['work'])) {
throw new Exception(get_lang('ActionNotAllowed'));
Expand Down

0 comments on commit 475fde3

Please sign in to comment.