From 79172a30244d8cca194e6580a568dddb67a0c5d7 Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Sun, 1 May 2022 19:40:29 +0200 Subject: [PATCH] Add cheats script Co-authored-by: Julian; --- lzk-cheatsheet.html | 2 +- lzk/.htaccess | 2 + lzk/add-question.php | 16 +++++ lzk/lzk-cheats.user.js | 130 +++++++++++++++++++++++++++++++++++ lzk/questions-log.json | 83 ++++++++++++++++++++++ lzk/questions-logger.user.js | 90 ++++++++++++++++++++++++ lzk/questions.json | 102 +++++++++++++++++++++++++++ lzk/test-questions.json | 8 +++ matrix.html | 3 - 9 files changed, 432 insertions(+), 4 deletions(-) create mode 100644 lzk/.htaccess create mode 100644 lzk/add-question.php create mode 100644 lzk/lzk-cheats.user.js create mode 100755 lzk/questions-log.json create mode 100644 lzk/questions-logger.user.js create mode 100644 lzk/questions.json create mode 100644 lzk/test-questions.json diff --git a/lzk-cheatsheet.html b/lzk-cheatsheet.html index 6dac6c7..160dff9 100644 --- a/lzk-cheatsheet.html +++ b/lzk-cheatsheet.html @@ -1 +1 @@ -

What is the correct tag for the largest heading in HTML?

<h1>

What are semantic HTML elements?

Elements with meanings which allow a reader of the document to understand the meaning of the element

The class attribute is defined as following:

        class=”name”

The class Attribute is used to devide different elements into logical groups

What is the “alt” - Attribute for?

The classname is case sensitive

Link the positions to corresponding persons.

An iframe is an element which is used to display a webpage within a web page. Is this statement true or false?

        True

URLs are used to define the path to a destination site or to a ressource needed in the HTML file.

What is the charset meta declaration used for?

It defines the character encoding of a document so that the browser can interpret it properly.

Choose how ids are referenced in CSS.

#idname

Which of the following statements are true?

document.getElementById(“demo”).innterHTML = “Hello JavaScript!”;

selects an element with the name “demo” and changes its text to “Hello Javascript”

In some cases IDs should be used more than once. Is this statement true or false?

False

An inline CSS is used to apply a unique style to a single HTML element.

An internal CSS is used to define a style for a single HTML a page.

An external style sheet is used to define the style for many HTML pages.

Who develops the different standards for the Open Web Platform?

         W3 Consortium (W3C)

Who is responsible for HTML standards?

        W3 Consortium (W3C)

What does the abbreviation CSS mean?

        Cascading Style Sheets

What is the &nbsp; entity for?

        Introduces a non-breaking space.

In HTML each element must have an ID. Is this statement true or false?

        False

What is new in HTML5? Select all corresponding answers.

An HTML page can have one unique id(s) applied to one specific element, while a class name can be applied to multiple elements.

In HTML special entities must be rferenced with “&#entityNumber;”. Is this statement true or false?

        False

Match the tags to the fitting type.

        <ol>, <table>, <ul> block elements

<style> CSS formatting

<i>, <strong>, <b> text formatting

What is the basic syntax of HTML tags that need one attribute?

        <tagName attributeName=”value”>content</tagName>


What does the abbreviation HTML mean?

        Hyper Text Markup Language

What do you need as a preparation for coding HTML?

What is the latest and recommended HTML5 version number?

        HTML 5.2

The form-handler is typically a server page with a script for processing input data. Is this statement true or false?

        True

Select all valid HTML elements.

Which attribute opens the action url in a new browser tab?

        target=”_blank”

The POST Method is used to transfer form input which is sensitive and shouldn’t be displayed open.

The GET Method is used to transfer form input in plaintext over the URL.

What is the correct tag for a line break in HTML?

        <br>

Select all statements which are true about the HTML canvas tag.

var c = document.getElementById(“myCanvas”);

var ctx = c.getContext(“2d”);

ctx.beginPath();

ctx.arc(95,50,30,0,2*Math.PI);

ctx.stroke();

draws a circle

The HTML <body> element is used to store <style> and <link> elements. Is this statement true or false?

        False

Select all elements which should be in the head tag.

Combine the tags to their purpose.

        <var> various text (probably)

        <pre> preformated text

        <code> used for program code

        <kbd> denotes keyboard input

        <samp> used for sample computer output

Select all contributions which contribute to an elements bounding box (pixel size) in the box model.

The title tag specifies additional information about an element, which is often shown as a tooltip when the mouse moves over an element. Is this statement true or false?

        False

Choose 3 ways to specify a color in HTML or CSS.

By whom Web Standards are made?

oder

🤷

How does the definition of the doctype of an HTML5 document look like?

        <!DOCTYPE html>

XHTML is a combination of the strength of both XML and HTML to allow browser to interpret the document more efficiently. Is this statement true or false?

        True


Select the right expression to introduce a special character using its entity number in your HTML code.

        &#

How a CSS class may be used?

        .classname

Which input type does not exist?

\ No newline at end of file +

What is the correct tag for the largest heading in HTML?

<h1>

What are semantic HTML elements?

Elements with meanings which allow a reader of the document to understand the meaning of the element

The class attribute is defined as following:

        class=”name”

The class Attribute is used to devide different elements into logical groups

What is the “alt” - Attribute for?

The classname is case sensitive

Link the positions to corresponding persons.

An iframe is an element which is used to display a webpage within a web page. Is this statement true or false?

        True

URLs are used to define the path to a destination site or to a ressource needed in the HTML file.

What is the charset meta declaration used for?

It defines the character encoding of a document so that the browser can interpret it properly.

Choose how ids are referenced in CSS.

#idname

Which of the following statements are true?

document.getElementById(“demo”).innterHTML = “Hello JavaScript!”;

selects an element with the name “demo” and changes its text to “Hello Javascript”

In some cases IDs should be used more than once. Is this statement true or false?

False

An inline CSS is used to apply a unique style to a single HTML element.

An internal CSS is used to define a style for a single HTML a page.

An external style sheet is used to define the style for many HTML pages.

Who develops the different standards for the Open Web Platform?

         W3 Consortium (W3C)

Who is responsible for HTML standards?

        W3 Consortium (W3C)

What does the abbreviation CSS mean?

        Cascading Style Sheets

What is the &nbsp; entity for?

        Introduces a non-breaking space.

In HTML each element must have an ID. Is this statement true or false?

        False

What is new in HTML5? Select all corresponding answers.

An HTML page can have one unique id(s) applied to one specific element, while a class name can be applied to multiple elements.

In HTML special entities must be rferenced with “&#entityNumber;”. Is this statement true or false?

        False

Match the tags to the fitting type.

        <ol>, <table>, <ul> block elements

<style> CSS formatting

<i>, <strong>, <b> text formatting

What is the basic syntax of HTML tags that need one attribute?

        <tagName attributeName=”value”>content</tagName>


What does the abbreviation HTML mean?

        Hyper Text Markup Language

What do you need as a preparation for coding HTML?

What is the latest and recommended HTML5 version number?

        HTML 5.2

The form-handler is typically a server page with a script for processing input data. Is this statement true or false?

        True

Select all valid HTML elements.

Which attribute opens the action url in a new browser tab?

        target=”_blank”

The POST Method is used to transfer form input which is sensitive and shouldn’t be displayed open.

The GET Method is used to transfer form input in plaintext over the URL.

What is the correct tag for a line break in HTML?

        <br>

Select all statements which are true about the HTML canvas tag.

var c = document.getElementById(“myCanvas”);

var ctx = c.getContext(“2d”);

ctx.beginPath();

ctx.arc(95,50,30,0,2*Math.PI);

ctx.stroke();

draws a circle

The HTML <body> element is used to store <style> and <link> elements. Is this statement true or false?

        False

Select all elements which should be in the head tag.

Combine the tags to their purpose.

        <var> various text (probably)

        <pre> preformated text

        <code> used for program code

        <kbd> denotes keyboard input

        <samp> used for sample computer output

Select all contributions which contribute to an elements bounding box (pixel size) in the box model.

The title tag specifies additional information about an element, which is often shown as a tooltip when the mouse moves over an element. Is this statement true or false?

        False

Choose 3 ways to specify a color in HTML or CSS.

By whom Web Standards are made?

oder

🤷

How does the definition of the doctype of an HTML5 document look like?

        <!DOCTYPE html>

XHTML is a combination of the strength of both XML and HTML to allow browser to interpret the document more efficiently. Is this statement true or false?

        True


Select the right expression to introduce a special character using its entity number in your HTML code.

        &#

How a CSS class may be used?

        .classname

Which input type does not exist?

\ No newline at end of file diff --git a/lzk/.htaccess b/lzk/.htaccess new file mode 100644 index 0000000..9486f0d --- /dev/null +++ b/lzk/.htaccess @@ -0,0 +1,2 @@ +Header set Access-Control-Allow-Origin "*" +Header set Access-Control-Allow-Headers "content-type" \ No newline at end of file diff --git a/lzk/add-question.php b/lzk/add-question.php new file mode 100644 index 0000000..d276575 --- /dev/null +++ b/lzk/add-question.php @@ -0,0 +1,16 @@ + $type, "answers" => $answers); + file_put_contents("questions-log.json", json_encode($qs, JSON_PRETTY_PRINT)); + echo "Success"; +?> \ No newline at end of file diff --git a/lzk/lzk-cheats.user.js b/lzk/lzk-cheats.user.js new file mode 100644 index 0000000..99c926a --- /dev/null +++ b/lzk/lzk-cheats.user.js @@ -0,0 +1,130 @@ +// ==UserScript== +// @name Moodle Cheats +// @namespace http://cringe-studios.com/ +// @version 1.0 +// @description Advanced cheat tools +// @author MrLetsplay, JDobeshow +// @match https://moodle.cringe-studios.com/mod/quiz/attempt.php* +// @icon https://nsfw.cringe-studios.com/grimacing.png +// @grant none +// ==/UserScript== + +var questionAnswers = null; + +function normalize(text) { + return text.replaceAll(/[^a-zA-Z0-9]/g, "").toLowerCase(); +} + +function msg(text) { + let form = document.getElementById("responseform"); + let sad = document.getElementById("cheat-msg"); + if(!sad){ + sad = document.createElement("span"); + sad.id = "cheat-msg"; + sad.innerText = text; + sad.style.color = "gray"; + let q = form.getElementsByClassName("qtext")[0]; + q.parentElement.insertBefore(sad, q); + }else { + sad.innerText = text; + } +} + +function insertAnswers() { + console.log("Solve"); + let form = document.getElementById("responseform"); + let qText = form.getElementsByClassName("qtext")[0]; + if(qText.getElementsByTagName("select").length > 0) { + // Fixes bug in Chrome + let clone = form.cloneNode(true); + let selects; + while((selects = clone.getElementsByClassName("qtext")[0].getElementsByTagName("select")).length > 0) { + selects[0].remove(); + } + qText = clone.getElementsByClassName("qtext")[0]; + } + let question = normalize(qText.innerText); + let answer = questionAnswers[question]; + if(answer == null) { + console.log("No answer for question:", question); + msg("No answer found"); + return; + } + + let answers = form.getElementsByClassName("answer")[0]; + if(answers != null && answers.tagName == "TABLE") { + for(let tr of answers.getElementsByTagName("tr")) { + let ans = answer[normalize(tr.children[0].getElementsByTagName("p")[0].innerText)]; + let s = tr.children[1].getElementsByTagName("select")[0]; + for(let j = 0; j < s.options.length; j++) { + if(normalize(s.options[j].innerText) == ans) { + s.selectedIndex = j; + break; + } + } + } + }else { + let selects = form.getElementsByTagName("select"); + if(selects.length > 0) { // Question with placeholders + for(let i = 0; i < selects.length; i++) { + let ans = answer[i]; + let s = selects[i]; + for(let j = 0; j < s.options.length; j++) { + if(normalize(s.options[j].innerText) == ans) { + s.selectedIndex = j; + break; + } + } + } + }else { + for(let a of answers.children) { + let aEl = a.getElementsByTagName("p")[0]; + if(!aEl) aEl = a.getElementsByTagName("label")[0]; + if(!aEl) aEl = a.getElementsByClassName("answernumber")[0].nextElementSibling; + let aText = normalize(aEl.innerText); + let input = a.getElementsByTagName("input")[0]; + if(input.type == "hidden") input = a.getElementsByTagName("input")[1]; + input.checked = answer.includes(aText); + } + } + } +} + +function loadQuestions() { + let xhr = new XMLHttpRequest(); + + xhr.open("GET", "https://cringe-studios.com/lzk/questions.json"); + xhr.send(); + + xhr.onload = () => { + questionAnswers = JSON.parse(xhr.responseText); + let newQAs = {}; + for(let q in questionAnswers) { + let ans = questionAnswers[q]; + let newAs = Array.isArray(ans) ? [] : {}; + for(let k in ans) { + newAs[normalize(k)] = normalize(ans[k]); + } + newQAs[normalize(q)] = newAs; + } + questionAnswers = newQAs; + console.log(questionAnswers); + } +} + +(function() { + 'use strict'; + + loadQuestions(); + + document.addEventListener("keydown", event => { + if(event.key == "A") { + if(questionAnswers == null) { + msg("Not ready yet"); + return; + } + + insertAnswers(); + } + }); +})(); diff --git a/lzk/questions-log.json b/lzk/questions-log.json new file mode 100755 index 0000000..033311c --- /dev/null +++ b/lzk/questions-log.json @@ -0,0 +1,83 @@ +{ + "Choose \"Yay\", \"Woo\" and \"Sus\"": { + "type": "Multiple choice (mehrfach)", + "answers": [ + "Amogus\n", + "Sus\n", + "Test\n", + "Woo\n", + "Yay\n" + ] + }, + "Answer is \"A\"\n": { + "type": "Multiple choice (einzeln)", + "answers": [ + "A\n", + "C\n", + "D\n", + "B\n" + ] + }, + "Choose\n": { + "type": "Zuordnung", + "answers": { + "Choose \"C\"\n": [ + "Ausw\u00e4hlen ...", + "A", + "C", + "B" + ], + "Choose \"A\"\n": [ + "Ausw\u00e4hlen ...", + "A", + "C", + "B" + ], + "Choose \"B\"\n": [ + "Ausw\u00e4hlen ...", + "A", + "C", + "B" + ] + } + }, + "The impostor is ___ and ___ .Crewmates are ___ and ___ .": { + "type": "L\u00fcckentext", + "answers": [ + [ + "\u00a0", + "sus", + "very nice" + ], + [ + "\u00a0", + "a sussy baka", + "innocent" + ], + [ + "\u00a0", + "sus", + "very nice" + ], + [ + "\u00a0", + "a sussy baka", + "innocent" + ] + ] + }, + "Very weird formatting, but the answer is sus": { + "type": "Multiple choice (mehrfach)", + "answers": [ + "The correct code is let a = \"sus\"; console.log(a);.\n", + "The correct code is console.log(\"amogus\");.\n" + ] + }, + "Is\n\n\n0 == true\n\nor\n\n\n0 == false?\n": { + "type": "Multiple choice (einzeln)", + "answers": [ + "Wahr", + "Falsch" + ] + } +} \ No newline at end of file diff --git a/lzk/questions-logger.user.js b/lzk/questions-logger.user.js new file mode 100644 index 0000000..6502e67 --- /dev/null +++ b/lzk/questions-logger.user.js @@ -0,0 +1,90 @@ +// ==UserScript== +// @name Moodle Questions Logger +// @namespace http://cringe-studios.com/ +// @version 1.0 +// @description Advanced cheat tools +// @author MrLetsplay, JDobeshow +// @match https://moodle.cringe-studios.com/mod/quiz/attempt.php* +// @icon https://nsfw.cringe-studios.com/sus.png +// @grant none +// ==/UserScript== + +function saveQuestion() { + let form = document.getElementById("responseform"); + let qText = form.getElementsByClassName("qtext")[0]; + if(qText.getElementsByTagName("select").length > 0) { + // Fixes bug in Chrome + let clone = form.cloneNode(true); + let selects; + while((selects = clone.getElementsByClassName("qtext")[0].getElementsByTagName("select")).length > 0) { + let span = document.createElement("span"); + span.innerText = "___"; + selects[0].parentElement.replaceChild(span, selects[0]); + } + qText = clone.getElementsByClassName("qtext")[0]; + console.log(qText); + } + + let question = qText.innerText; + let answers = []; + let type = "unknown"; + + for(let select of form.getElementsByClassName("qtext")[0].getElementsByTagName("select")) { + type = "Lückentext"; + let a = []; + for(let op of select.children) { + a.push(op.innerText); + } + answers.push(a); + } + + let answersEl = form.getElementsByClassName("answer")[0]; + if(answersEl) { + if(answersEl.tagName == "TABLE") { + answers = {}; + type = "Zuordnung"; + for(let tr of answersEl.getElementsByTagName("tr")) { + let tx = tr.children[0].getElementsByTagName("p")[0].innerText; + let s = tr.children[1].getElementsByTagName("select")[0]; + let ops = []; + for(let j = 0; j < s.options.length; j++) { + ops.push(s.options[j].innerText); + } + answers[tx] = ops; + } + }else { + let isMultiple = false; + for(let a of answersEl.children) { + let input = a.getElementsByTagName("input")[0]; + if(input.type == "hidden") input = a.getElementsByTagName("input")[1]; + if(input.type == "checkbox") isMultiple = true; + + let aEl = a.getElementsByTagName("p")[0]; + if(!aEl) aEl = a.getElementsByTagName("label")[0]; + if(!aEl) aEl = a.getElementsByClassName("answernumber")[0].nextElementSibling; + answers.push(aEl.innerText); + } + type = isMultiple ? "Multiple choice (mehrfach)" : "Multiple choice (einzeln)"; + } + } + + let xhr = new XMLHttpRequest(); + + xhr.open("POST", "https://cringe-studios.com/lzk/add-question.php"); + xhr.setRequestHeader("Content-Type", "application/json"); + + let obj = { + question: question, + answers: answers, + type: type + } + + console.log(obj); + xhr.send(JSON.stringify(obj)); +} + +(function() { + 'use strict'; + + saveQuestion(); +})(); \ No newline at end of file diff --git a/lzk/questions.json b/lzk/questions.json new file mode 100644 index 0000000..d014aa8 --- /dev/null +++ b/lzk/questions.json @@ -0,0 +1,102 @@ +{ + "What is the correct tag for the largest heading in HTML?": ["

"], + "What are semantic HTML elements?": ["Elements with meanings which allow a reader of the document to understand the meaning of the element"], + "The class attribute is defined as following:": ["class=\"name\""], + "The class Attribute is used to devide different into logical groups": ["elements"], + "What is the \"alt\" - Attribute for?": [ + "It is used to display information about an element when the content cannot be displayed or loaded by the browser.", + "Disabled people can access the information of an element, which they wouldn't be able to understand due to their disabilities." + ], + "The classname is": ["case sensitive"], + "Link the positions to corresponding persons.": { + "Who is W3C CEO?": "Jeffrey Jaffe", + "Who is W3C director?": "Who is W3C director?" + }, + "An iframe is an element which is used to display a webpage within a web page. Is this statement true or false?": ["True"], + "URLs are used to define the to a destination site or to a ressource needed in the HTML file.": ["path"], + "What is the charset meta declaration used for?": ["It defines the character encoding of a document so that the browser can interpret it properly."], + "Choose how ids are referenced in CSS.": ["#idname"], + "Which of the following statements are true?": [ + "With Javascript you can create new elements.", + "You can include a Javascript file at the end of the HTML body.", + "With the