Skip to content

Commit a480dbd

Browse files
committed
WebServices: allow show document in frame + quiz tool + survey tool
1 parent f3e7652 commit a480dbd

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

main/inc/lib/webservices/Rest.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ class Rest extends WebService
6868
const DELETE_WORK_STUDENT_ITEM = 'delete_work_student_item';
6969
const DELETE_WORK_CORRECTIONS = 'delete_work_corrections';
7070

71+
const VIEW_DOCUMENT_IN_FRAME = 'view_document_in_frame';
72+
73+
const VIEW_QUIZ_TOOL = 'view_quiz_tool';
74+
75+
const VIEW_SURVEY_TOOL = 'view_survey_tool';
76+
7177
const CREATE_CAMPUS = 'add_campus';
7278
const EDIT_CAMPUS = 'edit_campus';
7379
const DELETE_CAMPUS = 'delete_campus';
@@ -2858,6 +2864,67 @@ function ($userId) use ($courseId, $sessionId, $workParents, $workIdList) {
28582864
);
28592865
}
28602866

2867+
public function viewDocumentInFrame(int $documentId)
2868+
{
2869+
$courseCode = $this->course->getCode();
2870+
$sessionId = $this->session ? $this->session->getId() : 0;
2871+
2872+
$url = api_get_path(WEB_CODE_PATH).'document/showinframes.php?'
2873+
.http_build_query(
2874+
[
2875+
'cidReq' => $courseCode,
2876+
'id_session' => $sessionId,
2877+
'gidReq' => 0,
2878+
'gradebook' => 0,
2879+
'origin' => self::SERVICE_NAME,
2880+
'id' => $documentId,
2881+
]
2882+
);
2883+
2884+
header("Location: $url");
2885+
exit;
2886+
}
2887+
2888+
public function viewQuizTool()
2889+
{
2890+
$courseCode = $this->course->getCode();
2891+
$sessionId = $this->session ? $this->session->getId() : 0;
2892+
2893+
$url = api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'
2894+
.http_build_query(
2895+
[
2896+
'cidReq' => $courseCode,
2897+
'id_session' => $sessionId,
2898+
'gidReq' => 0,
2899+
'gradebook' => 0,
2900+
'origin' => self::SERVICE_NAME,
2901+
]
2902+
);
2903+
2904+
header("Location: $url");
2905+
exit;
2906+
}
2907+
2908+
public function viewSurveyTool()
2909+
{
2910+
$courseCode = $this->course->getCode();
2911+
$sessionId = $this->session ? $this->session->getId() : 0;
2912+
2913+
$url = api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'
2914+
.http_build_query(
2915+
[
2916+
'cidReq' => $courseCode,
2917+
'id_session' => $sessionId,
2918+
'gidReq' => 0,
2919+
'gradebook' => 0,
2920+
'origin' => self::SERVICE_NAME,
2921+
]
2922+
);
2923+
2924+
header("Location: $url");
2925+
exit;
2926+
}
2927+
28612928
public static function isAllowedByRequest(bool $inpersonate = false): bool
28622929
{
28632930
$username = $_GET['username'] ?? null;

main/webservices/api/v2.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,19 @@
391391
);
392392
break;
393393

394+
case Rest::VIEW_DOCUMENT_IN_FRAME:
395+
$lpId = isset($_REQUEST['document']) ? (int) $_REQUEST['document'] : 0;
396+
$restApi->viewDocumentInFrame($lpId);
397+
break;
398+
399+
case Rest::VIEW_QUIZ_TOOL:
400+
$restApi->viewQuizTool();
401+
break;
402+
403+
case Rest::VIEW_SURVEY_TOOL:
404+
$restApi->viewSurveyTool();
405+
break;
406+
394407
case Rest::CREATE_CAMPUS:
395408
$data = $restApi->createCampusURL($_POST);
396409
$restResponse->setData($data);

0 commit comments

Comments
 (0)