Request is not well-formed, syntactically incorrect, or violates schema

I have this error:

Request is not well-formed, syntactically incorrect, or violates schema.

This is my request:

I was looking to make payments with Credit or Debit Cards with Paypal (not with any other), but without having to log in and use the function to make the payment.

 if ($transaction['payment_provider'] == 'card') {    
                // Validar que los datos de la tarjeta están presentes
                $cardName = $request->get('card-name');
                $cardNumber = $request->get('card-number');
                $cardExpiry = $request->get('card-expiry');
                $cardCVV = $request->get('card-cvv');
    
                if (!$cardName || !$cardNumber || !$cardExpiry || !$cardCVV) {
                    return $this->paymentHandler->redirectByTransaction($transaction, __('Missing card details'));
                }
    
                // Formatear fecha de vencimiento para pasarela de pago (ejemplo: MM/AA → MMYY)
                $cardExpiryFormatted = str_replace('/', '', $cardExpiry);
    
                // Simulación de procesamiento de pago con tarjeta (AQUÍ IRÍA LA INTEGRACIÓN REAL)
                $paymentResponse = $this->processCardPayment([
                    'amount' => $transaction['amount'],
                    'currency' => $transaction['currency'],
                    'card_name' => $cardName,
                    'card_number' => $cardNumber,
                    'card_expiry' => $cardExpiryFormatted,
                    'card_cvv' => $cardCVV
                ]);
    
                if ($paymentResponse['status'] == 'success') {
                    $transaction['status'] = Transaction::APPROVED_STATUS;
                } else {
                    $transaction['status'] = Transaction::DECLINED_STATUS;
                    return $this->paymentHandler->redirectByTransaction($transaction, __('Payment declined: ') . $paymentResponse['message']);
                }
    
                // $transaction->save();
                // return Redirect::route('feed')->with('success', __('Payment successful!'));
            }
private function processCardPayment($cardData)
    {
        // Configurar credenciales desde config/paypal.php
        $clientId = config('paypal.client_id');
        $clientSecret = config('paypal.secret');
        $paypalUrl = config('paypal.test_mode') 
            ? 'https://api-m.sandbox.paypal.com' 
            : 'https://api-m.paypal.com';

        Log::info("aaaa");
        try {
            // 1️⃣ Obtener el token de acceso de PayPal
            $client = new GuzzleHttpClient();
            $authResponse = $client->request('POST', "$paypalUrl/v1/oauth2/token", [
                'auth' => [$clientId, $clientSecret],
                'form_params' => [
                    'grant_type' => 'client_credentials'
                ]
            ]);
            Log::info("bbbb");


            $authData = json_decode($authResponse->getBody(), true);
            $accessToken = $authData['access_token'];
            Log::info("cccc");

            // 2️⃣ Crear una orden en PayPal con pago con tarjeta
            $response = $client->request('POST', "$paypalUrl/v2/checkout/orders", [
                'headers' => [
                    'Authorization'     => "Bearer $accessToken",
                    'Content-Type'      => 'application/json',
                    'PayPal-Request-Id' => (string) IlluminateSupportStr::uuid() // ID único
                ],
                'json' => [
                    'intent'          => 'CAPTURE',
                    'purchase_units'  => [[
                        'amount' => [
                            'currency_code' => $cardData['currency'],
                            'value'         => $cardData['amount']
                        ]
                    ]],
                    'payment_source' => [
                        'card' => [
                            'number'        => $cardData['card_number'],
                            'expiry'        => $cardData['card_expiry'],
                            'security_code' => $cardData['card_cvv'],
                            'name'          => $cardData['card_name'],
                            'billing_address' => [
                                'address_line_1' => '123 Fake Street',
                                'admin_area_2'   => 'Fake City',
                                'admin_area_1'   => 'Fake State',
                                'postal_code'    => '12345',
                                'country_code'   => 'US'
                            ]
                        ]
                    ]
                ]
            ]);

            Log::info("eeeee");


            $order = json_decode($response->getBody(), true);
            Log::info("ffff");


            if (!isset($order['id'])) {
                return [
                    'status'  => 'failed',
                    'message' => 'Error al crear la orden en PayPal'
                ];
            }

            // 3️⃣ Capturar el pago con tarjeta
            $orderId = $order['id'];
            $captureResponse = $client->request('POST', "$paypalUrl/v2/checkout/orders/$orderId/capture", [
                'headers' => [
                    'Authorization' => "Bearer $accessToken",
                    'Content-Type'  => 'application/json'
                ]
            ]);

            $captureData = json_decode($captureResponse->getBody(), true);

            if (isset($captureData['status']) && $captureData['status'] === 'COMPLETED') {
                return [
                    'status'          => 'success',
                    'transaction_id'  => $captureData['id'],
                    'message'         => 'Pago aprobado'
                ];
            }

            return [
                'status'  => 'failed',
                'message' => 'Pago no completado'
            ];

        } catch (Exception $e) {
            return [
                'status'  => 'failed',
                'message' => $e->getMessage()
            ];
        }
    }

The blogs are because I was checking, how should it be structured to be able to work?

How to structure the json to send a request to Paypal?

How do i submit a code snippet when the only way create a minimum reproducible example is by posting well over the 30,000 character limit? [migrated]

I am trying to resolve a problem with the responsive design of my website. However, when I try to paste in the code to create a minimum reproducible example, the only way the problem can be reproduced is by posting a lot of code – way over the 30,000 character limit.

What do people do in this situation?

tabulator edit color of text from frontend pov

I’m working on a project right now with my company using django and I have been working with tabulator recently to get a table up and running so our clients can stay on our website as much as possible, instead of resorting to excel. they didn’t need many complex features so they just edit and save data to the db. it was alright until just the other day when they requested the ability to color their text. I assumed this wouldn’t be an issue but for me it has been. I can’t seem to find a way to import jscolor or coloris etc into tabulator to get this to work. i’m thinking of converting my code and using a completely different library so long as it has that feature (as well as allowing front end updates), but I would need it to be free. does anyone know of any good libraries OR a solution to adding a color picker of some sort to tabulator. thanks

How do i get rid of trails?

Im working on a simple program where the ball needs to bounce down the hill. When I run the program, the ball bounces, but leaves each frame behind. Ive tried a few clear(); functions but nothing seems to work.
Ive done similar projects with sprites bouncing or rolling, and they’ve never had this problem. Ill try and show my whole program.

let coordinates;

 function setup() {
    new Canvas(400,400);
    allSprites.pixelPerfect = false;

    background('#434275');
    //reminder: add camera.x = .x; when ready for sprite
    world.gravity.y=9;
    mouseCoordinates();
    
    let floor = new Sprite();
    floor.width=800;
    floor.height=400;
    floor.y=370;
    floor.x=0;
    floor.collider='static';
    floor.color='#d17921';
    floor.rotation = 20;
    
    
    let boulder = new Sprite();
    boulder.diameter= 20;
    boulder.bounciness= 1;
    boulder.mass= 9;
    boulder.x=0;
    boulder.y=100;
    boulder.speed=2;
    boulder.rotationDrag= 5;
    boulder.color='#e39427';
}

function draw(){
    coordinates.text = round(mouse.x, 1) + ', ' + round(mouse.y, 1);
    
}
function mouseCoordinates() {
    coordinates = new Sprite();
    coordinates.color = 'white';
    coordinates.width = 80;
    coordinates.height = 20;
    coordinates.x = width - coordinates.width / 2 - 5;
    coordinates.y = coordinates.height / 2 + 5;
    coordinates.collider = 'none';
}

visual of the problem

Again, I’d like it to just be the ball. if it were to run properly, you’d just see the orange box and blue background because the ball would roll away.

Error when issuing NF with Ginfes and Soap

❌ Erro ao enviar NFS-e: <env:Envelope xmlns:env=’http://schemas.xmlsoap.org/soap/envelope/’>env:Header</env:Header>env:Body<env:Fault xmlns:env=’http://schemas.xmlsoap.org/soap/envelope/’>env:ClientEndpoint {http://homologacao.ginfes.com.br}ServiceGinfesImplPort does not contain operation meta data for: {http://www.ginfes.com.br/}RecepcionarLoteRpsRequest</env:Fault></env:Body></env:Envelope>

Tentei emitir a nf com o xml assinado e está me retornando esse erro

I had a color error in my project – react and google sheets

I created an online form with React and hosted it on Vercel… I need the data submitted in the form to fall into the spreadsheet in the sheets.
But it gives this error

Access to fetch at link do site ” from origin has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

My script in google sheets is this:

function doPost(e) {
  var headers = {
    "Access-Control-Allow-Origin": "*", 
    "Access-Control-Allow-Methods": "POST", 
    "Access-Control-Allow-Headers": "Content-Type", 
  };

  
  if (e.postData.contents) {
    var data = JSON.parse(e.postData.contents); 

    
    var sheet = SpreadsheetApp.openById('id da planilha').getSheetByName('Página1');

    
    var nome = data.nome || '';  
    var email = data.email || '';  
    var mensagem = data.mensagem || ''; 

    
    sheet.appendRow([nome, email, mensagem]); 
    return ContentService.createTextOutput("Dados recebidos com sucesso!")
      .setMimeType(ContentService.MimeType.JSON)
      .setHeaders(headers);
  } else {
    
    return ContentService.createTextOutput("Erro ao receber os dados.")
      .setMimeType(ContentService.MimeType.JSON)
      .setHeaders(headers);
  }
}

I used to fetch:

try {
        const response = await fetch("https://script.google.com/macros/s/AKfycbyMJPsRU2ECQlWlzavlbDk_m1lMOd4N1PaqsBxGo47JjgZfDIBCD0Kq7RLKb7xOQ3QJ/exec", {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify(formData),
        });
      
        
        if (response.ok) {
          const data = await response.json();
          console.log("Resposta da API:", data);
          alert("Dados enviados com sucesso!");
        } else {
          
          const errorData = await response.json();
          console.error("Erro na resposta:", errorData);
          alert("Erro ao enviar os dados: " + (errorData.message || "Erro desconhecido"));
        }
      } catch (error) {
        
        console.error("Erro ao enviar os dados:", error);
        alert("Ocorreu um erro ao enviar os dados.");
      }

    }
  }

I’ve already tried several aspects of the script, but still without success.
I’m starting to think there’s no way.

Use of ajax to modify a JavaScript file as opposed to the DOM

Say a website has a file structure such as:

/index.html
/js/main.js
/js/module.js

Is it possible for the JavaScript code in js/main.js to modify the contents of the /js/module.js file in response to user input?

The reason I am wondering about this is because I thought that while the user is online they could take various actions which would result in js/module.js being altered. Then they could install the website (as a PWA) onto their device for use offline and be able to use the personalized version of the website created by the modifications to js/module.js. I am wondering if this approach is viable.

making a ligth behind text with phaser

please i would like to add light behind text using phaser js like in this image (its the purple light) purple light behid a text

i’ve tried to use these functions

this.add.pointlight(this.scoreText.x, this.scoreText.y, 0, 400, 0.2);

and

        this.lights.addLight(this.scoreText.x, this.scoreText.y, 800,0xff4433,30)

but none gave the result on the image please somebody can help

Why does this not work code for another user, How to fix the 409 conflict error for another user , so it will freely use that [closed]

Why i am facing 409 conflict error

I am working on career form for send website data to in Gmail.
All are perfectly done. i make my code live in cPanel , It will work perfectly in my pc and when i use another device to fill the data and submit my code then , in console show me the 409 conflict error.

       <form id="form" method="post" enctype="multipart/form-data">
                <input id="name"  type="text" name="name" placeholder="Name"> <br>
                <input id="email" type="text" name="email" placeholder="email"> <br>
                 <input  id="phone" type="tel" name="phone" placeholder="Phone number">
                <input  id="message" type="text" name="message" placeholder="Message"> <br>
                <input id="file" type="file" name="file"> <br>
                <input type="submit" value="Submit">
          </form>
 <script>    
    
    // toastr.options = {
    //     positionClass: 'toast-top-right',
    //     timeOut: 3000,
    // };

    $(document).ready(function () {
        $('#form').on('submit', function (event) {
            // Example JavaScript code to disable submit button
            this.disabled = true;

            event.preventDefault(); // Prevent default form submission

            // Perform client-side validation
            let isValid = true;
            const name = $('#name').val().trim();
            const email = $('#email').val().trim();
            const phone = $('#phone').val().trim();
            const experience = $('#experience').val();
            const resume = $('#file').val();

            // Clear previous toastr messages
            toastr.clear();


            if (document.getElementById("name").value == "") { 
        // result.innerHTML = "Please Enter Your Name..."; 
                toastr.error("Please Enter Your Name...");
                isValid = false;
            } else if (document.getElementById("email").value == "") { 
            // result.innerHTML = "Please Enter Email..."; 
             toastr.error("Please Enter Your Email...");
              isValid = false; 
            }
            else if (!validateEmail(email)) {
                toastr.error('Invalid Email Address.');
                isValid = false;
            }
           else if (document.getElementById("phone").value == "") { 
            // result.innerHTML = "Please Enter Email..."; 
             toastr.error("Please Enter Your Phone Number...");
              isValid = false; 
            } else if (!/^d{10}$/.test(phone)) {
                toastr.error('Phone Number must be 10 digits.');
                isValid = false;
            } else if (experience.value == "") {
                toastr.error("Please Select Your Work Experience.");
                isValid = false;
            }  
            else if (document.getElementById("file").value == "") { 
            // result.innerHTML = "Please Enter Email..."; 
             toastr.error("Please Upload Your CV...");
              isValid = false; 
            }

            // If validation passes, proceed with AJAX submission
            if (isValid) {
                const formData = new FormData(this); 

            $.ajax({
                url: 'mail.php', // The PHP script that processes the form
                // url: 'https://formbold.com/s/3Kr4p',
                
                type: 'POST',
                data: formData,
                processData: false, // Prevent jQuery from converting the data
                contentType: false, // Prevent jQuery from overriding the content type
                success: function (response) {
                    console.log(response, "done");
                    toastr.success('Form submitted successfully!');
                    $('#form')[0].reset(); // Reset the form
                },
                error: function () {
                    toastr.error('An error occurred while submitting the form.');
                },
                
            });
        }
    });

    // Helper function to validate email format
    function validateEmail(email) {
            const re = /^[^s@]+@[^s@]+.[^s@]+$/;
            return re.test(email);
        }
    });
 </script>   
<?php
if (!isset($_FILES['file']) || $_FILES['file']['error'] != UPLOAD_ERR_OK) {
    die("Error: File upload failed. Error Code: " . $_FILES['file']['error']);
}

$filenameee = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$experience = $_POST['experience'];

$mailto = '[email protected]';
$subject = "Test Subject";
$fromname = "Form";
$fromemail = '[email protected]';

$message = "Name: " . $name . "rnEmail: " . $email . "rnPhone: " . $phone . "rnExperience: " . $experience;

// Read the file content directly from the temporary location
$content = file_get_contents($fileTmpName);
$content = chunk_split(base64_encode($content)); // Encode file in Base64

$separator = md5(time()); // Unique boundary
$eol = "rn"; // End of line

// Headers
$headers = "From: " . $fromname . " <" . $fromemail . ">" . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary="" . $separator . """ . $eol;

$uniqueFilename = time() . '_' . basename($filenameee);
// Email Body
$body = "--" . $separator . $eol;
$body .= "Content-Type: text/plain; charset="UTF-8"" . $eol;
$body .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;
$body .= $message . $eol . $eol;

// Attachment
$body .= "--" . $separator . $eol;
$body .= "Content-Type: application/pdf; name="" . $uniqueFilename . """ . $eol;
$body .= "Content-Transfer-Encoding: base64" . $eol;
$body .= "Content-Disposition: attachment; filename="" . $uniqueFilename . """ . $eol . $eol;
$body .= $content . $eol . $eol;
$body .= "--" . $separator . "--" . $eol;

// Send Email
if (mail($mailto, $subject, $body, $headers)) {
    echo "Email sent successfully!";
} else {
    echo "Error: Failed to send email.";
    print_r(error_get_last());
}
?>

It will work perfectly in my pc and when i use another device to fill the data and submit my code then , in console show me the 409 conflict error.

how do i resize two flexbox in a animation?

okay i’m trying to make a chat app and at the press of a button you can see timestamps of the message slide in.

My stimestamp always takes 200px in size and the other takes the rest.
(https://i.sstatic.net/L89Oz8dr.png)

let’s call:
div1 <– timestamp | 200px

div2 <– messages | the rest of the space

I tried using the translate on the first div1 and to move and quickly realised it, that the div2 won’t resize automatically:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        *{
            padding: 0px;
            margin: 0px;
            box-sizing: border-box;
        }
        .chat-container {
            display: flex;
            height: 50vh;
            width: 50vw;
            background-color: #f0f0f0;
        }
        #div1 {
            background-color: #0004ff;
            height: 100%;
            width: 200px;
            text-align: center;
            
            position: relative;
            left:-200px;
            transition: left 1s;
        }
        #div2 {
            background-color: #ff0000;
            height: 100%;
            text-align: center;
            width: calc(100% - 200px); /* 100% - 200px or auto would work*/
        }
    </style>
</head>
<body>
    <div class="chat-container">
        <div id="div1">
            <p>div1</p>
        </div>
        <div id="div2">
            <p>div2</p>
        </div>
    </div>
    <button id="button">animation</button>
    <script>
        let actived = false;
        document.getElementById("button").addEventListener("click", function() {
            const div1 = document.getElementById("div1");
            const div2 = document.getElementById("div2");
            div1.style.left = actived ? "-200px" : "0px";
            actived = !actived;
        });
    </script>
</body>
</html>

So i tried resizing the size of the div2 but when then i did calc(100% – 200px) but it wasn’t the same size!!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        *{
            padding: 0px;
            margin: 0px;
            box-sizing: border-box;
        }
        .chat-container {
            display: flex;
            height: 50vh;
            width: 50vw;
            background-color: #f0f0f0;
            overflow: hidden;
        }
        #div1 {
            background-color: #0004ff;
            height: 100%;
            width: 200px;
            text-align: center;
            
            position: relative;
            left:-200px;
            transition: left 1s;
        }
        #div2 {
            background-color: #ff0000;
            height: 100%;
            text-align: center;
            width: calc(100% - 200px); /* 100% - 200px or auto would work*/

            position: relative;
            transition: width 1s;
        }
    </style>
</head>
<body>
    <div class="chat-container">
        <div id="div1">
            <p>div1</p>
        </div>
        <div id="div2">
            <p>div2</p>
        </div>
    </div>
    <button id="button">animation</button>
    <script>
        let actived = false;
        document.getElementById("button").addEventListener("click", function() {
            const div1 = document.getElementById("div1");
            const div2 = document.getElementById("div2");
            div1.style.left = actived ? "-200px" : "0px";
            div2.style.width = actived ? "100%" : "calc(100% - 200px)";
            actived = !actived;
        });
    </script>
</body>
</html>

how can 100% of the parent minus the div1’s size isn’t the rest i’m so confused.

Please tell me what method i should use and why 100% – 200px doens’t line up.

TinyMCE not fully loading on a LearnDash/WordPress installation

I have a bug on a WordPress installation with the plugin LearnDash :
I use a feature called “Frontend course creator” but I can’t create or save a course, because I have a JavaScript error directly linked to TinyMCE.

When the page is loaded, this error is logged in the console :

save.js:1 Uncaught (in promise) TypeError: Cannot read properties of
null (reading ‘setContent’)
at save.js:1:460896

This line is concerned :

tinymce.get("ir-course-material-editor").setContent(e.materials.rendered);

…and when I try to save a course :

save.js:1 Uncaught (in promise) TypeError: Cannot read properties of
null (reading ‘getContent’)
at save.js:1:539787

The code whis is concerned :

materials: tinymce.get("ir-course-material-editor").getContent(),

So I understand that TinyMCE is supposed to be loaded on the textarea with the ID “ir-course-material-editor”.

The thing is, TinyMCE is loaded on another textarea of this page. So TinyMCE works on my website.

But the very weird thing is that the page publication works on an another environmnent : Ubuntu + Chrome.

I have tried other environments (MacOS with Firefox, Safari… Windows 11 + Chrome, even IpadOS + Chrome) and it doesn’t work for me. I have also tried a fresh installation on a fresh website. It doesn’t work.

I have contacted the Learndash support team, and they can’t reproduce the error. They tell me it works for them on my website with MacOS + Chrome or Windows 11 + Chrome. They won’t help me.

So I guess there is something, somewhere, on my environment, that cause this page not working.

In the inspector, I can see that TinyMCE is supposed to be loaded here :

a.useEffect)(( () => {
                wp.editor.initialize("ir-content-editor", {
                    tinymce: {
                        wpautop: !0,
                        height: "300px",
                        plugins: "charmap colorpicker compat3x directionality hr image lists media paste tabfocus textcolor wordpress wpautoresize wpdialogs wpeditimage link",
                        toolbar1: "formatselect bold italic underline strikethrough | bullist numlist | blockquote hr wp_more | alignleft aligncenter alignright | link unlink |  media wp_add_media"
                    },
                    quicktags: !1,
                    mediaButtons: !0
                }),
                wp.editor.initialize("ir-course-material-editor", {
                    tinymce: {
                        wpautop: !0,
                        height: "300px",
                        plugins: "charmap colorpicker compat3x directionality hr image lists media paste tabfocus textcolor wordpress wpautoresize wpdialogs wpeditimage link",
                        toolbar1: "formatselect bold italic underline strikethrough | bullist numlist | blockquote hr wp_more | alignleft aligncenter alignright | link unlink |  media wp_add_media"
                    },
                    quicktags: !1,
                    mediaButtons: !0
                }),

I guess it’s React code but I’m not even sure of that. For “ir-content-editor” tinyMCE is loaded properly, but not for “ir-course-material-editor”.

What can impeach the loading of TinyMCE on a navigator, on an environmnent ? I’m completely lost with this one.

data is not inserting into sql table

the clo performance data table is showing whether the clo has been achieved or not, but the problem is when i click the ok button it just doesn’t insert any data to the sql table and shows “No CLO data received” even though the data is shown.

clo performance data table

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
    <title>CLO Analysis Report</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        .container {
            margin-top: 20px;
        }
        table {
            width: 100%;
            margin-top: 20px;
        }
        th, td {
            text-align: center;
            vertical-align: middle;
        }
        .table-section {
            margin-top: 40px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2 class="text-center">CLO Analysis Report</h2>

        <div class="card mt-3">
            <div class="card-body">
                <h4>Course Details</h4>
                <p><strong>Course Code:</strong> <span id="courseCode"></span></p>
                <p><strong>Course Name:</strong> <span id="courseName"></span></p>
                <p><strong>Programme:</strong> <span id="programme"></span></p>
                <p><strong>Lecturer Name:</strong> <span id="lecturerName"></span></p>
                <p><strong>Semester:</strong> <span id="semester"></span></p>
                <p><strong>Total Students:</strong> <span id="totalStudents"></span></p>
            </div>
        </div>

        <!-- CLO Benchmark Table -->
        <div id="clo-benchmark-section" class="table-section">
            <h3>% of Students Achieving the Benchmark for Each CLO</h3>
            <table class="table table-bordered" id="clo-benchmark-table">
                <thead>
                    <tr>
                        <th>Learning Outcome</th>
                        <th>Benchmark</th>
                        <th>% Achieved</th>
                        <th>Remark</th>
                    </tr>
                </thead>
                <tbody>
                    <!-- CLO Benchmark Rows will be dynamically added here -->
                </tbody>
            </table>
        </div>

        <!-- LO Benchmark Table -->
        <div id="lo-benchmark-section" class="table-section">
            <h3>% of Students Achieving the Total Learning Outcomes</h3>
            <table class="table table-bordered" id="lo-benchmark-table">
                <thead>
                    <tr>
                        <th>Total LOs</th>
                        <th>Number of Students Achieved</th>
                        <th>% Achieved</th>
                    </tr>
                </thead>
                <tbody>
                    <!-- LO Benchmark Rows will be dynamically added here -->
                </tbody>
            </table>
        </div>

    <!-- SQL Table -->
    <div class="table-section">
        <h3>CLO Performance Data</h3>
        <form id="submitCLOForm" action="store_clo_data.php" method="POST">
            <input type="hidden" name="course_code" id="hiddenCourseCode">
            <input type="hidden" name="course_name" id="hiddenCourseName">
            <input type="hidden" name="programme" id="hiddenProgramme">
            <input type="hidden" name="lecturer_name" id="hiddenLecturerName">
            <input type="hidden" name="semester" id="hiddenSemester">
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>Student Name</th>
                        <th>Student ID</th>
                        <th>CLO1</th>
                        <th>CLO2</th>
                        <th>CLO3</th>
                        <th>CLO4</th>
                        <th>CLO5</th>
                        <th>CLO6</th>
                        <th>Total CLO</th>
                        <th>U</th>
                        <th>P</th>
                    </tr>
                </thead>
                <tbody id="cloDataTable">
                    <!-- Rows dynamically added -->
                </tbody>
            </table>
            <button type="submit" class="btn btn-primary btn-submit" id="okButton">OK</button>
        </form>
    </div>
</div>    

    <script>
        let studentData;

        document.addEventListener("DOMContentLoaded", function () {
            studentData = JSON.parse(localStorage.getItem("studentData"));
            console.log("Student Data:", studentData);
            const moduleData = JSON.parse(localStorage.getItem("moduleData"));

            if (!studentData || studentData.length === 0) {
                console.error("No student data found in localStorage.");
                return;
            }

            if (!studentData || studentData.length === 0 || !moduleData || !moduleData.courseworkRows) {
                alert("Missing data! Please return to the main or student page to input the required data.");
                return;
            }

            // Populate Course Details
            document.getElementById("courseCode").textContent = moduleData.courseCode;
            document.getElementById("courseName").textContent = moduleData.courseName;
            document.getElementById("programme").textContent = moduleData.programme;
            document.getElementById("lecturerName").textContent = moduleData.lecturerName;
            document.getElementById("semester").textContent = moduleData.semester;
            document.getElementById("totalStudents").textContent = moduleData.totalStudents;

            // Populate hidden inputs
            document.getElementById("hiddenCourseCode").value = moduleData.courseCode || "";
            document.getElementById("hiddenCourseName").value = moduleData.courseName || "";
            document.getElementById("hiddenProgramme").value = moduleData.programme || "";
            document.getElementById("hiddenLecturerName").value = moduleData.lecturerName || "";
            document.getElementById("hiddenSemester").value = moduleData.semester || "";

            console.log("Raw Coursework Weight:", moduleData.courseworkWeight);
            console.log("Raw Exam Weight:", moduleData.examWeight);

            const courseworkWeight = parseFloat(moduleData.courseworkWeight || "0") / 100;
            const examWeight = parseFloat(moduleData.examWeight || "0") / 100;
            const totalCLOs = 6; // Fixed number of CLOs (CLO1 to CLO6)

            if (courseworkWeight === 0 || examWeight === 0) {
                console.error("Weights are zero or missing. Check moduleData:", moduleData);
                alert("Error: Coursework or exam weights are missing or invalid. Please check your inputs.");
                return;
            }

            console.log("Student Data:", studentData);
            console.log("Module Data:", moduleData);
            console.log("Coursework Weight:", courseworkWeight);
            console.log("Exam Weight:", examWeight);

            const cloBenchmarks = calculateCLOBenchmarks(studentData, moduleData, courseworkWeight, examWeight, totalCLOs);
            const loBenchmarks = calculateLOBenchmarks(studentData, totalCLOs);

            console.log("CLO Benchmarks:", cloBenchmarks);
            console.log("LO Benchmarks:", loBenchmarks);

            populateCLOBenchmarkTable(cloBenchmarks, studentData.length);
            populateLOBenchmarkTable(loBenchmarks, studentData.length);
            populateCLODataTable(studentData, totalCLOs);
        });

        function calculateCLOBenchmarks(studentData, moduleData, courseworkWeight, examWeight, totalCLOs) {
            const cloBenchmarks = Array(totalCLOs).fill(0).map(() => ({ total: 0, achieved: 0 }));

            studentData.forEach(student => {
                console.log("Processing student:", student);

                // Process Coursework
                student.coursework.forEach((score, index) => {
                    const cwRow = moduleData.courseworkRows[index];
                    if (cwRow && cwRow.clos) { // Ensure cwRow and cwRow.clos exist
                        cwRow.clos.forEach(clo => {
                            const cloIndex = parseInt(clo.lo.replace("LO", "")) - 1;
                            const weightedScore = (score * courseworkWeight * clo.percent) / 100;
                            cloBenchmarks[cloIndex].total += weightedScore;
                        });
                    }
                });

                // Process Final Exam
                student.finalExam.forEach((score, index) => {
                    const feRow = moduleData.finalExamRows[index];
                    if (feRow && feRow.clos) { // Ensure feRow and feRow.clos exist
                        feRow.clos.forEach(clo => {
                            const cloIndex = parseInt(clo.lo.replace("LO", "")) - 1;
                            const weightedScore = (score * examWeight * clo.percent) / 100;
                            cloBenchmarks[cloIndex].total += weightedScore;
                        });
                    }
                });
                
                // Check if benchmarks are achieved for each CLO
                cloBenchmarks.forEach((clo, index) => {
                    const totalScore = student.coursework[index] + student.finalExam[index];
                    console.log(`CLO${index + 1} - Total Score for Student:`, totalScore);
                    if (totalScore >= 50) {
                        clo.achieved++;
                        console.log(`CLO${index + 1} - Benchmark Achieved`);
                    }
                });
            });

            return cloBenchmarks;
        }

        function calculateLOBenchmarks(studentData, totalCLOs) {
            const loBenchmarks = Array(totalCLOs).fill(0);

            studentData.forEach(student => {
                const totalLOScores = Array(totalCLOs).fill(0);

                student.coursework.forEach(score => {
                    totalLOScores[0] += score;
                });

                student.finalExam.forEach(score => {
                    totalLOScores[1] += score;
                });

                console.log("Total LO Scores for Student:", totalLOScores);

                const achievedLOCount = totalLOScores.filter(score => score >= 50).length;
                loBenchmarks[achievedLOCount - 1]++;

                console.log("Achieved LO Count for Student:", achievedLOCount);
            });

            return loBenchmarks;
        }

        function populateCLOBenchmarkTable(cloBenchmarks, totalStudents) {
            const cloBenchmarkTable = document.getElementById("clo-benchmark-table").querySelector("tbody");

            cloBenchmarks.forEach((clo, index) => {
                const percentAchieved = clo.total ? ((clo.achieved / totalStudents) * 100).toFixed(2) : 0;
                const remark = percentAchieved >= 50 ? "Achieved" : "Review Needed";

                cloBenchmarkTable.innerHTML += `
                    <tr>
                        <td>CLO${index + 1}</td>
                        <td>${(clo.total / totalStudents).toFixed(2)}</td>
                        <td>${percentAchieved}%</td>
                        <td>${remark}</td>
                    </tr>
                `;
            });
        }

        function populateLOBenchmarkTable(loBenchmarks, totalStudents) {
            const loBenchmarkTable = document.getElementById("lo-benchmark-table").querySelector("tbody");

            loBenchmarks.forEach((count, index) => {
                const percentAchieved = ((count / totalStudents) * 100).toFixed(2);

                loBenchmarkTable.innerHTML += `
                    <tr>
                        <td>${index + 1} LOs</td>
                        <td>${count}</td>
                        <td>${percentAchieved}%</td>
                    </tr>
                `;
            });

            loBenchmarkTable.innerHTML += `
                <tr class="table-primary">
                    <td>Total</td>
                    <td>${totalStudents}</td>
                    <td>100%</td>
                </tr>
            `;
        }

        function populateCLODataTable(studentData, totalCLOs) {
            const tableBody = document.getElementById("cloDataTable");
            studentData.forEach((student, idx) => {
                const row = document.createElement("tr");
                row.innerHTML = `
                <td>${student.name || `Student ${idx + 1}`}</td>
                <td><input type="text" name="student_ids[]" class="form-control" placeholder="Enter ID"></td>
                `;
                for (let i = 0; i < totalCLOs; i++) {
                    row.innerHTML += `<td>${i < student.coursework.length && student.coursework[i] >= 50 ? "Achieved" : "No"}</td>`;
                }
                tableBody.appendChild(row);
            });
        }

        // Populate CLO Performance Table
        const cloTable = document.getElementById("cloDataTable");
            studentData.forEach((student, index) => {
                const row = document.createElement("tr");

                row.innerHTML = `
                    <td>${student.name || `Student ${index + 1}`}</td>
                    <td><input type="text" name="student_ids[]" class="form-control" required placeholder="Enter ID"></td>
                    <td>${student.coursework[0] >= 50 ? "Achieved" : "No"}</td>
                    <td>${student.coursework[1] ? (student.coursework[1] >= 50 ? "Achieved" : "No") : "NA"}</td>
                    <td>${student.finalExam[0] >= 50 ? "Achieved" : "No"}</td>
                    <td>${student.finalExam[1] ? (student.finalExam[1] >= 50 ? "Achieved" : "No") : "NA"}</td>
                    <td>NA</td>
                    <td>NA</td>
                    <td>${student.coursework.filter(m => m >= 50).length + student.finalExam.filter(m => m >= 50).length}</td>
                    <td>${student.coursework[0] >= 50 || student.finalExam[0] >= 50 ? "Achieved" : "No"}</td>
                    <td>${student.coursework[1] >= 50 || student.finalExam[1] >= 50 ? "Achieved" : "No"}</td>
                `;

                cloTable.appendChild(row);
            });

            document.getElementById("okButton").addEventListener("click", function () {
                const tableRows = document.querySelectorAll("#cloDataTable tr");
                const cloData = [];
    
                tableRows.forEach(row => {
                    // Extract Student ID
                    const studentId = row.querySelector("input[name='student_ids[]']")?.value.trim() || "";
        
                    // Extract CLO1-CLO6 (columns 3 to 8)
                    const cloCells = Array.from(row.querySelectorAll("td")).slice(2, 8); // CLO1=td[2], CLO6=td[7]
                    const cloResults = cloCells.map(cell => cell.textContent.trim());

                    // Extract Total CLO (column 9)
                    const totalClo = row.cells[8]?.textContent.trim() || "0";

                    cloData.push({
                        student_id: studentId,
                        clo1: cloResults[0] || "No",
                        clo2: cloResults[1] || "No",
                        clo3: cloResults[2] || "No",
                        clo4: cloResults[3] || "No",
                        clo5: cloResults[4] || "No",
                        clo6: cloResults[5] || "No",
                        total_clo: totalClo
                    });
                });

                // Append CLO data to the form
                const form = document.getElementById("submitCLOForm");
                const cloDataField = document.createElement("input");
                cloDataField.type = "hidden";
                cloDataField.name = "clo_data";
                cloDataField.value = JSON.stringify(cloData);
                form.appendChild(cloDataField);
                form.submit();
            });

            // Function to create hidden input fields
            function createHiddenField(name, value) {
                const input = document.createElement("input");
                input.type = "hidden";
                input.name = name;
                input.value = value;
                return input;
            }
    </script>
</body>
</html>

the php code to insert the data

<?php
include 'db.php';

if ($_SERVER["REQUEST_METHOD"] === "POST") {
    $courseCode = $_POST['course_code'] ?? 'N/A';
    $courseName = $_POST['course_name'] ?? 'N/A';
    $programme = $_POST['programme'] ?? 'N/A';
    $lecturerName = $_POST['lecturer_name'] ?? 'N/A';
    $semester = $_POST['semester'] ?? 'N/A';

    // Decode CLO data
    $cloData = isset($_POST['clo_data']) ? json_decode($_POST['clo_data'], true) : [];
    
    if (json_last_error() !== JSON_ERROR_NONE) {
        die("Invalid CLO data: " . json_last_error_msg());
    }

    if (empty($cloData)) {
        die("No CLO data received.");
    }

    // Prepare SQL
    $stmt = $conn->prepare(
        "INSERT INTO clo_performance 
        (student_id, course_code, course_name, programme, lecturer_name, semester, clo1, clo2, clo3, clo4, clo5, clo6, total_clo) 
        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
    );

    foreach ($cloData as $entry) {
        $stmt->bind_param(
            "sssssssssssss",
            $entry['student_id'],
            $courseCode,
            $courseName,
            $programme,
            $lecturerName,
            $semester,
            $entry['clo1'],
            $entry['clo2'],
            $entry['clo3'],
            $entry['clo4'],
            $entry['clo5'],
            $entry['clo6'],
            $entry['total_clo']
        );
        $stmt->execute();
    }

    $stmt->close();
    echo "Data stored successfully!";
} else {
    echo "Invalid request method.";
}

$conn->close();
?>

sql table

CREATE TABLE clo_performance (
    id INT AUTO_INCREMENT PRIMARY KEY,
    student_id VARCHAR(50) NOT NULL,
    course_code VARCHAR(50) NOT NULL,
    course_name VARCHAR(255) NOT NULL,
    programme VARCHAR(50) NOT NULL,
    lecturer_name VARCHAR(255) NOT NULL,
    semester VARCHAR(50) NOT NULL,
    clo1 VARCHAR(20),
    clo2 VARCHAR(20),
    clo3 VARCHAR(20),
    clo4 VARCHAR(20),
    clo5 VARCHAR(20),
    clo6 VARCHAR(20),
    total_clo INT,
    domain_u VARCHAR(20),
    domain_p VARCHAR(20)
);

i expected it to insert data into the sql table and all i got is “No CLO data received” and no data was inserted.
sql table

Swiper Scrollbar with cursor [closed]

Following code I am using for developing a website. I am customizing the slider to make the movement based on the mouse cursor. As the mouse roller is used, slider shall be rolling from top to bottom of the page. Can some one help with this.

I am using swiper.js

<section>
          <div class="swiper-container swiper-slider">
            <div class="jumbotron-mod-1 text-center">
              <div>
                <h1><small>Professional</small><span class='font-weight-bold'>SOLUTIONS</span>
                </h1>
                <p>We offer high quality services.</p><div class='btn-group-variant'> <a class='btn btn-success btn-sm' href='#'>contact now</a> <a class='btn btn-white btn-sm' href='#'>View Services</a></div>
              </div>
            </div>
            
            <div class="swiper-wrapper">
              <div class="swiper-slide">
                <video class="swiper-video" autoplay muted loop>
                    <source src="videos/video-1.mp4" type="video/mp4">
                    Your browser does not support the video tag.
                </video>
             </div>
              <div class="swiper-slide" data-slide-bg="images/slider-1.png">
                <div class="swiper-slide-caption"></div>
              </div>
              <div class="swiper-slide" data-slide-bg="images/slider-2.png">
                <div class="swiper-slide-caption"></div>
              </div>
              <!-- <div class="swiper-slide" data-slide-bg="images/slider-3.jpg">
                <div class="swiper-slide-caption"></div> -->
              <!-- </div> -->
            </div>
            <!-- Swiper Pagination-->
            <div class="swiper-pagination"></div>
            
          </div>
        </section>

loading a vuejs module. in another laravel + vuejs (inertia)

I made a SAP with laravel + vuejs3 (inertia) my SAP works without worries.

But I made a module that is on several sites (WP) which is just a js file that loads on a tag with the id=”form”. it works well on the WP but here since I use a SAP I have the impression that it does not work.

so in my controller I simply have:

return Inertia::render('Form');

and at this point in my view I simply do:

<div id="form"></div>

and in my app.blade.php

<script type="module" crossorigin src="{{ asset('/js/index-8AJeVKiN.js') }}"></script>

when I do that the module does not load, so I did this in the .vue file:

        mounted(){
            this.loadScript('/js/index-8AJeVKiN.js', () => {
            });
        },
        watch:{
        },
        methods:{
            loadScript(src, callback) {
                if (!document.querySelector(`script[src="${src}"]`)) {
                    const script = document.createElement('script');
                    script.src = src;
                    script.type = 'module'; // Ajoute type="module" si nécessaire
                    script.onload = callback; // Appeler la fonction callback une fois chargé
                    document.head.appendChild(script);
                } else {
                    callback(); // Appeler la fonction directement si déjà chargé
                }
            },
        },

but as soon as I navigate elsewhere with a from inertia (so in SAP without refreshing the browser) and I come back to the form it does not work. so it only works the first time, do you have any idea what to do? because currently I am going through a complete php page but I do not like it if I would like to find a solution! Thank you in advance for your help.