Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…proctoring-gui into SEBSP-75-new
  • Loading branch information
kauzkoko committed Nov 27, 2023
2 parents e5ab1bb + 35ddaaf commit 5779120
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 80 deletions.
2 changes: 1 addition & 1 deletion client/src/components/views/gallery/GalleryImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
//props
const props = defineProps<{
screenshot: Screenshot | undefined,
screenshot: ScreenshotData | undefined,
timestamp: number,
groupUuid: string
}>();
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/views/gallery/GalleryViewPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
if(appBarStore.galleryIsMetadataEnabled && group?.value?.screenshots != null){
for(let i = 0; i < group.value?.screenshots.length; i++){
const screenshot: Screenshot | null = await galleryViewService.getLatestScreenshotData(group.value.screenshots[i].uuid, timestamp.value);
const screenshot: ScreenshotData | null = await galleryViewService.getLatestScreenshotData(group.value.screenshots[i].uuid, timestamp.value);
const metaData: MetaData | undefined = screenshot?.metaData;
group.value.screenshots[i].metaData = metaData == null ? {} : metaData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</v-row>
</v-card-text>

<v-card-title>Screenshot Metadata</v-card-title>
<v-card-title>ScreenshotData Metadata</v-card-title>
<v-card-text>
<v-row v-for="(value, key) in screenshotMetadata" :key="key">
<v-col>
Expand Down Expand Up @@ -107,8 +107,8 @@
//reactive variables
const isPlaying = ref<boolean>(false);
const session = ref<Screenshot>();
const currentScreenshot = ref<Screenshot>();
const session = ref<ScreenshotData>();
const currentScreenshot = ref<ScreenshotData>();
const sliderTime = ref<number>();
const firstScreenshotTime = ref<number>();
const lastScreenshotTime = ref<number>();
Expand Down Expand Up @@ -160,7 +160,7 @@
})
async function getAndAssignSession(){
const sessionResponse: Screenshot | null = await proctoringViewService.getSessionBySessionId(sessionId);
const sessionResponse: ScreenshotData | null = await proctoringViewService.getScreenshotDataBySessionId(sessionId);
if(sessionResponse == null){
showError.value = true;
Expand All @@ -182,9 +182,9 @@
//=============screenshot logic==================
async function getFirstScreenshotTime(){
let specificSessionResponse: Screenshot | null = null;
let specificSessionResponse: ScreenshotData | null = null;
if(session.value != null){
specificSessionResponse = await proctoringViewService.getSessionByTimestamp(sessionId, session.value?.startTime.toString());
specificSessionResponse = await proctoringViewService.getScreenshotDataByTimestamp(sessionId, session.value?.startTime.toString());
}
//error does not have to be shown here - if the slider moves too fast, some screenshots cannot be shown
Expand All @@ -195,7 +195,7 @@
}
async function getCurrentScreenshot(timestamp: string){
const specificSessionResponse: Screenshot | null = await proctoringViewService.getSessionByTimestamp(sessionId, timestamp);
const specificSessionResponse: ScreenshotData | null = await proctoringViewService.getScreenshotDataByTimestamp(sessionId, timestamp);
//error does not have to be shown here - if the slider moves too fast, some screenshots cannot be shown
if(specificSessionResponse == null) return;
Expand Down
2 changes: 1 addition & 1 deletion client/src/models/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ type GroupUuid = {
pageSize: number;
sortBy: string;
sortOrder: string;
screenshots: Screenshot[];
screenshots: ScreenshotData[];
exam: ExamView;
}
2 changes: 1 addition & 1 deletion client/src/models/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//todo: change name

type Screenshot = {
type ScreenshotData = {
startTime: number;
timestamp: number;
endTime: number;
Expand Down
8 changes: 1 addition & 7 deletions client/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import RegisterPage from "@/components/views/RegisterPage.vue"
import StartPage from "@/components/views/StartPage.vue"
import SearchPage from "@/components/views/search/SearchPage.vue"
import GalleryViewPage from "@/components/views/gallery/GalleryViewPage.vue"
import ProctoringViewPage from "@/components/views/ProctoringViewPage.vue"
import ChangePasswordDialog from "@/components/views/user-account/ChangePasswordDialog.vue"
import ProctoringViewPage from "@/components/views/proctoring/ProctoringViewPage.vue"
import UserAccountPage from "@/components/views/user-account/UserAccountPage.vue"
import UserInfo from "@/components/views/user-account/UserInfo.vue"
import * as authenticationService from "@/services/api-services/authenticationService";
Expand Down Expand Up @@ -65,11 +64,6 @@ const routes: Array<RouteRecordRaw> = [
},
component: LoginPage
},
{
path: "/changePasswordDialog",
name: "ChangePasswordDialog",
component: ChangePasswordDialog
},
{
path: "/",
component: ContainerLayout,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import axios, { AxiosResponse } from 'axios'
import * as apiService from "@/services/api-services/apiService";

export async function getSessionBySessionId(sessionId: string): Promise<Screenshot | any> {
export async function getScreenshotDataBySessionId(sessionId: string): Promise<ScreenshotData | any> {

try {
const url: string = "/session/" + sessionId;
const url: string = "/screenshot-data/" + sessionId;
const {data, status}: AxiosResponse = await apiService.api.get(url, {headers: apiService.getHeaders()});

if (status === 200) {
Expand All @@ -17,10 +17,10 @@ export async function getSessionBySessionId(sessionId: string): Promise<Screensh
}
}

export async function getSessionByTimestamp(sessionId: string, timestamp: string): Promise<Screenshot | any> {
export async function getScreenshotDataByTimestamp(sessionId: string, timestamp: string): Promise<ScreenshotData | any> {

try {
const url: string = "/session/" + sessionId + "/" + timestamp;
const url: string = "/screenshot-data/" + sessionId + "/" + timestamp;
const {data, status}: AxiosResponse = await apiService.api.get(url, {headers: apiService.getHeaders()});

if (status === 200) {
Expand Down
12 changes: 6 additions & 6 deletions client/src/services/component-services/galleryViewService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as groupService from "@/services/api-services/groupService";
import * as sessionService from "@/services/api-services/sessionService";
import * as screenshotDataService from "@/services/api-services/screenshotDataService";
import { SortOrder } from "@/models/sortOrderEnum";
import {navigateTo} from "@/router/navigation";
import { useAuthStore } from "@/store/app";
Expand All @@ -23,9 +23,9 @@ export async function getGroup(groupUuid: string, currentWindow: number, pageSiz
}
}

export async function getLatestScreenshotData(sessionUuid: string, timestamp: number): Promise<Screenshot | null>{
export async function getLatestScreenshotData(sessionUuid: string, timestamp: number): Promise<ScreenshotData | null>{
try{
return await sessionService.getSessionByTimestamp(sessionUuid, timestamp.toString());
return await screenshotDataService.getScreenshotDataByTimestamp(sessionUuid, timestamp.toString());
}catch(error){
console.error(error);
return null;
Expand All @@ -39,7 +39,7 @@ export function calcIndex(i: number, n: number, gridSize: number): number {
return ((i - 1) * gridSize + (n - 1));
}

export function currentIndexExists(screenshots: Screenshot[] | undefined, index: number): boolean {
export function currentIndexExists(screenshots: ScreenshotData[] | undefined, index: number): boolean {

if (screenshots != null && screenshots.length > index) {
return true;
Expand Down Expand Up @@ -67,7 +67,7 @@ export function currentIndexExists(screenshots: Screenshot[] | undefined, index:
// return screenshotLink;
// }

export function createImageLinkWithToken(screenshot: Screenshot | undefined, timestamp: number): string {
export function createImageLinkWithToken(screenshot: ScreenshotData | undefined, timestamp: number): string {
const authStore = useAuthStore();

if(screenshot == null){
Expand All @@ -90,7 +90,7 @@ export function createImageLinkWithToken(screenshot: Screenshot | undefined, tim
// }
// }

export function navigateToProctoringView(screenshot: Screenshot | undefined, groupUuid: string) {
export function navigateToProctoringView(screenshot: ScreenshotData | undefined, groupUuid: string) {
if (screenshot != null) {
navigateTo("/recording/" + screenshot.uuid);
}
Expand Down
12 changes: 6 additions & 6 deletions client/src/services/component-services/proctoringViewService.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import * as sessionService from "@/services/api-services/sessionService";
import * as screenshotDataService from "@/services/api-services/screenshotDataService";
import * as timeUtils from "@/utils/timeUtils";


//=============api==================
export async function getSessionBySessionId(sessionId: string): Promise<Screenshot | null>{
export async function getScreenshotDataBySessionId(sessionId: string): Promise<ScreenshotData | null>{
try{
return await sessionService.getSessionBySessionId(sessionId);
return await screenshotDataService.getScreenshotDataBySessionId(sessionId);
}catch(error){
console.error(error);
return null;
}
}

export async function getSessionByTimestamp(sessionId: string, timestamp: string): Promise<Screenshot | null>{
export async function getScreenshotDataByTimestamp(sessionId: string, timestamp: string): Promise<ScreenshotData | null>{
try{
return await sessionService.getSessionByTimestamp(sessionId, timestamp);
return await screenshotDataService.getScreenshotDataByTimestamp(sessionId, timestamp);
}catch(error){
console.error(error);
return null;
Expand All @@ -34,7 +34,7 @@ export function getScreenshotMetadata(sliderTime: number, currentScreenshotMetad
};
}

export function getSessionInfodata(session: Screenshot | null): object{
export function getSessionInfodata(session: ScreenshotData | null): object{
if(session == null){
return {};
}
Expand Down
7 changes: 7 additions & 0 deletions client/src/store/proctoringStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineStore } from "pinia";
import * as timeUtils from "@/utils/timeUtils";
import { ref, computed } from "vue";


export const useProctoringStore = defineStore("proctoring", () => {
});
28 changes: 28 additions & 0 deletions server/src/controllers/screenshot-data.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {Request, Response} from 'express';
import * as apiService from "../services/api.service";
import * as screenshotDataService from '../services/screenshot-data.service';

export async function getScreenshotDataBySessionId(req: Request, res: Response){

try{
const session: object = await screenshotDataService.getScreenshotDataBySessionId(req.headers.authorization, req.params.sessionId);

return res.status(200).json(session);

}catch(error){
apiService.handleGenericApiError(error, res);
}
}


export async function getScreenshotDataByTimestamp(req: Request, res: Response){

try{
const session: object = await screenshotDataService.getScreenshotDataByTimestamp(req.headers.authorization, req.params.sessionId, req.params.timestamp);

return res.status(200).json(session);

}catch(error){
apiService.handleGenericApiError(error, res);
}
}
28 changes: 0 additions & 28 deletions server/src/controllers/session.controller.ts

This file was deleted.

6 changes: 3 additions & 3 deletions server/src/routes/routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express, {Router} from 'express';
import * as groupController from '../controllers/group.controller';
import * as sessionController from '../controllers/session.controller';
import * as screenshotDataController from '../controllers/screenshot-data.controller';
import * as searchController from '../controllers/search.controller';
import * as userAccountController from '../controllers/user-account.controller';
import * as settingsController from '../controllers/settings.controller';
Expand All @@ -13,8 +13,8 @@ router.get("/settings", settingsController.getSettings)
router.get("/group", groupController.getGroups);
router.get("/group/:uuid", groupController.getGroupByUuid);

router.get("/session/:sessionId", sessionController.getSessionBySessionId);
router.get("/session/:sessionId/:timestamp", sessionController.getSessionByTimestamp);
router.get("/screenshot-data/:sessionId", screenshotDataController.getScreenshotDataBySessionId);
router.get("/screenshot-data/:sessionId/:timestamp", screenshotDataController.getScreenshotDataByTimestamp);

router.get("/search/sessions", searchController.searchSessions);
router.get("/search/screenshots", searchController.searchScreenshots);
Expand Down
2 changes: 1 addition & 1 deletion server/src/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getAuthorizationHeaders(encodedCredentials: string): object {
};
}

export function getJwtAuthorizationHeaders(encodedCredentials: string): object {
export function getAuthorizationHeadersBasic(encodedCredentials: string): object {
return {
"Authorization": "Basic " + encodedCredentials,
"Content-Type": "application/x-www-form-urlencoded"
Expand Down
15 changes: 6 additions & 9 deletions server/src/services/authorization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import axios from 'axios';
import {Buffer} from 'buffer';
import * as ENV from "../config/envConfig";
import * as apiService from "../services/api.service";
import * as utils from "../utils/utils";


const tokenUrl: string = ENV.PROCTOR_SERVER_URL + ENV.PROCTOR_SERVER_PORT + "/oauth/token?grant_type=";
const jwtUrl: string = ENV.PROCTOR_SERVER_URL + ENV.PROCTOR_SERVER_PORT + "/oauth/jwttoken/verify";

export async function authorizeViaScreenProctoringServer(username: string, password: string): Promise<object>{
const url: string = tokenUrl + "password&username=" + username + "&password=" + password;
const encodedCredentials: string = createEncodedCredentials(ENV.PROCTOR_SERVER_USERNAME, ENV.PROCTOR_SERVER_PASSWORD);
const encodedCredentials: string = utils.createEncodedCredentials(ENV.PROCTOR_SERVER_USERNAME, ENV.PROCTOR_SERVER_PASSWORD);

const {data, status} = await axios.post(url, {}, {
headers: apiService.getAuthorizationHeaders(encodedCredentials)
Expand All @@ -19,18 +21,18 @@ export async function authorizeViaScreenProctoringServer(username: string, passw

export async function verifyJwt(logintoken: string): Promise<object>{
const url: string = jwtUrl;
const encodedCredentials: string = createEncodedCredentials(ENV.PROCTOR_SERVER_USERNAME, ENV.PROCTOR_SERVER_PASSWORD);
const encodedCredentials: string = utils.createEncodedCredentials(ENV.PROCTOR_SERVER_USERNAME, ENV.PROCTOR_SERVER_PASSWORD);

const {data, status} = await axios.post(url, {logintoken}, {
headers: apiService.getJwtAuthorizationHeaders(encodedCredentials)
headers: apiService.getAuthorizationHeadersBasic(encodedCredentials)
});

return data;
}

export async function refreshViaScreenProctoringServer(refreshToken: string): Promise<object>{
const url: string = tokenUrl + "refresh_token&client_id=" + ENV.PROCTOR_SERVER_USERNAME + "&refresh_token=" + refreshToken;
const encodedCredentials: string = createEncodedCredentials(ENV.PROCTOR_SERVER_USERNAME, ENV.PROCTOR_SERVER_PASSWORD);
const encodedCredentials: string = utils.createEncodedCredentials(ENV.PROCTOR_SERVER_USERNAME, ENV.PROCTOR_SERVER_PASSWORD);

const {data, status} = await axios.post(url, {}, {
headers: apiService.getAuthorizationHeaders(encodedCredentials)
Expand All @@ -52,9 +54,4 @@ export async function logLogout(token: string){
const {data, status} = await apiService.api.post(url, {}, {headers: apiService.getHeaders(token)});

return data;
}


function createEncodedCredentials(username: string, password: string): string{
return Buffer.from(username + ":" + password).toString("base64");
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import axios from "axios";
import * as apiService from "./api.service";

const sessionUrl: string = "/proctoring/session/";
const sessionUrl: string = "/proctoring/screenshot-data/";

export async function getSessionBySessionId(token: string, sessionId: string): Promise<object>{
export async function getScreenshotDataBySessionId(token: string, sessionId: string): Promise<object>{
const url: string = sessionUrl + sessionId;
const {data, status} = await apiService.api.get(url, {headers: apiService.getHeaders(token)});

return data;
}


export async function getSessionByTimestamp(token: string, sessionId: string, timestamp: string): Promise<object>{
export async function getScreenshotDataByTimestamp(token: string, sessionId: string, timestamp: string): Promise<object>{
const url: string = sessionUrl + sessionId + "/" + timestamp;
const {data, status} = await apiService.api.get(url, {headers: apiService.getHeaders(token)});

Expand Down
Loading

0 comments on commit 5779120

Please sign in to comment.