Skip to content

Commit

Permalink
Start single exam.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiarn committed Jul 9, 2024
1 parent b89c3b4 commit ac87d64
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 26 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ angular.module('lmn.session_new').controller 'LMNSessionController', ($scope, $h

# Exam mode

$scope.startExam = () ->
if $scope.examMode
$scope.startExam = (user) ->
if $scope.examMode and !user
return

# End exam for a whole group
Expand All @@ -306,10 +306,15 @@ angular.module('lmn.session_new').controller 'LMNSessionController', ($scope, $h
}).then () ->
wait.modal(gettext("Starting exam mode ..."), "spinner")
$scope.stateChanged = true
$scope.examMode = true
$http.patch("/api/lmn/session/exam/start", {session: $scope.session}).then (resp) ->
if user
session = {"members":[{'cn': user}]}
else
session = $scope.session
$scope.examMode = true

$http.patch("/api/lmn/session/exam/start", {session: session}).then (resp) ->
$scope.stateChanged = false
lmnSession.getExamUsers()
lmnSession.getExamUsers(user)
$scope.stopRefreshFiles()
$rootScope.$emit('updateWaiting', 'done')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,25 @@ angular.module('lmn.session_new').service('lmnSession', function($http, $uibModa
$location.path('/view/lmn/session');
}

this.getExamUsers = () => {
users = this.current.members.map((user) => user.cn);
$http.post('/api/lmn/session/exam/userinfo', {'users': users}).then((resp) => {
this.current.members = resp.data;
this.createWorkingDirectory(this.current.members);
this.filterExamUsers();
$location.path('/view/lmn/session');
});
this.getExamUsers = (single_user) => {
users = this.current.members.map((user) => user.cn);
if (single_user) {
pos = users.indexOf(single_user);
this.current.members.splice(pos, 1);
$http.post('/api/lmn/session/exam/userinfo', {'users': [single_user]}).then((resp) => {
this.current.members.push(resp.data[0]);
this.createWorkingDirectory(this.current.members);
this.filterExamUsers();
$location.path('/view/lmn/session');
});
} else {
$http.post('/api/lmn/session/exam/userinfo', {'users': users}).then((resp) => {
this.current.members = resp.data;
this.createWorkingDirectory(this.current.members);
this.filterExamUsers();
$location.path('/view/lmn/session');
});
}
}

this.refreshUsers = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@
<!-- <i class="fas fa-stop pull-right"></i>-->
</a>
</div>
<div ng:show="!participant.examMode" style="text-align: center;">
<a style="display:inline-block; width:80px; font-size:100%"
class="btn btn-default"
ng:click="startExam(participant.cn)"
title="Start exam for {{participant.examTeacher}}"
>
<i class="fa fa-graduation-cap"></i>
{{participant.examTeacher}}
<!-- <i class="fas fa-stop pull-right"></i>-->
</a>
</div>
</td>

<td width="1" style="text-align:center;" ng:show="isStudent(participant)">
Expand Down
2 changes: 1 addition & 1 deletion usr/lib/linuxmuster-webui/plugins/lmn_session_new/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def handle_api_start_exam(self, http_context):
@endpoint(api=True)
def handle_api_stop_exam(self, http_context):
session = http_context.json_body()['session']
participants = ','.join([member['cn'] for member in session['members']])
participants = ','.join([member['cn'] for member in session['members'] if member['cn'].endswith('-exam')])
group_type = _(session['type'])
group_name = session['name']

Expand Down

0 comments on commit ac87d64

Please sign in to comment.