Skip to content

Commit 8ef919c

Browse files
Cleaning 1
1 parent 541fdfb commit 8ef919c

File tree

2 files changed

+82
-84
lines changed

2 files changed

+82
-84
lines changed

tmcrstudioaddin/R/Submissions.R

+80-82
Original file line numberDiff line numberDiff line change
@@ -410,27 +410,25 @@ getDialogMessage <- function(submitResults) {
410410
cat("Server couldn't run tests with your code,",
411411
"since your code produced the following error:", sep = "\n")
412412
cat(console_error, "\n")
413-
if (console_error == "unable to start data viewer") {
414-
next_line <- paste("Server does not have View(...) functionality, so please",
415-
"comment out or remove all the View(...) commands.",
416-
sep = " ")
417-
} else if (grepl("invalid multibyte character", console_error)) {
418-
next_line <- paste("You might have used",
419-
"nordic letters in text with encoding that is not UTF-8.",
420-
"Try using UTF-8 encoding or use only ASCII characters.",
421-
sep = " ")
422-
} else {
423-
next_line <- paste("You can find the error message on the console.",
424-
"This should help you identifying and locating the error.",
425-
sep = " ")
426-
}
427-
server_error <- paste("Server could not run tests.",
428-
next_line,
429-
## "#gsub("\n", "<p>", console_error),
430-
sep = "<p>")
431-
## print(gsub("\n", "<br>", console_error))
413+
if (console_error == "unable to start data viewer") {
414+
next_line <- paste("Server does not have View(...) functionality, so please",
415+
"comment out or remove all the View(...) commands.",
416+
sep = " ")
417+
} else if (grepl("invalid multibyte character", console_error)) {
418+
next_line <- paste("You might have used",
419+
"nordic letters in text with encoding that is not UTF-8.",
420+
"Try using UTF-8 encoding or use only ASCII characters.",
421+
sep = " ")
422+
} else {
423+
next_line <- paste("You can find the error message on the console.",
424+
"This should help you identifying and locating the error.",
425+
sep = " ")
426+
}
427+
server_error <- paste("Server could not run tests.",
428+
next_line,
429+
sep = "<p>")
432430
.ddprint(server_error)
433-
submitResults$error <- server_error
431+
submitResults$error <- server_error
434432
message$title <- "Submission succeeded with code problem"
435433
submitResults$error
436434
} else {
@@ -444,75 +442,75 @@ getDialogMessage <- function(submitResults) {
444442
}
445443
messages_tmp <-
446444
matrix(byrow = TRUE, ncol = 3,
447-
c(c("Unauthorized (HTTP 401).",
448-
paste("Your submission was refused by server (HTTP 401).",
449-
"This most likely means that the submission deadline",
450-
"has closed."),
451-
paste("Your submission was refused by server (HTTP 401).",
452-
"This most likely means that the submission deadline",
453-
"has closed.")),
454-
c("Forbidden (HTTP 403).",
455-
paste("Your submission failed as forbidden request (HTTP 403).",
456-
"<p>The most common cause of this are firewalls, VPN's,",
457-
"antivirus programs that block the connection as well as",
458-
"stale credentials. It can also happen if the server is",
459-
"down. <p> Try logging out and back in from addin in a",
460-
"different network and check if tmc.mooc.fi is working.",
461-
"<p> If the problem persists, please contact the course",
462-
"instructors."),
463-
paste("Your submission failed as forbidden request (HTTP 403).",
464-
"<p>The most common cause of this are firewalls, VPN's,",
465-
"antivirus programs that block the connection as well as",
466-
"stale credentials. It can also happen if the server is",
467-
"down. <p> Try logging out and back in from addin in a",
468-
"different network and check if tmc.mooc.fi is working.",
469-
"<p> If the problem persists, please contact the course",
470-
"instructors.")),
471-
c("file.exists(path) is not TRUE",
472-
paste("Submission uploading failed with 'file.exists(path)",
473-
"is not TRUE'. <p> The reason for this is most likely",
474-
"with your installation of Rtools. Please take a look at",
475-
"Rtools installationmanual. <p> If you are unable to fix this",
476-
"contact the course instructors in this case."),
477-
paste("Submission uploading failed with 'file.exists(path)",
478-
"is not TRUE'. <p> This is most likely an issue with",
479-
"file permissions. <p> Please contact the course instructors",
480-
"in this case.")),
481-
c("Bad Gateway (HTTP 502).",
482-
paste("Your submission failed with 'Bad Gateway (HTTP 502)'.",
483-
"You can try restarting RStudio and RTMC and then resubmitting.<p>",
484-
"This can also mean that server is is temporarily not accepting",
485-
"requests. You should try resubmitting again later, but if you",
486-
"are in a hurry, contact the course teacher"),
487-
paste("Your submission failed with 'Bad Gateway (HTTP 502)'.",
488-
"You can try restarting RStudio and RTMC and then resubmitting.<p>",
489-
"This can also mean that server is is temporarily not accepting",
490-
"requests. You should try resubmitting again later, but if you",
491-
"are in a hurry, contact the course teacher")),
445+
c(c("Unauthorized (HTTP 401).",
446+
paste("Your submission was refused by server (HTTP 401).",
447+
"This most likely means that the submission deadline",
448+
"has closed."),
449+
paste("Your submission was refused by server (HTTP 401).",
450+
"This most likely means that the submission deadline",
451+
"has closed.")),
452+
c("Forbidden (HTTP 403).",
453+
paste("Your submission failed as forbidden request (HTTP 403).",
454+
"<p>The most common cause of this are firewalls, VPN's,",
455+
"antivirus programs that block the connection as well as",
456+
"stale credentials. It can also happen if the server is",
457+
"down. <p> Try logging out and back in from addin in a",
458+
"different network and check if tmc.mooc.fi is working.",
459+
"<p> If the problem persists, please contact the course",
460+
"instructors."),
461+
paste("Your submission failed as forbidden request (HTTP 403).",
462+
"<p>The most common cause of this are firewalls, VPN's,",
463+
"antivirus programs that block the connection as well as",
464+
"stale credentials. It can also happen if the server is",
465+
"down. <p> Try logging out and back in from addin in a",
466+
"different network and check if tmc.mooc.fi is working.",
467+
"<p> If the problem persists, please contact the course",
468+
"instructors.")),
469+
c("file.exists(path) is not TRUE",
470+
paste("Submission uploading failed with 'file.exists(path)",
471+
"is not TRUE'. <p> The reason for this is most likely",
472+
"with your installation of Rtools. Please take a look at",
473+
"Rtools installationmanual. <p> If you are unable to fix this",
474+
"contact the course instructors in this case."),
475+
paste("Submission uploading failed with 'file.exists(path)",
476+
"is not TRUE'. <p> This is most likely an issue with",
477+
"file permissions. <p> Please contact the course instructors",
478+
"in this case.")),
479+
c("Bad Gateway (HTTP 502).",
480+
paste("Your submission failed with 'Bad Gateway (HTTP 502)'.",
481+
"You can try restarting RStudio and RTMC and then resubmitting.<p>",
482+
"This can also mean that server is is temporarily not accepting",
483+
"requests. You should try resubmitting again later, but if you",
484+
"are in a hurry, contact the course teacher"),
485+
paste("Your submission failed with 'Bad Gateway (HTTP 502)'.",
486+
"You can try restarting RStudio and RTMC and then resubmitting.<p>",
487+
"This can also mean that server is is temporarily not accepting",
488+
"requests. You should try resubmitting again later, but if you",
489+
"are in a hurry, contact the course teacher")),
492490
c("LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60",
493-
paste("Your submission failed with 'LibreSSL ... errno 60'",
494-
"This usually means that your connection failed just before",
491+
paste("Your submission failed with 'LibreSSL ... errno 60'",
492+
"This usually means that your connection failed just before",
495493
"submission. You should try resubmitting again for more informative",
496494
"error message."),
497-
paste("Your submission failed with 'LibreSSL ... errno 60'",
498-
"This usually means that your connection failed just before",
495+
paste("Your submission failed with 'LibreSSL ... errno 60'",
496+
"This usually means that your connection failed just before",
499497
"submission. You should try resubmitting again for more informative",
500498
"error message.")),
501-
c("Could not resolve host: tmc.mooc.fi",
502-
paste("Host tmc.mooc.fi could not be reached. Do you have a working",
503-
"network connection? If you do, then tmc.mooc.fi might be",
504-
"currently unreachable. You should try resubmitting again later,",
505-
"but if you are in a hurry, contact the course teacher"),
506-
paste("Host tmc.mooc.fi could not be reached. Do you have a working",
507-
"network connection? If you do, then tmc.mooc.fi might be",
508-
"currently unreachable. You should try resubmitting again later,",
509-
"but if you are in a hurry, contact the course teacher")),
499+
c("Could not resolve host: tmc.mooc.fi",
500+
paste("Host tmc.mooc.fi could not be reached. Do you have a working",
501+
"network connection? If you do, then tmc.mooc.fi might be",
502+
"currently unreachable. You should try resubmitting again later,",
503+
"but if you are in a hurry, contact the course teacher"),
504+
paste("Host tmc.mooc.fi could not be reached. Do you have a working",
505+
"network connection? If you do, then tmc.mooc.fi might be",
506+
"currently unreachable. You should try resubmitting again later,",
507+
"but if you are in a hurry, contact the course teacher")),
510508
c(pre_error,
511-
paste(pre_error, "<p>Please contact the course instructors in this case."),
512-
paste(pre_error, "<p>Please contact the course instructors in this case."))))
509+
paste(pre_error, "<p>Please contact the course instructors in this case."),
510+
paste(pre_error, "<p>Please contact the course instructors in this case."))))
513511
errormsgs <- list(keys = messages_tmp[ , 1],
514-
msgs_win = messages_tmp[ , 2],
515-
msgs_unix = messages_tmp[ , 3])
512+
msgs_win = messages_tmp[ , 2],
513+
msgs_unix = messages_tmp[ , 3])
516514
if (!is.null(.Platform$OS.type) && .Platform$OS.type == "windows") {
517515
errormsg <- errormsgs$msgs_win[errormsgs$keys == pre_error][1]
518516
} else {

tmcrstudioaddin/R/Zipper.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.dprint(".zip")
33
old_wd <- getwd()
44
setwd(folder)
5-
if ( file.exists(zip_path) ) {
5+
if (file.exists(zip_path)) {
66
cat("Zip was already created. This should not happen.\n")
77
setwd(old_wd)
88
stop("Zip file already exists")
@@ -16,7 +16,7 @@
1616
stop(e)
1717
})
1818
setwd(old_wd)
19-
if ( !file.exists(zip_path) ) {
19+
if (!file.exists(zip_path)) {
2020
cat("Zip has not not been created.\n")
2121
stop("Zip file not created")
2222
}

0 commit comments

Comments
 (0)