From 985292b7cde0a5d2f90f10c98a217ed8f817aada Mon Sep 17 00:00:00 2001 From: jonhartm Date: Thu, 19 Apr 2018 12:42:30 -0400 Subject: [PATCH 01/62] start of template-based quiz authoring --- configure.php | 168 ++++++++----------------------------- css/authoring.css | 3 + js/author.js | 67 +++++++++++++++ old_configure.php | 154 ++++++++++++++++++++++++++++++++++ quiz_data.php | 22 +++++ templates/common.hbs | 11 +++ templates/mc_authoring.hbs | 6 ++ templates/sa_authoring.hbs | 4 + templates/tf_authoring.hbs | 3 + 9 files changed, 307 insertions(+), 131 deletions(-) create mode 100644 css/authoring.css create mode 100644 js/author.js create mode 100644 old_configure.php create mode 100644 quiz_data.php create mode 100644 templates/common.hbs create mode 100644 templates/mc_authoring.hbs create mode 100644 templates/sa_authoring.hbs create mode 100644 templates/tf_authoring.hbs diff --git a/configure.php b/configure.php index be9ade2..20e8c0f 100644 --- a/configure.php +++ b/configure.php @@ -1,7 +1,6 @@ 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']); - 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.'; - 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(); - } -} - // View $OUTPUT->header(); +?> + +bodyStart(); $OUTPUT->topNav(); $OUTPUT->flashMessages(); ?> -

Be careful in making any changes if this quiz has submissions.

-\n"); -// echo(''."\n"); -echo(''."\n"); -foreach($files as $file) { - if ( $default && $default == $file ) { - echo(''."\n"); - } else { - echo(''."\n"); - } -} -echo("\n"); -if ( $lock != false ) { - echo(' Password '); -} -echo(''); -echo("\n"); -} -?> -

-The assignment is configured by carefully editing the gift below. -The documentation for the GIFT format comes from -Moodle Documentation. -

-
- -

+ +

+
+

- +

footer(); +$OUTPUT->templateInclude(array('common', 'tf_authoring', 'mc_authoring', 'sa_authoring')); +?> + + diff --git a/css/authoring.css b/css/authoring.css new file mode 100644 index 0000000..cb36044 --- /dev/null +++ b/css/authoring.css @@ -0,0 +1,3 @@ +.question { + width: 75%; +} diff --git a/js/author.js b/js/author.js new file mode 100644 index 0000000..b8c9d4a --- /dev/null +++ b/js/author.js @@ -0,0 +1,67 @@ +function addQuestion(context) { + tsugiHandlebarsToDiv_noEmpty('quiz_content', 'common', context); + switch (context.type) { + case "true_false_question": addTrueFalse(context); break; + case "multiple_choice_question": addMultipleChoice(context); break; + case "multiple_answers_question": addMultipleChoice(context); break; + case "short_answer_question": addShortAnswer(context); break; + default: console.log("unrecognized question type: " + context.type); + } + lti_frameResize(); +} + +function addTrueFalse(context) { + if (context.answer == "T") { + context.answer_true = true; + } else if (context.answer == "F") { + context.answer_false = true; + } + tsugiHandlebarsToDiv_noEmpty("q"+context.count+"_content", 'tf_authoring', context); +} + +function addMultipleChoice(context) { + if ("parsed_answer" in context) { + for (var a=0; ainstructor ) die("Requires instructor role"); + +// Model +$p = $CFG->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']); + 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.'; + 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(); + } +} + +// View +$OUTPUT->header(); +$OUTPUT->bodyStart(); +$OUTPUT->topNav(); +$OUTPUT->flashMessages(); +?> +

Be careful in making any changes if this quiz has submissions.

+\n"); +// echo(''."\n"); +echo(''."\n"); +foreach($files as $file) { + if ( $default && $default == $file ) { + echo(''."\n"); + } else { + echo(''."\n"); + } +} +echo("\n"); +if ( $lock != false ) { + echo(' Password '); +} +echo(''); +echo("\n"); +} +?> +

+The assignment is configured by carefully editing the gift below. +The documentation for the GIFT format comes from +Moodle Documentation. +

+
+ +

+ +

+
+footer(); diff --git a/quiz_data.php b/quiz_data.php new file mode 100644 index 0000000..005934c --- /dev/null +++ b/quiz_data.php @@ -0,0 +1,22 @@ +getJson(); + +$questions = false; +$errors = array("No questions found"); +if ( strlen($gift) > 0 ) { + $questions = array(); + $errors = array(); + parse_gift($gift, $questions, $errors); +} + +echo json_encode($questions, JSON_PRETTY_PRINT); diff --git a/templates/common.hbs b/templates/common.hbs new file mode 100644 index 0000000..d80a3f2 --- /dev/null +++ b/templates/common.hbs @@ -0,0 +1,11 @@ +
+

{{__ 'Question'}} {{count}}

+ + + +
+ + +
+
diff --git a/templates/mc_authoring.hbs b/templates/mc_authoring.hbs new file mode 100644 index 0000000..e538496 --- /dev/null +++ b/templates/mc_authoring.hbs @@ -0,0 +1,6 @@ +
+ + + + +
diff --git a/templates/sa_authoring.hbs b/templates/sa_authoring.hbs new file mode 100644 index 0000000..97a2d64 --- /dev/null +++ b/templates/sa_authoring.hbs @@ -0,0 +1,4 @@ +
+ + +
diff --git a/templates/tf_authoring.hbs b/templates/tf_authoring.hbs new file mode 100644 index 0000000..18d6b26 --- /dev/null +++ b/templates/tf_authoring.hbs @@ -0,0 +1,3 @@ + +{{__ 'True'}} +{{__ 'False'}} From cf518b876975478c3d1a651ef074dc6af69dea17 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Thu, 19 Apr 2018 12:52:57 -0400 Subject: [PATCH 02/62] just a file rename --- configure.php | 3 +-- js/{author.js => authoring.js} | 0 2 files changed, 1 insertion(+), 2 deletions(-) rename js/{author.js => authoring.js} (100%) diff --git a/configure.php b/configure.php index 20e8c0f..9ad1b66 100644 --- a/configure.php +++ b/configure.php @@ -1,6 +1,5 @@ footer(); $OUTPUT->templateInclude(array('common', 'tf_authoring', 'mc_authoring', 'sa_authoring')); ?> - + +footerEnd(); diff --git a/css/authoring.css b/css/authoring.css index cb36044..0f121fa 100644 --- a/css/authoring.css +++ b/css/authoring.css @@ -1,3 +1,60 @@ -.question { - width: 75%; -} +h1 { + font-size: 18px; } + +.question-container { + display: flex; + flex-flow: column; + margin: 2em auto; + width: 80%; } + .question-container > div:first-of-type { + align-items: center; + background-color: #e7e7e7; + border: 1px solid #808080; + border-radius: 5px; + display: flex; + flex-flow: row; + justify-content: space-between; + margin: 1em 0; + padding: 0 .25em; + padding-left: .75em; } + .question-container > label { + margin-top: .5em; } + +.question-title { + display: inline-block; + margin: 0; + margin-right: 2em; } + +.question-content-container { + margin: auto; + margin-top: 1em; + width: 90%; } + +.truefalse-container { + display: flex; + justify-content: flex-end; } + .truefalse-container > * { + margin: 0 .5em; } + +.possible-answer { + align-items: center; + display: flex; + margin: 0 auto; } + .possible-answer > * { + margin: 0 .5em; } + .possible-answer > [type="text"] { + width: 50%; } + +.question-type-select { + margin: .5em; + width: 66%; } + +.btn { + margin: .5em; + min-width: 35px; } + +.quiz-controls { + margin: 2em auto; + width: 80%; } + +/*# sourceMappingURL=authoring.css.map */ diff --git a/css/authoring.css.map b/css/authoring.css.map new file mode 100644 index 0000000..ba4ea4d --- /dev/null +++ b/css/authoring.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAGA,EAAG;EACD,SAAS,EAAE,IAAI;;AAGjB,mBAAoB;EAClB,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,MAAM;EACjB,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG;EAEV,uCAAoB;IAClB,WAAW,EAAE,MAAM;IACnB,gBAAgB,EAdP,OAAO;IAehB,MAAM,EAAE,iBAAe;IACvB,aAAa,EAAE,GAAG;IAClB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,aAAa;IAC9B,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,KAAK;EAGrB,2BAAQ;IACN,UAAU,EAAE,IAAI;;AAIpB,eAAgB;EACd,OAAO,EAAE,YAAY;EACrB,MAAM,EAAE,CAAC;EACT,YAAY,EAAE,GAAG;;AAGnB,2BAA4B;EAC1B,MAAM,EAAE,IAAI;EACZ,UAAU,EAAE,GAAG;EACf,KAAK,EAAE,GAAG;;AAGZ,oBAAqB;EACnB,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,QAAQ;EAEzB,wBAAI;IACF,MAAM,EAAE,MAAM;;AAIlB,gBAAiB;EACf,WAAW,EAAE,MAAM;EACnB,OAAO,EAAE,IAAI;EACb,MAAM,EAAE,MAAM;EAEd,oBAAI;IACF,MAAM,EAAE,MAAM;EAIhB,gCAAgB;IACd,KAAK,EAAE,GAAG;;AAId,qBAAsB;EACpB,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,GAAG;;AAGZ,IAAK;EACH,MAAM,EAAE,IAAI;EACZ,SAAS,EAAE,IAAI;;AAGjB,cAAe;EACb,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG", +"sources": ["scss/authoring.scss"], +"names": [], +"file": "authoring.css" +} \ No newline at end of file diff --git a/css/scss/authoring.scss b/css/scss/authoring.scss new file mode 100644 index 0000000..964653c --- /dev/null +++ b/css/scss/authoring.scss @@ -0,0 +1,81 @@ +$grey: #808080; +$light-grey: #e7e7e7; + +h1 { + font-size: 18px; +} + +.question-container { + display: flex; + flex-flow: column; + margin: 2em auto; + width: 80%; + + > div:first-of-type { + align-items: center; + background-color: $light-grey; + border: 1px solid $grey; + border-radius: 5px; + display: flex; + flex-flow: row; + justify-content: space-between; + margin: 1em 0; + padding: 0 .25em; + padding-left: .75em; + } + + > label { + margin-top: .5em; + } +} + +.question-title { + display: inline-block; + margin: 0; + margin-right: 2em; +} + +.question-content-container { + margin: auto; + margin-top: 1em; + width: 90%; +} + +.truefalse-container { + display: flex; + justify-content: flex-end; + + > * { + margin: 0 .5em; + } +} + +.possible-answer { + align-items: center; + display: flex; + margin: 0 auto; + + > * { + margin: 0 .5em; + } + + + > [type="text"] { + width: 50%; + } +} + +.question-type-select { + margin: .5em; + width: 66%; +} + +.btn { + margin: .5em; + min-width: 35px; +} + +.quiz-controls { + margin: 2em auto; + width: 80%; +} diff --git a/templates/common.hbs b/templates/common.hbs index d6de018..0213f24 100644 --- a/templates/common.hbs +++ b/templates/common.hbs @@ -1,12 +1,13 @@ -
-

{{__ 'Question'}} {{count}}

- - - -
+
+
+

{{__ 'Question'}} {{count}}

+ +
+ + - + -
+
diff --git a/templates/mc_authoring.hbs b/templates/mc_authoring.hbs index 996bfa2..fd28732 100644 --- a/templates/mc_authoring.hbs +++ b/templates/mc_authoring.hbs @@ -1,18 +1,18 @@ -
+
- + {{#if value}} - {{else}} - {{/if}} diff --git a/templates/sa_authoring.hbs b/templates/sa_authoring.hbs index 8e4e8d2..a2fcb10 100644 --- a/templates/sa_authoring.hbs +++ b/templates/sa_authoring.hbs @@ -1,12 +1,12 @@ -
+
- + {{#if value}} - + {{else}} - {{/if}} diff --git a/templates/tf_authoring.hbs b/templates/tf_authoring.hbs index 2eca8ca..1f4b19d 100644 --- a/templates/tf_authoring.hbs +++ b/templates/tf_authoring.hbs @@ -1,3 +1,5 @@ - -{{__ 'True'}} -{{__ 'False'}} +
+ +

{{__ 'True'}}

+

{{__ 'False'}}

+
From cb6cdaddc3041d599f9073438ae6e0ccf90ec345 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Wed, 25 Apr 2018 23:33:52 -0400 Subject: [PATCH 26/62] fixed javascript bug from changing input names earlier --- js/authoring.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/authoring.js b/js/authoring.js index a18028b..a04beb6 100644 --- a/js/authoring.js +++ b/js/authoring.js @@ -89,7 +89,7 @@ function repurposeButton(btn_id) { // re-assign the on-click value of the button and change the value it displays $("#"+btn_id).attr("onclick", - "$('#mc_possible_answer"+answer_num+"_question"+question_num+"').remove(); renumber_answers("+question_num+");" + "$('#possible_answer"+answer_num+"_question"+question_num+"').remove(); renumber_answers("+question_num+");" ); $("#"+btn_id).val("-"); } @@ -98,7 +98,7 @@ function renumber_answers(question_number) { var answers = $("#content_question"+question_number).children(); for (var i = 0; i < answers.length; i++) { // get the number that this answer currently has - var to_replace = answers[i].id.split('_')[2]; + var to_replace = answers[i].id.split('_')[1]; // update the id of the div for this with the new answer answers[i].id = answers[i].id.replace(to_replace, "answer" + (i+1)); // update the entirety of the html for this div with the new answer From 1f319eaab9e9120eb0cf9e0ad1eeac1ef80b6953 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Wed, 25 Apr 2018 23:53:01 -0400 Subject: [PATCH 27/62] set focus to the input field when adding or removing an answer --- configure.php | 1 + js/authoring.js | 2 +- js/authoring_keyboard_nav.js | 3 +++ templates/mc_authoring.hbs | 2 ++ templates/sa_authoring.hbs | 7 ++++++- 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 js/authoring_keyboard_nav.js diff --git a/configure.php b/configure.php index 63bd7a9..2439e56 100644 --- a/configure.php +++ b/configure.php @@ -64,6 +64,7 @@ $OUTPUT->templateInclude(array('common', 'tf_authoring', 'mc_authoring', 'sa_authoring')); ?> + - + p:first-child { + font-weight: bold; + text-align: center; } .question-container { display: flex; diff --git a/css/authoring.css.map b/css/authoring.css.map index 9dcc587..b618b27 100644 --- a/css/authoring.css.map +++ b/css/authoring.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAOA,EAAG;EACD,SAAS,EAAE,IAAI;;AAGjB,QAAS;EACP,gBAAgB,EATL,OAAO;EAUlB,MAAM,EAAE,iBAAoB;EAC5B,aAAa,EAAE,GAAG;;AAGpB,mBAAoB;EAClB,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,MAAM;EACjB,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG;EAEV,uCAAoB;IAClB,WAAW,EAAE,MAAM;IACnB,gBAAgB,EAxBP,OAAO;IAyBhB,MAAM,EAAE,iBAAe;IACvB,aAAa,EAAE,GAAG;IAClB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,aAAa;IAC9B,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,KAAK;EAGrB,2BAAQ;IACN,UAAU,EAAE,IAAI;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ClB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,aAAa;IAC9B,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,KAAK;EAGrB,2BAAQ;IACN,UAAU,EAAE,IAAI;;AAIpB,eAAgB;EACd,OAAO,EAAE,YAAY;EACrB,MAAM,EAAE,CAAC;EACT,YAAY,EAAE,GAAG;;AAGnB,2BAA4B;EAC1B,MAAM,EAAE,IAAI;EACZ,UAAU,EAAE,GAAG;EACf,KAAK,EAAE,GAAG;;AAGZ,oBAAqB;EACnB,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,aAAa;EAC9B,WAAW,EAAE,IAAI;EACjB,YAAY,EAAE,CAAC;EACf,KAAK,EAAE,GAAG;EAEV,wBAAI;IACF,MAAM,EAAE,MAAM;;AAIlB,gBAAiB;EACf,WAAW,EAAE,MAAM;EACnB,OAAO,EAAE,IAAI;EACb,MAAM,EAAE,MAAM;EAEd,oBAAI;IACF,MAAM,EAAE,MAAM;EAIhB,gCAAgB;IACd,KAAK,EAAE,GAAG;;AAId,qBAAsB;EACpB,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,GAAG;;AAGZ,IAAK;EACH,MAAM,EAAE,IAAI;EACZ,SAAS,EAAE,IAAI;;AAGjB,cAAe;EACb,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG", "sources": ["scss/authoring.scss"], "names": [], "file": "authoring.css" diff --git a/css/scss/authoring.scss b/css/scss/authoring.scss index eabcbb5..619cc52 100644 --- a/css/scss/authoring.scss +++ b/css/scss/authoring.scss @@ -13,6 +13,18 @@ h1 { background-color: $light-pink; border: 1px solid $dark-pink; border-radius: 5px; + color: $maroon; +} + +.validation-error-list { + margin: auto; + padding: 1em; + width: 80%; + + > p:first-child { + font-weight: bold; + text-align: center; + } } .question-container { diff --git a/js/validation.js b/js/validation.js new file mode 100644 index 0000000..a6cff8d --- /dev/null +++ b/js/validation.js @@ -0,0 +1,104 @@ +/* ----------------------------------------------------------------------------- +// validation.js +// Check the quiz to make sure we don't have an error that's going to create +// a problem when we try and save. +// ----------------------------------------------------------------------------- +*/ + +/* Iterate through every question in the quiz and call validate_question +// on each. Any errors that validate_question returns are added to a list, +// which is shown in the error list div. +// If there are no errors, make sure the error list div is hidden and the +// "save" buttons are enabled. +*/ +function validate_quiz() { + var validation_errors = []; + for (var i = 1; i <= $(".question-container").length; i++) { + var question_validation_errors = validate_question(i); + // don't touch the error list unless we got something back + if (question_validation_errors != null) { + validation_errors = validation_errors.concat(question_validation_errors); + } + } + + // Did we get any errors? + if (validation_errors.length > 0) { + // Yes, so show the error list + $(".validation-error-list").show(); + // disable the save buttons + $("input[name='save_quiz']").attr("disabled", "disabled"); + // set the text at the start of the div + $(".validation-error-list").html('

WARNING: Please fix the following errors before saving...

'); + + // Add each error as a seperate

element + for (var i = 0; i < validation_errors.length; i++) { + var p = $("

").text(validation_errors[i]); + $(".validation-error-list").append(p); + } + } + else { + // No errors, so hide the error list and enable the "save" buttons + $(".validation-error-list").hide(); + $("input[name='save_quiz']").removeAttr("disabled"); + } +} + +// Check the given question number to make sure there are no validation errors +// If there are, return a list of strings indicating which errors were found +// If not, return null +function validate_question(num) { + var validation_errors = []; + var q_div = "#question"+num; // the div id for this question + var q_type = $(q_div + " [type='hidden']").val(); // the type of this question + + // check that there's at least something in the question text field + var q_text = $(q_div + " [name^=text_question]"); + if (q_text.val().length == 0) { + q_text.addClass("warning"); + validation_errors.push("Question " + num + ": Question Text must not be blank."); + } else { + q_text.removeClass("warning"); + } + + // specific checks for different question types + if (q_type == "true_false_question") { + // make sure the user has selected either true or false for this question + var checked_count = $(q_div + " [type='radio']:checked").length; + if (checked_count == 0) { + $(q_div + " .truefalse-container").addClass("warning"); + validation_errors.push("Question " + num + ": True/False Questions must have \"True\" or \"False\" selected."); + } else { + $(q_div + " .truefalse-container").removeClass("warning"); + } + } else if ( q_type == "multiple_choice_question" || q_type == "multiple_answers_question") { + // make sure there's at least one right answer checked for MC/MA questions + var checked_count = $(q_div + " [type='checkbox']:checked").length; + if (checked_count == 0) { + $(q_div + " .question-content-container").addClass("warning"); + validation_errors.push("Question " + num + ": At least one correct answer must be provided."); + } else { + $(q_div + " .question-content-container").removeClass("warning"); + } + } else if (q_type == "short_answer_question") { + // make sure there's at least one answer at least 1 character long + var answer_present = false; + var answers = $(q_div + " .answer-option"); + for (var i = 0; i < answers.length; i++) { + if ($(answers[i]).val().length > 0) { + answer_present = true; + } + } + if (!answer_present) { + $(q_div + " .question-content-container").addClass("warning"); + validation_errors.push("Question " + num + ": At least one correct answer must be provided."); + } else { + $(q_div + " .question-content-container").removeClass("warning"); + } + } + // return the list of errors, or null if there weren't any + if (validation_errors.length > 0) { + return validation_errors; + } else { + return null; + } +} From 213db0114391ee4b16d379fe15575929ad502738 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sat, 28 Apr 2018 14:05:05 -0400 Subject: [PATCH 38/62] create a "right" css class for right aligned objects I'm going to use this once or twice more, so I'm making a new rule rather than type the margins multiple times --- css/authoring.css | 6 ++++-- css/authoring.css.map | 2 +- css/scss/authoring.scss | 7 +++++-- templates/tf_authoring.hbs | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/css/authoring.css b/css/authoring.css index ffbddc3..dcc7e0d 100644 --- a/css/authoring.css +++ b/css/authoring.css @@ -47,12 +47,14 @@ h1 { .truefalse-container { display: flex; justify-content: space-between; - margin-left: auto; - margin-right: 0; width: 25%; } .truefalse-container > * { margin: 0 .5em; } +.right { + margin-left: auto; + margin-right: 0; } + .possible-answer { align-items: center; display: flex; diff --git a/css/authoring.css.map b/css/authoring.css.map index b618b27..bb757dc 100644 --- a/css/authoring.css.map +++ b/css/authoring.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAOA,EAAG;EACD,SAAS,EAAE,IAAI;;AAGjB,QAAS;EACP,gBAAgB,EATL,OAAO;EAUlB,MAAM,EAAE,iBAAoB;EAC5B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oBAAI;IACF,MAAM,EAAE,MAAM;EAIhB,gCAAgB;IACd,KAAK,EAAE,GAAG;;AAId,qBAAsB;EACpB,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,GAAG;;AAGZ,IAAK;EACH,MAAM,EAAE,IAAI;EACZ,SAAS,EAAE,IAAI;;AAGjB,cAAe;EACb,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG", "sources": ["scss/authoring.scss"], "names": [], "file": "authoring.css" diff --git a/css/scss/authoring.scss b/css/scss/authoring.scss index 619cc52..5575dfe 100644 --- a/css/scss/authoring.scss +++ b/css/scss/authoring.scss @@ -66,8 +66,6 @@ h1 { .truefalse-container { display: flex; justify-content: space-between; - margin-left: auto; - margin-right: 0; width: 25%; > * { @@ -75,6 +73,11 @@ h1 { } } +.right { + margin-left: auto; + margin-right: 0; +} + .possible-answer { align-items: center; display: flex; diff --git a/templates/tf_authoring.hbs b/templates/tf_authoring.hbs index 1f4b19d..09a71f5 100644 --- a/templates/tf_authoring.hbs +++ b/templates/tf_authoring.hbs @@ -1,4 +1,4 @@ -
+

{{__ 'True'}}

{{__ 'False'}}

From 3b640b627c836a41fccb135cf87f0937069053bb Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sat, 28 Apr 2018 14:44:28 -0400 Subject: [PATCH 39/62] added ability to put simple html in question --- configure.php | 4 +++- configure_parse.php | 4 ++++ parse.php | 1 + templates/common.hbs | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/configure.php b/configure.php index 06d3a84..c6720ef 100644 --- a/configure.php +++ b/configure.php @@ -62,7 +62,7 @@

- +

').html(context.question).text(); context.count = $("#quiz_content").children().length+1; addQuestion(context); } diff --git a/configure_parse.php b/configure_parse.php index 550a9e0..fc17b11 100644 --- a/configure_parse.php +++ b/configure_parse.php @@ -89,6 +89,10 @@ function create_gift_format($question) { } $answers= implode(" ", $answers); } + // was the html box checked? if so, prepend the text with [html] for the parser + if (isset($question['html'])) { + $question['text'] = '[html]'.$question['text']; + } // create the formatted string and return it return "::{$question['title']}:: {$question['text']} {{$answers}}"; } diff --git a/parse.php b/parse.php index c58c45f..63b310e 100644 --- a/parse.php +++ b/parse.php @@ -224,6 +224,7 @@ function parse_gift($text, &$questions, &$errors) { $qobj->name = $name; if ( strpos($question,'[html]') === 0 ) { $question = ltrim(substr($question,6)); + $qobj->html = true; } else { $question = htmlentities($question); } diff --git a/templates/common.hbs b/templates/common.hbs index 4a2a49c..990f47c 100644 --- a/templates/common.hbs +++ b/templates/common.hbs @@ -26,5 +26,9 @@ +
From edf3dad3735262e9d8eb3275e227a900abf8fc68 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sat, 28 Apr 2018 14:48:44 -0400 Subject: [PATCH 40/62] converted question text to a textarea field --- templates/common.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/common.hbs b/templates/common.hbs index 990f47c..84cba80 100644 --- a/templates/common.hbs +++ b/templates/common.hbs @@ -24,7 +24,7 @@ - +
@@ -88,7 +90,7 @@ } }); - $(".quiz-controls").mouseenter(function() { + $(".save-buttons").mouseenter(function() { validate_quiz(); }) }) diff --git a/css/authoring.css b/css/authoring.css index dcc7e0d..716dde0 100644 --- a/css/authoring.css +++ b/css/authoring.css @@ -75,5 +75,7 @@ h1 { .quiz-controls { margin: 2em auto; width: 80%; } + .quiz-controls .save-buttons { + width: 33%; } /*# sourceMappingURL=authoring.css.map */ diff --git a/css/authoring.css.map b/css/authoring.css.map index bb757dc..44cae23 100644 --- a/css/authoring.css.map +++ b/css/authoring.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAOA,EAAG;EACD,SAAS,EAAE,IAAI;;AAGjB,QAAS;EACP,gBAAgB,EATL,OAAO;EAUlB,MAAM,EAAE,iBAAoB;EAC5B,aAAa,EAAE,GAAG;EAClB,KAAK,EAVE,OAAO;;AAahB,sBAAuB;EACrB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,GAAG;EACZ,KAAK,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I;EACZ,KAAK,EAAE,GAAG;;AAGZ,IAAK;EACH,MAAM,EAAE,IAAI;EACZ,SAAS,EAAE,IAAI;;AAGjB,cAAe;EACb,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG;EAEV,4BAAc;IACZ,KAAK,EAAE,GAAG", "sources": ["scss/authoring.scss"], "names": [], "file": "authoring.css" diff --git a/css/scss/authoring.scss b/css/scss/authoring.scss index 5575dfe..6f81548 100644 --- a/css/scss/authoring.scss +++ b/css/scss/authoring.scss @@ -106,4 +106,8 @@ h1 { .quiz-controls { margin: 2em auto; width: 80%; + + .save-buttons { + width: 33%; + } } From 496326438df7c0c256a7ad286c6083cf664a9a90 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sat, 28 Apr 2018 17:55:47 -0400 Subject: [PATCH 43/62] validate the entire quiz anytime an object is changed. Might be overkill. We'll see. --- configure.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.php b/configure.php index 183880a..b5873a3 100644 --- a/configure.php +++ b/configure.php @@ -93,6 +93,11 @@ $(".save-buttons").mouseenter(function() { validate_quiz(); }) + + $("#quiz_content").change(function() { + validate_quiz(); + }); + }) Date: Sun, 29 Apr 2018 00:00:38 -0400 Subject: [PATCH 44/62] removed hardcoded style for top-nav buttons --- configure.php | 4 ++-- css/authoring.css | 3 ++- css/scss/authoring.scss | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/configure.php b/configure.php index b5873a3..aef9937 100644 --- a/configure.php +++ b/configure.php @@ -43,10 +43,10 @@ bodyStart(); $OUTPUT->topNav(); -echo(''); +echo('
'); echo('Cancel '); echo('Input GIFT Quiz Format '); -echo(''); +echo('
'); $OUTPUT->flashMessages(); ?>
diff --git a/css/authoring.css b/css/authoring.css index 716dde0..4ce2a9e 100644 --- a/css/authoring.css +++ b/css/authoring.css @@ -53,7 +53,8 @@ h1 { .right { margin-left: auto; - margin-right: 0; } + margin-right: 0; + text-align: right; } .possible-answer { align-items: center; diff --git a/css/scss/authoring.scss b/css/scss/authoring.scss index 6f81548..980443a 100644 --- a/css/scss/authoring.scss +++ b/css/scss/authoring.scss @@ -76,6 +76,7 @@ h1 { .right { margin-left: auto; margin-right: 0; + text-align: right; } .possible-answer { From 41ca75f703b7aa858b2132197953e0245e95585c Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sun, 29 Apr 2018 00:24:50 -0400 Subject: [PATCH 45/62] Added a confirmation in the event that a quiz has results SQL query to see if this particular Link object has at least one result from a student, and if so display a warning message that must be dismissed before the quiz can be edited --- configure.php | 67 +++++++++++++++++++++++++++++++---------- css/authoring.css | 9 ++++-- css/authoring.css.map | 2 +- css/scss/authoring.scss | 10 +++++- js/validation.js | 8 ++--- 5 files changed, 72 insertions(+), 24 deletions(-) diff --git a/configure.php b/configure.php index aef9937..f0ed5cf 100644 --- a/configure.php +++ b/configure.php @@ -13,7 +13,15 @@ // Model $p = $CFG->dbprefix; - +// 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)) { @@ -50,23 +58,44 @@ $OUTPUT->flashMessages(); ?> -
- -
- -
- - + +
+

WARNING: Results have already been recorded for this quiz - are you sure you want to make changes?

+
+ +
-

-

-
+
+ +
+ +
+ +
+ +
+ + +
+

+

+
+
+ footerStart(); $OUTPUT->templateInclude(array('common', 'tf_authoring', 'mc_authoring', 'sa_authoring')); @@ -98,6 +127,12 @@ validate_quiz(); }); + // In the event the confirmation div appears at the top of the form + // Pressing the button will hide the div and enable the form + $("#confirm_edit_with_results").click(function() { + $("#warning_for_edit_with_results").hide(); + $("fieldset").removeAttr("disabled"); + }); }) p:first-child { + .error-list > p:first-child { font-weight: bold; text-align: center; } + .error-list div { + text-align: center; } .question-container { display: flex; diff --git a/css/authoring.css.map b/css/authoring.css.map index 44cae23..888d4fd 100644 --- a/css/authoring.css.map +++ b/css/authoring.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAOA,EAAG;EACD,SAAS,EAAE,IAAI;;AAGjB,QAAS;EACP,gBAAgB,EATL,OAAO;EAUlB,MAAM,EAAE,iBAAoB;EAC5B,aAAa,EAAE,GAAG;EAClB,KAAK,EAVE,OAAO;;AAahB,sBAAuB;EACrB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,GAAG;EACZ,KAAK,EAAE,GAAG;EAEV,sCAAgB;IACd,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,MAAM;;AAItB,mBAAoB;EAClB,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,MAAM;EACjB,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG;EAEV,uCAAoB;IAClB,WAAW,EAAE,MAAM;IACnB,gBAAgB,EApCP,OAAO;IAqChB,MAAM,EAAE,iBAAe;IACvB,aAAa,EAAE,GAAG;IAClB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,aAAa;IAC9B,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,KAAK;EAGrB,2BAAQ;IACN,UAAU,EAAE,IAAI;;AAIpB,eAAgB;EACd,OAAO,EAAE,YAAY;EACrB,MAAM,EAAE,CAAC;EACT,YAAY,EAAE,GAAG;;AAGnB,2BAA4B;EAC1B,MAAM,EAAE,IAAI;EACZ,UAAU,EAAE,GAAG;EACf,KAAK,EAAE,GAAG;;AAGZ,oBAAqB;EACnB,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,aAAa;EAC9B,KAAK,EAAE,GAAG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K;EAGrB,2BAAQ;IACN,UAAU,EAAE,IAAI;;AAIpB,eAAgB;EACd,OAAO,EAAE,YAAY;EACrB,MAAM,EAAE,CAAC;EACT,YAAY,EAAE,GAAG;;AAGnB,2BAA4B;EAC1B,MAAM,EAAE,IAAI;EACZ,UAAU,EAAE,GAAG;EACf,KAAK,EAAE,GAAG;;AAGZ,oBAAqB;EACnB,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,aAAa;EAC9B,KAAK,EAAE,GAAG;EAEV,wBAAI;IACF,MAAM,EAAE,MAAM;;AAIlB,MAAO;EACL,WAAW,EAAE,IAAI;EACjB,YAAY,EAAE,CAAC;EACf,UAAU,EAAE,KAAK;;AAGnB,gBAAiB;EACf,WAAW,EAAE,MAAM;EACnB,OAAO,EAAE,IAAI;EACb,MAAM,EAAE,MAAM;EAEd,oBAAI;IACF,MAAM,EAAE,MAAM;EAIhB,gCAAgB;IACd,KAAK,EAAE,GAAG;;AAId,qBAAsB;EACpB,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,GAAG;;AAGZ,IAAK;EACH,MAAM,EAAE,IAAI;EACZ,SAAS,EAAE,IAAI;;AAGjB,cAAe;EACb,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG;EAEV,4BAAc;IACZ,KAAK,EAAE,GAAG", "sources": ["scss/authoring.scss"], "names": [], "file": "authoring.css" diff --git a/css/scss/authoring.scss b/css/scss/authoring.scss index 980443a..cb6ca81 100644 --- a/css/scss/authoring.scss +++ b/css/scss/authoring.scss @@ -9,6 +9,10 @@ h1 { font-size: 18px; } +fieldset { + width: 100%; +} + .warning { background-color: $light-pink; border: 1px solid $dark-pink; @@ -16,7 +20,7 @@ h1 { color: $maroon; } -.validation-error-list { +.error-list { margin: auto; padding: 1em; width: 80%; @@ -25,6 +29,10 @@ h1 { font-weight: bold; text-align: center; } + + div { + text-align: center; + } } .question-container { diff --git a/js/validation.js b/js/validation.js index aebef43..723c27f 100644 --- a/js/validation.js +++ b/js/validation.js @@ -24,21 +24,21 @@ function validate_quiz() { // Did we get any errors? if (validation_errors.length > 0) { // Yes, so show the error list - $(".validation-error-list").show(); + $("#validation-error-list").show(); // disable the save buttons $("input[name='save_quiz']").attr("disabled", "disabled"); // set the text at the start of the div - $(".validation-error-list").html('

WARNING: Please fix the following errors before saving...

'); + $("#validation-error-list").html('

WARNING: Please fix the following errors before saving...

'); // Add each error as a seperate

element for (var i = 0; i < validation_errors.length; i++) { var p = $("

").text(validation_errors[i]); - $(".validation-error-list").append(p); + $("#validation-error-list").append(p); } } else { // No errors, so hide the error list and enable the "save" buttons - $(".validation-error-list").hide(); + $("#validation-error-list").hide(); $("input[name='save_quiz']").removeAttr("disabled"); } } From 4390c74ce224589108f62bd3784b98c07caaa0cb Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sun, 29 Apr 2018 00:26:48 -0400 Subject: [PATCH 46/62] resize the frame in the event we get a really long error list --- js/validation.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/validation.js b/js/validation.js index 723c27f..e8056a8 100644 --- a/js/validation.js +++ b/js/validation.js @@ -41,6 +41,7 @@ function validate_quiz() { $("#validation-error-list").hide(); $("input[name='save_quiz']").removeAttr("disabled"); } + lti_frameResize(); } // Check the given question number to make sure there are no validation errors From ac27f8f2c88df1ec37bf87d7928a195f3df13cf4 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sun, 29 Apr 2018 14:29:07 -0400 Subject: [PATCH 47/62] check to make sure the quiz has at least one question --- js/validation.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/validation.js b/js/validation.js index e8056a8..51620aa 100644 --- a/js/validation.js +++ b/js/validation.js @@ -21,6 +21,11 @@ function validate_quiz() { } } + // is there at least one question in the quiz? + if ($(".question-container").length == 0) { + validation_errors.push("Quiz must contain at least one question"); + } + // Did we get any errors? if (validation_errors.length > 0) { // Yes, so show the error list From 38f938933225c584ecd2d9947b85772519070c9c Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sun, 29 Apr 2018 14:31:48 -0400 Subject: [PATCH 48/62] set the question type selector to autofocus --- configure.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.php b/configure.php index f0ed5cf..658924e 100644 --- a/configure.php +++ b/configure.php @@ -80,7 +80,7 @@
- From 00da7ad765f6fadb98b8380a4c9163b96261602e Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sun, 29 Apr 2018 14:37:56 -0400 Subject: [PATCH 49/62] validate the quiz when the user clicks either save button --- configure.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.php b/configure.php index 658924e..f112fb8 100644 --- a/configure.php +++ b/configure.php @@ -119,7 +119,7 @@ } }); - $(".save-buttons").mouseenter(function() { + $(".save-buttons").click(function() { validate_quiz(); }) From b2130739d15b1106b7f8d20ecf359ce18994f9c1 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Sun, 29 Apr 2018 17:22:24 -0400 Subject: [PATCH 50/62] re-did how buttons are presented there's always the option to remove an answer, and the last answer always has an add option. --- js/authoring.js | 24 +++++++----------------- templates/mc_authoring.hbs | 18 ++++++++---------- templates/sa_authoring.hbs | 14 ++++++-------- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/js/authoring.js b/js/authoring.js index 6fced59..74ab9cf 100644 --- a/js/authoring.js +++ b/js/authoring.js @@ -85,23 +85,6 @@ function addAnswer(div, template_name, answer_context={}) { lti_frameResize(); } -// Change the function of an answer button from "+" (add) to "-" (remove this option) -// requires the id of the button to affect -function repurposeButton(btn_id) { - // TODO: This feels really gross and messy - look at it again later - // get the numbers for the answer and question by parsing the button id - var answer_num = btn_id.split('_')[2]; - answer_num = answer_num.charAt(answer_num.length-1); - var question_num = btn_id.split('_')[3]; - question_num = question_num.charAt(question_num.length-1); - - // re-assign the on-click value of the button and change the value it displays - $("#"+btn_id).attr("onclick", - "$('#possible_answer"+answer_num+"_question"+question_num+"').remove(); renumber_answers("+question_num+"); set_focus_on_lastinput('#content_question"+question_num+"');" - ); - $("#"+btn_id).val("-"); -} - // runs through all the provided answers for the given question number and modifies the // html so the answers are always numbered sequentially from 1 to X function renumber_answers(question_number) { @@ -115,6 +98,13 @@ function renumber_answers(question_number) { var html = $(answers[i]).html(); var new_html = html.replace(new RegExp(to_replace, 'g'), "answer" + (i+1)); $(answers[i]).html(new_html); + + // if this is not the last button, make sure the "+" button is display:none + if (i < answers.length-1) { + $(answers[i]).find("[name^=btn_add]").hide(); + } else { + $(answers[i]).find("[name^=btn_add]").show(); + } } } diff --git a/templates/mc_authoring.hbs b/templates/mc_authoring.hbs index b033efb..b40d938 100644 --- a/templates/mc_authoring.hbs +++ b/templates/mc_authoring.hbs @@ -3,19 +3,17 @@ - {{#if value}} - - {{else}} - + - {{/if}} + renumber_answers({{count}}); + set_focus_on_lastinput('#content_question{{count}}');" + {{#if value}}style="display:none"{{/if}} + >
diff --git a/templates/sa_authoring.hbs b/templates/sa_authoring.hbs index e623e97..5554191 100644 --- a/templates/sa_authoring.hbs +++ b/templates/sa_authoring.hbs @@ -1,18 +1,16 @@
- {{#if value}} - - {{else}} - - {{/if}} + renumber_answers({{count}}); + set_focus_on_lastinput('#content_question{{count}}');" + {{#if value}}style="display:none"{{/if}}>
From 01036a6ec35fa2d69770c38e5aea7f89aef896bf Mon Sep 17 00:00:00 2001 From: jonhartm Date: Mon, 30 Apr 2018 01:13:17 -0400 Subject: [PATCH 51/62] fixed issue where user can delete the last possible answer The "-" button is supressed in the template when it is the first answer in a question. Also a CSS change to standardize the height of the answer div to keep it from jumping up and down when the "+" appears/disappears on the first answer. --- css/authoring.css | 3 ++- css/authoring.css.map | 2 +- css/scss/authoring.scss | 1 + js/authoring.js | 5 +++++ templates/mc_authoring.hbs | 2 ++ templates/sa_authoring.hbs | 2 ++ 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/css/authoring.css b/css/authoring.css index a22fba8..e603fcd 100644 --- a/css/authoring.css +++ b/css/authoring.css @@ -64,7 +64,8 @@ fieldset { .possible-answer { align-items: center; display: flex; - margin: 0 auto; } + margin: 0 auto; + min-height: 48px; } .possible-answer > * { margin: 0 .5em; } .possible-answer > [type="text"] { diff --git a/css/authoring.css.map b/css/authoring.css.map index 888d4fd..4eada3d 100644 --- a/css/authoring.css.map +++ b/css/authoring.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAOA,EAAG;EACD,SAAS,EAAE,IAAI;;AAGjB,QAAS;EACP,KAAK,EAAE,IAAI;;AAGb,QAAS;EACP,gBAAgB,EAbL,OAAO;EAclB,MAAM,EAAE,iBAAoB;EAC5B,aAAa,EAAE,GAAG;EAClB,KAAK,EAdE,OAAO;;AAiBhB,WAAY;EACV,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,GAAG;EACZ,KAAK,EAAE,GAAG;EAEV,2BAAgB;IACd,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,MAAM;EAGpB,eAAI;IACF,UAAU,EAAE,MAAM;;AAItB,mBAAoB;EAClB,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,MAAM;EACjB,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG;EAEV,uCAAoB;IAClB,WAAW,EAAE,MAAM;IACnB,gBAAgB,EA5CP,OAAO;IA6ChB,MAAM,EAAE,iBAAe;IACvB,aAAa,EAAE,GAAG;IAClB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,aAAa;IAC9B,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,KAAK;EAGrB,2BAAQ;IACN,UAAU,EAAE,IAAI;;AAIpB,eAAgB;EACd,OAAO,EAAE,YAAY;EACrB,MAAM,EAAE,CAAC;EACT,YAAY,EAAE,GAAG;;AAGnB,2BAA4B;EAC1B,MAAM,EAAE,IAAI;EACZ,UAAU,EAAE,GAAG;EACf,KAAK,EAAE,GAAG;;AAGZ,oBAAqB;EACnB,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,aAAa;EAC9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b,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,KAAK;EAGrB,2BAAQ;IACN,UAAU,EAAE,IAAI;;AAIpB,eAAgB;EACd,OAAO,EAAE,YAAY;EACrB,MAAM,EAAE,CAAC;EACT,YAAY,EAAE,GAAG;;AAGnB,2BAA4B;EAC1B,MAAM,EAAE,IAAI;EACZ,UAAU,EAAE,GAAG;EACf,KAAK,EAAE,GAAG;;AAGZ,oBAAqB;EACnB,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,aAAa;EAC9B,KAAK,EAAE,GAAG;EAEV,wBAAI;IACF,MAAM,EAAE,MAAM;;AAIlB,MAAO;EACL,WAAW,EAAE,IAAI;EACjB,YAAY,EAAE,CAAC;EACf,UAAU,EAAE,KAAK;;AAGnB,gBAAiB;EACf,WAAW,EAAE,MAAM;EACnB,OAAO,EAAE,IAAI;EACb,MAAM,EAAE,MAAM;EACd,UAAU,EAAE,IAAI;EAEhB,oBAAI;IACF,MAAM,EAAE,MAAM;EAIhB,gCAAgB;IACd,KAAK,EAAE,GAAG;;AAId,qBAAsB;EACpB,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,GAAG;;AAGZ,IAAK;EACH,MAAM,EAAE,IAAI;EACZ,SAAS,EAAE,IAAI;;AAGjB,cAAe;EACb,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG;EAEV,4BAAc;IACZ,KAAK,EAAE,GAAG", "sources": ["scss/authoring.scss"], "names": [], "file": "authoring.css" diff --git a/css/scss/authoring.scss b/css/scss/authoring.scss index cb6ca81..f6e8469 100644 --- a/css/scss/authoring.scss +++ b/css/scss/authoring.scss @@ -91,6 +91,7 @@ fieldset { align-items: center; display: flex; margin: 0 auto; + min-height: 48px; > * { margin: 0 .5em; diff --git a/js/authoring.js b/js/authoring.js index 74ab9cf..72ebc16 100644 --- a/js/authoring.js +++ b/js/authoring.js @@ -45,6 +45,8 @@ function addMultipleChoice(context) { if ("parsed_answer" in context) { for (var a=0; a + {{#unless first}} + {{/unless}} + {{#unless first}} + {{/unless}} Date: Mon, 30 Apr 2018 01:30:46 -0400 Subject: [PATCH 53/62] hide the html checkbox for the moment - it seems a little risky --- templates/common.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/common.hbs b/templates/common.hbs index 84cba80..ae2aba4 100644 --- a/templates/common.hbs +++ b/templates/common.hbs @@ -26,7 +26,7 @@ -
diff --git a/css/authoring.css b/css/authoring.css index 568929f..faa73de 100644 --- a/css/authoring.css +++ b/css/authoring.css @@ -86,7 +86,5 @@ fieldset { .quiz-controls { margin: 2em auto; width: 80%; } - .quiz-controls .save-buttons { - width: 33%; } /*# sourceMappingURL=authoring.css.map */ diff --git a/css/authoring.css.map b/css/authoring.css.map index a2f590d..0fbb354 100644 --- a/css/authoring.css.map +++ b/css/authoring.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAOA,EAAG;EACD,SAAS,EAAE,IAAI;;AAGjB,QAAS;EACP,KAAK,EAAE,IAAI;;AAGb,QAAS;EACP,gBAAgB,EAbL,OAAO;EAclB,MAAM,EAAE,iBAAoB;EAC5B,aAAa,EAAE,GAAG;EAClB,KAAK,EAdE,OAAO;;AAiBhB,WAAY;EACV,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,GAAG;EACZ,KAAK,EAAE,GAAG;EAEV,2BAAgB;IACd,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,MAAM;EAGpB,eAAI;IACF,UAAU,EAAE,MAAM;;AAItB,mBAAoB;EAClB,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,MAAM;EACjB,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG;EAEV,uCAAoB;IAClB,WAAW,EAAE,MAAM;IACnB,gBAAgB,EA5CP,OAAO;IA6ChB,MAAM,EAAE,iBAAe;IACvB,aAAa,EAAE,GAAG;IAClB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,aAAa;IAC9B,MAA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M,EAAE,IAAI;EACZ,SAAS,EAAE,IAAI;;AAGjB,cAAe;EACb,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,GAAG", "sources": ["scss/authoring.scss"], "names": [], "file": "authoring.css" diff --git a/css/scss/authoring.scss b/css/scss/authoring.scss index d9deefa..8de61e5 100644 --- a/css/scss/authoring.scss +++ b/css/scss/authoring.scss @@ -121,8 +121,4 @@ fieldset { .quiz-controls { margin: 2em auto; width: 80%; - - .save-buttons { - width: 33%; - } } From 79ecd251b9545d4dddf9d008456c445b6d39dd33 Mon Sep 17 00:00:00 2001 From: jonhartm Date: Mon, 30 Apr 2018 04:40:35 -0400 Subject: [PATCH 62/62] Fixed bug when trying to change type of a question that was renamed. Not pretty, but it works. change_question_type is now called with the div, which is parsed to get the question number. When the questions are renumbered, the html that makes this call is updated as well. --- js/authoring.js | 3 ++- templates/common.hbs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/js/authoring.js b/js/authoring.js index 68c7fd9..157acb1 100644 --- a/js/authoring.js +++ b/js/authoring.js @@ -176,7 +176,8 @@ function renumber_questions() { // Called by the question type selector in each question header. // Replaces the answer options with those of the newly selected type -function change_question_type(question_num) { +function change_question_type(question_div) { + var question_num = question_div.split("question")[1]; var selected_value = $("#question"+question_num+"_type_select").val(); $("#question"+question_num+"_type_select").val(""); //reset the dropdown if (selected_value != "") { diff --git a/templates/common.hbs b/templates/common.hbs index c123380..3b6a016 100644 --- a/templates/common.hbs +++ b/templates/common.hbs @@ -3,7 +3,7 @@

{{__ 'Question'}} {{count}} ({{PrettyType}})