-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappunti.R
More file actions
63 lines (47 loc) · 1.62 KB
/
appunti.R
File metadata and controls
63 lines (47 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
library(fs)
library(zip)
library(Microsoft365R)
library(tidyverse)
site <- get_sharepoint_site("ex pubblica")
documenti <- site$get_drive("Documenti")
dir.create("videos")
cartella_registrazioni <- documenti$get_item(
"Formazione anno corrente/3 Erogazione/14220_FR_GP_ANTICORRUZIONE E TRASPARENZA/MATERIALE DIDATTICO CORSO ETICA E DEONTOLOGIA 2025 MANENTI/REGISTRAZIONI"
)
cartella_registrazioni$list_items() |>
filter(str_detect(name, "mp4$")) |>
pull(name) |>
walk(\(x) {
cartella_registrazioni$get_item(x)$download(str_glue("videos/{x}"))
})
video_list <- list.files("videos", full.names = TRUE)
template_folder <- "scorm_template"
for (v in video_list[4:11]) {
scorm_name <- v |>
str_remove("\\.mp4$") |>
str_remove("videos/") |>
str_trim()
scorm_folder <- path(tempdir(), scorm_name)
# 1. Copia il modello
dir_copy(template_folder, scorm_folder)
# 2. Sostituisci il video
file_copy(v, path(scorm_folder, "video.mp4"), overwrite = TRUE)
# 3. Aggiorna titolo in HTML
html_file <- path(scorm_folder, "index.html")
html_lines <- readLines(html_file)
html_lines <- gsub("Titolo", scorm_name, html_lines)
writeLines(html_lines, html_file)
# 4. Aggiorna titolo nel manifest
manifest_file <- path(scorm_folder, "imsmanifest.xml")
manifest_lines <- readLines(manifest_file)
manifest_lines <- gsub("Titolo", scorm_name, manifest_lines)
writeLines(manifest_lines, manifest_file)
zip_name <- paste0(scorm_name, ".zip")
# 5. Zip SCORM
zip(
path(getwd(), zip_name),
list.files(scorm_folder, recursive = TRUE),
root = scorm_folder
)
cartella_registrazioni$upload(zip_name)
}