Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
PAIL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Paul
PAIL
Commits
aa63bf9a
Commit
aa63bf9a
authored
6 months ago
by
David Paul
Browse files
Options
Downloads
Patches
Plain Diff
Add debug information and more customisation
parent
9497b8e7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
index.php
+31
-6
31 additions, 6 deletions
index.php
settings.php
+13
-0
13 additions, 0 deletions
settings.php
with
44 additions
and
6 deletions
index.php
+
31
−
6
View file @
aa63bf9a
...
...
@@ -4,6 +4,17 @@ session_start();
require_once
(
"lib/parsedown/Parsedown.php"
);
require_once
(
"lib/lti/lti_util.php"
);
require_once
(
"settings.php"
);
function
debug
(
$message
,
$variable
)
{
if
(
$pail_debug
)
{
if
(
$message
)
{
echo
$message
;
}
if
(
$variable
)
{
var_dump
(
$variable
);
}
}
}
?>
<html
lang=
"en"
>
<head>
...
...
@@ -22,6 +33,7 @@ require_once("settings.php");
<body
class=
"markdown-body"
>
<?php
debug
(
"Starting..."
);
// Check if this is a valid LTI request
$valid_lti_request
=
is_lti_request
();
if
(
$valid_lti_request
)
{
...
...
@@ -33,32 +45,44 @@ require_once("settings.php");
$_SESSION
[
"oauth_consumer_key"
]
=
$oauth_consumer_key
;
$_SESSION
[
"oauth_consumer_secret"
]
=
$oauth_consumer_secret
;
}
debug
(
"oauth_consumer_key"
,
$oauth_consumer_key
);
debug
(
"oauth_consumer_secret"
,
$oauth_consumer_secret
);
$context
=
new
BLTI
(
$oauth_consumer_secret
,
true
,
false
);
// Ensure context is valid and context_id and user_id are alphanumeric only
$valid_lti_request
=
$context
->
valid
&&
ctype_alnum
(
$context
->
info
[
"
context_id
"
])
&&
ctype_alnum
(
$context
->
info
[
"
user_id
"
]);
&&
ctype_alnum
(
$context
->
info
[
$pail_
context_id
])
&&
ctype_alnum
(
$context
->
info
[
$pail_
user_id
]);
}
if
(
!
$valid_lti_request
)
{
// If not a valid LTI request, display an error
debug
(
"Ensure context id is alphanumeric only"
,
$context
->
info
[
$pail_context_id
]);
debug
(
"Ensure user id is alphanumeric only"
,
$context
->
info
[]
$pail_user_id
);
debug
(
"Invalid LTI context"
,
$context
);
require
(
"error_templates/not_lti.php"
);
}
else
{
// Determine name of file to display
$pail_dirname
=
getcwd
()
.
DIRECTORY_SEPARATOR
.
"
generated
"
.
DIRECTORY_SEPARATOR
.
$context
->
info
[
"
context_id
"
]
.
DIRECTORY_SEPARATOR
.
$context
->
info
[
"
user_id
"
]
.
DIRECTORY_SEPARATOR
;
$pail_
generated
_dir
.
DIRECTORY_SEPARATOR
.
$context
->
info
[
$pail_
context_id
]
.
DIRECTORY_SEPARATOR
.
$context
->
info
[
$pail_
user_id
]
.
DIRECTORY_SEPARATOR
;
// Default to display.md unless another file is requested
$pail_filename
=
isset
(
$_REQUEST
[
"display"
])
?
$_REQUEST
[
"display"
]
:
"display.md"
;
$pail_filename
=
$pail_dirname
.
$pail_filename
;
debug
(
"pail_filename:"
,
$pail_filename
);
debug
(
"pail_reset:"
,
$pail_reset
);
debug
(
"pail_filename exists: "
.
file_exists
(
$pail_filename
));
// Generate file if necessary
if
(
$pail_reset
||
!
file_exists
(
$pail_filename
))
{
debug
(
"Generating:"
,
$pail_filename
);
$output
=
null
;
$retval
=
null
;
$pail_command
=
"./generate.sh "
.
"-c
\"
"
.
$context
->
info
[
"
context_id
"
]
.
"
\"
"
.
" "
.
"-u
\"
"
.
$context
->
info
[
"
user_id
"
]
.
"
\"
"
.
"-c
\"
"
.
$context
->
info
[
$pail_
context_id
]
.
"
\"
"
.
" "
.
"-u
\"
"
.
$context
->
info
[
$pail_
user_id
]
.
"
\"
"
.
$pail_generate_command
;
debug
(
"Executing:"
,
$pail_command
);
exec
(
$pail_command
,
$output
,
$retval
);
debug
(
"Output:"
,
$output
);
debug
(
"retval"
,
$retval
);
}
// Attempt to read the file
...
...
@@ -68,6 +92,7 @@ require_once("settings.php");
}
if
(
$file_contents
===
false
)
{
// Display error if unable to read file
debug
(
"Unable to read file:"
,
$file_contents
);
require
(
"error_templates/file_unavailable.php"
);
// Display file
}
else
{
...
...
This diff is collapsed.
Click to expand it.
settings.php
+
13
−
0
View file @
aa63bf9a
...
...
@@ -8,6 +8,9 @@ $pail_title = "Personalising Assessment for Individualised Learning";
// A short description of the page generated by PAIL.
$pail_description
=
"Personalising assessment for individualised learning"
;
// The subdirectory where assessments are generated
$pail_generated_dir
=
"generated"
// The command to execute to generate files.
// It will be passed a final parameter that is the directory in which all files should be generated.
$pail_generate_command
=
"python3 example.py"
;
...
...
@@ -18,4 +21,14 @@ $pail_contact = "pail@example.edu";
// If true, files are regenerated each time a user visits the site.
// If false, files are only generated the first time (and then redisplayed on subsequent visits).
$pail_reset
=
false
;
// The key to use to get the context id from the LTI context
$pail_context_id
=
"context_id"
;
// The key to use to get the user id from the LTI context
$pail_user_id
=
"user_id"
;
// If true, prints out some debug information with the assessment page
// If false, no debug information is printed on the assessment page
$pail_debug
=
false
;
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment