Skip to content

Commit 28717e3

Browse files
committed
some missing parts added
1 parent 6b80618 commit 28717e3

File tree

13 files changed

+1674
-2
lines changed

13 files changed

+1674
-2
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.vscode
2-
database
2+
/database

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If it occurs it leads to a failure on a test that was added for this purpose. In
1818
If the repository was cloned without recursively cloning submodules, clone them now.
1919

2020
``` sh
21-
git submodule update --init
21+
git submodule update --init
2222
```
2323

2424
The following will build and run the CMWB using [docker](docker.com).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"description": "question.md",
3+
"models": [
4+
{
5+
"name": "Exercise 1",
6+
"file": "models/exercise1.dtmc"
7+
}
8+
],
9+
"answers": [
10+
{
11+
"type": "multipleChoice",
12+
"question": "What is the Markov Chain Type?",
13+
"choices": ["ergodic unichain", "non-ergodic unichain", "ergodic non-unichain", "non-ergodic non-unichain"],
14+
"solution": 0
15+
}
16+
]
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
markov chain Exercise1 {
2+
A [p: 1; r: 1] -- 1/2 -> A
3+
A -- 1/2 -> B
4+
B [p: 0; r: 2] -- 1/2 -> B
5+
B -- 1/2 -> C
6+
C [p: 0; r: -3] -- 1/2 -> C
7+
C -- 1/2 -> B
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Exercise 1
2+
3+
In your scratch models you find a Markov Chain model named `Exercise1`.
4+
5+
Please determine the type of the Markov Chain.
6+
You are expected to determine the type by inspection of the Markov Chain, as you would on a written exam.
7+
8+
If you have determined your answer, please go to the "Submit Answer" page to submit your result.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { ICompModModel } from "./modelsschema";
2+
import { PasswordUserDb } from "./passwdb";
3+
4+
export function CheckWriteAccess(model: ICompModModel, sessionUserId: string) {
5+
return model.isOwnedBy(sessionUserId)
6+
}
7+
8+
export function CheckReadAccess(model: ICompModModel, sessionUserId: string) {
9+
return model.isAccessibleTo(sessionUserId)
10+
}
11+
12+
export async function CheckAdminAccess(passwordUserDb: PasswordUserDb, sessionUserId: string): Promise<boolean> {
13+
return await passwordUserDb.isAdmin(sessionUserId)
14+
}
15+
16+
export function WriteAccessBarrier(model: ICompModModel, sessionUserId: string) {
17+
if (! CheckWriteAccess(model, sessionUserId)) throw new Error("Model is not write-accessible")
18+
}
19+
20+
export function ReadAccessBarrier(model: ICompModModel, sessionUserId: string) {
21+
if (! CheckReadAccess(model, sessionUserId)) throw new Error("Model is not read-accessible")
22+
}
23+
24+
export async function AdminAccessAsyncBarrier(passwordUserDb: PasswordUserDb, sessionUserId: string): Promise<void> {
25+
const accessible = await CheckAdminAccess(passwordUserDb, sessionUserId)
26+
if (! accessible) throw new Error("User is not an administrator")
27+
}
28+
29+
export function LocalModeBarrier() {
30+
if (! global.localMode) throw new Error("Server is not in local mode.")
31+
}
32+

0 commit comments

Comments
 (0)