Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

r - How to name html files produced by nops_eval with the students ID?

I am aware that nops_eval creates folders named with students' ID, and inside each of those folders, an HTML file (with the same name for all students) is created. I would like to have the HTML files with the students' ID or the students' names. It would be necessary to have a folder per student, just the HTML files all in the same folder, without Is it possible? The code used:

eval <- nops_eval(register = "register_df.csv",
          solutions = "solutions.rds",
          scans = "nops_scan.zip",
          language = "pt",
          eval = exams_eval(partial = F, negative = -0.25, rule = "false"),
          dir = "eval",
          interactive = T,
          mark = F)
question from:https://stackoverflow.com/questions/65870245/how-to-name-html-files-produced-by-nops-eval-with-the-students-id

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Recently, in version 2.4-0 nops_eval() gained the option to plug in custom writers for the evaluation results. So, in principle, this could be used. However, if the focus is just to rename the HTML files, I would probably simply unzip() the ZIP file, file.rename() the HTML files, and then file.remove() the previous directories.

For me on Linux this works:

f <- unzip("nops_eval.zip")
id <- strsplit(f, "/", fixed = TRUE)
id <- sapply(id, function(x) x[length(x) - 1])
for(i in seq_along(id)) {
  file.rename(f[i], paste0(id[i], ".html"))
  file.remove(id[i])
}

Note: Possibly, the file paths in f are separated with a backslash rather than a slash on Windows. If so, you would have to replace "/" with "\" in the strsplit() call.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...