Difference between revisions of "Congestion charge"

From Testiwiki
Jump to: navigation, search
(first draft of item management code based on op_fi:Malline:Kommentointityökalu)
 
(codes for adding and showing relations and evaluations added)
Line 22: Line 22:
 
} else {
 
} else {
 
at <- "append"
 
at <- "append"
obs <- obs$JaeID
+
obs <- obs$ID
 
obs <- gsub("[A-Za-z]", "", as.character(obs))
 
obs <- gsub("[A-Za-z]", "", as.character(obs))
obs <- max(as.numeric(obs)) + 1
+
obs <- max(as.integer(obs)) + 1
 
}
 
}
 
} else {
 
} else {
Line 39: Line 39:
 
)
 
)
 
oprint(dat)
 
oprint(dat)
ident
 
pagename
 
at
 
wiki_username
 
  
 
opbase.upload(
 
opbase.upload(
Line 71: Line 67:
 
)
 
)
 
}
 
}
oprint("Your comment has been successfully saved.")
+
cat("Your item has been successfully saved.\n")
 +
</rcode>
 +
 
 +
== Add a relation ==
 +
 
 +
<rcode name="add_relation" embed=1 label="Add a relation" showcode=-1 variables="
 +
name:subject|description:The ID of the subject in the relation|type:text|
 +
name:predicate|description:What is the relation (predicate)?|type:selection|options:
 +
'connects';connects with (by some non-specified way);
 +
'can coincide with';can conincide with;
 +
'instance of';is an instance of class;
 +
'subclass of';is a subclass of class|
 +
name:object|description:The ID of the object in the relation|type:text|
 +
name:name|description:A short name for the relation|type:text|
 +
name:pagename|type:hidden|default:'{{PAGENAME}}'|
 +
name:ident|type:hidden|default:'Op_en{{PAGEID}}'
 +
">
 +
library(OpasnetUtils)
 +
 
 +
obs <- tryCatch(
 +
opbase.data(ident, subset = "Relations"),
 +
error = function(...) return(NULL)
 +
)
 +
 
 +
if (!is.null(obs)) {
 +
if ("Obs" %in% colnames(obs)) {
 +
at <- "replace"
 +
obs <- 1
 +
} else {
 +
at <- "append"
 +
obs <- obs$Rel_ID
 +
obs <- gsub("[A-Za-z]", "", as.character(obs))
 +
obs <- max(as.integer(obs)) + 1
 +
}
 +
} else {
 +
at <- "replace"
 +
obs <- 1
 +
}
 +
dat <- data.frame(
 +
Rel_ID = obs,
 +
Timestamp = date(),
 +
User = wiki_username,
 +
Subject = subject,
 +
Predicate = predicate,
 +
Object = object,
 +
Result = name
 +
)
 +
oprint(dat)
 +
 
 +
opbase.upload(
 +
dat,
 +
ident = ident,
 +
name = pagename,
 +
subset = "Relations",
 +
act_type = at,
 +
language = "eng",
 +
who = wiki_username
 +
)
 +
 
 +
if (at == "replace") {
 +
dat <- data.frame(
 +
Timestamp = date(),
 +
User = wiki_username,
 +
Reason = "Initiation",
 +
Result = "NA"
 +
)
 +
opbase.upload(
 +
dat,
 +
ident = ident,
 +
name = pagename,
 +
subset = "Relationremoves",
 +
act_type = at,
 +
language = "eng",
 +
who = wiki_username
 +
)
 +
}
 +
cat("Your relation has been successfully saved.\n")
 +
</rcode>
 +
 
 +
== Evaluate an item or relation for its truth value ==
 +
 
 +
<rcode name="add_tru" embed=1 label="Add a truth value" showcode=-1 variables="
 +
name:type|description:Is the truth value for an item or a relation?|type:selection|options:
 +
'Item';For an item;'Relation';For a relation|
 +
name:object|description:The ID of the item or relation you want to evaluate|type:text|
 +
name:description|description:A short description for the evaluation|type:textbox|
 +
name:evaluation|description:Is the item or relation true?|type:selection|options:
 +
'True';It is true;'Maybe';It is maybe true;'False';It is false|
 +
name:pagename|type:hidden|default:'{{PAGENAME}}'|
 +
name:ident|type:hidden|default:'Op_en{{PAGEID}}'
 +
">
 +
library(OpasnetUtils)
 +
 
 +
obs <- tryCatch(
 +
opbase.data(ident, subset = "Evaluations"),
 +
error = function(...) return(NULL)
 +
)
 +
oprint(obs)
 +
if (!is.null(obs)) {
 +
if ("Obs" %in% colnames(obs)) {
 +
at <- "replace"
 +
obs <- 1
 +
} else {
 +
at <- "append"
 +
obs <- obs$Eva_ID
 +
obs <- gsub("[A-Za-z]", "", as.character(obs))
 +
obs <- max(as.integer(obs)) + 1
 +
}
 +
} else {
 +
at <- "replace"
 +
obs <- 1
 +
}
 +
dat <- data.frame(
 +
Eva_ID = obs,
 +
Timestamp = date(),
 +
User = wiki_username,
 +
Type = type,
 +
Object = object,
 +
Description = description,
 +
Result = evaluation
 +
)
 +
oprint(dat)
 +
 
 +
opbase.upload(
 +
dat,
 +
ident = ident,
 +
name = pagename,
 +
subset = "Evaluations",
 +
act_type = at,
 +
language = "eng",
 +
who = wiki_username
 +
)
 +
 
 +
if (at == "replace") {
 +
dat <- data.frame(
 +
Timestamp = date(),
 +
User = wiki_username,
 +
Reason = "Initiation",
 +
Result = "NA"
 +
)
 +
opbase.upload(
 +
dat,
 +
ident = ident,
 +
name = pagename,
 +
subset = "Evaluationremoves",
 +
act_type = at,
 +
language = "eng",
 +
who = wiki_username
 +
)
 +
}
 +
cat("Your evaluation has been successfully saved.\n")
 
</rcode>
 
</rcode>
  
Line 82: Line 228:
 
">
 
">
 
library(OpasnetUtils)
 
library(OpasnetUtils)
library(OpasnetUtilsExt)
 
  
 
pagename <- gsub(" ", "_", pagename)
 
pagename <- gsub(" ", "_", pagename)
Line 100: Line 245:
 
if(nrow(dat) == 0) {
 
if(nrow(dat) == 0) {
 
oprint("No items to show.")
 
oprint("No items to show.")
 +
} else {
 +
oprint(dat, include.rownames = FALSE)
 +
}
 +
}
 +
</rcode>
 +
 +
;<span id="Items">Current discussion relations.</span>
 +
 +
<rcode name="show_relation" label="Show relations" embed=1 showcode=-1 variables="
 +
name:ident|type:hidden|default:'Op_en{{PAGEID}}'|
 +
name:pagename|type:hidden|default:'{{PAGENAME}}'
 +
">
 +
library(OpasnetUtils)
 +
 +
pagename <- gsub(" ", "_", pagename)
 +
dat <- tryCatch(
 +
opbase.data(ident, subset = "Relations"),
 +
error = function(...) return(NULL)
 +
)
 +
 +
if (is.null(dat)) oprint("No relations were found") else {
 +
poistot <- tryCatch(
 +
opbase.data(ident, subset = "Relationremoves"),
 +
error = function(...) return(NULL)
 +
)
 +
 +
if (!is.null(poistot)) dat <- dat[!dat$Rel_ID %in% poistot$Result, ]
 +
 +
if(nrow(dat) == 0) {
 +
oprint("No relations to show.")
 +
} else {
 +
oprint(dat, include.rownames = FALSE)
 +
}
 +
}
 +
</rcode>
 +
 +
;<span id="Evaluations">Current evaluations.</span>
 +
 +
<rcode name="show_evaluation" label="Show evaluations" embed=1 showcode=-1 variables="
 +
name:ident|type:hidden|default:'Op_en{{PAGEID}}'|
 +
name:pagename|type:hidden|default:'{{PAGENAME}}'
 +
">
 +
library(OpasnetUtils)
 +
 +
pagename <- gsub(" ", "_", pagename)
 +
dat <- tryCatch(
 +
opbase.data(ident, subset = "Evaluations"),
 +
error = function(...) return(NULL)
 +
)
 +
 +
if (is.null(dat)) oprint("No evaluations were found") else {
 +
poistot <- tryCatch(
 +
opbase.data(ident, subset = "Evaluationremoves"),
 +
error = function(...) return(NULL)
 +
)
 +
if (!is.null(poistot)) dat <- dat[!dat$Eva_ID %in% poistot$Result, ]
 +
 +
if(nrow(dat) == 0) {
 +
oprint("No evaluations to show.")
 
} else {
 
} else {
 
oprint(dat, include.rownames = FALSE)
 
oprint(dat, include.rownames = FALSE)

Revision as of 07:59, 6 April 2017

Add a discussion item

The item you want to add:

A short name for the item:

Is this a value of factual statement?:

Add a relation

The ID of the subject in the relation:

What is the relation (predicate)?:

The ID of the object in the relation:

A short name for the relation:

Evaluate an item or relation for its truth value

Is the truth value for an item or a relation?:

The ID of the item or relation you want to evaluate:

A short description for the evaluation:

Is the item or relation true?:


Current discussion items.

Current discussion relations.

Current evaluations.