├── R
├── homework.R
├── copycats.R
├── check_hw.R
└── test_students.R
├── .gitignore
├── .Rbuildignore
├── inst
└── extdata
│ ├── HW01
│ ├── submissions
│ │ ├── 01_456_student_04_only_5.R
│ │ ├── 01_159_student_03_file_cannot_source.R
│ │ ├── 01_123_student_01_correct.R
│ │ ├── 01_789_student_05_wrong_function_name.R
│ │ └── 01_147_student_02_always_wrong.R
│ ├── HW01_questions.txt
│ └── hw01_solutions.R
│ ├── HW.Rproj
│ └── check_hw_master.R
├── NAMESPACE
├── homework.Rproj
├── man
├── substrRight.Rd
├── source_to_env.Rd
├── file_ext_to_keep.Rd
├── fix_first_arg_in_fun.Rd
├── can_source.Rd
├── copycats_trap.Rd
├── create_grade_files.Rd
├── check_hw.Rd
└── test_students.Rd
├── DESCRIPTION
├── CONDUCT.md
├── README.Rmd
├── README.md
└── LICENSE
/R/homework.R:
--------------------------------------------------------------------------------
1 | ## TODO...
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | .RData
4 | .Ruserdata
5 |
--------------------------------------------------------------------------------
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^.*\.Rproj$
2 | ^\.Rproj\.user$
3 | ^CONDUCT\.md$
4 | ^README\.Rmd$
5 | ^README-.*\.png$
6 |
--------------------------------------------------------------------------------
/inst/extdata/HW01/submissions/01_456_student_04_only_5.R:
--------------------------------------------------------------------------------
1 | # student_02.R
2 | my_sum <- function(x) {
3 | 5
4 | }
5 |
6 | my_pwr <- function(x, p) {
7 | 5
8 | }
9 |
--------------------------------------------------------------------------------
/inst/extdata/HW01/submissions/01_159_student_03_file_cannot_source.R:
--------------------------------------------------------------------------------
1 | # student_05.R
2 |
3 | # we have this issue sometimes...
4 |
5 | stop("I don't want to be sourced!!")
6 |
7 |
--------------------------------------------------------------------------------
/inst/extdata/HW01/submissions/01_123_student_01_correct.R:
--------------------------------------------------------------------------------
1 | # correct
2 |
3 | my_sum <- function(x) {
4 | sum(x)
5 | }
6 |
7 | my_pwr <- function(x, p) {
8 | x^p
9 | }
10 |
--------------------------------------------------------------------------------
/inst/extdata/HW01/submissions/01_789_student_05_wrong_function_name.R:
--------------------------------------------------------------------------------
1 | # student_03.R
2 |
3 | my_sum_wrong_name <- function(x) {
4 | sum(x) + 5 # always wrong
5 | }
6 |
7 |
8 | my_pwr_misspelled <- function(x, p) {
9 | x^p
10 | }
11 |
--------------------------------------------------------------------------------
/inst/extdata/HW.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: knitr
13 | LaTeX: pdfLaTeX
14 |
--------------------------------------------------------------------------------
/inst/extdata/HW01/submissions/01_147_student_02_always_wrong.R:
--------------------------------------------------------------------------------
1 | # student_04.R
2 |
3 | # my_sum(1:4)
4 | # my_sum(100:105)
5 | # sum(100:105)
6 | my_sum <- function(x) {
7 | sum(x) + 5 # always wrong
8 | }
9 |
10 | my_pwr <- function(x, p) {
11 | x^p + 5
12 | }
13 |
14 |
15 |
--------------------------------------------------------------------------------
/inst/extdata/HW01/HW01_questions.txt:
--------------------------------------------------------------------------------
1 | Homework assignment 01:
2 | 1) Please write a "my_sum" function which accepts a vector `x` and returns the sum of its elements
3 | 2) Please write a "my_pwr" function which accepts a vector `x` and a numeric p, and returns the vector x in the power of p (for each element of x)
4 |
--------------------------------------------------------------------------------
/inst/extdata/check_hw_master.R:
--------------------------------------------------------------------------------
1 |
2 | library(homework)
3 | demo_base_dir <- file.path(system.file(package = "homework"), "extdata")
4 | demo_base_dir
5 | check_hw("HW01", demo_base_dir)
6 | # run the following to see any warnings within R:
7 | warnings()
8 |
9 |
10 | # etc.
11 | check_hw("HW02", demo_base_dir)
12 |
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | # Generated by roxygen2: do not edit by hand
2 |
3 | export(can_source)
4 | export(check_hw)
5 | export(copycats_find)
6 | export(copycats_trap)
7 | export(create_grade_files)
8 | export(create_grade_files_OLD)
9 | export(file_ext_to_keep)
10 | export(fix_first_arg_in_fun)
11 | export(only_R_files)
12 | export(source_to_env)
13 | export(substrRight)
14 | export(test_students)
15 | importFrom(R.utils,withTimeout)
16 | importFrom(tools,file_ext)
17 | importFrom(tools,file_path_sans_ext)
18 |
--------------------------------------------------------------------------------
/homework.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: Sweave
13 | LaTeX: pdfLaTeX
14 |
15 | AutoAppendNewline: Yes
16 | StripTrailingWhitespace: Yes
17 |
18 | BuildType: Package
19 | PackageUseDevtools: Yes
20 | PackageInstallArgs: --no-multiarch --with-keep.source
21 | PackageRoxygenize: rd,collate,namespace
22 |
--------------------------------------------------------------------------------
/inst/extdata/HW01/hw01_solutions.R:
--------------------------------------------------------------------------------
1 | # hw01_solutions.R
2 |
3 | # my_sum(1:5)
4 | # sum(1:5)
5 |
6 | my_sum <- function(x) {
7 | out <- 0
8 | for(i in x) out <- out + i
9 | out
10 | }
11 |
12 | my_pwr <- function(x, p) {
13 | x^p
14 | }
15 |
16 |
17 |
18 | tests_to_run <-
19 | list(
20 | "my_sum" = list(1, 5, 1:5, 100:105),
21 | "my_pwr" = list(
22 | list(x=5, p =1),
23 | list(x=1:4, p =2),
24 | list(x=1:4, p =3),
25 | list(x=10:14, p =1/2)
26 | )
27 | )
28 |
29 |
30 |
--------------------------------------------------------------------------------
/man/substrRight.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/test_students.R
3 | \name{substrRight}
4 | \alias{substrRight}
5 | \title{FUNCTION_TITLE}
6 | \usage{
7 | substrRight(x, n)
8 | }
9 | \arguments{
10 | \item{x}{PARAM_DESCRIPTION}
11 |
12 | \item{n}{PARAM_DESCRIPTION}
13 | }
14 | \value{
15 | OUTPUT_DESCRIPTION
16 | }
17 | \description{
18 | FUNCTION_DESCRIPTION
19 | }
20 | \details{
21 | DETAILS
22 | }
23 | \examples{
24 | \dontrun{
25 | if(interactive()){
26 | #EXAMPLE1
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/man/source_to_env.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/test_students.R
3 | \name{source_to_env}
4 | \alias{source_to_env}
5 | \title{Loads sources function into an envir}
6 | \usage{
7 | source_to_env(file, env_name, envir_home = .GlobalEnv)
8 | }
9 | \arguments{
10 | \item{file}{the location of the .R file to source.}
11 |
12 | \item{env_name}{A name for the envir in which to store the data.}
13 |
14 | \item{envir_home}{the environment into which to assign the object (env_name). The default is .GlobalEnv.}
15 | }
16 | \value{
17 | A named environment with the content of the .R file
18 | }
19 | \description{
20 | Sources an R file to get its functions and content into the environment.
21 | }
22 | \examples{
23 | \dontrun{
24 | if(interactive()){
25 | #EXAMPLE1
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/man/file_ext_to_keep.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/test_students.R
3 | \name{file_ext_to_keep}
4 | \alias{file_ext_to_keep}
5 | \alias{only_R_files}
6 | \title{Get only .R files}
7 | \usage{
8 | file_ext_to_keep(files, file_ext = c("R"), case_sensitive = FALSE)
9 |
10 | only_R_files(files, case_sensitive = FALSE)
11 | }
12 | \arguments{
13 | \item{files}{- a charachter vector of file names}
14 |
15 | \item{case_sensitive}{PARAM_DESCRIPTION, Default: FALSE}
16 | }
17 | \value{
18 | only files which are R/r files.
19 | }
20 | \description{
21 | Give a vector of possible file names, returns only the ones that are .R files.
22 | }
23 | \examples{
24 |
25 | files <- c("a", "b.R", "c.RR", "d.Rdata", "e.R")
26 | only_R_files(files)
27 |
28 | }
29 | \seealso{
30 | \code{\link[tools]{file_ext}}
31 | }
32 |
--------------------------------------------------------------------------------
/man/fix_first_arg_in_fun.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/test_students.R
3 | \name{fix_first_arg_in_fun}
4 | \alias{fix_first_arg_in_fun}
5 | \title{Change the first argument of a function}
6 | \usage{
7 | fix_first_arg_in_fun(fun, first_arg = "x")
8 | }
9 | \arguments{
10 | \item{fun}{the function to change}
11 |
12 | \item{first_arg}{the name of the first argument of the function to return, Default: x}
13 | }
14 | \value{
15 | The original function, just with a different arg.
16 | }
17 | \description{
18 | Useful when the teacher uses a function like function(x) and the student
19 | does something like function(X) or function(y)
20 | If the student had the first argument correct, it would not be changed.
21 | }
22 | \examples{
23 | fo <- function(y, ...) {
24 | x+3
25 | }
26 | # fo(x=5) # errors...
27 | fo_x <- fix_first_arg_in_fun(fo, "x")
28 | fo_x(x=5)
29 | }
30 |
--------------------------------------------------------------------------------
/man/can_source.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/test_students.R
3 | \name{can_source}
4 | \alias{can_source}
5 | \title{Check that .R file can be sourced without errors}
6 | \usage{
7 | can_source(files, ...)
8 | }
9 | \arguments{
10 | \item{files}{a charachter vector of R file names to be sourced and checked if they can be run with no problem.}
11 |
12 | \item{...}{not used.}
13 | }
14 | \value{
15 | A data.frame with the name of the file, it's status (TRUE if was sourced properly, and FALSE otherwise),
16 | and a note indicating possible issues.
17 | }
18 | \description{
19 | The function gets a vector of .R file names and returns for each of them if it can be sourced or not.
20 | This is helpful as an initial step before checking the homework (to make sure it can be loaded).
21 | }
22 | \examples{
23 | \dontrun{
24 | if(interactive()){
25 | #EXAMPLE1
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: homework
2 | Type: Package
3 | Title: Automatically Check R Programming Homework Assignments
4 | Version: 0.2.0
5 | Date: 2018-11-17
6 | Authors@R: c(person("Tal", "Galili", role = c("aut", "cre", "cph"),
7 | email = "tal.galili@gmail.com", comment =
8 | "https://www.r-statistics.com"))
9 | Description: This package aims to help teachers of R courses (especially
10 | when teaching how to program with R) to automatically check and
11 | grade homework assignments of students.
12 | Depends: R (>= 3.0.0)
13 | Imports: tools,R.utils
14 | Suggests: knitr, covr, testthat
15 | VignetteBuilder: knitr
16 | License: GPL-3 + file LICENSE
17 | URL: https://cran.r-project.org/package=homework,
18 | https://github.com/talgalili/homework/,
19 | https://www.r-statistics.com/tag/homework/
20 | BugReports: https://github.com/talgalili/homework/issues
21 | Encoding: UTF-8
22 | LazyData: true
23 | RoxygenNote: 6.1.1
24 |
--------------------------------------------------------------------------------
/man/copycats_trap.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/copycats.R
3 | \name{copycats_trap}
4 | \alias{copycats_trap}
5 | \alias{copycats_find}
6 | \title{Help catch copycats}
7 | \usage{
8 | copycats_trap(file, ...)
9 |
10 | copycats_find(file, show_print = TRUE, ...)
11 | }
12 | \arguments{
13 | \item{file}{an .R file to update.}
14 |
15 | \item{...}{not used}
16 |
17 | \item{show_print}{logical (TRUE) if to print the rows with the suspected extra spaces.}
18 | }
19 | \value{
20 | invisible TRUE. Also modifies the .R file that was in the input.
21 | }
22 | \description{
23 | Takes a vector of .R files which includes solutions to homework
24 | and adds 7 trailing spaces to each even line in the file.
25 | This way, if the next semester you get homework which includes such a line,
26 | it is clear that the student copied these homework from a solution another student
27 | gave him from a previous year.
28 | }
29 | \examples{
30 | \dontrun{
31 | if(interactive()){
32 | #EXAMPLE1
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Code of Conduct
2 |
3 | As contributors and maintainers of this project, we pledge to respect all people who
4 | contribute through reporting issues, posting feature requests, updating documentation,
5 | submitting pull requests or patches, and other activities.
6 |
7 | We are committed to making participation in this project a harassment-free experience for
8 | everyone, regardless of level of experience, gender, gender identity and expression,
9 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
10 |
11 | Examples of unacceptable behavior by participants include the use of sexual language or
12 | imagery, derogatory comments or personal attacks, trolling, public or private harassment,
13 | insults, or other unprofessional conduct.
14 |
15 | Project maintainers have the right and responsibility to remove, edit, or reject comments,
16 | commits, code, wiki edits, issues, and other contributions that are not aligned to this
17 | Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed
18 | from the project team.
19 |
20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
21 | opening an issue or contacting one or more of the project maintainers.
22 |
23 | This Code of Conduct is adapted from the Contributor Covenant
24 | (http:contributor-covenant.org), version 1.0.0, available at
25 | http://contributor-covenant.org/version/1/0/0/
26 |
--------------------------------------------------------------------------------
/man/create_grade_files.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/check_hw.R, R/test_students.R
3 | \name{create_grade_files}
4 | \alias{create_grade_files}
5 | \alias{create_grade_files_OLD}
6 | \title{FUNCTION_TITLE}
7 | \usage{
8 | create_grade_files(grades, hw_sub_dir, grades_sub_dir = "grades",
9 | char_to_keep = 5, get_id_from_file_name = TRUE)
10 |
11 | create_grade_files_OLD(results, HW_number, tests_to_run,
12 | grades_folder = "grades\\\\", char_to_trim = 6)
13 | }
14 | \arguments{
15 | \item{grades}{PARAM_DESCRIPTION}
16 |
17 | \item{hw_sub_dir}{PARAM_DESCRIPTION}
18 |
19 | \item{grades_sub_dir}{PARAM_DESCRIPTION, Default: 'grades'}
20 |
21 | \item{char_to_keep}{PARAM_DESCRIPTION, Default: 5}
22 |
23 | \item{get_id_from_file_name}{PARAM_DESCRIPTION, Default: TRUE}
24 |
25 | \item{results}{PARAM_DESCRIPTION}
26 |
27 | \item{HW_number}{PARAM_DESCRIPTION}
28 |
29 | \item{tests_to_run}{PARAM_DESCRIPTION}
30 |
31 | \item{grades_folder}{PARAM_DESCRIPTION, Default: grades}
32 |
33 | \item{char_to_trim}{PARAM_DESCRIPTION, Default: 6}
34 | }
35 | \value{
36 | OUTPUT_DESCRIPTION
37 |
38 | OUTPUT_DESCRIPTION
39 | }
40 | \description{
41 | FUNCTION_DESCRIPTION
42 |
43 | FUNCTION_DESCRIPTION
44 | }
45 | \details{
46 | DETAILS
47 |
48 | DETAILS
49 | }
50 | \examples{
51 | \dontrun{
52 | if(interactive()){
53 | #EXAMPLE1
54 | }
55 | }
56 | \dontrun{
57 | if(interactive()){
58 | #EXAMPLE1
59 | }
60 | }
61 | }
62 | \seealso{
63 | \code{\link[tools]{fileutils}}
64 | }
65 |
--------------------------------------------------------------------------------
/man/check_hw.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/check_hw.R
3 | \name{check_hw}
4 | \alias{check_hw}
5 | \title{FUNCTION_TITLE}
6 | \usage{
7 | check_hw(hw_sub_dir = "", base_dir = getwd(),
8 | submissions_sub_dir = "submissions", sol_file, tests_to_run,
9 | create_grade_files = TRUE, unzip_submissions = TRUE,
10 | submission_file_ext_to_keep = c("R", "zip"), catch_copycats = TRUE,
11 | max_grade = 100, ...)
12 | }
13 | \arguments{
14 | \item{hw_sub_dir}{PARAM_DESCRIPTION, Default: ''}
15 |
16 | \item{base_dir}{PARAM_DESCRIPTION, Default: getwd()}
17 |
18 | \item{submissions_sub_dir}{PARAM_DESCRIPTION, Default: 'submissions'}
19 |
20 | \item{sol_file}{PARAM_DESCRIPTION}
21 |
22 | \item{tests_to_run}{PARAM_DESCRIPTION}
23 |
24 | \item{create_grade_files}{PARAM_DESCRIPTION, Default: TRUE}
25 |
26 | \item{unzip_submissions}{PARAM_DESCRIPTION, Default: TRUE}
27 |
28 | \item{submission_file_ext_to_keep}{PARAM_DESCRIPTION, Default: c("R", "zip")}
29 |
30 | \item{catch_copycats}{PARAM_DESCRIPTION, Default: TRUE}
31 |
32 | \item{max_grade}{PARAM_DESCRIPTION, Default: 100}
33 |
34 | \item{...}{PARAM_DESCRIPTION}
35 |
36 | \item{grades}{PARAM_DESCRIPTION}
37 |
38 | \item{hw_sub_dir}{PARAM_DESCRIPTION}
39 |
40 | \item{grades_sub_dir}{PARAM_DESCRIPTION, Default: 'grades'}
41 |
42 | \item{char_to_keep}{PARAM_DESCRIPTION, Default: 5}
43 |
44 | \item{get_id_from_file_name}{PARAM_DESCRIPTION, Default: TRUE}
45 | }
46 | \value{
47 | OUTPUT_DESCRIPTION
48 |
49 | OUTPUT_DESCRIPTION
50 | }
51 | \description{
52 | FUNCTION_DESCRIPTION
53 |
54 | FUNCTION_DESCRIPTION
55 | }
56 | \details{
57 | DETAILS
58 |
59 | DETAILS
60 | }
61 | \examples{
62 | \dontrun{
63 | if(interactive()){
64 | #EXAMPLE1
65 | }
66 | }
67 | \dontrun{
68 | if(interactive()){
69 | #EXAMPLE1
70 | }
71 | }
72 | }
73 | \seealso{
74 | \code{\link[tools]{fileutils}}
75 |
76 | \code{\link[tools]{fileutils}}
77 | }
78 |
--------------------------------------------------------------------------------
/R/copycats.R:
--------------------------------------------------------------------------------
1 | # copycats
2 |
3 |
4 |
5 |
6 | #
7 | # list.files("sol")
8 | # a <- readLines("sol\\HW_01_sol.R")
9 | # # removing trailing spaces
10 | # # https://stackoverflow.com/questions/9532340/how-do-i-remove-trailing-whitespace-using-a-regular-expression
11 | # gsub("[ \t]+$", "", a)
12 |
13 |
14 | # add trailing spaces of 0 and 7 length repeateadly in order to find when a student will copy paste a solution from one year to the next.
15 |
16 |
17 |
18 | #' @title Help catch copycats
19 | #' @description
20 | #' Takes a vector of .R files which includes solutions to homework
21 | #' and adds 7 trailing spaces to each even line in the file.
22 | #' This way, if the next semester you get homework which includes such a line,
23 | #' it is clear that the student copied these homework from a solution another student
24 | #' gave him from a previous year.
25 | #' @param file an .R file to update.
26 | #' @param show_print logical (TRUE) if to print the rows with the suspected extra spaces.
27 | #' @param ... not used
28 | #'
29 | #' @return
30 | #' invisible TRUE. Also modifies the .R file that was in the input.
31 | #' @examples
32 | #' \dontrun{
33 | #' if(interactive()){
34 | #' #EXAMPLE1
35 | #' }
36 | #' }
37 | #' @rdname copycats_trap
38 | #' @export
39 | copycats_trap <- function(file, ...) {
40 | if (!file.exists(file)) return(invisible(FALSE))
41 |
42 | R_txt <- readLines(file)
43 | # removing trailing spaces
44 | # https://stackoverflow.com/questions/9532340/how-do-i-remove-trailing-whitespace-using-a-regular-expression
45 | R_txt <- gsub("[ \t]+$", "", R_txt)
46 |
47 | # add 7 trailing spaces to each second line in the file
48 | R_txt <- paste0(R_txt, c("", " "))
49 |
50 | writeLines(R_txt, file)
51 |
52 | invisible(TRUE)
53 | }
54 |
55 |
56 |
57 | #' @rdname copycats_trap
58 | #' @export
59 | copycats_find <- function(file, show_print = TRUE, ...) {
60 | if (!file.exists(file)) return(invisible(FALSE))
61 |
62 | R_txt <- readLines(file)
63 | # removing trailing spaces
64 | # https://stackoverflow.com/questions/9532340/how-do-i-remove-trailing-whitespace-using-a-regular-expression
65 | space_loc <- grepl(" $", R_txt)
66 |
67 | if (any(space_loc)) {
68 | if (show_print) print(R_txt[space_loc])
69 | return(TRUE)
70 | }
71 | return(FALSE)
72 | }
73 |
74 |
75 | #
76 | #
77 | # # I'm making sure this will be run everytime so that
78 | #
79 | # for(i in 1:9) {
80 | # trap_copycats(paste0("sol\\HW_0",i,"_sol.R"))
81 | # }
82 | # trap_copycats("sol\\HW_10_sol.R")
83 | # trap_copycats("sol\\HW_11_sol.R")
84 | # trap_copycats("sol\\HW_12_sol.R")
85 | # trap_copycats("sol\\HW_13_sol.R")
86 | #
87 | #
88 | #
89 | #
90 |
--------------------------------------------------------------------------------
/man/test_students.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/test_students.R
3 | \name{test_students}
4 | \alias{test_students}
5 | \title{FUNCTION_TITLE}
6 | \usage{
7 | test_students(hw_submitters, sol_file, tests_to_run, timeout = 0.5,
8 | use_do.call, check_sol_fun = function(student_sol, teacher_sol) {
9 | isTRUE(all.equal(student_sol, teacher_sol, tolerance = 1e-04, check.attributes
10 | = FALSE)) }, update_student_fun = NULL, max_grade = 100,
11 | mistakes_folder = "mistakes")
12 | }
13 | \arguments{
14 | \item{hw_submitters}{a vector of .R files to check}
15 |
16 | \item{sol_file}{the location of the .R file with the correct solution.
17 | This file should have the functions that solves the homework's questions.}
18 |
19 | \item{tests_to_run}{a list with elements as the number of questions in the homework assignment.
20 | Each element in the list is named by the name of the function.
21 | So if the homework said to create a function called fo then the list will contain an element named "fo".
22 | The "fo" element will itself be a list with the inputs to check on the functions.
23 | If the input is NA then the function will be run as `fo()`.`
24 | If the function fo includes several parameters (say fo(a = "something", b = "another smthng")) then
25 | each element inside "fo" will be a list of the form list("input", "b input"). (you can also use
26 | list(a = "input", b = "b input") but then if the student wrote the function as function(A="not a", B = "not b")
27 | then his function would fail. Indicating the input just by the order makes it simpler).
28 | The function do.call will be used to run this input in fo.}
29 |
30 | \item{timeout}{The number of seconds to wait for the function to end before deciding
31 | the student got into an infinite loop and to exist the function and declare the student failed to answer
32 | the question. Default: 0.5}
33 |
34 | \item{use_do.call}{if to force the use of do.call on the list_of_inputs. By default is not set, in which case the function will try to guess if to use it or not (based on the solution by the teacher and the arguments in the list_of_inputs)}
35 |
36 | \item{check_sol_fun}{the function to use to compare the solutions. if you wish to set a specific function for a test, the
37 | "check_sol_fun" attribute should be added to that test in the list.
38 | attr(current_test, "check_sol_fun")
39 | PARAM_DESCRIPTION, Default:
40 | function(student_sol, teacher_sol) {
41 | isTRUE(all.equal(
42 | student_sol, teacher_sol, tolerance = 0.01,
43 | check.attributes = FALSE
44 | ))
45 | }}
46 |
47 | \item{update_student_fun}{the function to use on the student's function to fix a problem.
48 | "update_student_fun" attribute can be added to that test in the list.
49 | default is NULL.
50 | this is when the teachers write fo <- function(x) {...}
51 | And the student writes fo <- function(y) {...}
52 | we can make sure to fix the student's mistake using:
53 | function(f) fix_first_arg_in_fun(f, "x")}
54 |
55 | \item{student_id_fun}{a character string indicating the name of the function a student was instructed to create that returns is id (for example my_id() {"id number"})
56 | If NULL, then the file name is used.}
57 | }
58 | \value{
59 | OUTPUT_DESCRIPTION
60 | }
61 | \description{
62 | FUNCTION_DESCRIPTION
63 | }
64 | \details{
65 | DETAILS
66 | }
67 | \examples{
68 | \dontrun{
69 | if(interactive()){
70 | #EXAMPLE1
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/README.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | output: github_document
3 | ---
4 |
5 |
6 |
7 | ```{r, echo = FALSE}
8 | knitr::opts_chunk$set(
9 | collapse = TRUE,
10 | comment = "#>",
11 | fig.path = "README-"
12 | )
13 | ```
14 |
15 | # homework
16 |
17 | The `homework` package let's R teachers automatically check homeworks that they are giving to their students. A recommended workflow is to have a master directory for all homework files, and then a sub-directory for each homework assignment (such as "HW01", "HW02", etc.). The master directory will have a `check_hw_master.R` master file to include the code to check homework everyweek. A subfolder of homework (say, HW01, HW02, etc.), must have a folder with the submissions of the students (called "submissions"), an R file with the correct solutions (it should be called solutions.R or hw01_solutions.R). The submissions folder can include one zip file with all assignments, or just all the assignments (each student's assignment is an R file). An answer for each homework question should be a function (for example "write a function that calculates the sum of a vector"). The solution file should include an object called `tests_to_run` at the end of it. This object is a nested list, each element of the list is a name of a function that the hw has asked for, and in it is either a list of possible inputs to check against the function, OR, a list of lists, each sublist will check some other input (see later for an example). After running the `check_hw` on the subdirectory "HW01", the function will create a "mistakes" folder with an .R file for each function in the hw, and in the files will be a list of the mistakes that were found for each question/student. There is also a "grades" folder, with a csv including the grades of students (based on the filenames the students submit). The standard of the filenames of hw assignment is assingment_number_student_id.R (e.g.: 01_123456.R). In the grades folder there is the grades file we need for giving students the grade at the end of the course, plus a file to send the students (this one will include only the first 5 characters of the student's id, so that people won't know who got which grade).
18 |
19 | An example of a folder structure before running check_hw:
20 |
21 | ```
22 | hw
23 | -check_hw_master.R
24 | -hw01
25 | --submissions
26 | ---students_homework.zip (maybe from moodle)
27 | --hw01_solutions.R (includes the corrects functions and the inputs to check)
28 | --hw.txt/hw.pdf/hw.docx/etc. (ignored)
29 | -hw02
30 | --...
31 | -hw03
32 | --...
33 | ```
34 |
35 | Folder structure AFTER running check_hw:
36 |
37 | ```
38 | hw
39 | -check_hw_master.R
40 | -hw01
41 | --submissions
42 | ---students_homework.zip (maybe from moodle)
43 | ---01_123456.R
44 | ---01_456987.R
45 | ---01_879456.R
46 | --hw01_solutions.R (includes the corrects functions and the inputs to check)
47 | --mistakes
48 | ---mistakes_in_foo.R
49 | ---mistakes_in_bar.R
50 | --grades
51 | ---grades.csv
52 | ---grades_for_students.csv
53 | --hw.txt/hw.pdf/hw.docx/etc. (ignored)
54 | -hw02
55 | --...
56 | -hw03
57 | --...
58 | ```
59 |
60 |
61 | ## Installation
62 |
63 | You can install homework from github with:
64 |
65 | ```{r gh-installation, eval = FALSE}
66 | if(!requireNamespace("remotes", quietly=TRUE)) install.packages("remotes")
67 | remotes::install_github("talgalili/homework")
68 | ```
69 |
70 | ## Example
71 |
72 | The package comes with a simple example. The following code shows where the example is, and how to run a homework check on it.
73 |
74 | Some of the homework file have intentional problems in them to deomnstrate how the function is able to deal with them:
75 |
76 |
77 | ```{r example}
78 | library(homework)
79 | # it is best to just create an RStudio project for the homework checking of a course...
80 | demo_base_dir <- file.path(system.file(package = "homework"), "extdata")
81 | demo_base_dir
82 | check_hw("HW01", demo_base_dir)
83 |
84 | ```
85 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | homework
4 | ========
5 |
6 | The `homework` package let's R teachers automatically check homeworks that they are giving to their students. A recommended workflow is to have a master directory for all homework files, and then a sub-directory for each homework assignment (such as "HW01", "HW02", etc.). The master directory will have a `check_hw_master.R` master file to include the code to check homework everyweek. A subfolder of homework (say, HW01, HW02, etc.), must have a folder with the submissions of the students (called "submissions"), an R file with the correct solutions (it should be called solutions.R or hw01\_solutions.R). The submissions folder can include one zip file with all assignments, or just all the assignments (each student's assignment is an R file). An answer for each homework question should be a function (for example "write a function that calculates the sum of a vector"). The solution file should include an object called `tests_to_run` at the end of it. This object is a nested list, each element of the list is a name of a function that the hw has asked for, and in it is either a list of possible inputs to check against the function, OR, a list of lists, each sublist will check some other input (see later for an example). After running the `check_hw` on the subdirectory "HW01", the function will create a "mistakes" folder with an .R file for each function in the hw, and in the files will be a list of the mistakes that were found for each question/student. There is also a "grades" folder, with a csv including the grades of students (based on the filenames the students submit). The standard of the filenames of hw assignment is assingment\_number\_student\_id.R (e.g.: 01\_123456.R). In the grades folder there is the grades file we need for giving students the grade at the end of the course, plus a file to send the students (this one will include only the first 5 characters of the student's id, so that people won't know who got which grade).
7 |
8 | An example of a folder structure before running check\_hw:
9 |
10 | hw
11 | -check_hw_master.R
12 | -hw01
13 | --submissions
14 | ---students_homework.zip (maybe from moodle)
15 | --hw01_solutions.R (includes the corrects functions and the inputs to check)
16 | --hw.txt/hw.pdf/hw.docx/etc. (ignored)
17 | -hw02
18 | --...
19 | -hw03
20 | --...
21 |
22 | Folder structure AFTER running check\_hw:
23 |
24 | hw
25 | -check_hw_master.R
26 | -hw01
27 | --submissions
28 | ---students_homework.zip (maybe from moodle)
29 | ---01_123456.R
30 | ---01_456987.R
31 | ---01_879456.R
32 | --hw01_solutions.R (includes the corrects functions and the inputs to check)
33 | --mistakes
34 | ---mistakes_in_foo.R
35 | ---mistakes_in_bar.R
36 | --grades
37 | ---grades.csv
38 | ---grades_for_students.csv
39 | --hw.txt/hw.pdf/hw.docx/etc. (ignored)
40 | -hw02
41 | --...
42 | -hw03
43 | --...
44 |
45 | Installation
46 | ------------
47 |
48 | You can install homework from github with:
49 |
50 | ``` r
51 | if(!require(devtools)) install.packages("devtools")
52 | devtools::install_github("talgalili/homework")
53 | ```
54 |
55 | Example
56 | -------
57 |
58 | The package comes with a simple example. The following code shows where the example is, and how to run a homework check on it.
59 |
60 | Some of the homework file have intentional problems in them to deomnstrate how the function is able to deal with them:
61 |
62 | ``` r
63 | library(homework)
64 | # it is best to just create an RStudio project for the homework checking of a course...
65 | demo_base_dir <- file.path(system.file(package = "homework"), "extdata")
66 | demo_base_dir
67 | #> [1] "C:/R/library/homework/extdata"
68 | check_hw("HW01", demo_base_dir)
69 | #> Warning in check_hw("HW01", demo_base_dir): The following file could not be
70 | #> sourced (it would get a 0 grade): 01_159_student_03_file_cannot_source.R
71 | #> Warning in fun_student(current_test): The function 'my_sum' was not found
72 | #> in file: 01_789_student_05_wrong_function_name.R
73 | #> Warning in (function (...) : The function 'my_pwr' was not found in file:
74 | #> 01_789_student_05_wrong_function_name.R
75 | #> ID my_sum_test_1 my_sum_test_2
76 | #> 1 01_123_student_01_correct.R TRUE TRUE
77 | #> 2 01_147_student_02_always_wrong.R FALSE FALSE
78 | #> 3 01_159_student_03_file_cannot_source.R FALSE FALSE
79 | #> 4 01_456_student_04_only_5.R FALSE TRUE
80 | #> 5 01_789_student_05_wrong_function_name.R FALSE FALSE
81 | #> my_sum_test_3 my_sum_test_4 my_pwr_test_1 my_pwr_test_2 my_pwr_test_3
82 | #> 1 TRUE TRUE TRUE TRUE TRUE
83 | #> 2 FALSE FALSE FALSE FALSE FALSE
84 | #> 3 FALSE FALSE FALSE FALSE FALSE
85 | #> 4 FALSE FALSE TRUE FALSE FALSE
86 | #> 5 FALSE FALSE FALSE FALSE FALSE
87 | #> my_pwr_test_4 grade
88 | #> 1 TRUE 100
89 | #> 2 FALSE 0
90 | #> 3 FALSE 0
91 | #> 4 FALSE 25
92 | #> 5 FALSE 0
93 | ```
94 |
--------------------------------------------------------------------------------
/R/check_hw.R:
--------------------------------------------------------------------------------
1 | # check_hw
2 |
3 | if(F) {
4 | demo_base_dir <- file.path(system.file(package = "homework"), "extdata")
5 | check_hw("HW01", demo_base_dir, max_grade = 150)
6 |
7 | # in mac, how to quickly browse this folder:
8 | system(paste("open ", demo_base_dir))
9 |
10 | list.files(demo_base_dir)
11 | list.files(file.path(demo_base_dir, "HW01"))
12 | list.files(file.path(demo_base_dir, "HW01", "submissions"))
13 |
14 | r_files <- file.path(demo_base_dir, "HW01", "submissions", list.files(file.path(demo_base_dir, "HW01", "submissions")))
15 | a <- can_source(r_files)
16 |
17 | if(!all(a$status))
18 |
19 | check_hw("HW01", demo_base_dir)
20 |
21 | debug(check_hw)
22 | check_hw("HW01", demo_base_dir)
23 | undebug(check_hw)
24 |
25 | debug(test_students)
26 | check_hw("HW01", demo_base_dir)
27 | undebug(test_students)
28 | }
29 |
30 |
31 |
32 |
33 | #' @title FUNCTION_TITLE
34 | #' @description FUNCTION_DESCRIPTION
35 | #' @param grades PARAM_DESCRIPTION
36 | #' @param hw_sub_dir PARAM_DESCRIPTION
37 | #' @param grades_sub_dir PARAM_DESCRIPTION, Default: 'grades'
38 | #' @param char_to_keep PARAM_DESCRIPTION, Default: 5
39 | #' @param get_id_from_file_name PARAM_DESCRIPTION, Default: TRUE
40 | #' @return OUTPUT_DESCRIPTION
41 | #' @details DETAILS
42 | #' @examples
43 | #' \dontrun{
44 | #' if(interactive()){
45 | #' #EXAMPLE1
46 | #' }
47 | #' }
48 | #' @seealso
49 | #' \code{\link[tools]{fileutils}}
50 | #' @rdname create_grade_files
51 | #' @export
52 | #' @importFrom tools file_path_sans_ext
53 | create_grade_files <- function(grades, hw_sub_dir, grades_sub_dir = "grades", char_to_keep = 5,
54 | get_id_from_file_name = TRUE) {
55 |
56 | grades_sub_dir <- file.path(hw_sub_dir, grades_sub_dir)
57 | if(dir.exists(grades_sub_dir)) {
58 | # clear all grades files
59 | unlink(list.files(grades_sub_dir))
60 | } else { # let's make sure we have this folder available!
61 | dir.create(grades_sub_dir)
62 | }
63 |
64 | if(get_id_from_file_name) {
65 | # remove .R
66 | grades$ID <- tools::file_path_sans_ext(grades$ID)
67 | # remove initial 01_
68 | grades$ID <- sub("[0-9]+_", "", grades$ID)
69 | }
70 |
71 | grades2 <- grades
72 | grades2$ID <- substr(grades2$ID, 1, char_to_keep)
73 |
74 | write.csv(grades, file.path(grades_sub_dir, "grades.csv"), row.names = FALSE)
75 | write.csv(grades2, file.path(grades_sub_dir, "grades_for_students.csv"), row.names = FALSE)
76 |
77 | NULL
78 | }
79 |
80 |
81 |
82 |
83 |
84 | #' @title FUNCTION_TITLE
85 | #' @description FUNCTION_DESCRIPTION
86 | #' @param hw_sub_dir PARAM_DESCRIPTION, Default: ''
87 | #' @param base_dir PARAM_DESCRIPTION, Default: getwd()
88 | #' @param submissions_sub_dir PARAM_DESCRIPTION, Default: 'submissions'
89 | #' @param sol_file PARAM_DESCRIPTION
90 | #' @param tests_to_run PARAM_DESCRIPTION
91 | #' @param create_grade_files PARAM_DESCRIPTION, Default: TRUE
92 | #' @param unzip_submissions PARAM_DESCRIPTION, Default: TRUE
93 | #' @param submission_file_ext_to_keep PARAM_DESCRIPTION, Default: c("R", "zip")
94 | #' @param catch_copycats PARAM_DESCRIPTION, Default: TRUE
95 | #' @param max_grade PARAM_DESCRIPTION, Default: 100
96 | #' @param ... PARAM_DESCRIPTION
97 | #' @return OUTPUT_DESCRIPTION
98 | #' @details DETAILS
99 | #' @examples
100 | #' \dontrun{
101 | #' if(interactive()){
102 | #' #EXAMPLE1
103 | #' }
104 | #' }
105 | #' @seealso
106 | #' \code{\link[tools]{fileutils}}
107 | #' @rdname check_hw
108 | #' @export
109 | #' @importFrom tools file_ext
110 | check_hw <- function(hw_sub_dir = "", base_dir = getwd(),
111 | submissions_sub_dir = "submissions", sol_file, tests_to_run,
112 | #' @title FUNCTION_TITLE
113 | #' @description FUNCTION_DESCRIPTION
114 | #' @param grades PARAM_DESCRIPTION
115 | #' @param hw_sub_dir PARAM_DESCRIPTION
116 | #' @param grades_sub_dir PARAM_DESCRIPTION, Default: 'grades'
117 | #' @param char_to_keep PARAM_DESCRIPTION, Default: 5
118 | #' @param get_id_from_file_name PARAM_DESCRIPTION, Default: TRUE
119 | #' @return OUTPUT_DESCRIPTION
120 | #' @details DETAILS
121 | #' @examples
122 | #' \dontrun{
123 | #' if(interactive()){
124 | #' #EXAMPLE1
125 | #' }
126 | #' }
127 | #' @seealso
128 | #' \code{\link[tools]{fileutils}}
129 | #' @rdname create_grade_files
130 | #' @export
131 | #' @importFrom tools file_path_sans_ext
132 | create_grade_files = TRUE,
133 | unzip_submissions = TRUE,
134 | submission_file_ext_to_keep = c("R", "zip"),
135 | catch_copycats = TRUE,
136 | max_grade = 100,
137 | ...) {
138 | # if sol_file empty, find a file that includes the word "solutions"
139 | hw_sub_dir <- file.path(base_dir, hw_sub_dir)
140 |
141 | # finding the solutions file to work with.
142 | # this file should include all the functions that we want to test, and the tests_to_run object
143 | if(missing(sol_file)) {
144 | hw_sub_dir_files <- list.files(hw_sub_dir)
145 | sol_file_loc <- grepl("solutions", hw_sub_dir_files)
146 | if(!any(sol_file_loc)) stop("Cannot find a solutions.R file")
147 | if(sum(sol_file_loc) > 1) stop("I see more than one file called solutions.R, please specify the file you wish to use in the sol_file argument.")
148 | sol_file <- file.path(hw_sub_dir, hw_sub_dir_files[sol_file_loc])
149 | }
150 |
151 | # a good workflow is that every solutions file will include
152 | # a tests_to_run object at the end of it, including all the things that need to be checked.
153 | if(missing(tests_to_run)) {
154 | # create an env object with the objects from the solutions file
155 | source_to_env(sol_file, "solutions_objects")
156 | tests_to_run <- solutions_objects$tests_to_run
157 | }
158 |
159 | # temp$copycats_find
160 | # system.file("tools", "HW01", package = "homework")
161 | # file.path(system.file(package = "homework"), "tools")
162 |
163 | # the place where all the hw files of the students (the submissions) should be located
164 | # submissions_sub_dir <- file.path(base_dir, hw_sub_dir, submissions_sub_dir)
165 | submissions_sub_dir <- file.path(hw_sub_dir, submissions_sub_dir)
166 | # hw_submitters = list.files(submissions_sub_dir)
167 | # list.files("/Library/Frameworks/R.framework/Versions/3.3/Resources/library/homework/extdata//Library/Frameworks/R.framework/Versions/3.3/Resources/library/homework/extdata/HW01/submissions")
168 | # list.files("/Library/Frameworks/R.framework/Versions/3.3/Resources/library/homework/extdata/")
169 |
170 |
171 | hw_submissions_files <- file.path(submissions_sub_dir, list.files(submissions_sub_dir))
172 |
173 | if(unzip_submissions) {
174 | # if the submissions folder has ANY zip files,
175 | # it will extract it and remove all files that are not .zip and .R files
176 | if(any(tools::file_ext(hw_submissions_files) %in% "zip")) {
177 | zip_files <- hw_submissions_files[tools::file_ext(hw_submissions_files) %in% "zip"]
178 | unzip(zip_files, exdir = submissions_sub_dir, junkpaths= TRUE) # extract all .R files
179 |
180 | # remove all non R or zip files.
181 | hw_submissions_files <- file.path(submissions_sub_dir, list.files(submissions_sub_dir))
182 | to_keep <- tools::file_ext(hw_submissions_files) %in% submission_file_ext_to_keep
183 | unlink(hw_submissions_files[!to_keep])
184 | }
185 | }
186 |
187 |
188 |
189 | # warning if some files could not be checked because they couldn't be sourced properly...
190 | check_if_can_source <- can_source(hw_submissions_files)
191 | if(!all(check_if_can_source$status)) {
192 | files_with_issues <- check_if_can_source[!check_if_can_source$status, ]
193 | for(i in 1:nrow(files_with_issues)) {
194 | warning("The following file could not be sourced (it would get a 0 grade): ", basename(files_with_issues$file[i]))
195 | }
196 | }
197 |
198 | results <- test_students(hw_submitters = hw_submissions_files,
199 | sol_file = sol_file,
200 | tests_to_run = tests_to_run ,
201 | mistakes_folder = file.path(hw_sub_dir, "mistakes"),
202 | max_grade = max_grade,
203 | ...
204 | )
205 |
206 | if(create_grade_files) create_grade_files(results, hw_sub_dir)
207 |
208 | if(catch_copycats) {
209 | # make sure the solution file we have will catch copycats in the future:
210 | copycats_trap(sol_file)
211 | # issue a warning if some student seems to have been cheating:
212 | any_copycats <- sapply(hw_submissions_files, copycats_find)
213 | if(any(any_copycats)) {
214 | hw_submissions_files_cheaters <- hw_submissions_files[any_copycats]
215 | for(i in hw_submissions_files_cheaters) warning("There are signs the following student cheated: ", i)
216 | }
217 | }
218 |
219 | results
220 | }
221 |
--------------------------------------------------------------------------------
/R/test_students.R:
--------------------------------------------------------------------------------
1 |
2 | # # to not have functions crash in case of errors.
3 | # options(error = function(e) NULL)
4 | # ?stop("afaffa")
5 | # options(error = expression(NULL))
6 | # http://stackoverflow.com/questions/19111956/suppress-error-message-in-r
7 |
8 |
9 | # ------ Get the teacher's solutions
10 | # -----------------------------
11 |
12 |
13 | #' @title Loads sources function into an envir
14 | #' @description
15 | #' Sources an R file to get its functions and content into the environment.
16 | #' @param file the location of the .R file to source.
17 | #' @param env_name A name for the envir in which to store the data.
18 | #' @param envir_home the environment into which to assign the object (env_name). The default is .GlobalEnv.
19 | #' @return A named environment with the content of the .R file
20 | #' @examples
21 | #' \dontrun{
22 | #' if(interactive()){
23 | #' #EXAMPLE1
24 | #' }
25 | #' }
26 | #' @export
27 | source_to_env <- function(file, env_name, envir_home = .GlobalEnv) {
28 | assign(env_name, new.env(), envir = envir_home) # create a new mystical env
29 | source(file, local = get(env_name, envir = envir_home)) # brings all the functions to the local env created by the function
30 | }
31 |
32 |
33 | # ".teacher_env"
34 |
35 | #
36 | # create_solutions <- function(file) {
37 | #
38 | # # source(file, local = TRUE) # brings all the functions to the local env created by the function
39 | # # fun_vec <- as.vector(lsf.str())
40 | # #
41 | # #
42 | # # assign(".teacher_env", new.env(), envir = .GlobalEnv) # create a new mystical env
43 | # #
44 | # # for(i in fun_vec) {
45 | # # # assign(paste0(i,"s"), get(i), envir = .GlobalEnv)
46 | # # assign(i, get(i), envir = .teacher_env)
47 | # # }
48 | #
49 | #
50 | # assign(".teacher_env", new.env(), envir = .GlobalEnv) # create a new mystical env
51 | # source(file, local = .teacher_env) # brings all the functions to the local env created by the function
52 | #
53 | # NULL
54 | #
55 | # }
56 | # # run this everytime we want the teachers solutions
57 | # # create_solutions("sol\\HW_01_sol.R")
58 | #
59 |
60 |
61 | #' @title Change the first argument of a function
62 | #' @description
63 | #' Useful when the teacher uses a function like function(x) and the student
64 | #' does something like function(X) or function(y)
65 | #' If the student had the first argument correct, it would not be changed.
66 | #' @param fun the function to change
67 | #' @param first_arg the name of the first argument of the function to return, Default: x
68 | #' @return
69 | #' The original function, just with a different arg.
70 | #' @examples
71 | #' fo <- function(y, ...) {
72 | #' x+3
73 | #' }
74 | #' # fo(x=5) # errors...
75 | #' fo_x <- fix_first_arg_in_fun(fo, "x")
76 | #' fo_x(x=5)
77 | #' @rdname fix_first_arg_in_fun
78 | #' @export
79 | fix_first_arg_in_fun <- function(fun, first_arg = "x") {
80 | if (first_arg != names(formals(fun))[1]) {
81 | # n_Args <- length(formals(fun))
82 | formals(fun)[first_arg] <- NA
83 | # formals(fun)
84 | formals(fun)[[1]] <- as.name(first_arg)
85 | }
86 | fun
87 | }
88 |
89 |
90 | # ------ Function to check student vs teacher answers
91 | # -----------------------------
92 |
93 |
94 |
95 |
96 | #' @title FUNCTION_TITLE
97 | #' @description FUNCTION_DESCRIPTION
98 | #' @param hw_submitters a vector of .R files to check
99 | #' @param sol_file the location of the .R file with the correct solution.
100 | #' This file should have the functions that solves the homework's questions.
101 | #' @param tests_to_run a list with elements as the number of questions in the homework assignment.
102 | #' Each element in the list is named by the name of the function.
103 | #' So if the homework said to create a function called fo then the list will contain an element named "fo".
104 | #' The "fo" element will itself be a list with the inputs to check on the functions.
105 | #' If the input is NA then the function will be run as `fo()`.`
106 | #' If the function fo includes several parameters (say fo(a = "something", b = "another smthng")) then
107 | #' each element inside "fo" will be a list of the form list("input", "b input"). (you can also use
108 | #' list(a = "input", b = "b input") but then if the student wrote the function as function(A="not a", B = "not b")
109 | #' then his function would fail. Indicating the input just by the order makes it simpler).
110 | #' The function do.call will be used to run this input in fo.
111 | #' @param student_id_fun a character string indicating the name of the function a student was instructed to create that returns is id (for example my_id() {"id number"})
112 | #' If NULL, then the file name is used.
113 | #' @param timeout The number of seconds to wait for the function to end before deciding
114 | #' the student got into an infinite loop and to exist the function and declare the student failed to answer
115 | #' the question. Default: 0.5
116 | #' @param use_do.call if to force the use of do.call on the list_of_inputs. By default is not set, in which case the function will try to guess if to use it or not (based on the solution by the teacher and the arguments in the list_of_inputs)
117 | #' @param check_sol_fun the function to use to compare the solutions. if you wish to set a specific function for a test, the
118 | #' "check_sol_fun" attribute should be added to that test in the list.
119 | #' attr(current_test, "check_sol_fun")
120 | #' PARAM_DESCRIPTION, Default:
121 | #' function(student_sol, teacher_sol) {
122 | #' isTRUE(all.equal(
123 | #' student_sol, teacher_sol, tolerance = 0.01,
124 | #' check.attributes = FALSE
125 | #' ))
126 | #' }
127 | #' @param update_student_fun the function to use on the student's function to fix a problem.
128 | #' "update_student_fun" attribute can be added to that test in the list.
129 | #' default is NULL.
130 | #' this is when the teachers write fo <- function(x) {...}
131 | #' And the student writes fo <- function(y) {...}
132 | #' we can make sure to fix the student's mistake using:
133 | #' function(f) fix_first_arg_in_fun(f, "x")
134 | #' @return OUTPUT_DESCRIPTION
135 | #' @details DETAILS
136 | #' @examples
137 | #' \dontrun{
138 | #' if(interactive()){
139 | #' #EXAMPLE1
140 | #' }
141 | #' }
142 | #' @rdname test_students
143 | #' @importFrom R.utils withTimeout
144 | #' @export
145 | test_students <- function(hw_submitters, sol_file, tests_to_run,
146 | # student_id_fun = NULL, # my_id
147 | timeout = .5,
148 | use_do.call,
149 | check_sol_fun = function(student_sol, teacher_sol) {
150 | isTRUE(all.equal(student_sol, teacher_sol, tolerance = 1e-4, check.attributes = FALSE))
151 | },
152 | update_student_fun = NULL,
153 | max_grade = 100,
154 | mistakes_folder = "mistakes") {
155 |
156 | if(dir.exists(mistakes_folder)) {
157 | # clear all mistakes files
158 | unlink(list.files(mistakes_folder))
159 | } else { # let's make sure we have this folder available!
160 | dir.create(mistakes_folder)
161 | }
162 |
163 |
164 |
165 | grades <- data.frame(ID = NA)
166 |
167 | # get teacher's solutions
168 | # create_solutions(sol_file)
169 | # lsf.str(envir = .teacher_env)
170 |
171 | source_to_env(file = sol_file, env_name = ".teacher_env")
172 | # lsf.str(envir = .teacher_env)
173 | #
174 |
175 | functions_to_check <- names(tests_to_run)
176 |
177 | for (i in seq_along(hw_submitters)) {
178 |
179 |
180 | # no longer needed since we now use env
181 | # clear ALL functions except "create_solutions"
182 | # fun to remove:
183 | # rm(list=as.vector(lsf.str())[-1]) # -1 so to not remove "create_solutions"
184 |
185 |
186 | if (exists(".student_env")) rm(.student_env, envir = .GlobalEnv)
187 | assign(".student_env", NULL, envir = .GlobalEnv)
188 |
189 |
190 | # get student's functions
191 | # try(source(hw_submitters[i]), silent = TRUE)
192 | try(
193 | source_to_env(file = hw_submitters[i], env_name = ".student_env"),
194 | silent = TRUE
195 | )
196 |
197 |
198 | # if (is.null(student_id_fun)) {
199 | # # use file name
200 | # # https://stackoverflow.com/questions/2548815/find-file-name-from-full-file-path
201 | # grades[i, 1] <- basename(hw_submitters[i]) # gets the filename
202 | # current_id <- grades[i, 1]
203 | # } else {
204 | # # # lsf.str(envir = .student_env)
205 | # # moved to using the file name.
206 | # # ls()
207 | # # lsf.str()
208 | # try(my_id <- get(student_id_fun, envir = .student_env), silent = TRUE)
209 | # if (!exists("my_id")) next # skip current file since we don't have the my_id function!
210 | # try(grades[i, 1] <- my_id(), silent = TRUE)
211 | # current_id <- grades[i, 1]
212 | # }
213 | grades[i, 1] <- basename(hw_submitters[i]) # gets the filename
214 | current_id <- grades[i, 1]
215 |
216 | # if (!exists(".student_env")) next # skip current file as the source failed...
217 | if (length(.student_env) == 0) next
218 |
219 |
220 |
221 | # go through every question
222 | for (i_fun in functions_to_check) {
223 | fun_to_get <- i_fun
224 |
225 | fun_teacher <- if (exists(fun_to_get, envir = .teacher_env, inherits = FALSE)) {
226 | get(fun_to_get, envir = .teacher_env, inherits = FALSE)
227 | } else {
228 | function(...) {
229 | # i_tests will be defined later
230 | # this is used so to not print a warning everytime a test is run.
231 | if(i_tests == 1) warning("The function '",fun_to_get ,"' was not found in the solutions file!")
232 | }
233 | }
234 |
235 | fun_student_exists <- exists(fun_to_get, envir = .student_env, inherits = FALSE)
236 | fun_student <- if (fun_student_exists) {
237 | get(fun_to_get, envir = .student_env, inherits = FALSE)
238 | } else {
239 | function(...) {
240 | if(i_tests == 1) {
241 | warning("The function '",fun_to_get ,"' was not found in file: ", current_id)
242 | }
243 | return(paste0("The function '",fun_to_get ,"' was not found in file: ", current_id))
244 | }
245 | }
246 |
247 | # fun_student <- get(paste0("q", i_question), envir = .student_env)
248 |
249 | # get("q3", envir = .student_env)
250 |
251 | teachers_tests <- tests_to_run[[i_fun]]
252 | teachers_tests_seq <- if (all(is.na(teachers_tests))) 1 else seq_along(teachers_tests)
253 |
254 |
255 | current_test_attr <- names(attributes(teachers_tests))
256 |
257 | # this is when the teachers write fo <- function(x) {...}
258 | # And the student writes fo <- function(y) {...}
259 | # we can make sure to fix the student's mistake
260 | if (!is.null(update_student_fun)) {
261 | # a general fix to all questions
262 | fun_student <- update_student_fun(fun_student)
263 | }
264 | if ("update_student_fun" %in% current_test_attr) {
265 | # a specific fix to only one q
266 | fun_student <- attr(teachers_tests, "update_student_fun")(fun_student)
267 | }
268 |
269 |
270 | for (i_tests in teachers_tests_seq) {
271 | # teachers_tests = tests_to_run
272 | # i_tests = 2
273 | current_test <- teachers_tests[[i_tests]]
274 |
275 | student_sol <- "The function didn't complete"
276 | teacher_sol <- "The student's function didn't complete"
277 |
278 | # I'm using R.utils::withTimeout so to deal with infinite loops...
279 | # https://stackoverflow.com/questions/7891073/time-out-an-r-command-via-something-like-try
280 |
281 | # library(R.utils)
282 |
283 |
284 | if (missing(use_do.call)) {
285 | if (all(names(current_test) %in% names(formals(fun_teacher)))) {
286 | use_do.call <- TRUE
287 | } else {
288 | use_do.call <- FALSE
289 | }
290 | }
291 |
292 |
293 | R.utils::withTimeout({
294 | try({
295 | # if(is.list(current_test) && length(current_test) > 1) {
296 |
297 | if (is.na(current_test[1])) {
298 | student_sol <- fun_student()
299 | teacher_sol <- fun_teacher()
300 | } else {
301 | if (is.list(current_test) && use_do.call) {
302 | # then we must be having to use a function with several arguments
303 | student_sol <- do.call(fun_student, current_test)
304 | teacher_sol <- do.call(fun_teacher, current_test)
305 | } else {
306 | # it is a simple function with only one argument
307 | student_sol <- fun_student(current_test)
308 | teacher_sol <- fun_teacher(current_test)
309 | }
310 | }
311 | }, silent = TRUE)
312 | }, timeout = timeout, onTimeout = "warning")
313 |
314 | # post modifications due to issue that might happen from rounding or others
315 | if (!is.null(current_test_attr) & is.numeric(student_sol) & is.numeric(teacher_sol)) {
316 | if ("sort" %in% current_test_attr && isTRUE(attr(current_test, "sort"))) {
317 | student_sol <- sort(student_sol)
318 | teacher_sol <- sort(teacher_sol)
319 | }
320 | if ("round" %in% current_test_attr && is.numeric(attr(current_test, "round"))) {
321 | how_much_to_round <- attr(current_test, "round")
322 | # print(paste(how_much_to_round, "----------------------"))
323 | student_sol <- round(student_sol, how_much_to_round)
324 | teacher_sol <- round(teacher_sol, how_much_to_round)
325 | }
326 | }
327 |
328 | if ("check_sol_fun" %in% current_test_attr) {
329 | current_check_sol_fun <- attr(teachers_tests, "check_sol_fun")
330 | } else {
331 | current_check_sol_fun <- check_sol_fun
332 | }
333 |
334 |
335 | # is_correct_answer <- identical( student_sol, teacher_sol) # does not fully work...
336 | # is_correct_answer <- isTRUE(all.equal( student_sol, teacher_sol, tolerance = 1e-2))
337 |
338 | is_correct_answer <- current_check_sol_fun(student_sol, teacher_sol)
339 |
340 |
341 |
342 |
343 |
344 |
345 | # try(grades[i, paste0("q", i_question, "_test_", i_tests)] <-
346 | # identical( student_sol, teacher_sol) ,
347 | # silent = TRUE)
348 | # grades[i, paste0("q", i_question, "_test_", i_tests)] <- is_correct_answer
349 | grades[i, paste0(i_fun, "_test_", i_tests)] <- is_correct_answer
350 |
351 | if (!is_correct_answer) {
352 | # then - save the function and test to a file, so that the TA could more easily check it.
353 | # mistakes_file <- paste0(sol_file, "_students_errors.R")
354 | txt_fun_student <- if(fun_student_exists) {
355 | capture.output(dput(fun_student))
356 | } else {
357 | "# NULL! This function was not found in the student's .R file."
358 | }
359 | txt_current_test <- capture.output(current_test)
360 | txt_teacher_sol <- capture.output(teacher_sol)
361 | txt_student_sol <- capture.output(student_sol)
362 |
363 | mistakes_file <- file.path(mistakes_folder, paste0("mistakes_in_", i_fun, ".R"))
364 |
365 | write("# ======================", file = mistakes_file, append = TRUE)
366 | write(paste0("# Student's file: ", current_id), file = mistakes_file, append = TRUE)
367 | write("# ======================", file = mistakes_file, append = TRUE)
368 | write(paste0("# A wrong solution to question: ", i_fun, " test: ", i_tests), file = mistakes_file, append = TRUE)
369 | write("# The test:", file = mistakes_file, append = TRUE)
370 | write(txt_current_test, file = mistakes_file, append = TRUE)
371 | write("# --------------------", file = mistakes_file, append = TRUE)
372 | write("# The correct solution:", file = mistakes_file, append = TRUE)
373 | write(txt_teacher_sol, file = mistakes_file, append = TRUE)
374 | write("# --------------------", file = mistakes_file, append = TRUE)
375 | write("# The student's solution:", file = mistakes_file, append = TRUE)
376 | write(txt_student_sol, file = mistakes_file, append = TRUE)
377 | write("# --------------------", file = mistakes_file, append = TRUE)
378 | write("# The student's function:", file = mistakes_file, append = TRUE)
379 | write(txt_fun_student, file = mistakes_file, append = TRUE)
380 | write("# ======================", file = mistakes_file, append = TRUE)
381 | }
382 | }
383 | }
384 | }
385 |
386 | # all the errors mean the function failed
387 | grades[is.na(grades)] <- FALSE
388 |
389 |
390 | # hw_grades <- rowSums(grades[,-1] / (ncol(grades)-1)) * 150
391 | hw_grades <- rowMeans(grades[, -1, drop = FALSE]) * max_grade
392 |
393 | # last value is the median of the grades
394 | # question_difficulty <- c(colMeans(grades[,-1]) , median(hw_grades))
395 |
396 | grades[, "grade"] <- hw_grades
397 | # grades["question_difficulty",] <- question_difficulty
398 |
399 |
400 | # clean the .GlobalEnv
401 | rm(.student_env, envir = .GlobalEnv)
402 | rm(.teacher_env, envir = .GlobalEnv)
403 |
404 |
405 | grades
406 | }
407 |
408 |
409 | # https://stackoverflow.com/questions/7963898/extracting-the-last-n-characters-from-a-string-in-r
410 |
411 |
412 | #' @title FUNCTION_TITLE
413 | #' @description FUNCTION_DESCRIPTION
414 | #' @param x PARAM_DESCRIPTION
415 | #' @param n PARAM_DESCRIPTION
416 | #' @return OUTPUT_DESCRIPTION
417 | #' @details DETAILS
418 | #' @examples
419 | #' \dontrun{
420 | #' if(interactive()){
421 | #' #EXAMPLE1
422 | #' }
423 | #' }
424 | #' @rdname substrRight
425 | #' @export
426 | substrRight <- function(x, n) {
427 | substr(x, nchar(x) - n + 1, nchar(x))
428 | }
429 |
430 |
431 |
432 |
433 |
434 |
435 | #' @title Check that .R file can be sourced without errors
436 | #' @description
437 | #' The function gets a vector of .R file names and returns for each of them if it can be sourced or not.
438 | #' This is helpful as an initial step before checking the homework (to make sure it can be loaded).
439 | #' @param files a charachter vector of R file names to be sourced and checked if they can be run with no problem.
440 | #' @param ... not used.
441 | #' @return
442 | #' A data.frame with the name of the file, it's status (TRUE if was sourced properly, and FALSE otherwise),
443 | #' and a note indicating possible issues.
444 | #' @examples
445 | #' \dontrun{
446 | #' if(interactive()){
447 | #' #EXAMPLE1
448 | #' }
449 | #' }
450 | #' @rdname can_source
451 | #' @export
452 | can_source <- function(files, ...) {
453 | # find any errors...
454 | hw_submitters <- files
455 | file_status <- data.frame(file = files, status = TRUE, note = "ok", stringsAsFactors = FALSE)
456 | # outputs <- character(length(hw_submitters))
457 | for (i in seq_along(hw_submitters)) {
458 | # print(hw_submitters[i])
459 | # flush.console()
460 | source_failed <- TRUE
461 | source_txt <- character(0)
462 |
463 | try({
464 | source_txt <- capture.output(source(hw_submitters[i]))
465 | source_failed <- FALSE
466 | }, silent = TRUE)
467 |
468 | if (length(source_txt) > 0) {
469 | # outputs[i] <- tmp
470 | file_status$note[i] <- "Unnecessary printing of output when running source"
471 | # next
472 | }
473 | # } else {
474 | # }
475 | # else?! I have no idea how this coule happen...
476 | # source(hw_submitters[i])
477 | if (source_failed) {
478 | file_status$note[i] <- "Failed to source!"
479 | file_status$status[i] <- FALSE
480 | }
481 | }
482 |
483 | file_status
484 | }
485 |
486 |
487 |
488 |
489 | #' @title Get only .R files
490 | #' @description
491 | #' Give a vector of possible file names, returns only the ones that are .R files.
492 | #' @param files - a charachter vector of file names
493 | #' @param case_sensitive PARAM_DESCRIPTION, Default: FALSE
494 | #' @return only files which are R/r files.
495 | #' @examples
496 | #'
497 | #' files <- c("a", "b.R", "c.RR", "d.Rdata", "e.R")
498 | #' only_R_files(files)
499 | #'
500 | #' @seealso
501 | #' \code{\link[tools]{file_ext}}
502 | #' @rdname file_ext_to_keep
503 | #' @export
504 | #' @importFrom tools file_ext
505 | file_ext_to_keep <- function(files, file_ext = c("R"), case_sensitive = FALSE) {
506 | files_ext <- tools::file_ext(files)
507 | if (!case_sensitive) files_ext <- toupper(files_ext)
508 | files[files_ext %in% file_ext]
509 | }
510 |
511 |
512 | #' @rdname file_ext_to_keep
513 | #' @export
514 | only_R_files <- function(files, case_sensitive = FALSE) {
515 | file_ext_to_keep(files = files, file_ext = "R", case_sensitive = case_sensitive)
516 | }
517 |
518 |
519 |
520 |
521 | #' @title FUNCTION_TITLE
522 | #' @description FUNCTION_DESCRIPTION
523 | #' @param results PARAM_DESCRIPTION
524 | #' @param HW_number PARAM_DESCRIPTION
525 | #' @param tests_to_run PARAM_DESCRIPTION
526 | #' @param grades_folder PARAM_DESCRIPTION, Default: grades
527 | #' @param char_to_trim PARAM_DESCRIPTION, Default: 6
528 | #' @return OUTPUT_DESCRIPTION
529 | #' @details DETAILS
530 | #' @examples
531 | #' \dontrun{
532 | #' if(interactive()){
533 | #' #EXAMPLE1
534 | #' }
535 | #' }
536 | #' @rdname create_grade_files
537 | #' @export
538 | create_grade_files_OLD <- function(results, HW_number, tests_to_run, grades_folder = "grades\\", char_to_trim = 6) {
539 | results2 <- results
540 | success_per_question <- round(colMeans(results2[, -1]), 2) # this includes the mean final grade
541 | results2 <- rbind(results2, c("Success", success_per_question))
542 | write.csv(results2, paste0(grades_folder, HW_number, "_grades.csv"), row.names = FALSE)
543 |
544 | results2$ID[-nrow(results2)] <- substrRight(results2$ID[-nrow(results2)], char_to_trim)
545 | colnames(results2)[1] <- "ID (last 4 digits)"
546 | write.csv(results2, paste0(grades_folder, HW_number, "_grades_for_students.csv"), row.names = FALSE)
547 |
548 |
549 | # which questions should Yarden check (by order)
550 | tests_per_question <- sapply(tests_to_run, length)
551 | tests_per_question <- rep(names(tests_to_run), times = tests_per_question)
552 | success_per_question2 <- head(success_per_question, -1)
553 | success_per_question <- sort(tapply(success_per_question2, tests_per_question, mean))
554 | what_to_check <- data.frame(question = names(success_per_question), success_per_question = round(success_per_question, 2))
555 | write.csv(what_to_check, paste0(grades_folder, HW_number, "_what_to_chack.csv"), row.names = FALSE)
556 | #
557 | invisible(TRUE)
558 | }
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU General Public License
2 | ==========================
3 |
4 | _Version 3, 29 June 2007_
5 | _Copyright © 2007 Free Software Foundation, Inc. <>_
6 |
7 | Everyone is permitted to copy and distribute verbatim copies of this license
8 | document, but changing it is not allowed.
9 |
10 | ## Preamble
11 |
12 | The GNU General Public License is a free, copyleft license for software and other
13 | kinds of works.
14 |
15 | The licenses for most software and other practical works are designed to take away
16 | your freedom to share and change the works. By contrast, the GNU General Public
17 | License is intended to guarantee your freedom to share and change all versions of a
18 | program--to make sure it remains free software for all its users. We, the Free
19 | Software Foundation, use the GNU General Public License for most of our software; it
20 | applies also to any other work released this way by its authors. You can apply it to
21 | your programs, too.
22 |
23 | When we speak of free software, we are referring to freedom, not price. Our General
24 | Public Licenses are designed to make sure that you have the freedom to distribute
25 | copies of free software (and charge for them if you wish), that you receive source
26 | code or can get it if you want it, that you can change the software or use pieces of
27 | it in new free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you these rights or
30 | asking you to surrender the rights. Therefore, you have certain responsibilities if
31 | you distribute copies of the software, or if you modify it: responsibilities to
32 | respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether gratis or for a fee,
35 | you must pass on to the recipients the same freedoms that you received. You must make
36 | sure that they, too, receive or can get the source code. And you must show them these
37 | terms so they know their rights.
38 |
39 | Developers that use the GNU GPL protect your rights with two steps: **(1)** assert
40 | copyright on the software, and **(2)** offer you this License giving you legal permission
41 | to copy, distribute and/or modify it.
42 |
43 | For the developers' and authors' protection, the GPL clearly explains that there is
44 | no warranty for this free software. For both users' and authors' sake, the GPL
45 | requires that modified versions be marked as changed, so that their problems will not
46 | be attributed erroneously to authors of previous versions.
47 |
48 | Some devices are designed to deny users access to install or run modified versions of
49 | the software inside them, although the manufacturer can do so. This is fundamentally
50 | incompatible with the aim of protecting users' freedom to change the software. The
51 | systematic pattern of such abuse occurs in the area of products for individuals to
52 | use, which is precisely where it is most unacceptable. Therefore, we have designed
53 | this version of the GPL to prohibit the practice for those products. If such problems
54 | arise substantially in other domains, we stand ready to extend this provision to
55 | those domains in future versions of the GPL, as needed to protect the freedom of
56 | users.
57 |
58 | Finally, every program is threatened constantly by software patents. States should
59 | not allow patents to restrict development and use of software on general-purpose
60 | computers, but in those that do, we wish to avoid the special danger that patents
61 | applied to a free program could make it effectively proprietary. To prevent this, the
62 | GPL assures that patents cannot be used to render the program non-free.
63 |
64 | The precise terms and conditions for copying, distribution and modification follow.
65 |
66 | ## TERMS AND CONDITIONS
67 |
68 | ### 0. Definitions
69 |
70 | “This License” refers to version 3 of the GNU General Public License.
71 |
72 | “Copyright” also means copyright-like laws that apply to other kinds of
73 | works, such as semiconductor masks.
74 |
75 | “The Program” refers to any copyrightable work licensed under this
76 | License. Each licensee is addressed as “you”. “Licensees” and
77 | “recipients” may be individuals or organizations.
78 |
79 | To “modify” a work means to copy from or adapt all or part of the work in
80 | a fashion requiring copyright permission, other than the making of an exact copy. The
81 | resulting work is called a “modified version” of the earlier work or a
82 | work “based on” the earlier work.
83 |
84 | A “covered work” means either the unmodified Program or a work based on
85 | the Program.
86 |
87 | To “propagate” a work means to do anything with it that, without
88 | permission, would make you directly or secondarily liable for infringement under
89 | applicable copyright law, except executing it on a computer or modifying a private
90 | copy. Propagation includes copying, distribution (with or without modification),
91 | making available to the public, and in some countries other activities as well.
92 |
93 | To “convey” a work means any kind of propagation that enables other
94 | parties to make or receive copies. Mere interaction with a user through a computer
95 | network, with no transfer of a copy, is not conveying.
96 |
97 | An interactive user interface displays “Appropriate Legal Notices” to the
98 | extent that it includes a convenient and prominently visible feature that **(1)**
99 | displays an appropriate copyright notice, and **(2)** tells the user that there is no
100 | warranty for the work (except to the extent that warranties are provided), that
101 | licensees may convey the work under this License, and how to view a copy of this
102 | License. If the interface presents a list of user commands or options, such as a
103 | menu, a prominent item in the list meets this criterion.
104 |
105 | ### 1. Source Code
106 |
107 | The “source code” for a work means the preferred form of the work for
108 | making modifications to it. “Object code” means any non-source form of a
109 | work.
110 |
111 | A “Standard Interface” means an interface that either is an official
112 | standard defined by a recognized standards body, or, in the case of interfaces
113 | specified for a particular programming language, one that is widely used among
114 | developers working in that language.
115 |
116 | The “System Libraries” of an executable work include anything, other than
117 | the work as a whole, that **(a)** is included in the normal form of packaging a Major
118 | Component, but which is not part of that Major Component, and **(b)** serves only to
119 | enable use of the work with that Major Component, or to implement a Standard
120 | Interface for which an implementation is available to the public in source code form.
121 | A “Major Component”, in this context, means a major essential component
122 | (kernel, window system, and so on) of the specific operating system (if any) on which
123 | the executable work runs, or a compiler used to produce the work, or an object code
124 | interpreter used to run it.
125 |
126 | The “Corresponding Source” for a work in object code form means all the
127 | source code needed to generate, install, and (for an executable work) run the object
128 | code and to modify the work, including scripts to control those activities. However,
129 | it does not include the work's System Libraries, or general-purpose tools or
130 | generally available free programs which are used unmodified in performing those
131 | activities but which are not part of the work. For example, Corresponding Source
132 | includes interface definition files associated with source files for the work, and
133 | the source code for shared libraries and dynamically linked subprograms that the work
134 | is specifically designed to require, such as by intimate data communication or
135 | control flow between those subprograms and other parts of the work.
136 |
137 | The Corresponding Source need not include anything that users can regenerate
138 | automatically from other parts of the Corresponding Source.
139 |
140 | The Corresponding Source for a work in source code form is that same work.
141 |
142 | ### 2. Basic Permissions
143 |
144 | All rights granted under this License are granted for the term of copyright on the
145 | Program, and are irrevocable provided the stated conditions are met. This License
146 | explicitly affirms your unlimited permission to run the unmodified Program. The
147 | output from running a covered work is covered by this License only if the output,
148 | given its content, constitutes a covered work. This License acknowledges your rights
149 | of fair use or other equivalent, as provided by copyright law.
150 |
151 | You may make, run and propagate covered works that you do not convey, without
152 | conditions so long as your license otherwise remains in force. You may convey covered
153 | works to others for the sole purpose of having them make modifications exclusively
154 | for you, or provide you with facilities for running those works, provided that you
155 | comply with the terms of this License in conveying all material for which you do not
156 | control copyright. Those thus making or running the covered works for you must do so
157 | exclusively on your behalf, under your direction and control, on terms that prohibit
158 | them from making any copies of your copyrighted material outside their relationship
159 | with you.
160 |
161 | Conveying under any other circumstances is permitted solely under the conditions
162 | stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
163 |
164 | ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law
165 |
166 | No covered work shall be deemed part of an effective technological measure under any
167 | applicable law fulfilling obligations under article 11 of the WIPO copyright treaty
168 | adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention
169 | of such measures.
170 |
171 | When you convey a covered work, you waive any legal power to forbid circumvention of
172 | technological measures to the extent such circumvention is effected by exercising
173 | rights under this License with respect to the covered work, and you disclaim any
174 | intention to limit operation or modification of the work as a means of enforcing,
175 | against the work's users, your or third parties' legal rights to forbid circumvention
176 | of technological measures.
177 |
178 | ### 4. Conveying Verbatim Copies
179 |
180 | You may convey verbatim copies of the Program's source code as you receive it, in any
181 | medium, provided that you conspicuously and appropriately publish on each copy an
182 | appropriate copyright notice; keep intact all notices stating that this License and
183 | any non-permissive terms added in accord with section 7 apply to the code; keep
184 | intact all notices of the absence of any warranty; and give all recipients a copy of
185 | this License along with the Program.
186 |
187 | You may charge any price or no price for each copy that you convey, and you may offer
188 | support or warranty protection for a fee.
189 |
190 | ### 5. Conveying Modified Source Versions
191 |
192 | You may convey a work based on the Program, or the modifications to produce it from
193 | the Program, in the form of source code under the terms of section 4, provided that
194 | you also meet all of these conditions:
195 |
196 | * **a)** The work must carry prominent notices stating that you modified it, and giving a
197 | relevant date.
198 | * **b)** The work must carry prominent notices stating that it is released under this
199 | License and any conditions added under section 7. This requirement modifies the
200 | requirement in section 4 to “keep intact all notices”.
201 | * **c)** You must license the entire work, as a whole, under this License to anyone who
202 | comes into possession of a copy. This License will therefore apply, along with any
203 | applicable section 7 additional terms, to the whole of the work, and all its parts,
204 | regardless of how they are packaged. This License gives no permission to license the
205 | work in any other way, but it does not invalidate such permission if you have
206 | separately received it.
207 | * **d)** If the work has interactive user interfaces, each must display Appropriate Legal
208 | Notices; however, if the Program has interactive interfaces that do not display
209 | Appropriate Legal Notices, your work need not make them do so.
210 |
211 | A compilation of a covered work with other separate and independent works, which are
212 | not by their nature extensions of the covered work, and which are not combined with
213 | it such as to form a larger program, in or on a volume of a storage or distribution
214 | medium, is called an “aggregate” if the compilation and its resulting
215 | copyright are not used to limit the access or legal rights of the compilation's users
216 | beyond what the individual works permit. Inclusion of a covered work in an aggregate
217 | does not cause this License to apply to the other parts of the aggregate.
218 |
219 | ### 6. Conveying Non-Source Forms
220 |
221 | You may convey a covered work in object code form under the terms of sections 4 and
222 | 5, provided that you also convey the machine-readable Corresponding Source under the
223 | terms of this License, in one of these ways:
224 |
225 | * **a)** Convey the object code in, or embodied in, a physical product (including a
226 | physical distribution medium), accompanied by the Corresponding Source fixed on a
227 | durable physical medium customarily used for software interchange.
228 | * **b)** Convey the object code in, or embodied in, a physical product (including a
229 | physical distribution medium), accompanied by a written offer, valid for at least
230 | three years and valid for as long as you offer spare parts or customer support for
231 | that product model, to give anyone who possesses the object code either **(1)** a copy of
232 | the Corresponding Source for all the software in the product that is covered by this
233 | License, on a durable physical medium customarily used for software interchange, for
234 | a price no more than your reasonable cost of physically performing this conveying of
235 | source, or **(2)** access to copy the Corresponding Source from a network server at no
236 | charge.
237 | * **c)** Convey individual copies of the object code with a copy of the written offer to
238 | provide the Corresponding Source. This alternative is allowed only occasionally and
239 | noncommercially, and only if you received the object code with such an offer, in
240 | accord with subsection 6b.
241 | * **d)** Convey the object code by offering access from a designated place (gratis or for
242 | a charge), and offer equivalent access to the Corresponding Source in the same way
243 | through the same place at no further charge. You need not require recipients to copy
244 | the Corresponding Source along with the object code. If the place to copy the object
245 | code is a network server, the Corresponding Source may be on a different server
246 | (operated by you or a third party) that supports equivalent copying facilities,
247 | provided you maintain clear directions next to the object code saying where to find
248 | the Corresponding Source. Regardless of what server hosts the Corresponding Source,
249 | you remain obligated to ensure that it is available for as long as needed to satisfy
250 | these requirements.
251 | * **e)** Convey the object code using peer-to-peer transmission, provided you inform
252 | other peers where the object code and Corresponding Source of the work are being
253 | offered to the general public at no charge under subsection 6d.
254 |
255 | A separable portion of the object code, whose source code is excluded from the
256 | Corresponding Source as a System Library, need not be included in conveying the
257 | object code work.
258 |
259 | A “User Product” is either **(1)** a “consumer product”, which
260 | means any tangible personal property which is normally used for personal, family, or
261 | household purposes, or **(2)** anything designed or sold for incorporation into a
262 | dwelling. In determining whether a product is a consumer product, doubtful cases
263 | shall be resolved in favor of coverage. For a particular product received by a
264 | particular user, “normally used” refers to a typical or common use of
265 | that class of product, regardless of the status of the particular user or of the way
266 | in which the particular user actually uses, or expects or is expected to use, the
267 | product. A product is a consumer product regardless of whether the product has
268 | substantial commercial, industrial or non-consumer uses, unless such uses represent
269 | the only significant mode of use of the product.
270 |
271 | “Installation Information” for a User Product means any methods,
272 | procedures, authorization keys, or other information required to install and execute
273 | modified versions of a covered work in that User Product from a modified version of
274 | its Corresponding Source. The information must suffice to ensure that the continued
275 | functioning of the modified object code is in no case prevented or interfered with
276 | solely because modification has been made.
277 |
278 | If you convey an object code work under this section in, or with, or specifically for
279 | use in, a User Product, and the conveying occurs as part of a transaction in which
280 | the right of possession and use of the User Product is transferred to the recipient
281 | in perpetuity or for a fixed term (regardless of how the transaction is
282 | characterized), the Corresponding Source conveyed under this section must be
283 | accompanied by the Installation Information. But this requirement does not apply if
284 | neither you nor any third party retains the ability to install modified object code
285 | on the User Product (for example, the work has been installed in ROM).
286 |
287 | The requirement to provide Installation Information does not include a requirement to
288 | continue to provide support service, warranty, or updates for a work that has been
289 | modified or installed by the recipient, or for the User Product in which it has been
290 | modified or installed. Access to a network may be denied when the modification itself
291 | materially and adversely affects the operation of the network or violates the rules
292 | and protocols for communication across the network.
293 |
294 | Corresponding Source conveyed, and Installation Information provided, in accord with
295 | this section must be in a format that is publicly documented (and with an
296 | implementation available to the public in source code form), and must require no
297 | special password or key for unpacking, reading or copying.
298 |
299 | ### 7. Additional Terms
300 |
301 | “Additional permissions” are terms that supplement the terms of this
302 | License by making exceptions from one or more of its conditions. Additional
303 | permissions that are applicable to the entire Program shall be treated as though they
304 | were included in this License, to the extent that they are valid under applicable
305 | law. If additional permissions apply only to part of the Program, that part may be
306 | used separately under those permissions, but the entire Program remains governed by
307 | this License without regard to the additional permissions.
308 |
309 | When you convey a copy of a covered work, you may at your option remove any
310 | additional permissions from that copy, or from any part of it. (Additional
311 | permissions may be written to require their own removal in certain cases when you
312 | modify the work.) You may place additional permissions on material, added by you to a
313 | covered work, for which you have or can give appropriate copyright permission.
314 |
315 | Notwithstanding any other provision of this License, for material you add to a
316 | covered work, you may (if authorized by the copyright holders of that material)
317 | supplement the terms of this License with terms:
318 |
319 | * **a)** Disclaiming warranty or limiting liability differently from the terms of
320 | sections 15 and 16 of this License; or
321 | * **b)** Requiring preservation of specified reasonable legal notices or author
322 | attributions in that material or in the Appropriate Legal Notices displayed by works
323 | containing it; or
324 | * **c)** Prohibiting misrepresentation of the origin of that material, or requiring that
325 | modified versions of such material be marked in reasonable ways as different from the
326 | original version; or
327 | * **d)** Limiting the use for publicity purposes of names of licensors or authors of the
328 | material; or
329 | * **e)** Declining to grant rights under trademark law for use of some trade names,
330 | trademarks, or service marks; or
331 | * **f)** Requiring indemnification of licensors and authors of that material by anyone
332 | who conveys the material (or modified versions of it) with contractual assumptions of
333 | liability to the recipient, for any liability that these contractual assumptions
334 | directly impose on those licensors and authors.
335 |
336 | All other non-permissive additional terms are considered “further
337 | restrictions” within the meaning of section 10. If the Program as you received
338 | it, or any part of it, contains a notice stating that it is governed by this License
339 | along with a term that is a further restriction, you may remove that term. If a
340 | license document contains a further restriction but permits relicensing or conveying
341 | under this License, you may add to a covered work material governed by the terms of
342 | that license document, provided that the further restriction does not survive such
343 | relicensing or conveying.
344 |
345 | If you add terms to a covered work in accord with this section, you must place, in
346 | the relevant source files, a statement of the additional terms that apply to those
347 | files, or a notice indicating where to find the applicable terms.
348 |
349 | Additional terms, permissive or non-permissive, may be stated in the form of a
350 | separately written license, or stated as exceptions; the above requirements apply
351 | either way.
352 |
353 | ### 8. Termination
354 |
355 | You may not propagate or modify a covered work except as expressly provided under
356 | this License. Any attempt otherwise to propagate or modify it is void, and will
357 | automatically terminate your rights under this License (including any patent licenses
358 | granted under the third paragraph of section 11).
359 |
360 | However, if you cease all violation of this License, then your license from a
361 | particular copyright holder is reinstated **(a)** provisionally, unless and until the
362 | copyright holder explicitly and finally terminates your license, and **(b)** permanently,
363 | if the copyright holder fails to notify you of the violation by some reasonable means
364 | prior to 60 days after the cessation.
365 |
366 | Moreover, your license from a particular copyright holder is reinstated permanently
367 | if the copyright holder notifies you of the violation by some reasonable means, this
368 | is the first time you have received notice of violation of this License (for any
369 | work) from that copyright holder, and you cure the violation prior to 30 days after
370 | your receipt of the notice.
371 |
372 | Termination of your rights under this section does not terminate the licenses of
373 | parties who have received copies or rights from you under this License. If your
374 | rights have been terminated and not permanently reinstated, you do not qualify to
375 | receive new licenses for the same material under section 10.
376 |
377 | ### 9. Acceptance Not Required for Having Copies
378 |
379 | You are not required to accept this License in order to receive or run a copy of the
380 | Program. Ancillary propagation of a covered work occurring solely as a consequence of
381 | using peer-to-peer transmission to receive a copy likewise does not require
382 | acceptance. However, nothing other than this License grants you permission to
383 | propagate or modify any covered work. These actions infringe copyright if you do not
384 | accept this License. Therefore, by modifying or propagating a covered work, you
385 | indicate your acceptance of this License to do so.
386 |
387 | ### 10. Automatic Licensing of Downstream Recipients
388 |
389 | Each time you convey a covered work, the recipient automatically receives a license
390 | from the original licensors, to run, modify and propagate that work, subject to this
391 | License. You are not responsible for enforcing compliance by third parties with this
392 | License.
393 |
394 | An “entity transaction” is a transaction transferring control of an
395 | organization, or substantially all assets of one, or subdividing an organization, or
396 | merging organizations. If propagation of a covered work results from an entity
397 | transaction, each party to that transaction who receives a copy of the work also
398 | receives whatever licenses to the work the party's predecessor in interest had or
399 | could give under the previous paragraph, plus a right to possession of the
400 | Corresponding Source of the work from the predecessor in interest, if the predecessor
401 | has it or can get it with reasonable efforts.
402 |
403 | You may not impose any further restrictions on the exercise of the rights granted or
404 | affirmed under this License. For example, you may not impose a license fee, royalty,
405 | or other charge for exercise of rights granted under this License, and you may not
406 | initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging
407 | that any patent claim is infringed by making, using, selling, offering for sale, or
408 | importing the Program or any portion of it.
409 |
410 | ### 11. Patents
411 |
412 | A “contributor” is a copyright holder who authorizes use under this
413 | License of the Program or a work on which the Program is based. The work thus
414 | licensed is called the contributor's “contributor version”.
415 |
416 | A contributor's “essential patent claims” are all patent claims owned or
417 | controlled by the contributor, whether already acquired or hereafter acquired, that
418 | would be infringed by some manner, permitted by this License, of making, using, or
419 | selling its contributor version, but do not include claims that would be infringed
420 | only as a consequence of further modification of the contributor version. For
421 | purposes of this definition, “control” includes the right to grant patent
422 | sublicenses in a manner consistent with the requirements of this License.
423 |
424 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license
425 | under the contributor's essential patent claims, to make, use, sell, offer for sale,
426 | import and otherwise run, modify and propagate the contents of its contributor
427 | version.
428 |
429 | In the following three paragraphs, a “patent license” is any express
430 | agreement or commitment, however denominated, not to enforce a patent (such as an
431 | express permission to practice a patent or covenant not to sue for patent
432 | infringement). To “grant” such a patent license to a party means to make
433 | such an agreement or commitment not to enforce a patent against the party.
434 |
435 | If you convey a covered work, knowingly relying on a patent license, and the
436 | Corresponding Source of the work is not available for anyone to copy, free of charge
437 | and under the terms of this License, through a publicly available network server or
438 | other readily accessible means, then you must either **(1)** cause the Corresponding
439 | Source to be so available, or **(2)** arrange to deprive yourself of the benefit of the
440 | patent license for this particular work, or **(3)** arrange, in a manner consistent with
441 | the requirements of this License, to extend the patent license to downstream
442 | recipients. “Knowingly relying” means you have actual knowledge that, but
443 | for the patent license, your conveying the covered work in a country, or your
444 | recipient's use of the covered work in a country, would infringe one or more
445 | identifiable patents in that country that you have reason to believe are valid.
446 |
447 | If, pursuant to or in connection with a single transaction or arrangement, you
448 | convey, or propagate by procuring conveyance of, a covered work, and grant a patent
449 | license to some of the parties receiving the covered work authorizing them to use,
450 | propagate, modify or convey a specific copy of the covered work, then the patent
451 | license you grant is automatically extended to all recipients of the covered work and
452 | works based on it.
453 |
454 | A patent license is “discriminatory” if it does not include within the
455 | scope of its coverage, prohibits the exercise of, or is conditioned on the
456 | non-exercise of one or more of the rights that are specifically granted under this
457 | License. You may not convey a covered work if you are a party to an arrangement with
458 | a third party that is in the business of distributing software, under which you make
459 | payment to the third party based on the extent of your activity of conveying the
460 | work, and under which the third party grants, to any of the parties who would receive
461 | the covered work from you, a discriminatory patent license **(a)** in connection with
462 | copies of the covered work conveyed by you (or copies made from those copies), or **(b)**
463 | primarily for and in connection with specific products or compilations that contain
464 | the covered work, unless you entered into that arrangement, or that patent license
465 | was granted, prior to 28 March 2007.
466 |
467 | Nothing in this License shall be construed as excluding or limiting any implied
468 | license or other defenses to infringement that may otherwise be available to you
469 | under applicable patent law.
470 |
471 | ### 12. No Surrender of Others' Freedom
472 |
473 | If conditions are imposed on you (whether by court order, agreement or otherwise)
474 | that contradict the conditions of this License, they do not excuse you from the
475 | conditions of this License. If you cannot convey a covered work so as to satisfy
476 | simultaneously your obligations under this License and any other pertinent
477 | obligations, then as a consequence you may not convey it at all. For example, if you
478 | agree to terms that obligate you to collect a royalty for further conveying from
479 | those to whom you convey the Program, the only way you could satisfy both those terms
480 | and this License would be to refrain entirely from conveying the Program.
481 |
482 | ### 13. Use with the GNU Affero General Public License
483 |
484 | Notwithstanding any other provision of this License, you have permission to link or
485 | combine any covered work with a work licensed under version 3 of the GNU Affero
486 | General Public License into a single combined work, and to convey the resulting work.
487 | The terms of this License will continue to apply to the part which is the covered
488 | work, but the special requirements of the GNU Affero General Public License, section
489 | 13, concerning interaction through a network will apply to the combination as such.
490 |
491 | ### 14. Revised Versions of this License
492 |
493 | The Free Software Foundation may publish revised and/or new versions of the GNU
494 | General Public License from time to time. Such new versions will be similar in spirit
495 | to the present version, but may differ in detail to address new problems or concerns.
496 |
497 | Each version is given a distinguishing version number. If the Program specifies that
498 | a certain numbered version of the GNU General Public License “or any later
499 | version” applies to it, you have the option of following the terms and
500 | conditions either of that numbered version or of any later version published by the
501 | Free Software Foundation. If the Program does not specify a version number of the GNU
502 | General Public License, you may choose any version ever published by the Free
503 | Software Foundation.
504 |
505 | If the Program specifies that a proxy can decide which future versions of the GNU
506 | General Public License can be used, that proxy's public statement of acceptance of a
507 | version permanently authorizes you to choose that version for the Program.
508 |
509 | Later license versions may give you additional or different permissions. However, no
510 | additional obligations are imposed on any author or copyright holder as a result of
511 | your choosing to follow a later version.
512 |
513 | ### 15. Disclaimer of Warranty
514 |
515 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
516 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
517 | PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
518 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
519 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
520 | QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
521 | DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
522 |
523 | ### 16. Limitation of Liability
524 |
525 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
526 | COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
527 | PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
528 | INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
529 | PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE
530 | OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
531 | WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
532 | POSSIBILITY OF SUCH DAMAGES.
533 |
534 | ### 17. Interpretation of Sections 15 and 16
535 |
536 | If the disclaimer of warranty and limitation of liability provided above cannot be
537 | given local legal effect according to their terms, reviewing courts shall apply local
538 | law that most closely approximates an absolute waiver of all civil liability in
539 | connection with the Program, unless a warranty or assumption of liability accompanies
540 | a copy of the Program in return for a fee.
541 |
542 | _END OF TERMS AND CONDITIONS_
543 |
544 | ## How to Apply These Terms to Your New Programs
545 |
546 | If you develop a new program, and you want it to be of the greatest possible use to
547 | the public, the best way to achieve this is to make it free software which everyone
548 | can redistribute and change under these terms.
549 |
550 | To do so, attach the following notices to the program. It is safest to attach them
551 | to the start of each source file to most effectively state the exclusion of warranty;
552 | and each file should have at least the “copyright” line and a pointer to
553 | where the full notice is found.
554 |
555 |
556 | Copyright (C)
557 |
558 | This program is free software: you can redistribute it and/or modify
559 | it under the terms of the GNU General Public License as published by
560 | the Free Software Foundation, either version 3 of the License, or
561 | (at your option) any later version.
562 |
563 | This program is distributed in the hope that it will be useful,
564 | but WITHOUT ANY WARRANTY; without even the implied warranty of
565 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
566 | GNU General Public License for more details.
567 |
568 | You should have received a copy of the GNU General Public License
569 | along with this program. If not, see .
570 |
571 | Also add information on how to contact you by electronic and paper mail.
572 |
573 | If the program does terminal interaction, make it output a short notice like this
574 | when it starts in an interactive mode:
575 |
576 | Copyright (C)
577 | This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
578 | This is free software, and you are welcome to redistribute it
579 | under certain conditions; type 'show c' for details.
580 |
581 | The hypothetical commands `show w` and `show c` should show the appropriate parts of
582 | the General Public License. Of course, your program's commands might be different;
583 | for a GUI interface, you would use an “about box”.
584 |
585 | You should also get your employer (if you work as a programmer) or school, if any, to
586 | sign a “copyright disclaimer” for the program, if necessary. For more
587 | information on this, and how to apply and follow the GNU GPL, see
588 | <>.
589 |
590 | The GNU General Public License does not permit incorporating your program into
591 | proprietary programs. If your program is a subroutine library, you may consider it
592 | more useful to permit linking proprietary applications with the library. If this is
593 | what you want to do, use the GNU Lesser General Public License instead of this
594 | License. But first, please read
595 | <>.
596 |
--------------------------------------------------------------------------------