diff --git a/.gitignore b/.gitignore
index 0d211d3..69d7715 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
vendor
composer.lock
+\.sass-cache
diff --git a/configure.php b/configure.php
index be9ade2..1c6f6e0 100644
--- a/configure.php
+++ b/configure.php
@@ -1,7 +1,7 @@
dbprefix;
-// If they pressed Submit on the quiz content
-if ( isset($_POST['gift']) ) {
- $gift = $_POST['gift'];
- $_SESSION['gift'] = $gift;
-
- // Some sanity checking...
- $retval = check_gift($gift);
- if ( ! $retval ) {
- header( 'Location: '.addSession('configure.php') ) ;
- return;
- }
-
- // This is not JSON - no one cares
- $LINK->setJson($gift);
- $_SESSION['success'] = 'Quiz updated';
- unset($_SESSION['gift']);
+// check to see if there are results from this link already
+$results_rows = $PDOX->allRowsDie("SELECT result_id, R.link_id AS link_id, R.user_id AS user_id, M.role as role,
+ sourcedid, service_id, grade, note, R.json AS json, R.note AS note
+ FROM lti_result AS R
+ JOIN lti_link AS L ON L.link_id = R.link_id AND R.link_id = :LI
+ JOIN lti_context AS C ON L.context_id = C.context_id AND C.context_id = :CI
+ JOIN lti_membership AS M ON R.user_id = M.user_id AND C.context_id = M.context_id
+ WHERE L.link_id = :LI AND M.role = 0 AND R.json IS NOT NULL",
+ array(':LI'=>$LINK->id, ':CI'=>$CONTEXT->id));
+
+if (!empty($_POST)) {
+
+ $gift = parse_configure_post();
+
+ // Sanity check
+ $retval = check_gift($gift);
+ if ( ! $retval ) {
+ header( 'Location: '.addSession('configure.php') ) ;
+ return;
+ }
+
+ $LINK->setJson($gift);
+ $_SESSION['success'] = 'Quiz updated';
+ if ($_POST['save_quiz'] == "Save and Return") {
header( 'Location: '.addSession('index.php') ) ;
- return;
-}
-
-// Check to see if we are supposed to preload a quiz
-$files = false;
-$lock = false;
-if ( isset ($CFG->giftquizzes) && is_dir($CFG->giftquizzes) ) {
- $files1 = scandir($CFG->giftquizzes);
- $files = array();
- foreach($files1 as $file) {
- if ( $file == '.lock' ) {
- $lock = trim(file_get_contents($CFG->giftquizzes.'/'.$file));
- continue;
- }
- if ( strpos($file, '.') === 0 ) continue;
- $files[] = $file;
- }
- sort($files);
-}
-if ( count($files) < 1 ) {
- $_SESSION['error'] = "Found no files in ".$CFG->giftquizzes;
- header( 'Location: '.addSession('configure.php') ) ;
- return;
-}
-// print_r($files);
-// echo("LOCK = ".$lock);
-
-$default = isset($_SESSION['default_quiz']) ? $_SESSION['default_quiz'] : false;
-
-// Load up the selected file
-if ( $files && isset($_POST['file']) ) {
- $key = isset($_POST['lock']) ? $_POST['lock'] : false;
- if ( $lock && $lock != $key ) {
- $_SESSION['error'] = 'Incorrect password';
- header( 'Location: '.addSession('configure.php') ) ;
- return;
- }
-
- $name = $_POST['file'];
- if ( ! in_array($name, $files) ) {
- $_SESSION['error'] = 'Quiz file not found: '.$_POST['file'];
- header( 'Location: '.addSession('configure.php') ) ;
- return;
- }
-
- $gift = file_get_contents($CFG->giftquizzes.'/'.$name);
- $_SESSION['gift'] = $gift;
-
- // Also pre-check for sanity
- $retval = check_gift($gift);
- if ( ! $retval ) {
- header( 'Location: '.addSession('configure.php') ) ;
- return;
- }
-
- $_SESSION['success'] = 'Preloaded quiz content from file. Make sure to save the quiz below.';
+ } else {
header( 'Location: '.addSession('configure.php') ) ;
- return;
-}
-
-// Load up the quiz from session or DB
-if ( isset($_SESSION['gift']) ) {
- $gift = $_SESSION['gift'];
- unset($_SESSION['gift']);
-} else {
- $gift = $LINK->getJson();
-}
-
-// Clean up the JSON for presentation
-if ( $gift === false || strlen($gift) < 1 ) {
- if ( $default != false && $lock == false && in_array($default, $files) ) {
- $gift = file_get_contents($CFG->giftquizzes.'/'.$default);
- $_SESSION['success'] = 'Loaded quiz '.$default.' as default';
- } else {
- $gift = getSampleGIFT();
- }
+ }
+ return;
}
// View
$OUTPUT->header();
+?>
+
+bodyStart();
$OUTPUT->topNav();
+echo('
');
$OUTPUT->flashMessages();
?>
-Be careful in making any changes if this quiz has submissions.
-\n");
-// echo('