Commit edc369c1 authored by Daniel Haag's avatar Daniel Haag
Browse files

Merge branch 'master' into uibk

parents 7d6b43d9 c3a19945
......@@ -317,7 +317,7 @@ switch($menu_mode) {
$sqlq .= $sql_answer_position;
$sqlq .= ' GROUP BY answer_question_id';
if ($tsubset_answers > 0) {
$sqlq .= ' HAVING (COUNT(answer_id)>='.($tsubset_answers-1).')';
$sqlq .= ' HAVING (COUNT(answer_id)='.($tsubset_answers-1).')'; //changed, ESM
}
$sqlq .= ' )';
} elseif ($tsubset_type == 2) {
......@@ -330,7 +330,7 @@ switch($menu_mode) {
$sqlq .= $sql_answer_position;
$sqlq .= ' GROUP BY answer_question_id';
if ($tsubset_answers > 0) {
$sqlq .= ' HAVING (COUNT(answer_id)>='.$tsubset_answers.')';
$sqlq .= ' HAVING (COUNT(answer_id)='.$tsubset_answers.')'; //changed, ESM
}
$sqlq .= ' )';
} elseif ($tsubset_type == 4) {
......
......@@ -38,7 +38,7 @@ a:hover {
/* delete link ------------ */
a.deletebutton:link, a.deletebutton:visited {
border: 1px solid #000000;
color: #003399;
color: #003361;
font-size: 75%;
padding: 0px 3px 0px 3px;
text-decoration: none;
......@@ -231,45 +231,50 @@ div.float {
/* header (logo + timer) ------------ */
div.header {
background-color: #003399;
/* background-color: #f39200;
color: #003361;
border: 0px none;
height: 40px;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
width: 100%;
width: 100%;*/
}
/* header logo ------------ */
div.header div.left {
background-color: #003399;
background-image: url(../../images/logo_tcexam_118x25.png);
background-position: top;
background-color: #ffffff;
background-image: url(../../images/eexams_header.png);
background-position: top left;
background-repeat: no-repeat;
border: 0px none;
float: left;
height: 25px;
margin: 4px 0px 0px 4px;
height: 80px;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
text-align: left;
width: 118px;
width: 100%;
}
/* header banner ------------ */
div.header div.right {
background-color: #003399;
background-color:#ffffff;
background-image: url(../../images/logo_tcexam_118x25.png);
background-repeat: no-repeat;
background-position: 98% 30%;
color: #003361;
border: 0px none;
float: right;
height: 25px;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
margin: -80px 0px 0px 0px;
padding: 40px 0px 0px 0px;
text-align: right;
width: 400px;
}
div.header div.right input{
background-color: #003399;
background-color:#ffffff;
color: #003361;
border: 0px none;
color: #FFFFFF;
font-size: 100%;
font-weight: bold;
text-align: right;
......@@ -333,7 +338,7 @@ div.popupcontainer {
}
div.popuptitle {
color: #003399;
color: #003361;
font-size: 130%;
font-weight: bold;
margin: 0px 10px 0px 10px;
......@@ -463,7 +468,7 @@ div.contentbox {
/* TITLE ------------------------------- */
div.title {
color: #003399;
color: #003361;
font-size: 140%;
font-weight: bold;
margin: 0px 10px 0px 10px;
......@@ -473,7 +478,7 @@ div.title {
/* USER BAR ------------------- */
div.userbar {
background-color: #003399;
background-color: #003361;
clear: both;
color: #FFFFFF;
font-size: 95%;
......@@ -526,7 +531,7 @@ fieldset.noborder {
}
h1 {
color: #003399;
color: #003361;
font-size: 140%;
font-weight: bold;
margin: 0px 10px 0px 10px;
......@@ -535,7 +540,7 @@ h1 {
}
h2 {
color: #003399;
color: #003361;
font-size: 120%;
font-weight: bold;
margin: 0px 10px 0px 10px;
......@@ -568,9 +573,10 @@ label {
}
label.timerlabel {
color: #003399;
background-color: #ffffff;
color: #ffffff;
font-size: 80%;
}
li.tcecode{
}
......@@ -747,7 +753,7 @@ div.scrollmenu {
font-size: 75%;
font-weight: bold;
text-decoration: none;
background: #003399;
background: #003361;
border: 0;
}
......@@ -775,7 +781,7 @@ ul.menu {
ul.menu li > ul {
display: none;
background-color: #003399;
background-color: #003361;
}
ul.menu li a {
......@@ -810,17 +816,17 @@ ul.menu li:hover > ul, ul.menu *:focus + ul {
margin: 0;
padding: 0;
border: 0;
background-color: #003399;
background-color: #003361;
z-index: 1;
}
ul.menu li:hover, ul.menu li.CSStoHighlight {
background-color: #003399;
background-color: #003361;
color: #FFCC00;
}
ul.menu ul li {
background-color: #003399;
background-color: #003361;
float: left;
list-style-type: none;
margin-bottom: 2px;
......@@ -837,40 +843,40 @@ ul.menu ul li:hover > ul, ul.menu ul *:focus + ul {
top: 0px;
margin: 0;
padding: 0;
background-color: #003399;
background-color: #003361;
z-index: 1;
}
ul.menu li a.active {
color: #003399;
color: #003361;
display: block;
text-decoration: underline;
padding: 0px 6px 0 6px;
border-top: 1px solid #003399;
border-left: 1px solid #003399;
border-right: 1px solid #003399;
border-top: 1px solid #003361;
border-left: 1px solid #003361;
border-right: 1px solid #003361;
border-bottom: 1px solid white;
background-color: white;
}
ul.menu li span.active {
color: #003399;
color: #003361;
display: block;
text-decoration: none;
padding: 0px 6px 0 6px;
border-top: 1px solid #003399;
border-left: 1px solid #003399;
border-right: 1px solid #003399;
border-top: 1px solid #003361;
border-left: 1px solid #003361;
border-right: 1px solid #003361;
border-bottom: 1px solid white;
background-color: white;
}
ul.menu ul li *.active {
color: #003399;
color: #003361;
display: block;
text-decoration: none;
padding: 0px 6px 0 6px;
border: 1px solid #003399;
border: 1px solid #003361;
background-color: white;
}
......
-- modifying the schema to allow an external_id
ALTER TABLE tce_user_groups ADD COLUMN external_id varchar(255);
-- functions for tcexam esb integration
-- assign_tcexam_user_to_group
CREATE OR REPLACE FUNCTION assign_tcexam_user_to_group(xmlbody text, pgroupid character varying, pappointmentid character varying)
RETURNS void AS
$BODY$
DECLARE
login character varying;
externalid character varying;
userid bigint;
groupid bigint;
uservo xml;
BEGIN
uservo = xmlbody::xml;
externalid = CONCAT (pgroupid,':',pappointmentid);
SELECT (xpath('/userVO/login/text()', uservo))[1] into login;
SELECT user_id INTO userid FROM tce_users WHERE user_name = login;
SELECT group_id INTO groupid FROM tce_user_groups WHERE external_id = externalid ;
INSERT INTO tce_usrgroups (usrgrp_user_id, usrgrp_group_id) VALUES (userid, groupid);
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION assign_tcexam_user_to_group(text, character varying, character varying)
OWNER TO tcexam;
-- delete_tcexam_user
CREATE OR REPLACE FUNCTION delete_tcexam_user(login character varying)
RETURNS void AS
$BODY$
BEGIN
-- delete only if no tests for this user available
IF (SELECT COUNT(*) FROM (SELECT user_id, user_name FROM tce_users u INNER JOIN tce_tests t ON (t.test_user_id = u.user_id) where u.user_name = login) AS numberofusers) = 0 THEN
DELETE FROM tce_users WHERE user_name = login;
END IF;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION delete_tcexam_user(character varying)
OWNER TO tcexam;
-- get_tcexam_group
CREATE OR REPLACE FUNCTION get_tcexam_group(externalid character varying)
RETURNS text AS
$BODY$
DECLARE
xoutput text;
BEGIN
IF NOT EXISTS(SELECT group_name from tce_user_groups where external_id like concat(externalid,':%'))
THEN
RETURN '<appointments><appointment><appointmentId>' || '' || '</appointmentId></appointment></appointments>';
END IF;
SELECT XMLSERIALIZE ( CONTENT
XMLELEMENT(name "appointments",
xmlagg(
XMLELEMENT(name "appointment",
XMLFOREST(
split_part(u.external_id,':',2) as "appointmentId",
u.group_id as "tcexamGroupKey",
u.group_name as "tcexamGroupName"
)
)
)
)
as text )
INTO xoutput
FROM tce_user_groups u
WHERE u.external_id LIKE concat(externalid,':%')
;
RETURN xoutput;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION get_tcexam_group(character varying)
OWNER TO tcexam;
-- get_tcexam_group_appointment_users
CREATE OR REPLACE FUNCTION get_tcexam_group_appointment_users(pgroupid character varying, pappointmentid character varying)
RETURNS text AS
$BODY$
DECLARE
xoutput text;
BEGIN
SELECT XMLSERIALIZE ( CONTENT
XMLELEMENT(name "userVOes",
xmlagg(
XMLELEMENT(name "userVO",
XMLFOREST(u.user_id),
XMLFOREST(u.user_name as login),
XMLFOREST(u.user_email),
XMLFOREST(u.user_firstname),
XMLFOREST(u.user_lastname),
XMLFOREST(u.user_level)
))) as text )
INTO xoutput
FROM tce_user_groups g
LEFT JOIN tce_usrgroups ug ON g.group_id = ug.usrgrp_group_id
LEFT JOIN tce_users u ON u.user_id = ug.usrgrp_user_id
WHERE g.external_id = concat(pgroupid,':',pappointmentid)
;
RETURN xoutput;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION get_tcexam_group_appointment_users(character varying, character varying)
OWNER TO tcexam;
-- get_tcexam_group_users
CREATE OR REPLACE FUNCTION get_tcexam_group_users(group_id character varying)
RETURNS text AS
$BODY$
SELECT XMLSERIALIZE ( CONTENT
XMLELEMENT(name "userVOes",
xmlagg(
XMLELEMENT(name "userVO",
XMLFOREST(u.user_id),
XMLFOREST(u.user_name as login),
XMLFOREST(u.user_email),
XMLFOREST(u.user_firstname),
XMLFOREST(u.user_lastname),
XMLFOREST(u.user_level)
)
)
) as text )
FROM tce_user_groups g
LEFT JOIN tce_usrgroups ug ON g.group_id = ug.usrgrp_group_id
LEFT JOIN tce_users u ON u.user_id = ug.usrgrp_user_id
WHERE g.external_id LIKE concat($1,':%');
$BODY$
LANGUAGE sql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION get_tcexam_group_users(character varying)
OWNER TO tcexam;
-- insert_tcexam_group
CREATE OR REPLACE FUNCTION insert_tcexam_group(xmlbody text, pgroupid character varying, pappointmentid character varying, pgroupname character varying)
RETURNS void AS
$BODY$
DECLARE
externalid character varying;
appointmentid character varying;
groupvo xml;
BEGIN
groupvo = xmlbody::xml;
externalid = CONCAT (pgroupid,':',pappointmentid);
IF NOT EXISTS(SELECT group_id FROM tce_user_groups WHERE external_id = externalid)
THEN
INSERT INTO tce_user_groups (group_name, external_id) VALUES (pgroupname,externalid);
END IF;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION insert_tcexam_group(text, character varying, character varying, character varying)
OWNER TO tcexam;
-- insert_tcexam_user
CREATE OR REPLACE FUNCTION insert_tcexam_user(xmlbody text, pgroupid character varying, pappointmentid character varying)
RETURNS void AS
$BODY$
DECLARE
login character varying;
email character varying;
firstname character varying;
lastname character varying;
uservo xml;
BEGIN
uservo = xmlbody::xml;
SELECT (xpath('/userVO/login/text()', uservo))[1] into login;
SELECT (xpath('/userVO/email/text()', uservo))[1] into email;
SELECT (xpath('/userVO/firstName/text()', uservo))[1] into firstname;
SELECT (xpath('/userVO/lastName/text()', uservo))[1] into lastname;
IF NOT EXISTS(SELECT user_name from tce_users where user_name = login )
THEN
INSERT INTO tce_users (user_name, user_email, user_firstname, user_lastname, user_level, user_regdate, user_password, user_ip)
VALUES (login,email,firstname,lastname, 1, now(), 'no£password', '127.0.0.1') ;
END IF;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION insert_tcexam_user(text, character varying, character varying)
OWNER TO tcexam;
-- remove_tcexam_user_from_group
CREATE OR REPLACE FUNCTION remove_tcexam_user_from_group(xmlbody text, pgroupid character varying, pappointmentid character varying)
RETURNS void AS
$BODY$
DECLARE
login character varying;
userid integer;
groupid integer;
uservo xml;
BEGIN
uservo = xmlbody::xml;
SELECT (xpath('/userVO/login/text()', uservo))[1] into login;
SELECT user_id INTO userid FROM tce_users WHERE user_name = login;
SELECT group_id INTO groupid FROM tce_user_groups WHERE external_id = pgroupid || ':' || pappointmentid;
UPDATE tce_users SET user_level = 0 WHERE user_id = userid;
DELETE FROM tce_usrgroups WHERE usrgrp_user_id = userid AND usrgrp_group_id = groupid;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION remove_tcexam_user_from_group(text, character varying, character varying)
OWNER TO tcexam;
-- update_tcexam_group
CREATE OR REPLACE FUNCTION update_tcexam_group(pgroupid character varying, pappointmentid character varying, pgroupname character varying)
RETURNS void AS
$BODY$
DECLARE
theKey character varying;
BEGIN
theKey = pgroupid || ':' || pappointmentid;
IF (SELECT group_name FROM tce_user_groups WHERE external_id = theKey) != pgroupname THEN
UPDATE tce_user_groups set group_name = pgroupname WHERE external_id = theKey;
END IF;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION update_tcexam_group(character varying, character varying, character varying)
OWNER TO tcexam;
-- update_tcexam_user
CREATE OR REPLACE FUNCTION update_tcexam_user(xmlbody text, pgroupid character varying, pappointmentid character varying)
RETURNS void AS
$BODY$
DECLARE
login character varying;
email character varying;
firstname character varying;
lastname character varying;
uservo xml;
BEGIN
uservo = xmlbody::xml;
SELECT (xpath('/userVO/login/text()', uservo))[1] into login;
SELECT (xpath('/userVO/email/text()', uservo))[1] into email;
SELECT (xpath('/userVO/firstName/text()', uservo))[1] into firstname;
SELECT (xpath('/userVO/lastName/text()', uservo))[1] into lastname;
IF (SELECT user_email FROM tce_users WHERE user_name = login) != email
THEN
UPDATE tce_users SET user_email = email WHERE user_name = login;
END IF;
IF (SELECT user_firstname FROM tce_users WHERE user_name = login) != firstname
THEN
UPDATE tce_users SET user_firstname = firstname WHERE user_name = login;
END IF;
IF (SELECT user_lastname FROM tce_users WHERE user_name = login) != lastname
THEN
UPDATE tce_users SET user_lastname = lastname WHERE user_name = login;
END IF;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
SECURITY DEFINER
-- Set a secure search_path: trusted schema(s), then 'pg_temp'.
SET search_path = tcexam, pg_temp;
ALTER FUNCTION update_tcexam_user(text, character varying, character varying)
OWNER TO tcexam;
-- create esb user
-- CREATE USER esb WITH PASSWORD '....';
-- grant execute right on the functions
--
-- # Generated with:
-- # grep 'CREATE OR REPLACE FUNCTION' postgres_db_structure_functions.sql | sed 's/CREATE OR REPLACE FUNCTION //' | while read f; do echo "GRANT EXECUTE ON FUNCTION $f TO esb;"; done
GRANT EXECUTE ON FUNCTION assign_tcexam_user_to_group(xmlbody text, pgroupid character varying, pappointmentid character varying) TO esb;
GRANT EXECUTE ON FUNCTION delete_tcexam_user(login character varying) TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group(externalid character varying) TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group_appointment_users(pgroupid character varying, pappointmentid character varying) TO esb;
GRANT EXECUTE ON FUNCTION get_tcexam_group_users(group_id character varying) TO esb;
GRANT EXECUTE ON FUNCTION insert_tcexam_group(xmlbody text, pgroupid character varying, pappointmentid character varying, pgroupname character varying) TO esb;
GRANT EXECUTE ON FUNCTION insert_tcexam_user(xmlbody text, pgroupid character varying, pappointmentid character varying) TO esb;
GRANT EXECUTE ON FUNCTION remove_tcexam_user_from_group(xmlbody text, pgroupid character varying, pappointmentid character varying) TO esb;
GRANT EXECUTE ON FUNCTION update_tcexam_group(pgroupid character varying, pappointmentid character varying, pgroupname character varying) TO esb;
GRANT EXECUTE ON FUNCTION update_tcexam_user(xmlbody text, pgroupid character varying, pappointmentid character varying) TO esb;
......@@ -202,45 +202,50 @@ div.float {
/* header (logo + timer) ------------ */
div.header {
background-color: #003399;
/* background-color: #f39200;