kandi background
Explore Kits

ultraviolet | Ultraviolet Framework | Game Engine library

 by   tlgkccampbell C# Version: v2019.06 License: Non-SPDX

 by   tlgkccampbell C# Version: v2019.06 License: Non-SPDX

Download this library from

kandi X-RAY | ultraviolet Summary

ultraviolet is a C# library typically used in Gaming, Game Engine applications. ultraviolet has no bugs, it has no vulnerabilities and it has low support. However ultraviolet has a Non-SPDX License. You can download it from GitHub.
[![Join the chat at https://gitter.im/ultraviolet-framework/Lobby](https://badges.gitter.im/ultraviolet-framework/Lobby.svg)](https://gitter.im/ultraviolet-framework/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge). Ultraviolet is a cross-platform, .NET game development framework written in C# and released under the [MIT License](http://opensource.org/licenses/MIT). It is heavily inspired by Microsoft’s XNA Framework, and is intended to be easy for XNA developers to quickly pick up and start using. However, unlike [MonoGame](http://www.monogame.net/) and similar projects, Ultraviolet is not intended to be a drop-in replacement for XNA. Its current implementation is written on top of [SDL2](https://www.libsdl.org/) and [OpenGL](https://www.opengl.org/), but its modular design makes it (relatively) easy to re-implement using other technologies if it becomes necessary to do so in the future. At present, Ultraviolet officially supports Windows, Linux, and macOS using .NET Core 3.1, as well as Android through Xamarin. Support for iOS is no longer provided due to a lack of the requisite development hardware. If anyone wants to take responsibility for providing this support, please contact me at [cole.campbell@twistedlogik.net](mailto:cole.campbell@twistedlogik.net).
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • ultraviolet has a low active ecosystem.
  • It has 482 star(s) with 22 fork(s). There are 36 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 1 open issues and 118 have been closed. On average issues are closed in 54 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of ultraviolet is v2019.06
ultraviolet Support
Best in #Game Engine
Average in #Game Engine
ultraviolet Support
Best in #Game Engine
Average in #Game Engine

quality kandi Quality

  • ultraviolet has 0 bugs and 0 code smells.
ultraviolet Quality
Best in #Game Engine
Average in #Game Engine
ultraviolet Quality
Best in #Game Engine
Average in #Game Engine

securitySecurity

  • ultraviolet has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • ultraviolet code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
ultraviolet Security
Best in #Game Engine
Average in #Game Engine
ultraviolet Security
Best in #Game Engine
Average in #Game Engine

license License

  • ultraviolet has a Non-SPDX License.
  • Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
ultraviolet License
Best in #Game Engine
Average in #Game Engine
ultraviolet License
Best in #Game Engine
Average in #Game Engine

buildReuse

  • ultraviolet releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
  • ultraviolet saves you 3809 person hours of effort in developing the same functionality from scratch.
  • It has 8121 lines of code, 0 functions and 2406 files.
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
ultraviolet Reuse
Best in #Game Engine
Average in #Game Engine
ultraviolet Reuse
Best in #Game Engine
Average in #Game Engine
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

ultraviolet Key Features

A runtime content pipeline Easily load game assets using Ultraviolet's content pipeline. Unlike XNA, Ultraviolet's content pipeline operates at runtime, meaning no special Visual Studio projects are required to make it work. Content preprocessing is supported in order to increase efficiency and decrease load times.

High-level 2D rendering abstractions Familiar classes like SpriteBatch allow you to efficiently render large numbers of 2D sprites. Ultraviolet includes built-in support for texture atlases and XML-driven sprite sheets.

High-level 3D rendering abstractions Built-in support for [glTF 2.0 models](https://www.khronos.org/gltf/) and skinned animation makes it easy to get started with 3D rendering. Alternatively, you can write your own GLSL shader programs to take full control of the rendering process, and support for additional model types can be provided by extending the runtime content pipeline.

Low-level rendering functionality In addition to the abstractions described above, Ultraviolet's graphics subsystem allows you to push polygons directly to the graphics device, giving you complete control.

A powerful text formatting and layout engine Do more than draw plain strings of text. Ultraviolet's text formatting engine allows you to change your text's font, style, and color on the fly. The layout engine allows you to easily position and align text wherever you need it.

XML-driven object loader for easy content creation Ultraviolet's object loader allows you to easily create complicated hierarchies of objects from simple XML files. This is more than just an XML serializer—because it is integrated with Ultraviolet, it has direct knowledge of your game's content assets and object lists, making it possible to reference them in a simple, flexible, and readable way.

What is Ultraviolet?

copy iconCopydownload iconDownload
Easily load game assets using Ultraviolet's content pipeline. Unlike XNA, Ultraviolet's content pipeline operates at runtime, meaning no special Visual Studio projects are required to make it work. Content preprocessing is supported in order to increase efficiency and decrease load times.

Building

copy iconCopydownload iconDownload
msbuild Ultraviolet.proj /t:BuildAndroid

How do you use a random element from an array, remove that element from the array, and keep using random elements until the array is empty?

copy iconCopydownload iconDownload
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Random Quiz</title>
    <style>
        * {
            box-sizing: border-box;
        }

        button {
            cursor: pointer;
        }

        #quiz-text {
            position: relative;
            left: 42vw;
            top: 25vh;
            transform: translateX(-2%) translateY(5%);
            font-size: 1.5rem;

        }

        #quiz-button {
            position: relative;
            left: 45vw;
            top: 25vh;
            transform: translateX(-2%) translateY(5%);
            font-size: 20px;
        }
    </style>
</head>
<body id="body">
<p id="quiz-text">Want to take a short quiz?</p>
<button id="quiz-button"> START</button>

<script>

    function shuffle(array) {
        let currentIndex = array.length, randomIndex;

        // While there remain elements to shuffle...
        while (currentIndex != 0) {

            // Pick a remaining element...
            randomIndex = Math.floor(Math.random() * currentIndex);
            currentIndex--;

            // And swap it with the current element.
            [array[currentIndex], array[randomIndex]] = [
                array[randomIndex], array[currentIndex]];
        }

        return array;
    }

    const quizButton = document.getElementById("quiz-button");

    /*  =========================
        Question and answer pairs
        =========================
    */
    let shortQuizPrompts =
        [{prompt: "10 + 10\n(a) 10\n(b) 15\n(c) 20\n(d) 25", answer: "c"},
            {
                prompt: "What status did astronomers downgrade Pluto to in 2006?\n(a) Dwarf Planet\n(b) White Dwarf\n(c) Black Dwarf\n(d) Dwarf Star",
                answer: "a"
            },
            {
                prompt: 'What tart fruit has a sweet variety called "Meyer"?\n(a) lime\n(b) lemon\n(c) grapefruit\n(d) dragonfruit',
                answer: "c"
            },
            {
                prompt: `What bird lays its eggs in other birds' nests?\n(a) Blue Jay\n(b) Robin\n(c) Eagle\n (d) Cuckoo`,
                answer: "d"
            },
            {
                prompt: `What is a female goat called?\n(a) a foe\n(b) a larp\n(c) a nanny\n(d) a maur`,
                answer: "c"
            },
            {
                prompt: `What is Eisoptrophobia? \n(a) the fear of mirrors\n(b) the fear of cold temperatures\n(c) the fear of farm animals\n(d) the fear of viruses`,
                answer: `a`
            },
            {
                prompt: `Which element of the periodic table is named after the sun?\n(a) slinerium\n(b) helium\n(c) magnesium\n(d) uranium`,
                answer: `b`
            },
            {
                prompt: `What color is the octopus blood?\n(a) pink\n(b) light green\n(c) violet\n(d) light blue`,
                answer: `d`
            },
            {
                prompt: `What value does the Roman numeral C represent?\n(a) 20\n(b) 50\n(c) 100\n(d) 200`,
                answer: `c`
            },
            {
                prompt: `What is measured in fathoms?\n(a) depth of water \n(b) sound \n(c) pressure \n(d) light`,
                answer: `a`
            },
            {
                prompt: `What is Chiroptophobia?\n(a) fear of plants \n(b) fear of insects\n(c) fear of chirogenics \n(d) fear of bats`,
                answer: `d`
            },
            {
                prompt: `What is the longest and heaviest bone in the human body?\n(a) tibia\n(b) skull\n(c) femur\n(d) humorous`,
                answer: `c`
            },
            {
                prompt: `What are the two major elements making up the sun?\n(a) hydrogen and helium\n(b) nitrogen and hydrogen\n(c) oxygen and nitrogen\n(d) oxygen and hydrogen`,
                answer: `a`
            },
            {
                prompt: `What is poliosis?\n(a) a disease impacting your balance\n(b) graying of hair\n(c) loss of hair\n(d) high potassium pressence in blood`,
                answer: `b`
            },
            {
                prompt: `When held to ultraviolet light, what animal’s urine glows in the dark?\n(a) lemur\n(b) cat\n(c) dog\n(d) lamb`,
                answer: ``
            },
            {
                prompt: `What year did the "ILOVEYOU" virus began infecting computers worldwide?\n(a) 2000\n(b) 2001\n(c) 2002\n(d) 2004`,
                answer: `a`
            },
            {
                prompt: `What planet's four largest moons are collectively known as the Galilean Moons?\n(a) neptune\n(b) jupiter\n(c) saturn\n(d) uranus`,
                answer: `b`
            },
            {
                prompt: `What North American mammal is also known as the prairie wolf or brush wolf?\n(a) brown bears\n(b) ocelots\n(c) coyotes\n(d) hyenas`,
                answer: `c`
            },
            {
                prompt: `How often are brain cells replaced?\n(a) once every few hours\n(b) once every few days\n(c) once every few weeks\n(d) never`,
                answer: `d`
            },
            {
                prompt: `What physical property of a diamond do carats measure?\n(a) mass\n(b) purity \n(c) color quality\n(d) mineral composition`,
                answer: `a`
            },
            {
                prompt: `Nosocomephobia is the fear of what?\n(a) night time\n(b) very large objects\n(c) hospitals\n(d) loud noises`,
                answer: `c`
            },
            {
                prompt: `In what year did the Soviet Union launch its first Sputnik satellite?\n(a) 1049\n(b) 1957\n(c) 1963\n(d)1972`,
                answer: `b`
            },
            {
                prompt: `What is measured in Ergs?\n(a) Work\n(b) mass\n(c) depth\n(d) emotion`,
                answer: `a`
            },
            {
                prompt: `What does a Scoville unit measure?\n(a) sourness\n(b) pain\n(c) spiciness\n(d) taste`,
                answer: `c`
            },];


    /*  ======================
        initiation of the quiz
        ======================
    */

    quizButton.onclick = () => {
        let correct = 0;
        const amountOfQuestions = prompt(`How many questions do you want? There are ${shortQuizPrompts.length} maximum`);
        alert('You are about to start the quiz. \nFor each question, enter either "a", "b", "c", or "d". \nPress enter to continue');
        shuffle(shortQuizPrompts);
        for (i = 0; i < amountOfQuestions; i++) {
            const answer = prompt(shortQuizPrompts[i].prompt);
            if (answer === shortQuizPrompts[i].answer && answer !== null && answer !== undefined) {
                alert("Correct");
                correct++;
            } else if (answer !== shortQuizPrompts[i].answer && answer !== null && answer !== undefined && answer.length >= 1 && (answer === "a" || answer === "b" || answer === "c" || answer === "d")) {
                alert("Incorrect");
            } else if (answer === null) {
                alert(`Bruh, why'd you start the quiz if you didnt want to answer the questions lol`);
            } else if (answer.length == 0) {
                setInterval(alert("Trying to skip questions, I see?? Yeah, you thought you weren't gonna get caught, huh? Well think again")), 100;
            }
            console.log(answer)
            if (i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) <= 33) {
                alert(`Wow, you're bad! You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions correct!`);

            }

            if (i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) > 33 && (Math.floor(correct / amountOfQuestions * 100)) <= 66) {
                alert(`You did ok. You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions right!`);

            }

            if (i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) > 66) {
                alert(`Congratulations! 🎉 You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions right!`);
            }
            if (answer !== "a" && answer !== "b" && answer !== "c" && answer !== "d" && answer.length > 0 && answer !== null && answer !== undefined) {
                alert(`What are you doing? I told you to only enter "a", "b", "c", or "d" as answers`);
            }
        }

    }
</script>
</body>
</html>

Why is my padding right and bottom only changing but not my top and left?

copy iconCopydownload iconDownload
if (window.y > e.clientY) {
                square.style.height = `${window.y - e.clientY}px`;
            } else {
                square.style.top = `${window.y}px`;
                square.style.height = `${e.clientY - window.y}px`;
            }
            if (window.x > e.clientX) {
                square.style.width = `${window.x - e.clientX}px`;
                square.style.left = `${e.clientX}px`;
            } else {
                square.style.left = `${window.x}px`;
                square.style.width = `${e.clientX - window.x}px`;
            }
-----------------------
var active = false;
var a = 0;
var b = 0;

document.addEventListener("mousedown", (e) => {
    const sq = document.getElementById("square");
    sq.style.display = "block";
    active = true;
    a = e.clientX;
    b = e.clientY;
    sq.style.left = `${a}px`;
    sq.style.top = `${b}px`;
});

document.addEventListener("mouseup", (e) => {
    active = false;
    const sq = document.getElementById("square");
    sq.style.display = "none";
    sq.style.height = sq.style.width = sq.style.top = sq.style.left= "0px";
});

document.addEventListener("mousemove", (e) => {
    if (active) {
        var x = e.clientX;
        var y = e.clientY;
        const sq = document.getElementById("square");

        if (a < x) {
            sq.style.width = `${x - a}px`;
            sq.style.left = `${a}px`;
        }
        else{
            sq.style.width = `${a - x}px`;
            sq.style.left = `${x}px`;
        }
    
        if (b < y) {
            sq.style.height = `${y - b}px`;
            sq.style.top = `${b}px`;
        }
        else {
            sq.style.height = `${b - y}px`;
            sq.style.top = `${y}px`;
        }
    }
});
.container{
  height:100%;
  width:100%;
  background:#fff;
}

#square{
  background:blue;
  position:fixed;
  display:none;
}
<div class="container"></div>
<div id="square"></div>
-----------------------
var active = false;
var a = 0;
var b = 0;

document.addEventListener("mousedown", (e) => {
    const sq = document.getElementById("square");
    sq.style.display = "block";
    active = true;
    a = e.clientX;
    b = e.clientY;
    sq.style.left = `${a}px`;
    sq.style.top = `${b}px`;
});

document.addEventListener("mouseup", (e) => {
    active = false;
    const sq = document.getElementById("square");
    sq.style.display = "none";
    sq.style.height = sq.style.width = sq.style.top = sq.style.left= "0px";
});

document.addEventListener("mousemove", (e) => {
    if (active) {
        var x = e.clientX;
        var y = e.clientY;
        const sq = document.getElementById("square");

        if (a < x) {
            sq.style.width = `${x - a}px`;
            sq.style.left = `${a}px`;
        }
        else{
            sq.style.width = `${a - x}px`;
            sq.style.left = `${x}px`;
        }
    
        if (b < y) {
            sq.style.height = `${y - b}px`;
            sq.style.top = `${b}px`;
        }
        else {
            sq.style.height = `${b - y}px`;
            sq.style.top = `${y}px`;
        }
    }
});
.container{
  height:100%;
  width:100%;
  background:#fff;
}

#square{
  background:blue;
  position:fixed;
  display:none;
}
<div class="container"></div>
<div id="square"></div>
-----------------------
var active = false;
var a = 0;
var b = 0;

document.addEventListener("mousedown", (e) => {
    const sq = document.getElementById("square");
    sq.style.display = "block";
    active = true;
    a = e.clientX;
    b = e.clientY;
    sq.style.left = `${a}px`;
    sq.style.top = `${b}px`;
});

document.addEventListener("mouseup", (e) => {
    active = false;
    const sq = document.getElementById("square");
    sq.style.display = "none";
    sq.style.height = sq.style.width = sq.style.top = sq.style.left= "0px";
});

document.addEventListener("mousemove", (e) => {
    if (active) {
        var x = e.clientX;
        var y = e.clientY;
        const sq = document.getElementById("square");

        if (a < x) {
            sq.style.width = `${x - a}px`;
            sq.style.left = `${a}px`;
        }
        else{
            sq.style.width = `${a - x}px`;
            sq.style.left = `${x}px`;
        }
    
        if (b < y) {
            sq.style.height = `${y - b}px`;
            sq.style.top = `${b}px`;
        }
        else {
            sq.style.height = `${b - y}px`;
            sq.style.top = `${y}px`;
        }
    }
});
.container{
  height:100%;
  width:100%;
  background:#fff;
}

#square{
  background:blue;
  position:fixed;
  display:none;
}
<div class="container"></div>
<div id="square"></div>

cant deserialize json string c#

copy iconCopydownload iconDownload
    public class HotspotResponse
    {
        public HotspotArray Done { get; set; }
    }

How do I prevent transform hover from overlapping with navigation bar?

copy iconCopydownload iconDownload
.normal {
  font-style: normal;
}

#intro-container {
  display: grid;
  grid-template-columns: repeat(3, 400px);
  grid-column-gap: 200px;
  margin-top: 30px;
  justify-content: center;
}

#header-image {
  display: flex;
  justify-content: center;
  grid-column: 2/3;
}

#vid1 {
  display: flex;
  justify-content: center;
}

#vid2 {
  display: flex;
  justify-content: center;
}

.navbar {
  overflow: hidden;
  background-color: #333;
  position: fixed;
  /* Set the navbar to fixed position */
  top: 0;
  /* Position the navbar at the top of the page */
  width: 100%;
  z-index: 9999999;
}

.navbar a:hover {
  background: #ddd;
  color: black;
}

.navbar a {
  float: right;
  color: #f2f2f2;
  display: block;
  text-decoration: none;
  padding: 30px 30px;
}

body {
  background-color: #c19f97;
}

#intro {
  padding-top: 50px;
  text-align: center;
}

#email-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#video {
  text-align: center;
}

#email-input {
  width: 348px;
  border-radius: 3px;
}

#email-submit {
  background-color: #7e544b;
  text-decoration: none;
  padding: 10px 20px;
  color: white;
  margin: 10px 14px;
  border-radius: 4px;
}

#email-submit:hover {
  background: #c4a49c;
  transform: scale(1.02);
}

#features-container {
  display: grid;
  grid-template-columns: 400px 400px 400px;
  grid-column-gap: 200px;
  justify-content: center;
}

#delivery-truck-container {
  display: flex;
  align-items: center;
  flex-direction: column;
  border-style: solid;
  padding: 40px;
  border-radius: 10px;
  font-style: oblique;
}

#delivery-truck-container:hover {
  background: #d6c0ba;
}

#clothes-container {
  display: flex;
  align-items: center;
  flex-direction: column;
  border-style: solid;
  padding: 40px;
  border-radius: 10px;
  font-style: oblique;
}

#clothes-container:hover {
  background: #d6c0ba
}

#credit-card-container {
  display: flex;
  align-items: center;
  flex-direction: column;
  border-style: solid;
  padding: 40px;
  border-radius: 10px;
  font-style: oblique;
}

#credit-card-container:hover {
  background: #d6c0ba;
}

#delivery-truck {
  height: 200px;
}

#clothes {
  height: 200px;
}

#credit-card {
  height: 200px;
}

.enlarge:hover {
  transform: scale(1.05);
}
<!DOCTYPE html>
<html>
<div class="navbar" id="navigationbar">
  <a href="#Features">Features</a>
  <a href="#intro">Introduction</a>
  <a href="#prices">Prices</a> <br><br><br>
</div>

<div id="main-container">

  <h1 id="header">
    <center>Company name</center>
  </h1>
  <div id="intro-container">
    <div id="vid1"><iframe id="vid1" src="https://www.youtube.com/embed/nSDgHBxUbVQ" width=300px height=300px></iframe></div>
    <div id="header-image"><img id="image1" src="https://image.shutterstock.com/image-vector/circle-business-logo-company-name-260nw-626261534.jpg" alt="company-logo"></div>
    <div id="vid2"><iframe id="vid2" src="https://www.youtube.com/embed/YdYwICNPDwI" width=300px height=300px></iframe></div><br><br>
  </div>




  <center>
    <h1>Lorem ipsum</h1>
  </center><br>
  <div id="features-container">

    <div class="enlarge" id="delivery-truck-container">
      <div id="delivery-truck-pic">
        <img class="pic" id="delivery-truck" src="https://maxcdn.icons8.com/Share/icon/ultraviolet/Ecommerce/delivery1600.png" alt="delivery-truck">
      </div>
      <div id="clothes-content">
        <center>
          <h1 class="normal">Lorem ipsum do</h1>
        </center>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
      </div>
    </div>

    <div class="enlarge" id="clothes-container">
      <div id="clothes-pic">
        <img class="pic1" id="clothes" src="https://image.flaticon.com/icons/png/512/106/106020.png" alt="clothes">

      </div>
      <div id="clothes-content">
        <center>
          <h1 class="normal">Lorem ipsum do</h1>
        </center>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
      </div>
    </div>

    <div class="enlarge" id="credit-card-container">
      <div class="pic" id="credit-card-pic">
        <img class="pic" id="credit-card" src="https://loanssos.com/wp-content/uploads/2014/07/credit-card.png" alt="credit-card">
      </div>
      <div id="credit-card-content">
        <center>
          <h1 class="normal">Lorem ipsum do</h1>
        </center>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
      </div>
    </div>
  </div>
  <br><br>
  <div id="email-container">
    <form action="https://www.freecodecamp.org/email-submit">
      <div id="email">
        <input id="email-input" type="email" placeholder="Enter your E-mail here..."></div>
      <button id="email-submit"><b>SUBMIT E-MAIL TO RECEIVE LATEST NEWS</b></button>
    </form>
  </div>

</html>
-----------------------
.normal {
  font-style: normal;
}

#intro-container {
  display: grid;
  grid-template-columns: repeat(3, 400px);
  grid-column-gap: 200px;
  margin-top: 30px;
  justify-content: center;
}

#header-image {
  display: flex;
  justify-content: center;
  grid-column: 2/3;
}

#vid1 {
  display: flex;
  justify-content: center;
}

#vid2 {
  display: flex;
  justify-content: center;
}

.navbar {
  overflow: hidden;
  background-color: #333;
  position: fixed;
  /* Set the navbar to fixed position */
  top: 0;
  /* Position the navbar at the top of the page */
  width: 100%;
  z-index: 9999999;
}

.navbar a:hover {
  background: #ddd;
  color: black;
}

.navbar a {
  float: right;
  color: #f2f2f2;
  display: block;
  text-decoration: none;
  padding: 30px 30px;
}

body {
  background-color: #c19f97;
}

#intro {
  padding-top: 50px;
  text-align: center;
}

#email-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#video {
  text-align: center;
}

#email-input {
  width: 348px;
  border-radius: 3px;
}

#email-submit {
  background-color: #7e544b;
  text-decoration: none;
  padding: 10px 20px;
  color: white;
  margin: 10px 14px;
  border-radius: 4px;
}

#email-submit:hover {
  background: #c4a49c;
  transform: scale(1.02);
}

#features-container {
  display: grid;
  grid-template-columns: 400px 400px 400px;
  grid-column-gap: 200px;
  justify-content: center;
}

#delivery-truck-container {
  display: flex;
  align-items: center;
  flex-direction: column;
  border-style: solid;
  padding: 40px;
  border-radius: 10px;
  font-style: oblique;
}

#delivery-truck-container:hover {
  background: #d6c0ba;
}

#clothes-container {
  display: flex;
  align-items: center;
  flex-direction: column;
  border-style: solid;
  padding: 40px;
  border-radius: 10px;
  font-style: oblique;
}

#clothes-container:hover {
  background: #d6c0ba
}

#credit-card-container {
  display: flex;
  align-items: center;
  flex-direction: column;
  border-style: solid;
  padding: 40px;
  border-radius: 10px;
  font-style: oblique;
}

#credit-card-container:hover {
  background: #d6c0ba;
}

#delivery-truck {
  height: 200px;
}

#clothes {
  height: 200px;
}

#credit-card {
  height: 200px;
}

.enlarge:hover {
  transform: scale(1.05);
}
<!DOCTYPE html>
<html>
<div class="navbar" id="navigationbar">
  <a href="#Features">Features</a>
  <a href="#intro">Introduction</a>
  <a href="#prices">Prices</a> <br><br><br>
</div>

<div id="main-container">

  <h1 id="header">
    <center>Company name</center>
  </h1>
  <div id="intro-container">
    <div id="vid1"><iframe id="vid1" src="https://www.youtube.com/embed/nSDgHBxUbVQ" width=300px height=300px></iframe></div>
    <div id="header-image"><img id="image1" src="https://image.shutterstock.com/image-vector/circle-business-logo-company-name-260nw-626261534.jpg" alt="company-logo"></div>
    <div id="vid2"><iframe id="vid2" src="https://www.youtube.com/embed/YdYwICNPDwI" width=300px height=300px></iframe></div><br><br>
  </div>




  <center>
    <h1>Lorem ipsum</h1>
  </center><br>
  <div id="features-container">

    <div class="enlarge" id="delivery-truck-container">
      <div id="delivery-truck-pic">
        <img class="pic" id="delivery-truck" src="https://maxcdn.icons8.com/Share/icon/ultraviolet/Ecommerce/delivery1600.png" alt="delivery-truck">
      </div>
      <div id="clothes-content">
        <center>
          <h1 class="normal">Lorem ipsum do</h1>
        </center>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
      </div>
    </div>

    <div class="enlarge" id="clothes-container">
      <div id="clothes-pic">
        <img class="pic1" id="clothes" src="https://image.flaticon.com/icons/png/512/106/106020.png" alt="clothes">

      </div>
      <div id="clothes-content">
        <center>
          <h1 class="normal">Lorem ipsum do</h1>
        </center>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
      </div>
    </div>

    <div class="enlarge" id="credit-card-container">
      <div class="pic" id="credit-card-pic">
        <img class="pic" id="credit-card" src="https://loanssos.com/wp-content/uploads/2014/07/credit-card.png" alt="credit-card">
      </div>
      <div id="credit-card-content">
        <center>
          <h1 class="normal">Lorem ipsum do</h1>
        </center>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
      </div>
    </div>
  </div>
  <br><br>
  <div id="email-container">
    <form action="https://www.freecodecamp.org/email-submit">
      <div id="email">
        <input id="email-input" type="email" placeholder="Enter your E-mail here..."></div>
      <button id="email-submit"><b>SUBMIT E-MAIL TO RECEIVE LATEST NEWS</b></button>
    </form>
  </div>

</html>

Cannot preview this file, app may have crashed -- Occurs when inputting specific line of code

copy iconCopydownload iconDownload
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        let context = (UIApplication.shared.delegate as! AppDelegate)
              .persistentContainer.viewContext
        return ContentView()
                  .environment(\.managedObjectContext, context)
    }
}

How to update ImageView contentDescription with Glide in a Widget

copy iconCopydownload iconDownload
GlideApp.with(context)
    .load("http://via.placeholder.com/300.png")
    .placeholder(R.drawable.placeholder)
    .error(R.drawable.imagenotfound)
    .listener(new RequestListener<Drawable>() {
        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
            // log exception
            Log.e("TAG", "Error loading image", e);
            return false; // important to return false so the error placeholder can be placed
        }

        @Override
        public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
            // load image success, update the contentDescription here
            return false;
        }
    })
    .into(ivImg);
-----------------------
data class UltravioletImageContents(@DrawableRes val drawableId: Int, val contentDescription: String)
@JvmStatic
private fun updateWidgetViews(context: Context, appWidgetId: Int, ultravioletImageContents: UltravioletImageContents) {
    val widgetView = RemoteViews(context.packageName, R.layout.ultraviolet_widget)

    // Set an Intent to launch MainActivity when clicking on the widget
    val intent = Intent(context, MainActivity::class.java)
    val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
    widgetView.setOnClickPendingIntent(R.id.rl_ultraviolet_widget_layout, pendingIntent)

    // Set image
    val appWidgetTarget = AppWidgetTarget(context, R.id.iv_ultraviolet_widget_image, widgetView, appWidgetId)
    Glide
        .with(context)
        .asBitmap() // This is needed because AppWidgetTarget is a Bitmap target. See: https://github.com/bumptech/glide/issues/2717#issuecomment-351791721
        .transition(BitmapTransitionOptions.withCrossFade())
        .load(ultravioletImageContents.drawableId)
        .listener(object : RequestListener<Bitmap> {
            override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target<Bitmap>?, isFirstResource: Boolean): Boolean {
                Timber.e(e, "Drawable cannot be loaded and set in widget image view")
                return false // Important to return false so the error placeholder can be placed
            }

            override fun onResourceReady(resource: Bitmap?, model: Any?, target: com.bumptech.glide.request.target.Target<Bitmap>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
                // Set contentDescription in order to enable accessibility and be usable with TalkBack
                widgetView.setContentDescription(R.id.iv_ultraviolet_widget_image, ultravioletImageContents.contentDescription)

                pushWidgetUpdate(context, appWidgetId, widgetView)

                return false
            }
        })
        .into(appWidgetTarget)
}
-----------------------
data class UltravioletImageContents(@DrawableRes val drawableId: Int, val contentDescription: String)
@JvmStatic
private fun updateWidgetViews(context: Context, appWidgetId: Int, ultravioletImageContents: UltravioletImageContents) {
    val widgetView = RemoteViews(context.packageName, R.layout.ultraviolet_widget)

    // Set an Intent to launch MainActivity when clicking on the widget
    val intent = Intent(context, MainActivity::class.java)
    val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
    widgetView.setOnClickPendingIntent(R.id.rl_ultraviolet_widget_layout, pendingIntent)

    // Set image
    val appWidgetTarget = AppWidgetTarget(context, R.id.iv_ultraviolet_widget_image, widgetView, appWidgetId)
    Glide
        .with(context)
        .asBitmap() // This is needed because AppWidgetTarget is a Bitmap target. See: https://github.com/bumptech/glide/issues/2717#issuecomment-351791721
        .transition(BitmapTransitionOptions.withCrossFade())
        .load(ultravioletImageContents.drawableId)
        .listener(object : RequestListener<Bitmap> {
            override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target<Bitmap>?, isFirstResource: Boolean): Boolean {
                Timber.e(e, "Drawable cannot be loaded and set in widget image view")
                return false // Important to return false so the error placeholder can be placed
            }

            override fun onResourceReady(resource: Bitmap?, model: Any?, target: com.bumptech.glide.request.target.Target<Bitmap>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
                // Set contentDescription in order to enable accessibility and be usable with TalkBack
                widgetView.setContentDescription(R.id.iv_ultraviolet_widget_image, ultravioletImageContents.contentDescription)

                pushWidgetUpdate(context, appWidgetId, widgetView)

                return false
            }
        })
        .into(appWidgetTarget)
}

Xcode preview crashes on DB loop read SwiftUI

copy iconCopydownload iconDownload
struct HomeItemListView_Previews: PreviewProvider {
    static var previews: some View {
        let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

        return HomeItemListView()
                .environment(\.managedObjectContext, context)
                .environmentObject(ViewRouter())
    }
}

How to avoid a bug in DBpedia Spotlight in python?

copy iconCopydownload iconDownload
r = requests.get(url=REQUEST, headers=HEADERS)

if r.status_code == requests.codes['ok']:
    .
    .
    .

resources = response['Resources']
resources = response.get('Resources', [])
import json
from SPARQLWrapper import SPARQLWrapper, JSON
import requests
import urllib.parse
import re

all_urls = []
## initial consts
BASE_URL = 'http://api.dbpedia-spotlight.org/en/annotate?text={text}&confidence={confidence}&support={support}'

i=0

lines_seen = set() # holds lines already seen
for TEXT in open("datos_01_noduplicado1.csv","r",encoding='utf-8'):
    i=i+1
    print("El número de la línea es : " + str(i))
    CONFIDENCE = '0.5'
    SUPPORT = '10'
    REQUEST = BASE_URL.format(
        text=urllib.parse.quote_plus(TEXT), 
        confidence=CONFIDENCE, 
        support=SUPPORT
    )
    HEADERS = {'Accept': 'application/json'}
    sparql = SPARQLWrapper("http://dbpedia.org/sparql")

    r = requests.get(url=REQUEST, headers=HEADERS)
    if r.status_code == requests.codes['ok']:
        response = r.json()
        resources = response.get('Resources', [])
        for res in resources:
            all_urls.append(res['@URI'])

        print(all_urls)
-----------------------
r = requests.get(url=REQUEST, headers=HEADERS)

if r.status_code == requests.codes['ok']:
    .
    .
    .

resources = response['Resources']
resources = response.get('Resources', [])
import json
from SPARQLWrapper import SPARQLWrapper, JSON
import requests
import urllib.parse
import re

all_urls = []
## initial consts
BASE_URL = 'http://api.dbpedia-spotlight.org/en/annotate?text={text}&confidence={confidence}&support={support}'

i=0

lines_seen = set() # holds lines already seen
for TEXT in open("datos_01_noduplicado1.csv","r",encoding='utf-8'):
    i=i+1
    print("El número de la línea es : " + str(i))
    CONFIDENCE = '0.5'
    SUPPORT = '10'
    REQUEST = BASE_URL.format(
        text=urllib.parse.quote_plus(TEXT), 
        confidence=CONFIDENCE, 
        support=SUPPORT
    )
    HEADERS = {'Accept': 'application/json'}
    sparql = SPARQLWrapper("http://dbpedia.org/sparql")

    r = requests.get(url=REQUEST, headers=HEADERS)
    if r.status_code == requests.codes['ok']:
        response = r.json()
        resources = response.get('Resources', [])
        for res in resources:
            all_urls.append(res['@URI'])

        print(all_urls)
-----------------------
r = requests.get(url=REQUEST, headers=HEADERS)

if r.status_code == requests.codes['ok']:
    .
    .
    .

resources = response['Resources']
resources = response.get('Resources', [])
import json
from SPARQLWrapper import SPARQLWrapper, JSON
import requests
import urllib.parse
import re

all_urls = []
## initial consts
BASE_URL = 'http://api.dbpedia-spotlight.org/en/annotate?text={text}&confidence={confidence}&support={support}'

i=0

lines_seen = set() # holds lines already seen
for TEXT in open("datos_01_noduplicado1.csv","r",encoding='utf-8'):
    i=i+1
    print("El número de la línea es : " + str(i))
    CONFIDENCE = '0.5'
    SUPPORT = '10'
    REQUEST = BASE_URL.format(
        text=urllib.parse.quote_plus(TEXT), 
        confidence=CONFIDENCE, 
        support=SUPPORT
    )
    HEADERS = {'Accept': 'application/json'}
    sparql = SPARQLWrapper("http://dbpedia.org/sparql")

    r = requests.get(url=REQUEST, headers=HEADERS)
    if r.status_code == requests.codes['ok']:
        response = r.json()
        resources = response.get('Resources', [])
        for res in resources:
            all_urls.append(res['@URI'])

        print(all_urls)
-----------------------
r = requests.get(url=REQUEST, headers=HEADERS)

if r.status_code == requests.codes['ok']:
    .
    .
    .

resources = response['Resources']
resources = response.get('Resources', [])
import json
from SPARQLWrapper import SPARQLWrapper, JSON
import requests
import urllib.parse
import re

all_urls = []
## initial consts
BASE_URL = 'http://api.dbpedia-spotlight.org/en/annotate?text={text}&confidence={confidence}&support={support}'

i=0

lines_seen = set() # holds lines already seen
for TEXT in open("datos_01_noduplicado1.csv","r",encoding='utf-8'):
    i=i+1
    print("El número de la línea es : " + str(i))
    CONFIDENCE = '0.5'
    SUPPORT = '10'
    REQUEST = BASE_URL.format(
        text=urllib.parse.quote_plus(TEXT), 
        confidence=CONFIDENCE, 
        support=SUPPORT
    )
    HEADERS = {'Accept': 'application/json'}
    sparql = SPARQLWrapper("http://dbpedia.org/sparql")

    r = requests.get(url=REQUEST, headers=HEADERS)
    if r.status_code == requests.codes['ok']:
        response = r.json()
        resources = response.get('Resources', [])
        for res in resources:
            all_urls.append(res['@URI'])

        print(all_urls)

Trying to generate a list from a JSON object (TypeError list indices must be integers or slices, not str)

copy iconCopydownload iconDownload
for doc in (articles['response']['docs']):
    print(doc['headline']['print_headline'])

how to insert data into arrayList from method like a global variable

copy iconCopydownload iconDownload
export class Test implements OnInit {
    result_arr = [];

    ngOnInit() {
         this.get_All_Col_data(myfrugalmap, Marker_array)
    }

    get_All_Col_data(map, markers){
        const myIcon_Col = L.icon({
            iconUrl: 'https://img.icons8.com/ultraviolet/40/000000/collect.png'
        });
        const myIcon_vente = L.icon({
        iconUrl: 'https://img.icons8.com/color/50/000000/low-price-euro.png'
        });
        this.CollectionService.getallCollections().subscribe((data: Collection_info[])                                 
         =>{
             this.Collection_info = data;
             for(var i =0; i<this.Collection_info.length;i++){
               console.log("name :" + this.Collection_info[i].emailcol);
               console.log("type :" + this.Collection_info[i].type);
               if(this.Collection_info[i].type==='collection'){
                   var m = L.marker([Number(this.Collection_info[i].lat_col), 
                   Number(this.Collection_info[i].long_col)], {icon: myIcon_Col}).addTo(map);
                   m.bindPopup("Collection pt " + this.Collection_info[i].nom_col);
                   markers.push(m);
                  this.result_arr.push(this.Collection_info[i]);
               }else{
                   var m = L.marker([Number(this.Collection_info[i].lat_col), 
                   Number(this.Collection_info[i].long_col)], {icon: myIcon_vente}).addTo(map);
                   m.bindPopup("Collection vente " + this.Collection_info[i].nom_col);
                   this.result_arr.push(this.Collection_info[i]);
                   markers.push(m);
              }
          }
       console.log(this.result_arr)
       });
}

Community Discussions

Trending Discussions on ultraviolet
  • How do you use a random element from an array, remove that element from the array, and keep using random elements until the array is empty?
  • Why is my padding right and bottom only changing but not my top and left?
  • cant deserialize json string c#
  • How do I prevent transform hover from overlapping with navigation bar?
  • Cannot preview this file, app may have crashed -- Occurs when inputting specific line of code
  • How to update ImageView contentDescription with Glide in a Widget
  • Xcode preview crashes on DB loop read SwiftUI
  • How to avoid a bug in DBpedia Spotlight in python?
  • Error when using Canvas to preview SwiftUI view
  • Trying to generate a list from a JSON object (TypeError list indices must be integers or slices, not str)
Trending Discussions on ultraviolet

QUESTION

How do you use a random element from an array, remove that element from the array, and keep using random elements until the array is empty?

Asked 2022-Jan-12 at 01:03

This is my first stack overflow question, so if I am presenting something wrong, please let me know. I am pretty new to computer programming, so I just have a small webpage where I am just implementing things that I am learning.

I made a little quiz with random trivia multiple choice questions you can take if you press a button. I am using window prompts to ask the questions and get the answers, and I have all of the questions and answers stored as objects with question/prompt and answer pairs. All of those objects are stored in an array in a variable called shortQuizPrompts. I already have the quiz working and everything, aka., It tells you after every question if you got the answer to that question right or wrong, and it gives you a grade afterwards... I also have it set up so that if you enter an answer that is not "a", "b", "c", or "d", it lets you know that it isnt a valid answer. Those sorts of things.

As of right now, you can choose how many questions long you want the quiz to be out of the 24 total questions I have so far. It just asks the questions in the order that they are stored in the array. For example, you will never be asked the last question in the array if you do not choose for the quiz to be the full 24 questions long. However, I want to make the quiz ask the questions in a random order, while also removing those questions from the array as to not ask the same question multiple times.

I have tried increasing the iterator while looping through the array to a random number from 0 to the length of however many questions they chose. Then checking to see if the iterator was larger than the length of the number of questions they chose, it would decrease the iterator until it found a question that is still in the array that it could ask...

If anyone knows how to go about doing that, it would be great. Sorry for the long question btw. I am pretty new to coding, so this is probably a simple answer, but I digress. I'm pretty sure I did everything right. Thx.

const quizButton = document.getElementById("quiz-button");

/*  =========================
    Question and answer pairs
    =========================
*/
let shortQuizPrompts = 
   [{prompt: "10 + 10\n(a) 10\n(b) 15\n(c) 20\n(d) 25", answer: "c"},
    {prompt: "What status did astronomers downgrade Pluto to in 2006?\n(a) Dwarf Planet\n(b) White Dwarf\n(c) Black Dwarf\n(d) Dwarf Star", answer: "a"},
    {prompt: 'What tart fruit has a sweet variety called "Meyer"?\n(a) lime\n(b) lemon\n(c) grapefruit\n(d) dragonfruit', answer: "c"},
    {prompt: `What bird lays its eggs in other birds' nests?\n(a) Blue Jay\n(b) Robin\n(c) Eagle\n (d) Cuckoo`, answer: "d"},
    {prompt: `What is a female goat called?\n(a) a foe\n(b) a larp\n(c) a nanny\n(d) a maur`, answer:"c"},
    {prompt: `What is Eisoptrophobia? \n(a) the fear of mirrors\n(b) the fear of cold temperatures\n(c) the fear of farm animals\n(d) the fear of viruses`, answer: `a`},
    {prompt: `Which element of the periodic table is named after the sun?\n(a) slinerium\n(b) helium\n(c) magnesium\n(d) uranium`, answer: `b`},
    {prompt: `What color is the octopus blood?\n(a) pink\n(b) light green\n(c) violet\n(d) light blue`, answer: `d`},
    {prompt: `What value does the Roman numeral C represent?\n(a) 20\n(b) 50\n(c) 100\n(d) 200`, answer: `c`},
    {prompt: `What is measured in fathoms?\n(a) depth of water \n(b) sound \n(c) pressure \n(d) light`, answer: `a`},
    {prompt: `What is Chiroptophobia?\n(a) fear of plants \n(b) fear of insects\n(c) fear of chirogenics \n(d) fear of bats`, answer: `d`},
    {prompt: `What is the longest and heaviest bone in the human body?\n(a) tibia\n(b) skull\n(c) femur\n(d) humorous`, answer: `c`},
    {prompt: `What are the two major elements making up the sun?\n(a) hydrogen and helium\n(b) nitrogen and hydrogen\n(c) oxygen and nitrogen\n(d) oxygen and hydrogen`, answer: `a`},
    {prompt: `What is poliosis?\n(a) a disease impacting your balance\n(b) graying of hair\n(c) loss of hair\n(d) high potassium pressence in blood`, answer: `b`},
    {prompt: `When held to ultraviolet light, what animal’s urine glows in the dark?\n(a) lemur\n(b) cat\n(c) dog\n(d) lamb`, answer: ``},
    {prompt: `What year did the "ILOVEYOU" virus began infecting computers worldwide?\n(a) 2000\n(b) 2001\n(c) 2002\n(d) 2004`, answer: `a`},
    {prompt: `What planet's four largest moons are collectively known as the Galilean Moons?\n(a) neptune\n(b) jupiter\n(c) saturn\n(d) uranus`, answer: `b`},
    {prompt: `What North American mammal is also known as the prairie wolf or brush wolf?\n(a) brown bears\n(b) ocelots\n(c) coyotes\n(d) hyenas`, answer: `c`},
    {prompt: `How often are brain cells replaced?\n(a) once every few hours\n(b) once every few days\n(c) once every few weeks\n(d) never`, answer: `d`},
    {prompt: `What physical property of a diamond do carats measure?\n(a) mass\n(b) purity \n(c) color quality\n(d) mineral composition`, answer: `a`},
    {prompt: `Nosocomephobia is the fear of what?\n(a) night time\n(b) very large objects\n(c) hospitals\n(d) loud noises`, answer: `c`},
    {prompt: `In what year did the Soviet Union launch its first Sputnik satellite?\n(a) 1049\n(b) 1957\n(c) 1963\n(d)1972`, answer: `b`},
    {prompt: `What is measured in Ergs?\n(a) Work\n(b) mass\n(c) depth\n(d) emotion`, answer: `a`},
    {prompt: `What does a Scoville unit measure?\n(a) sourness\n(b) pain\n(c) spiciness\n(d) taste`, answer: `c`},];
    
    
    
    
    /*  ======================
        initiation of the quiz
        ======================
    */
   
        quizButton.onclick = () => {
        let correct = 0;
        const amountOfQuestions = prompt(`How many questions do you want? There are ${shortQuizPrompts.length} maximum`);
        alert('You are about to start the quiz. \nFor each question, enter either "a", "b", "c", or "d". \nPress enter to continue');
        for(i = 0; i< amountOfQuestions; i++) {
           const answer = prompt(shortQuizPrompts[i].prompt);
            if(answer === shortQuizPrompts[i].answer && answer !== null && answer !== undefined) {
                alert("Correct");
                correct++;
            } else if (answer !== shortQuizPrompts[i].answer && answer !==null && answer !== undefined && answer.length >= 1 && (answer === "a" || answer === "b" || answer === "c" || answer === "d")) {
                alert("Incorrect");
            } else if (answer === null) {
                alert(`Bruh, why'd you start the quiz if you didnt want to answer the questions lol`);
            } else if (answer.length == 0) {
                setInterval(alert("Trying to skip questions, I see?? Yeah, you thought you weren't gonna get caught, huh? Well think again")), 100;
            }
            console.log(answer)
            if(i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) <= 33) {
                alert(`Wow, you're bad! You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions correct!`);
        
            }
    
            if(i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) > 33 && (Math.floor(correct / amountOfQuestions * 100)) <= 66) {
                alert(`You did ok. You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions right!`);
        
            }
    
            if(i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) > 66 ) {
                alert(`Congratulations! 🎉 You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions right!`);
            }
            if(answer !== "a" && answer !== "b" && answer!== "c" && answer !== "d" && answer.length > 0 && answer !== null && answer !== undefined) {
                alert(`What are you doing? I told you to only enter "a", "b", "c", or "d" as answers`);
            }
        }
    
    }
* {
    box-sizing: border-box;
}

button {
    cursor: pointer;
}

#quiz-text {
    position: relative;
    left: 42vw;
    top: 25vh;
    transform: translateX(-2%) translateY(5%);
    font-size: 1.5rem;

}

#quiz-button {
    position: relative;
    left: 45vw;
    top: 25vh;
    transform: translateX(-2%) translateY(5%);
    font-size: 20px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="game.css">
    <script src="D:/Coding/yt games/game.js" defer></script>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Random Stuff </title>
</head>
<body id="body">
    <p id="quiz-text">Want to take a short quiz?</p>
    <button id="quiz-button"> START</button>
    
</body>
</html>

ANSWER

Answered 2022-Jan-12 at 01:03

You can shuffle the shortQuizPrompts array before starting the quiz. Array shuffle details can be found in this answer.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Random Quiz</title>
    <style>
        * {
            box-sizing: border-box;
        }

        button {
            cursor: pointer;
        }

        #quiz-text {
            position: relative;
            left: 42vw;
            top: 25vh;
            transform: translateX(-2%) translateY(5%);
            font-size: 1.5rem;

        }

        #quiz-button {
            position: relative;
            left: 45vw;
            top: 25vh;
            transform: translateX(-2%) translateY(5%);
            font-size: 20px;
        }
    </style>
</head>
<body id="body">
<p id="quiz-text">Want to take a short quiz?</p>
<button id="quiz-button"> START</button>

<script>

    function shuffle(array) {
        let currentIndex = array.length, randomIndex;

        // While there remain elements to shuffle...
        while (currentIndex != 0) {

            // Pick a remaining element...
            randomIndex = Math.floor(Math.random() * currentIndex);
            currentIndex--;

            // And swap it with the current element.
            [array[currentIndex], array[randomIndex]] = [
                array[randomIndex], array[currentIndex]];
        }

        return array;
    }

    const quizButton = document.getElementById("quiz-button");

    /*  =========================
        Question and answer pairs
        =========================
    */
    let shortQuizPrompts =
        [{prompt: "10 + 10\n(a) 10\n(b) 15\n(c) 20\n(d) 25", answer: "c"},
            {
                prompt: "What status did astronomers downgrade Pluto to in 2006?\n(a) Dwarf Planet\n(b) White Dwarf\n(c) Black Dwarf\n(d) Dwarf Star",
                answer: "a"
            },
            {
                prompt: 'What tart fruit has a sweet variety called "Meyer"?\n(a) lime\n(b) lemon\n(c) grapefruit\n(d) dragonfruit',
                answer: "c"
            },
            {
                prompt: `What bird lays its eggs in other birds' nests?\n(a) Blue Jay\n(b) Robin\n(c) Eagle\n (d) Cuckoo`,
                answer: "d"
            },
            {
                prompt: `What is a female goat called?\n(a) a foe\n(b) a larp\n(c) a nanny\n(d) a maur`,
                answer: "c"
            },
            {
                prompt: `What is Eisoptrophobia? \n(a) the fear of mirrors\n(b) the fear of cold temperatures\n(c) the fear of farm animals\n(d) the fear of viruses`,
                answer: `a`
            },
            {
                prompt: `Which element of the periodic table is named after the sun?\n(a) slinerium\n(b) helium\n(c) magnesium\n(d) uranium`,
                answer: `b`
            },
            {
                prompt: `What color is the octopus blood?\n(a) pink\n(b) light green\n(c) violet\n(d) light blue`,
                answer: `d`
            },
            {
                prompt: `What value does the Roman numeral C represent?\n(a) 20\n(b) 50\n(c) 100\n(d) 200`,
                answer: `c`
            },
            {
                prompt: `What is measured in fathoms?\n(a) depth of water \n(b) sound \n(c) pressure \n(d) light`,
                answer: `a`
            },
            {
                prompt: `What is Chiroptophobia?\n(a) fear of plants \n(b) fear of insects\n(c) fear of chirogenics \n(d) fear of bats`,
                answer: `d`
            },
            {
                prompt: `What is the longest and heaviest bone in the human body?\n(a) tibia\n(b) skull\n(c) femur\n(d) humorous`,
                answer: `c`
            },
            {
                prompt: `What are the two major elements making up the sun?\n(a) hydrogen and helium\n(b) nitrogen and hydrogen\n(c) oxygen and nitrogen\n(d) oxygen and hydrogen`,
                answer: `a`
            },
            {
                prompt: `What is poliosis?\n(a) a disease impacting your balance\n(b) graying of hair\n(c) loss of hair\n(d) high potassium pressence in blood`,
                answer: `b`
            },
            {
                prompt: `When held to ultraviolet light, what animal’s urine glows in the dark?\n(a) lemur\n(b) cat\n(c) dog\n(d) lamb`,
                answer: ``
            },
            {
                prompt: `What year did the "ILOVEYOU" virus began infecting computers worldwide?\n(a) 2000\n(b) 2001\n(c) 2002\n(d) 2004`,
                answer: `a`
            },
            {
                prompt: `What planet's four largest moons are collectively known as the Galilean Moons?\n(a) neptune\n(b) jupiter\n(c) saturn\n(d) uranus`,
                answer: `b`
            },
            {
                prompt: `What North American mammal is also known as the prairie wolf or brush wolf?\n(a) brown bears\n(b) ocelots\n(c) coyotes\n(d) hyenas`,
                answer: `c`
            },
            {
                prompt: `How often are brain cells replaced?\n(a) once every few hours\n(b) once every few days\n(c) once every few weeks\n(d) never`,
                answer: `d`
            },
            {
                prompt: `What physical property of a diamond do carats measure?\n(a) mass\n(b) purity \n(c) color quality\n(d) mineral composition`,
                answer: `a`
            },
            {
                prompt: `Nosocomephobia is the fear of what?\n(a) night time\n(b) very large objects\n(c) hospitals\n(d) loud noises`,
                answer: `c`
            },
            {
                prompt: `In what year did the Soviet Union launch its first Sputnik satellite?\n(a) 1049\n(b) 1957\n(c) 1963\n(d)1972`,
                answer: `b`
            },
            {
                prompt: `What is measured in Ergs?\n(a) Work\n(b) mass\n(c) depth\n(d) emotion`,
                answer: `a`
            },
            {
                prompt: `What does a Scoville unit measure?\n(a) sourness\n(b) pain\n(c) spiciness\n(d) taste`,
                answer: `c`
            },];


    /*  ======================
        initiation of the quiz
        ======================
    */

    quizButton.onclick = () => {
        let correct = 0;
        const amountOfQuestions = prompt(`How many questions do you want? There are ${shortQuizPrompts.length} maximum`);
        alert('You are about to start the quiz. \nFor each question, enter either "a", "b", "c", or "d". \nPress enter to continue');
        shuffle(shortQuizPrompts);
        for (i = 0; i < amountOfQuestions; i++) {
            const answer = prompt(shortQuizPrompts[i].prompt);
            if (answer === shortQuizPrompts[i].answer && answer !== null && answer !== undefined) {
                alert("Correct");
                correct++;
            } else if (answer !== shortQuizPrompts[i].answer && answer !== null && answer !== undefined && answer.length >= 1 && (answer === "a" || answer === "b" || answer === "c" || answer === "d")) {
                alert("Incorrect");
            } else if (answer === null) {
                alert(`Bruh, why'd you start the quiz if you didnt want to answer the questions lol`);
            } else if (answer.length == 0) {
                setInterval(alert("Trying to skip questions, I see?? Yeah, you thought you weren't gonna get caught, huh? Well think again")), 100;
            }
            console.log(answer)
            if (i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) <= 33) {
                alert(`Wow, you're bad! You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions correct!`);

            }

            if (i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) > 33 && (Math.floor(correct / amountOfQuestions * 100)) <= 66) {
                alert(`You did ok. You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions right!`);

            }

            if (i === amountOfQuestions - 1 && (Math.floor(correct / amountOfQuestions * 100)) > 66) {
                alert(`Congratulations! 🎉 You made a ${Math.floor((correct / amountOfQuestions) * 100).toFixed(2)}% getting ${correct} out of ${amountOfQuestions} questions right!`);
            }
            if (answer !== "a" && answer !== "b" && answer !== "c" && answer !== "d" && answer.length > 0 && answer !== null && answer !== undefined) {
                alert(`What are you doing? I told you to only enter "a", "b", "c", or "d" as answers`);
            }
        }

    }
</script>
</body>
</html>

Source https://stackoverflow.com/questions/70675105

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install ultraviolet

If you don’t want to build Ultraviolet yourself, official packages are available through [NuGet](https://www.nuget.org/packages?q=ultraviolet). The wiki contains a [quick start guide](https://github.com/tlgkccampbell/ultraviolet/wiki/Getting-Started-with-.NET-Core-3.1) for development using .NET Core 3.1. A [dedicated repository](https://github.com/tlgkccampbell/ultraviolet-samples) contains a number of sample projects which demonstrate various features of the Framework.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with ultraviolet
Compare Game Engine Libraries with Highest Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.