Commit 79d8c757 authored by GROSS-AMBLARD David's avatar GROSS-AMBLARD David
Browse files

Offers artifactclass auto-instanciation. No longer need to insert artifact by...

Offers artifactclass auto-instanciation. No longer need to insert artifact by hand. Just set autostart to true in artifactclass. Startme table has been supressed.
parent 053299a7
......@@ -51,7 +51,7 @@ function initialize($conn)
// update all artifacts in the startme table
$query="select ID from StartMe";
$query="select ID from Artifact";
$table=$conn->query($query);
foreach ($table as $artifactid){
......
......@@ -301,6 +301,17 @@ function startArtifact($conn,$artifactid,$userid){
*/
function startAllArtifact($conn,$userid){
$table=$conn->query("select id from ArtifactClass where autostart and id not in (select classid from artifact where ownerid=$userid)");
if($table->rowCount()>0){
debug("ArtifactClass to instanciate available");
while($tuple=$table->fetch()){
$artifactclassid=$tuple['id'];
debug("Instanciating a $artifactclassid");
$conn->query("insert into Artifact(ownerid,classid,state,node,attributes) values ($userid,$artifactclassid,'running',1,1)");
}
}
/*
$table=$conn->query("select id from Artifact where ownerid=0");
if($table->rowCount()>0){
debug("Artifacts available");
......@@ -310,6 +321,7 @@ function startAllArtifact($conn,$userid){
startArtifact($conn, $artifactid, $userid);
}
}
*/
}
/**
......
......@@ -30,6 +30,8 @@ function addUser($conn)
$line=$stmt->fetch();
$_SESSION["login"]=true;
$_SESSION["id"]=$line['id'];
// Any user has the "common knowledge" skill
$conn->query("insert into Skills values (".$_SESSION["id"].",1,100)");
$_SESSION['username']=$line['name'];
if ($_POST["username"]!="anonymous") {
showProfile($conn);
......
......@@ -94,6 +94,7 @@ switch ($mode) {
answer($conn, $_REQUEST['choice']);
break;
case "insertAnswer":
// TODO modularize, hugly
$typeanswer=0;
$ajax = (isset($_POST['ajax']) and $_POST['ajax'] == true) ? true : false;
$help = (isset($_POST['help']) and $_POST['help'] == true) ? true : false;
......
......@@ -25,7 +25,6 @@ SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-- /* !40101 SET NAMES utf8mb4 */;
-- DROPing everything
DROP TABLE IF EXISTS StartMe;
DROP TABLE IF EXISTS CurrentArtifact;
DROP TABLE IF EXISTS Artifact;
DROP TABLE IF EXISTS BroadcastArtifactClass;
......@@ -44,7 +43,6 @@ DROP TABLE IF EXISTS Template;
DROP TABLE IF EXISTS ArtifactUser;
DROP TABLE IF EXISTS TaskClass;
DROP TABLE IF EXISTS Task;
DROP TABLE IF EXISTS StartMe;
DROP TABLE IF EXISTS Answered;
DROP TABLE IF EXISTS ServiceCall;
......@@ -479,13 +477,15 @@ function myFunction(){
-- TABLENAME: the table related to the Artifacts of this class
-- DEFINITION: the path to a .sca file describing the Artifact automaton
-- PROJECT: the project of the Artifact class
-- autostart: is the artifact available at start for anyone (default no)
CREATE TABLE ArtifactClass(
id varchar(100) PRIMARY KEY,
description varchar(1000),
tablename varchar(100),
definition varchar(10000) NOT NULL,
project varchar(250)
project varchar(250),
autostart boolean default false NOT NULL
-- TODO should be a foreign key to a PROJECT table with description, authors, ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
......@@ -557,14 +557,6 @@ CREATE TABLE IF NOT EXISTS CurrentArtifact (
-- INSERT INTO task(title,description,body,checker,checkermsg) values ('Change current Artifact','Change the current Artifact','Change the current Artifact',null,'insert valid Artifact id');
-- insert into profile values (1,1);
-- table StartMe, list all the Artifact that should be launched at initialization (initialize)
-- id: Artifact id to launch
CREATE TABLE StartMe(
id int NOT NULL PRIMARY KEY
-- id int NOT NULL PRIMARY KEY,
-- FOREIGN KEY(id) REFERENCES Artifact(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- table BroadcastArtifactClass, list all artifact classes that are available for instanciation for any user
......
......@@ -13,7 +13,6 @@ SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-- /* !40101 SET NAMES utf8mb4 */;
-- DROPing everything
DROP TABLE IF EXISTS StartMe;
DROP TABLE IF EXISTS CurrentArtifact;
DROP TABLE IF EXISTS Artifact;
DROP TABLE IF EXISTS BroadcastArtifactClass;
......@@ -30,7 +29,6 @@ DROP TABLE IF EXISTS Template;
DROP TABLE IF EXISTS ArtifactUser;
DROP TABLE IF EXISTS TaskClass;
DROP TABLE IF EXISTS Task;
DROP TABLE IF EXISTS StartMe;
DROP TABLE IF EXISTS Answered;
DROP TABLE IF EXISTS ServiceCall;
......@@ -414,13 +412,15 @@ function myFunction(){
-- TABLENAME: the table related to the Artifacts of this class
-- DEFINITION: the path to a .sca file describing the Artifact automaton
-- PROJECT: the project of the Artifact class
-- autostart: is the artifact available at start for anyone (default no)
CREATE TABLE ArtifactClass(
id varchar(100) PRIMARY KEY,
description varchar(1000),
tablename varchar(100),
definition varchar(10000) NOT NULL,
project varchar(250)
project varchar(250),
autostart boolean default false
-- TODO should be a foreign key to a PROJECT table with description, authors, ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
......@@ -492,15 +492,6 @@ CREATE TABLE IF NOT EXISTS CurrentArtifact (
-- INSERT INTO task(title,description,body,checker,checkermsg) values ('Change current Artifact','Change the current Artifact','Change the current Artifact',null,'insert valid Artifact id');
-- insert into profile values (1,1);
-- table StartMe, list all the Artifact that should be launched at initialization (initialize)
-- id: Artifact id to launch
CREATE TABLE StartMe(
id int NOT NULL PRIMARY KEY
-- id int NOT NULL PRIMARY KEY,
-- FOREIGN KEY(id) REFERENCES Artifact(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- table BroadcastArtifactClass, list all artifact classes that are available for instanciation for any user
CREATE TABLE BroadcastArtifactClass(
......
......@@ -48,6 +48,7 @@
"delete from Task where artifact=CURRENT_ARTIFACT",
"delete from Profile where idartifact=CURRENT_ARTIFACT",
"delete from Skills where iduser=SESSION_USER and idskill=1004",
"delete from Skills where iduser=SESSION_USER and idskill=1003",
"insert into Skills values (SESSION_USER,1004,50)",
"insert into Skills values (SESSION_USER,1003,20)"
]
......
DROP TABLE IF EXISTS Headwork;
DELETE from Artifact where classid in (select id from ArtifactClass where project = 'Headwork');
DELETE from ArtifactClass where project = 'Headwork';
DELETE from StartMe;
DROP TABLE IF EXISTS AnswerButton;
CREATE TABLE AnswerButton(id int,text varchar(100),class varchar(100));
......@@ -10,25 +9,13 @@ INSERT INTO AnswerButton values (2,'Why not','warning');
INSERT INTO AnswerButton values (3,'Awsome','success');
insert into ArtifactClass(id,description,definition,tablename,project) values (6000,'Headwork basics','Headwork/headwork.sca', 'Artifact', 'Headwork');
-- sending to broadcast
insert into Artifact(id,ownerid,classid,state,node,attributes) values (1000,0,6000,'running',1,1);
insert into ArtifactClass(id,description,definition,tablename,project,autostart) values (6000,'Headwork basics','Headwork/headwork.sca', 'Artifact', 'Headwork',true);
create table Headwork(id int primary key);
insert into ArtifactClass(id,description,definition,tablename,project) values (6001,'Task interface capabilities','Headwork/headworkGUI.sca', null, 'Headwork');
-- sending to broadcast
insert into Artifact(id,ownerid,classid,state,node,attributes) values (1001,0,6001,'running',1,1);
insert into ArtifactClass(id,description,definition,tablename,project,autostart) values (6001,'Task interface capabilities','Headwork/headworkGUI.sca', null, 'Headwork',true);
-- insert into ArtifactClass(id,description,definition,tablename,project) values (7001,'Belief in all modalities','Headwork/headworkGUIbelief.sca', null, 'Headwork');
-- sending to broadcast
-- insert into Artifact(id,ownerid,classid,state,node,attributes) values (1005,0,7001,'running',1,1);
insert into ArtifactClass(id,description,definition,tablename,project,autostart) values (6002,'Voting','Headwork/headworkVoting.sca', null, 'Headwork',true);
insert into ArtifactClass(id,description,definition,tablename,project) values (6002,'Voting','Headwork/headworkVoting.sca', null, 'Headwork');
insert into Artifact(id,ownerid,classid,state,node,attributes) values (1002,0,6002,'running',1,1);
-- deprecated: insert into Artifact(id,ownerid,classid,state,node,attributes) values (1003,0,6002,'running',1,1);
insert into ArtifactClass(id,description,definition,tablename,project) values (6003,'I want to believe!: Uncertain answers','Headwork/belief.sca', null, 'Headwork');
-- sending to broadcast
insert into Artifact(id,ownerid,classid,state,node,attributes) values (1004,0,6003,'running',1,1);
insert into ArtifactClass(id,description,definition,tablename,project,autostart) values (6003,'I want to believe!: Uncertain answers','Headwork/belief.sca', null, 'Headwork',true);
DELETE from Artifact where classid in (select id from ArtifactClass where project = 'Wirk');
DELETE from ArtifactClass where project = 'Wirk';
DELETE from StartMe;
-- Chasser le Totoro Artifact
insert into ArtifactClass(id,description,definition,tablename,project) values (7000,'Chasser le Totoro','Wirk/wirk.sca', 'Artifact', 'Wirk');
-- sending to broadcast
insert into Artifact(id,ownerid,classid,state,node,attributes) values (2000,0,7000,'running',1,1);
insert into ArtifactClass(id,description,definition,tablename,project,autostart) values (7000,'Chasser le Totoro','Wirk/wirk.sca', 'Artifact', 'Wirk',true);
-- Wirk Service call example
insert into ArtifactClass(id,description,definition,tablename,project) values (7001,'Wirk service call demo','Wirk/wirk-service.sca', 'Artifact', 'Wirk');
-- sending to broadcast
insert into Artifact(id,ownerid,classid,state,node,attributes) values (2001,0,7001,'running',1,1);
insert into ArtifactClass(id,description,definition,tablename,project,autostart) values (7001,'Wirk service call demo','Wirk/wirk-service.sca', 'Artifact', 'Wirk',true);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment