Update session log, XP value, and add question bank for RHEL learning

This commit is contained in:
2025-06-17 23:44:03 +02:00
parent 7014a682be
commit e9e9bd2e4d
4 changed files with 51 additions and 9 deletions
+20
View File
@@ -0,0 +1,20 @@
Which command creates a compressed tar archive?|gzip dir|tar czf archive.tar.gz dir|bzip2 dir|2
How do you append output to a file in Bash?|>>|>|&>|1
Which command finds all files named "passwd" under /etc?|find /etc -name passwd|ls /etc/passwd|grep passwd /etc|1
How do you switch to the root user?|sudo root|sudo su -|su -|3
Which command shows the SELinux context of a file?|ls --context|ls -Z|ls -l|2
How do you create a new user?|usermod|adduser|useradd|3
Which command lists all running containers?|docker ps|podman ps|podman list|2
How do you mount an NFS share?|mount -t ext4 /dev/sda1 /mnt|mount -t nfs server:/share /mnt|mount -o loop image.iso /mnt|2
How do you schedule a one-time job for 5 minutes from now?|at now + 5 minutes|cron 5|crontab -e|1
Which command sets a file's permissions to rwxr-xr--?|chmod 644 file|chmod 754 file|chmod 777 file|2
How do you check the status of firewalld?|systemctl firewall|firewall-cmd --state|firewallctl status|2
How do you extend a logical volume by 1G?|lvresize -L 1G /dev/vg/lv|lvcreate -L 1G /dev/vg/lv|lvextend -L +1G /dev/vg/lv|3
How do you display the last 10 lines of a file?|less file|tail file|head file|2
How do you change a user's password aging policy?|usermod|chage|passwd|2
How do you list all available systemd targets?|systemctl list-units --type=target --all|systemctl list-active-targets|systemctl list-targets|3
How do you display the current runlevel?|runlevel|who -r|systemctl get-default|1
How do you set a service to start at boot?|systemctl start|systemctl boot|systemctl enable|3
How do you transfer a file securely to a remote host?|scp file user@host:/path|rsync file user@host:/path|ftp file user@host:/path|1
How do you display the UUID of a filesystem?|uuidgen|blkid|lsblk|2
How do you reload the systemd daemon?|systemctl reload|systemctl restart|systemctl daemon-reload|3
+14
View File
@@ -439,3 +439,17 @@ XP and level updated: 225 XP, Level 3
Session start: 2025-06-17 23:23:35
Session duration: 22 minutes and 43 seconds
Session end: 2025-06-17 23:29:19
Session start: 2025-06-17 23:34:04
Session start: 2025-06-17 23:37:04
Session end: 2025-06-17 23:37:04
XP and level updated: 235 XP, Level 3
XP and level updated: 245 XP, Level 3
Session start: 2025-06-17 23:42:39
Session end: 2025-06-17 23:42:39
XP and level updated: 240 XP, Level 3
Session Ellipsis: 2025-06-17 23:42:54
Session Ellipsis: 2025-06-17 23:42:54
Session Ellipsis: 2025-06-17 23:42:55
Session start: 2025-06-17 23:43:21
Session end: 2025-06-17 23:43:21
XP and level updated: 250 XP, Level 3
+1 -1
View File
@@ -1 +1 @@
225
250
+16 -8
View File
@@ -6,6 +6,7 @@ from tkinter import messagebox
import random
import subprocess
from datetime import datetime, timedelta
import webbrowser
# Constants
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -107,7 +108,7 @@ def update_xp(correct):
return xp, level
def show_timer(minutes, questions_file, session_log, total_time, xp, level):
def show_timer(minutes, questions_file, session_log, total_time, xp, level, root):
def update_timer():
nonlocal seconds_left, elapsed_time
if seconds_left > 0:
@@ -189,10 +190,6 @@ def show_timer(minutes, questions_file, session_log, total_time, xp, level):
kill_steam()
root.after(10000, periodic_kill_steam)
root = tk.Tk()
root.title("RHEL Learning Timer")
root.protocol("WM_DELETE_WINDOW", on_closing)
seconds_left = minutes * 60
elapsed_time = 0
@@ -216,8 +213,6 @@ def show_timer(minutes, questions_file, session_log, total_time, xp, level):
root.after(1000, update_rol_timer)
root.after(10000, periodic_kill_steam)
root.mainloop()
def open_firefox(url):
print(f"Attempting to open Firefox with URL: {url}")
if 'DISPLAY' in os.environ:
@@ -245,14 +240,27 @@ def shuffle_questions(input_file, output_file):
new_correct = old_indices.index(correct) + 1
f.write(f"{q}|{'|'.join(new_answers)}|{new_correct}\n")
def open_learning_links():
urls = [
"https://rol.redhat.com",
"https://docs.google.com/spreadsheets/d/1ZQpE1fQoc-lyElFmvoQLW-2tOclMsMENYKiehu3jrxc/edit?gid=0#gid=0"
]
for url in urls:
webbrowser.open_new_tab(url)
def main():
initialize_assets()
log_session("start")
total_time, xp, level = display_summary()
kill_steam()
open_firefox(URL)
show_timer(TIMER_MINUTES, QUESTIONS_SHUFFLED_FILE, SESSION_LOG, total_time, xp, level)
open_learning_links()
root = tk.Tk()
root.title("RHEL Learning Timer")
root.protocol("WM_DELETE_WINDOW", lambda: log_session(...))
show_timer(TIMER_MINUTES, QUESTIONS_SHUFFLED_FILE, SESSION_LOG, total_time, xp, level, root)
log_session("end")
root.mainloop()
if __name__ == "__main__":
shuffle_questions(QUESTIONS_FILE, QUESTIONS_SHUFFLED_FILE)