Skip to content

Commit

Permalink
Add Ajax Answer Quiz + animate library + sweetalert2 library
Browse files Browse the repository at this point in the history
  • Loading branch information
amirroox committed Jul 10, 2023
1 parent fe9e90e commit 4a25c2e
Show file tree
Hide file tree
Showing 22 changed files with 5,471 additions and 58 deletions.
7 changes: 7 additions & 0 deletions Lessons/AjaxHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

$Season = $_POST['Season'];
$Lesson = $_POST['Lesson'];
$Quiz = $_POST['Quiz'];

die(readfile("$Season/$Lesson/Quiz/$Quiz.txt")); // Read Answer Quiz
7 changes: 3 additions & 4 deletions Lessons/GettingStart/ArchLinux/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -72,10 +73,8 @@
<!-- Custom Script -->
<script>
$('#<?=$name_file?>').addClass("bg-red-500");
$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);
</script>
<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>

</body>
</html>
9 changes: 3 additions & 6 deletions Lessons/GettingStart/Debian/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -78,17 +79,13 @@
<!-- Custom Script -->
<script>
$('#<?=$name_file?>').addClass("bg-red-500");
$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);

// Season next
$("#LessonsMenu ol").append(`
<a href="../../CommandLine">
<li id="CommandLine" class="hidden md:block LIST_LESSON py-1 hover:bg-red-500 hover:text-white duration-500">فصل بعدی : خط فرمان</li>
</a>
`);
</script>

<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>
</body>
</html>
8 changes: 3 additions & 5 deletions Lessons/GettingStart/Fedora/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -69,10 +70,7 @@
<!-- Custom Script -->
<script>
$('#<?=$name_file?>').addClass("bg-red-500");
$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);
</script>

<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>
</body>
</html>
7 changes: 3 additions & 4 deletions Lessons/GettingStart/Gentoo/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -63,9 +64,7 @@
<!-- Custom Script -->
<script>
$('#<?=$name_file?>').addClass("bg-red-500");
$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);
</script>
<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions Lessons/GettingStart/History/Quiz/1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
لینوس توروالدز

(Linus Torvalds)
30 changes: 19 additions & 11 deletions Lessons/GettingStart/History/index.php

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions Lessons/GettingStart/LinuxMint/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -65,9 +66,7 @@
<!-- Custom Script -->
<script>
$('#<?=$name_file?>').addClass("bg-red-500");
$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);
</script>
<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>
</body>
</html>
9 changes: 3 additions & 6 deletions Lessons/GettingStart/OpenSUSE/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -67,17 +68,13 @@
<script>
$('#<?=$name_file?>').addClass("bg-red-500"); //Active Lesson

$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);

// Season Next For Desktop
$("#LessonsMenu ol").append(`
<a href="../../CommandLine">
<li id="CommandLine" class="hidden md:block LIST_LESSON py-1 hover:bg-red-500 hover:text-white duration-500">فصل بعدی : خط فرمان</li>
</a>
`);
</script>

<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>
</body>
</html>
8 changes: 3 additions & 5 deletions Lessons/GettingStart/RedHat/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -65,10 +66,7 @@
<!-- Custom Script -->
<script>
$('#<?=$name_file?>').addClass("bg-red-500");
$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);
</script>

<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>
</body>
</html>
4 changes: 3 additions & 1 deletion Lessons/GettingStart/Ubuntu/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -68,6 +69,7 @@
scrollTop: $('#end_menu').offset().top
}, 800);
</script>
<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>

</body>
</html>
7 changes: 3 additions & 4 deletions Lessons/GettingStart/choosing-a-linux-distribution/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
include_once "../../../Constants.php" ;
$name_file = basename(__DIR__);
$name_file = basename(__DIR__); /* Name This Lesson */
$name_file_season = basename(dirname( __DIR__)); /* Name This Season */
?>
<!doctype html>
<html lang="fa" dir="rtl">
Expand Down Expand Up @@ -69,10 +70,8 @@
<!-- Custom Script -->
<script>
$('#<?=$name_file?>').addClass("bg-red-500");
$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);
</script>
<script src="<?= MAIN_SERVER . 'assets/js/needLessonsScript.js' ?>"></script>

</body>
</html>
6 changes: 5 additions & 1 deletion assets/css/MainMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
<link href="<?= MAIN_SERVER . 'assets/css/SeedStyle.css'?>" rel="stylesheet">

<!-- Tailwindcss -->
<link href="<?= MAIN_SERVER . 'dist/output.css'?>" rel="stylesheet">
<link href="<?= MAIN_SERVER . 'dist/output.css'?>" rel="stylesheet">

<!-- Sweetalert2 -->
<link href="<?= MAIN_SERVER . 'assets/vendor/animate.min.css'?>" rel="stylesheet">
<script src="<?= MAIN_SERVER . 'assets/vendor/sweetalert2.all.min.js'?>"></script>
Binary file added assets/img/anim.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions assets/js/needLessonsScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Animate Scroll H1 */
$('body,html').animate({
scrollTop: $('#end_menu').offset().top
}, 800);

/* All Link a */
let aLink = $('#referenceQuiz_lessons a');
aLink.attr("target" , "_blank");
aLink.attr("rel" , "noopener noreferrer nofollow");

/* Ajax For Answer Quiz */
$('#referenceQuiz_lessons button').on('click' , function () {
let Season = document.getElementById('referenceQuiz_lessons').getAttribute("nameSeason");
let Lesson = document.getElementById('referenceQuiz_lessons').getAttribute("nameLesson");
let Quiz = this.getAttribute("quiz");
$.ajax({
method: "POST",
data: {Season : Season , Lesson : Lesson , Quiz : Quiz},
url: "../../AjaxHandler.php",
success: function (res) {
Swal.fire({
showClass: {
popup: 'animate__animated animate__swing'
},
hideClass: {
popup: 'animate__animated animate__fadeOutUp'
},
backdrop: `
rgba(0,0,123,0.4)
url("../../../assets/img/anim.gif")
left top
no-repeat
`,
position: 'center',
icon: 'success',
title: res,
showConfirmButton: false,
timer: 10000,
})
},
error: function () {
Swal.fire({
position: 'center',
icon: 'error',
title: 'یه جایی به مشگل خوردیم!',
showConfirmButton: false,
timer: 1500
})
}
});
});
7 changes: 7 additions & 0 deletions assets/vendor/animate.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 4a25c2e

Please sign in to comment.