Skip to content
GitLab
Explore
Sign in
formatest
FormATest_QuestionSetPool
Compare revisions
dac62171f9f4b208778bdbb4996d236af1fe3adc to 381d5850e2bde24749dbdf4affb7ff3984e296ea
Show whitespace changes
Inline
Side-by-side
Parser/classes/Factory/ManufacturerInterface.php
View file @
381d5850
...
...
@@ -7,7 +7,8 @@
* @author Thomas Joußen <tjoussen@databay.de>
*/
interface
ManufacturerInterface
{
interface
ManufacturerInterface
{
/**
* Get an singleton of the manufacturer
...
...
Parser/classes/Factory/OperationManufacturer.php
View file @
381d5850
...
...
@@ -9,7 +9,8 @@ require_once "AbstractManufacturer.php";
* Time: 15:12
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
OperationManufacturer
extends
AbstractManufacturer
{
class
OperationManufacturer
extends
AbstractManufacturer
{
/**
* A Singleton Instance of the OperationManufacturer
...
...
@@ -26,7 +27,8 @@ class OperationManufacturer extends AbstractManufacturer{
*
* @return OperationManufacturer
*/
public
static
function
_getInstance
(){
public
static
function
_getInstance
()
{
if
(
self
::
$instance
==
null
)
{
self
::
$instance
=
new
OperationManufacturer
();
}
...
...
@@ -44,8 +46,7 @@ class OperationManufacturer extends AbstractManufacturer{
public
function
manufacture
(
$attribute
)
{
$operation
=
""
;
switch
(
$attribute
)
{
switch
(
$attribute
)
{
case
LesserOperation
::
$pattern
:
$operation
=
new
LesserOperation
();
break
;
...
...
@@ -121,5 +122,7 @@ class OperationManufacturer extends AbstractManufacturer{
/**
* Private clone to prevent cloning an object of OperationManufacturer
*/
private
function
__clone
()
{}
private
function
__clone
()
{
}
}
Parser/classes/Operations/AbstractOperation.php
View file @
381d5850
...
...
@@ -9,7 +9,8 @@ include_once __DIR__ . "/../AbstractComposite.php";
* Time: 15:37
* @author Thomas Joußen <tjoussen@databay.de>
*/
abstract
class
AbstractOperation
extends
AbstractComposite
{
abstract
class
AbstractOperation
extends
AbstractComposite
{
/**
* @var bool
...
...
Parser/classes/Operations/AndOperation.php
View file @
381d5850
...
...
@@ -9,7 +9,8 @@ include_once 'AbstractOperation.php';
* Time: 14:58
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
AndOperation
extends
AbstractOperation
{
class
AndOperation
extends
AbstractOperation
{
/**
* @var string
...
...
Parser/classes/Operations/EqualsOperation.php
View file @
381d5850
...
...
@@ -9,7 +9,8 @@ include_once 'AbstractOperation.php';
* Time: 14:57
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
EqualsOperation
extends
AbstractOperation
{
class
EqualsOperation
extends
AbstractOperation
{
/**
* @var string
...
...
Parser/classes/Operations/GreaterOperation.php
View file @
381d5850
...
...
@@ -9,14 +9,15 @@ include_once 'AbstractOperation.php';
* Time: 14:57
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
GreaterOperation
extends
AbstractOperation
{
class
GreaterOperation
extends
AbstractOperation
{
/**
* @var string
*/
public
static
$pattern
=
">"
;
function
getDescription
()
public
function
getDescription
()
{
return
"mit mehr als "
;
}
...
...
Parser/classes/Operations/GreaterOrEqualsOperation.php
View file @
381d5850
...
...
@@ -9,14 +9,15 @@ include_once 'AbstractOperation.php';
* Time: 14:58
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
GreaterOrEqualsOperation
extends
AbstractOperation
{
class
GreaterOrEqualsOperation
extends
AbstractOperation
{
/**
* @var string
*/
public
static
$pattern
=
">="
;
function
getDescription
()
public
function
getDescription
()
{
return
"mit mehr oder genau "
;
}
...
...
Parser/classes/Operations/LesserOperation.php
View file @
381d5850
...
...
@@ -9,14 +9,15 @@ include_once 'AbstractOperation.php';
* Time: 14:57
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
LesserOperation
extends
AbstractOperation
{
class
LesserOperation
extends
AbstractOperation
{
/**
* @var string
*/
public
static
$pattern
=
"<"
;
function
getDescription
()
public
function
getDescription
()
{
return
"mit weniger als "
;
}
...
...
Parser/classes/Operations/LesserOrEqualsOperation.php
View file @
381d5850
...
...
@@ -9,14 +9,15 @@ include_once 'AbstractOperation.php';
* Time: 14:58
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
LesserOrEqualsOperation
extends
AbstractOperation
{
class
LesserOrEqualsOperation
extends
AbstractOperation
{
/**
* @var string
*/
public
static
$pattern
=
"<="
;
function
getDescription
()
public
function
getDescription
()
{
return
"mit weniger oder gleich "
;
}
...
...
Parser/classes/Operations/NotEqualsOperation.php
View file @
381d5850
...
...
@@ -9,14 +9,15 @@ include_once 'AbstractOperation.php';
* Time: 14:57
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
NotEqualsOperation
extends
AbstractOperation
{
class
NotEqualsOperation
extends
AbstractOperation
{
/**
* @var string
*/
public
static
$pattern
=
"<>"
;
function
getDescription
()
public
function
getDescription
()
{
return
"nicht mit "
;
}
...
...
Parser/classes/Operations/OrOperation.php
View file @
381d5850
...
...
@@ -9,14 +9,15 @@ include_once 'AbstractOperation.php';
* Time: 14:58
* @author Thomas Joußen <tjoussen@databay.de>
*/
class
OrOperation
extends
AbstractOperation
{
class
OrOperation
extends
AbstractOperation
{
/**
* @var string
*/
public
static
$pattern
=
"|"
;
function
getDescription
()
public
function
getDescription
()
{
return
"oder "
;
}
...
...
README.md
View file @
381d5850
# ILIAS QuestionSetPool
*
For ILIAS versions:
5.3
.0 -
5.4
.999
*
For ILIAS versions:
6
.0 -
6
.999
## Installation Instructions
1.
Create the plugin path:
...
...
@@ -20,3 +20,10 @@
3. Select **Plugins** from the **Administration** main menu drop down.
4. Search the **QuestionSetPool** plugin in the list of plugin and choose **Activate** from the **Actions** drop down.
5. Choose **Configure** from the **Actions** drop down and enter the required data.
## Dependencies
### Graphviz
Please install [`Graphviz`](https://graphviz.org/). Graphviz is required for
the graph visualization of the question paths.
\ No newline at end of file
classes/class.ilObjQuestionSetPool.php
View file @
381d5850
<?php
/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
require_once
'Services/Repository/classes/class.ilObjectPlugin.php'
;
require_once
'models/interface.ilPluginModelInterface.php'
;
require_once
'Modules/TestQuestionPool/interfaces/interface.ilQuestionEditingFormConsumer.php'
;
/**
* Class ilObjQuestionSetPool
...
...
@@ -92,8 +90,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
$ilCtrl
->
setParameterByClass
(
'ilObjPluginDispatchGUI'
,
'ref_id'
,
$this
->
getRefId
());
$url
=
$ilCtrl
->
getLinkTargetByClass
(
array
(
'ilObjPluginDispatchGUI'
,
'ilObjQuestionSetPoolGUI'
),
''
,
''
,
false
,
false
);
foreach
((
array
)
$params
as
$key
=>
$value
)
{
foreach
((
array
)
$params
as
$key
=>
$value
)
{
$url
=
ilUtil
::
appendUrlParameterString
(
$url
,
$key
.
'='
.
$value
);
}
...
...
@@ -177,8 +174,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
protected
function
beforeDelete
()
{
$sets
=
$this
->
set_list
->
getData
();
foreach
(
$sets
as
$set
)
{
foreach
(
$sets
as
$set
)
{
/**
* @var $set ilQuestionSetPoolSet
*/
...
...
@@ -206,7 +202,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
* @param int $a_target_id
* @param int $a_copy_id
*/
public
function
doCloneObject
(
$new_obj
,
$a_target_id
,
$a_copy_id
=
NULL
)
public
function
doCloneObject
(
$new_obj
,
$a_target_id
,
$a_copy_id
=
null
)
{
$this
->
cloneMetaData
(
$new_obj
);
$this
->
cloneQuestionSets
(
$new_obj
);
...
...
@@ -224,8 +220,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
$setlist
=
$this
->
getSetList
();
$sets
=
$setlist
->
loadData
();
foreach
((
array
)
$sets
as
$set_index
=>
$set_data
)
{
foreach
((
array
)
$sets
as
$set_index
=>
$set_data
)
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$set_data
[
'id'
]);
$set
->
read
();
...
...
@@ -255,8 +250,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
$mapping
=
array
();
foreach
((
array
)
$questions
as
$question_index
=>
$question
)
{
foreach
((
array
)
$questions
as
$question_index
=>
$question
)
{
$mapping
=
$questionList
->
cloneQuestionList
(
array
(
$question
[
'question_id'
]),
$source_set
,
$new_set
)
+
$mapping
;
}
...
...
@@ -271,8 +265,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
protected
function
clonePathList
(
ilQuestionSetPoolPathList
$pathList
,
ilQuestionSetPoolSet
$new_set
,
array
$question_mapping
)
{
$paths
=
$pathList
->
loadData
();
foreach
((
array
)
$paths
as
$path_index
=>
$path_data
)
{
foreach
((
array
)
$paths
as
$path_index
=>
$path_data
)
{
$path
=
new
ilQuestionSetPoolPath
();
$path
->
setId
(
$path_data
[
'id'
]);
$path
->
read
();
...
...
@@ -297,18 +290,14 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
protected
function
cloneNodeList
(
ilQuestionSetPoolNodeList
$nodeList
,
ilQuestionSetPoolPath
$new_path
,
array
$question_mapping
)
{
$nodes
=
$nodeList
->
loadData
();
foreach
((
array
)
$nodes
as
$node_index
=>
$node_data
)
{
foreach
((
array
)
$nodes
as
$node_index
=>
$node_data
)
{
$node
=
new
ilQuestionSetPoolNode
((
int
)
$node_data
[
'id'
]);
$node
->
read
();
$new_node
=
new
ilQuestionSetPoolNode
();
if
(
isset
(
$question_mapping
[
$node
->
getQuestion
()
->
getId
()]))
{
if
(
isset
(
$question_mapping
[
$node
->
getQuestion
()
->
getId
()]))
{
$new_node
->
setQuestion
(
assQuestion
::
_instantiateQuestion
(
$question_mapping
[
$node
->
getQuestion
()
->
getId
()]));
}
else
{
}
else
{
$new_node
->
setQuestion
(
assQuestion
::
_instantiateQuestion
(
$node
->
getQuestion
()
->
getId
()));
}
$new_node
->
setPath
(
$new_path
);
...
...
@@ -330,8 +319,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
protected
function
cloneJumpConditions
(
ilQuestionSetPoolJumpConditionList
$jumpConditionList
,
ilQuestionSetPoolNode
$new_node
)
{
$jumpConditions
=
$jumpConditionList
->
getData
();
foreach
((
array
)
$jumpConditions
as
$jmp_con_index
=>
$jumpCondition_data
)
{
foreach
((
array
)
$jumpConditions
as
$jmp_con_index
=>
$jumpCondition_data
)
{
$jumpCondition
=
new
ilQuestionSetPoolJumpCondition
();
$jumpCondition
->
setId
(
$jumpCondition_data
[
'id'
]);
$jumpCondition
->
read
();
...
...
@@ -403,8 +391,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
*/
public
static
function
getOnlineStatusByObjId
(
$obj_id
)
{
if
(
isset
(
self
::
$online_status_map
[
$obj_id
]))
{
if
(
isset
(
self
::
$online_status_map
[
$obj_id
]))
{
return
(
bool
)
self
::
$online_status_map
[
$obj_id
];
}
...
...
@@ -420,12 +407,9 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
global
$DIC
;
$ilDB
=
$DIC
->
database
();
if
(
is_array
(
$obj_ids
)
&&
count
(
$obj_ids
)
==
1
)
{
if
(
is_array
(
$obj_ids
)
&&
count
(
$obj_ids
)
==
1
)
{
$in
=
' id = '
.
$ilDB
->
quote
(
current
(
$obj_ids
),
'integer'
)
.
' '
;
}
else
{
}
else
{
$in
=
$ilDB
->
in
(
'id'
,
$obj_ids
,
false
,
'integer'
);
}
...
...
@@ -436,13 +420,12 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
"
;
$res
=
$ilDB
->
query
(
$query
);
while
(
$row
=
$ilDB
->
fetchAssoc
(
$res
))
{
while
(
$row
=
$ilDB
->
fetchAssoc
(
$res
))
{
self
::
$online_status_map
[
$row
[
'id'
]]
=
$row
[
'is_online'
];
}
}
public
static
function
getAvailableQuestionSetPools
(
$could_be_offline
=
FALSE
)
public
static
function
getAvailableQuestionSetPools
(
$could_be_offline
=
false
)
{
global
$DIC
;
$ilDB
=
$DIC
->
database
();
...
...
@@ -453,18 +436,14 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
$pools
=
ilUtil
::
_getObjectsByOperations
(
"xqsp"
,
"read"
,
$ilUser
->
getId
(),
-
1
);
$obj_ids
=
array
();
$ref_ids
=
array
();
foreach
(
$pools
as
$ref_id
)
{
foreach
(
$pools
as
$ref_id
)
{
$obj_ids
[
$ref_id
]
=
ilObject
::
_lookupObjId
(
$ref_id
);
$ref_ids
[
ilObject
::
_lookupObjId
(
$ref_id
)]
=
$ref_id
;
}
if
(
$could_be_offline
)
{
if
(
$could_be_offline
)
{
$result
=
$ilDB
->
query
(
"SELECT id FROM rep_robj_xqsp_data WHERE "
.
$ilDB
->
in
(
"id"
,
$obj_ids
,
false
,
"integer"
));
}
else
{
}
else
{
$result
=
$ilDB
->
queryF
(
"SELECT id FROM rep_robj_xqsp_data WHERE is_online = %s AND "
.
$ilDB
->
in
(
"id"
,
$obj_ids
,
false
,
"integer"
),
array
(
"integer"
),
...
...
@@ -472,8 +451,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
);
}
while
((
$row
=
$ilDB
->
fetchAssoc
(
$result
))
!=
null
)
{
while
((
$row
=
$ilDB
->
fetchAssoc
(
$result
))
!=
null
)
{
$pool
=
new
ilObjQuestionSetPool
();
$pool
->
setRefId
(
$ref_ids
[
$row
[
"id"
]]);
$pool
->
read
();
...
...
@@ -488,24 +466,19 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
global
$DIC
;
$rbacsystem
=
$DIC
->
rbac
()
->
system
();
if
(
$set_id
==
null
)
{
if
(
$set_id
==
null
)
{
return
false
;
}
$set
=
new
ilQuestionSetPoolSet
(
$set_id
);
$set
->
read
();
if
(
$set
->
getContainerObjId
()
!=
null
)
{
if
(
$set
->
getContainerObjId
()
!=
null
)
{
$available
=
array_keys
(
self
::
getAvailableQuestionSetPools
());
if
(
in_array
(
$set
->
getContainerObjId
(),
$available
))
{
if
(
in_array
(
$set
->
getContainerObjId
(),
$available
))
{
$refs
=
ilObject
::
_getAllReferences
(
$set
->
getContainerObjId
());
foreach
(
$refs
as
$ref
)
{
if
(
$rbacsystem
->
checkAccess
(
"write"
,
$ref
)
&&
ilObject
::
_hasUntrashedReference
(
$set
->
getContainerObjId
()))
{
foreach
(
$refs
as
$ref
)
{
if
(
$rbacsystem
->
checkAccess
(
"write"
,
$ref
)
&&
ilObject
::
_hasUntrashedReference
(
$set
->
getContainerObjId
()))
{
return
true
;
}
}
...
...
@@ -528,8 +501,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
*/
public
function
isSkillServiceEnabled
()
{
if
(
!
self
::
isSkillManagementGloballyActivated
())
{
if
(
!
self
::
isSkillManagementGloballyActivated
())
{
return
false
;
}
...
...
@@ -541,10 +513,7 @@ class ilObjQuestionSetPool extends ilObjectPlugin implements ilPluginModelInterf
*/
public
static
function
isSkillManagementGloballyActivated
()
{
if
(
self
::
$isSkillManagementGloballyActivated
===
null
)
{
include_once
'./Services/Skill/classes/class.ilSkillManagementSettings.php'
;
if
(
self
::
$isSkillManagementGloballyActivated
===
null
)
{
$skmgSet
=
new
ilSkillManagementSettings
();
self
::
$isSkillManagementGloballyActivated
=
$skmgSet
->
isActivated
();
...
...
classes/class.ilObjQuestionSetPoolAccess.php
View file @
381d5850
<?php
/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
require_once
'Services/Repository/classes/class.ilObjectPluginAccess.php'
;
require_once
'class.ilObjQuestionSetPool.php'
;
/**
...
...
@@ -29,19 +28,16 @@ class ilObjQuestionSetPoolAccess extends ilObjectPluginAccess
*/
global
$ilUser
,
$ilAccess
;
if
(
!
$a_user_id
)
{
if
(
!
$a_user_id
)
{
$a_user_id
=
$ilUser
->
getId
();
}
switch
(
$a_permission
)
{
switch
(
$a_permission
)
{
case
'read'
:
if
(
!
ilObjQuestionSetPoolAccess
::
checkOnline
(
$a_obj_id
)
&&
!
$ilAccess
->
checkAccessOfUser
(
$a_user_id
,
'write'
,
''
,
$a_ref_id
)
)
{
)
{
return
false
;
}
return
true
;
...
...
@@ -62,7 +58,7 @@ class ilObjQuestionSetPoolAccess extends ilObjectPluginAccess
* @param array $a_obj_ids
* @param array $a_ref_ids
*/
static
function
_preloadData
(
$a_obj_ids
,
$a_ref_ids
)
public
static
function
_preloadData
(
$a_obj_ids
,
$a_ref_ids
)
{
ilObjQuestionSetPool
::
preloadDataForLists
(
$a_obj_ids
,
$a_ref_ids
);
}
...
...
classes/class.ilObjQuestionSetPoolGUI.php
View file @
381d5850
<?php
/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
require_once
'Services/Repository/classes/class.ilObjectPluginGUI.php'
;
require_once
'Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php'
;
/**
* Class ilObjQuestionSetPoolGUI
* Date: 23.09.13
...
...
@@ -36,16 +33,13 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
*/
global
$ilTabs
,
$tpl
;
require_once
"./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/dispatcher/class.ilPluginDispatcher.php"
;
$tpl
->
setDescription
(
$this
->
object
->
getDescription
());
$this
->
lng
->
loadLanguageModule
(
'assessment'
);
$tpl
->
addCss
(
'./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/templates/default/xqsp.css'
);
$next_class
=
$this
->
ctrl
->
getNextClass
(
$this
);
switch
(
$next_class
)
{
switch
(
$next_class
)
{
case
'ilquestionsetpoolskilladministrationgui'
:
require_once
'controllers/class.ilQuestionSetPoolSkillAdministrationGUI.php'
;
$this
->
prepareOutput
();
...
...
@@ -57,7 +51,6 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
case
'ilmdeditorgui'
:
$this
->
checkPermission
(
'write'
);
require_once
'Services/MetaData/classes/class.ilMDEditorGUI.php'
;
$md_gui
=
new
ilMDEditorGUI
(
$this
->
object
->
getId
(),
0
,
$this
->
object
->
getType
());
$md_gui
->
addObserver
(
$this
->
object
,
'MDUpdateListener'
,
'General'
);
$ilTabs
->
setTabActive
(
'meta_data'
);
...
...
@@ -65,14 +58,12 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
break
;
case
'ilpublicuserprofilegui'
:
require_once
'Services/User/classes/class.ilPublicUserProfileGUI.php'
;
$profile_gui
=
new
ilPublicUserProfileGUI
(
$_GET
[
'user'
]);
$profile_gui
->
setBackUrl
(
$this
->
ctrl
->
getLinkTarget
(
$this
,
'showContent'
));
$this
->
tpl
->
setContent
(
$this
->
ctrl
->
forwardCommand
(
$profile_gui
));
break
;
case
'ilcommonactiondispatchergui'
:
require_once
'Services/Object/classes/class.ilCommonActionDispatcherGUI.php'
;
$gui
=
ilCommonActionDispatcherGUI
::
getInstanceFromAjaxCall
();
$this
->
ctrl
->
forwardCommand
(
$gui
);
break
;
...
...
@@ -85,13 +76,11 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
$this
->
ctrl
->
forwardCommand
(
$exp_gui
);
break
;
default
:
switch
(
$cmd
)
{
switch
(
$cmd
)
{
case
'redrawHeaderAction'
:
case
'addToDesk'
:
case
'removeFromDesk'
:
if
(
in_array
(
$cmd
,
array
(
'addToDesk'
,
'removeFromDesk'
)))
{
if
(
in_array
(
$cmd
,
array
(
'addToDesk'
,
'removeFromDesk'
)))
{
$cmd
.
=
'Object'
;
}
$this
->
checkPermission
(
'read'
);
...
...
@@ -100,6 +89,7 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
default
:
$this
->
ensureEntityExistance
();
require_once
"./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/dispatcher/class.ilPluginDispatcher.php"
;
$dispatcher
=
ilPluginDispatcher
::
getInstance
(
$this
);
$dispatcher
->
dispatch
(
$cmd
);
break
;
...
...
@@ -117,34 +107,28 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
protected
function
ensureEntityExistance
()
{
if
(
isset
(
$_GET
[
'set_id'
])
&&
(
int
)
$_GET
[
'set_id'
])
{
if
(
isset
(
$_GET
[
'set_id'
])
&&
(
int
)
$_GET
[
'set_id'
])
{
$set_id
=
(
int
)
$_GET
[
'set_id'
];
$this
->
getPlugin
()
->
includeClass
(
'models/class.ilQuestionSetPoolSet.php'
);
if
(
!
ilQuestionSetPoolSet
::
exists
(
$set_id
))
{
if
(
!
ilQuestionSetPoolSet
::
exists
(
$set_id
))
{
ilUtil
::
sendFailure
(
$this
->
txt
(
'poss_sync_err_set'
),
true
);
$this
->
redirectToDefaultPage
();
}
}
if
(
isset
(
$_GET
[
'path_id'
])
&&
(
int
)
$_GET
[
'path_id'
])
{
if
(
isset
(
$_GET
[
'path_id'
])
&&
(
int
)
$_GET
[
'path_id'
])
{
$path_id
=
(
int
)
$_GET
[
'path_id'
];
$this
->
getPlugin
()
->
includeClass
(
'models/class.ilQuestionSetPoolPath.php'
);
if
(
!
ilQuestionSetPoolPath
::
exists
(
$path_id
))
{
if
(
!
ilQuestionSetPoolPath
::
exists
(
$path_id
))
{
ilUtil
::
sendFailure
(
$this
->
txt
(
'poss_sync_err_path'
),
true
);
$this
->
redirectToDefaultPage
();
}
}
if
(
isset
(
$_GET
[
'node_id'
])
&&
(
int
)
$_GET
[
'node_id'
])
{
if
(
isset
(
$_GET
[
'node_id'
])
&&
(
int
)
$_GET
[
'node_id'
])
{
$node_id
=
(
int
)
$_GET
[
'node_id'
];
$this
->
getPlugin
()
->
includeClass
(
'models/class.ilQuestionSetPoolNode.php'
);
if
(
!
ilQuestionSetPoolNode
::
exists
(
$node_id
))
{
if
(
!
ilQuestionSetPoolNode
::
exists
(
$node_id
))
{
ilUtil
::
sendFailure
(
$this
->
txt
(
'poss_sync_err_node'
),
true
);
$this
->
redirectToDefaultPage
();
}
...
...
@@ -176,7 +160,6 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
*/
public
function
populateContentStyleBlock
()
{
include_once
(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php"
);
$this
->
tpl
->
setCurrentBlock
(
"ContentStyle"
);
$this
->
tpl
->
setVariable
(
"LOCATION_CONTENT_STYLESHEET"
,
ilObjStyleSheet
::
getContentStylePath
(
0
));
$this
->
tpl
->
parseCurrentBlock
();
...
...
@@ -251,17 +234,15 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
// select question pool
include_once
(
"./Modules/Test/classes/class.ilObjTest.php"
);
$tst
=
new
ilObjTest
();
$questionpools
=
$tst
->
getAvailableQuestionpools
(
TRUE
,
FALSE
,
TRUE
,
TRUE
);
$questionpools
=
$tst
->
getAvailableQuestionpools
(
true
,
false
,
true
,
true
);
$this
->
getPlugin
()
->
includeClass
(
'class.ilQuestionSetPoolImporter.php'
);
$options
=
array
(
ilQuestionSetPoolImporter
::
SINGLE_IMPORT_NEW_POOL
=>
$this
->
lng
->
txt
(
"assessment_new_pool"
),
ilQuestionSetPoolImporter
::
SINGLE_IMPORT_NO_POOL
=>
$this
->
lng
->
txt
(
'assessment_no_pool'
)
);
if
(
is_array
(
$questionpools
)
&&
count
(
$questionpools
))
{
foreach
(
$questionpools
as
$key
=>
$value
)
{
if
(
is_array
(
$questionpools
)
&&
count
(
$questionpools
))
{
foreach
(
$questionpools
as
$key
=>
$value
)
{
$options
[
$key
]
=
$value
[
"title"
];
}
}
...
...
@@ -279,17 +260,13 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
{
$this
->
tabs_gui
->
clearTargets
();
if
(
$this
->
checkPermissionBool
(
'read'
))
{
if
(
$this
->
checkPermissionBool
(
'read'
))
{
$this
->
tabs_gui
->
addTab
(
'content'
,
$this
->
txt
(
'question_sets'
),
$this
->
ctrl
->
getLinkTarget
(
$this
,
'ilQuestionSetPoolSetsGUI.show'
));
}
$this
->
addInfoTab
();
if
(
$this
->
checkPermissionBool
(
'read'
)
&&
$this
->
object
->
isSkillServiceEnabled
()
&&
ilObjQuestionSetPool
::
isSkillManagementGloballyActivated
())
{
require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php'
;
if
(
$this
->
checkPermissionBool
(
'read'
)
&&
$this
->
object
->
isSkillServiceEnabled
()
&&
ilObjQuestionSetPool
::
isSkillManagementGloballyActivated
())
{
$link
=
$this
->
ctrl
->
getLinkTargetByClass
(
array
(
'ilQuestionSetPoolSkillAdministrationGUI'
,
'ilAssQuestionSkillAssignmentsGUI'
),
ilAssQuestionSkillAssignmentsGUI
::
CMD_SHOW_SKILL_QUEST_ASSIGNS
...
...
@@ -298,8 +275,7 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
$this
->
tabs_gui
->
addTarget
(
'tst_tab_competences'
,
$link
);
}
if
(
$this
->
checkPermissionBool
(
'write'
))
{
if
(
$this
->
checkPermissionBool
(
'write'
))
{
$this
->
tabs_gui
->
addTab
(
'properties'
,
$this
->
lng
->
txt
(
'properties'
),
$this
->
ctrl
->
getLinkTarget
(
$this
,
'ilQuestionSetPoolPropertiesGUI.edit'
));
$this
->
tabs_gui
->
addTarget
(
'meta_data'
,
$this
->
ctrl
->
getLinkTargetByClass
(
'ilmdeditorgui'
,
''
),
''
,
'ilmdeditorgui'
);
$this
->
tabs_gui
->
addTarget
(
"export"
,
$this
->
ctrl
->
getLinkTargetByClass
(
"ilquestionsetpoolexportgui"
,
""
),
""
,
"ilquestionsetpoolexportgui"
);
...
...
@@ -321,56 +297,12 @@ class ilObjQuestionSetPoolGUI extends ilObjectPluginGUI implements ilDesktopItem
global
$ilUser
;
$lg
=
parent
::
initHeaderAction
();
if
(
$lg
instanceof
ilObjQuestionSetPoolListGUI
)
{
if
(
$ilUser
->
getId
()
!=
ANONYMOUS_USER_ID
)
{
if
(
$lg
instanceof
ilObjQuestionSetPoolListGUI
)
{
if
(
$ilUser
->
getId
()
!=
ANONYMOUS_USER_ID
)
{
// Maybe handle notifications in future ...
}
}
return
$lg
;
}
/**
* @see ilDesktopItemHandling::addToDesk()
*/
public
function
addToDeskObject
()
{
/**
* @var $ilSetting ilSetting
* @var $lng ilLanguage
*/
global
$ilSetting
,
$lng
;
if
((
int
)
$ilSetting
->
get
(
'disable_my_offers'
))
{
$this
->
ctrl
->
redirect
(
$this
);
return
;
}
include_once
'./Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php'
;
ilDesktopItemGUI
::
addToDesktop
();
ilUtil
::
sendSuccess
(
$lng
->
txt
(
'added_to_desktop'
),
true
);
$this
->
ctrl
->
redirect
(
$this
);
}
/**
* @see ilDesktopItemHandling::removeFromDesk()
*/
public
function
removeFromDeskObject
()
{
global
$ilSetting
,
$lng
;
if
((
int
)
$ilSetting
->
get
(
'disable_my_offers'
))
{
$this
->
ctrl
->
redirect
(
$this
);
return
;
}
include_once
'./Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php'
;
ilDesktopItemGUI
::
removeFromDesktop
();
ilUtil
::
sendSuccess
(
$lng
->
txt
(
'removed_from_desktop'
),
true
);
$this
->
ctrl
->
redirect
(
$this
);
}
}
classes/class.ilObjQuestionSetPoolListGUI.php
View file @
381d5850
<?php
/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
require_once
'Services/Repository/classes/class.ilObjectPluginListGUI.php'
;
/**
* Class ilObjQuestionSetPoolListGUI
*
...
...
@@ -12,7 +10,6 @@ require_once 'Services/Repository/classes/class.ilObjectPluginListGUI.php';
*/
class
ilObjQuestionSetPoolListGUI
extends
ilObjectPluginListGUI
{
public
function
getGuiClass
()
{
return
'ilObj'
.
ilQuestionSetPoolPlugin
::
getName
()
.
'GUI'
;
...
...
@@ -55,8 +52,7 @@ class ilObjQuestionSetPoolListGUI extends ilObjectPluginListGUI
$props
=
array
();
include_once
"class.ilObjQuestionSetPoolAccess.php"
;
if
(
!
ilObjQuestionSetPoolAccess
::
checkOnline
(
$this
->
obj_id
))
{
if
(
!
ilObjQuestionSetPoolAccess
::
checkOnline
(
$this
->
obj_id
))
{
$props
[]
=
array
(
"alert"
=>
true
,
"property"
=>
$lng
->
txt
(
"status"
),
"value"
=>
$lng
->
txt
(
"offline"
));
}
...
...
classes/class.ilObjQuestionSetPoolXMLParser.php
View file @
381d5850
<?php
/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
require_once
'Services/Xml/classes/class.ilSaxParser.php'
;
/**
* Class ilObjQuestionSetPoolXMLParser
* @author Nadia Matuschek <nmatuschek@databay.de>
...
...
@@ -79,22 +77,19 @@ class ilObjQuestionSetPoolXMLParser extends ilSaxParser
*/
public
function
handlerBeginTag
(
$xmlParser
,
$tagName
,
$tagAttributes
)
{
switch
(
$tagName
)
{
switch
(
$tagName
)
{
case
'MetaData'
:
$this
->
inMetaDataTag
=
true
;
break
;
case
'General'
:
if
(
$this
->
inMetaDataTag
)
{
if
(
$this
->
inMetaDataTag
)
{
$this
->
inMdGeneralTag
=
true
;
}
break
;
case
'Description'
:
if
(
$this
->
inMetaDataTag
&&
$this
->
inMdGeneralTag
)
{
if
(
$this
->
inMetaDataTag
&&
$this
->
inMdGeneralTag
)
{
$this
->
cdata
=
''
;
}
break
;
...
...
@@ -105,8 +100,7 @@ class ilObjQuestionSetPoolXMLParser extends ilSaxParser
case
'Online'
:
case
'SkillService'
:
if
(
$this
->
inSettingsTag
)
{
if
(
$this
->
inSettingsTag
)
{
$this
->
cdata
=
''
;
}
break
;
...
...
@@ -125,30 +119,26 @@ class ilObjQuestionSetPoolXMLParser extends ilSaxParser
*/
public
function
handlerEndTag
(
$xmlParser
,
$tagName
)
{
switch
(
$tagName
)
{
switch
(
$tagName
)
{
case
'MetaData'
:
$this
->
inMetaDataTag
=
false
;
break
;
case
'General'
:
if
(
$this
->
inMetaDataTag
)
{
if
(
$this
->
inMetaDataTag
)
{
$this
->
inMdGeneralTag
=
false
;
}
break
;
case
'Title'
:
if
(
$this
->
inMetaDataTag
&&
$this
->
inMdGeneralTag
)
{
if
(
$this
->
inMetaDataTag
&&
$this
->
inMdGeneralTag
)
{
$this
->
xqsp_obj
->
setTitle
(
trim
(
$this
->
cdata
));
$this
->
cdata
=
''
;
}
break
;
case
'Description'
:
if
(
$this
->
inMetaDataTag
&&
$this
->
inMdGeneralTag
)
{
if
(
$this
->
inMetaDataTag
&&
$this
->
inMdGeneralTag
)
{
$this
->
xqsp_obj
->
setDescription
(
trim
(
$this
->
cdata
));
$this
->
cdata
=
''
;
}
...
...
@@ -253,8 +243,7 @@ class ilObjQuestionSetPoolXMLParser extends ilSaxParser
public
function
handlerCharacterData
(
$xmlParser
,
$charData
)
{
if
(
$charData
!=
"
\n
"
)
{
if
(
$charData
!=
"
\n
"
)
{
// Replace multiple tabs with one space
$charData
=
preg_replace
(
"/
\t
+/"
,
" "
,
$charData
);
...
...
classes/class.ilQuestionSetPoolExportGUI.php
View file @
381d5850
<?php
/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
require_once
'Services/Export/classes/class.ilExportGUI.php'
;
/**
* Export User Interface Class
* @author Nadia Matuschek <nmatuschek@databay.de>
...
...
@@ -24,8 +22,7 @@ class ilQuestionSetPoolExportGUI extends ilExportGUI
*/
public
function
download
()
{
if
(
isset
(
$_GET
[
'file'
])
&&
$_GET
[
'file'
])
{
if
(
isset
(
$_GET
[
'file'
])
&&
$_GET
[
'file'
])
{
$_POST
[
'file'
]
=
array
(
$_GET
[
'file'
]);
}
parent
::
download
();
...
...
classes/class.ilQuestionSetPoolExporter.php
View file @
381d5850
<?php
/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
include_once
'./Services/Export/classes/class.ilXmlExporter.php'
;
include_once
'./Services/Xml/classes/class.ilXmlWriter.php'
;
include_once
'./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php'
;
/**
* Class ilQuestionSetPoolExporter
* author Nadia Matuschek <nmatuschek@databay.de>
...
...
@@ -14,7 +10,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
/**
* @var ilXmlWriter
*/
protected
$xml_writer
=
NULL
;
protected
$xml_writer
=
null
;
/**
* @var string
...
...
@@ -49,12 +45,12 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
/**
* @var ilLog
*/
protected
$expLog
=
NULL
;
protected
$expLog
=
null
;
/**
* Initialisation
*/
function
init
()
public
function
init
()
{
}
...
...
@@ -71,7 +67,6 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
*/
public
function
initLogFile
()
{
include_once
"./Services/Logging/classes/class.ilLog.php"
;
$this
->
expLog
=
new
ilLog
(
$this
->
getExportDirectory
(),
"export.log"
);
$this
->
expLog
->
delete
();
$this
->
expLog
->
setLogFormat
(
""
);
...
...
@@ -83,23 +78,20 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
* (data_dir/qpl_data/qpl_<id>/export, depending on data
* directory that is set in ILIAS setup/ini)
*/
function
createExportDirectory
()
public
function
createExportDirectory
()
{
global
$ilErr
;
include_once
"./Services/Utilities/classes/class.ilUtil.php"
;
$xqsp_data_dir
=
ilUtil
::
getDataDir
()
.
"/xqsp_data"
;
ilUtil
::
makeDir
(
$xqsp_data_dir
);
if
(
!
is_writable
(
$xqsp_data_dir
))
{
if
(
!
is_writable
(
$xqsp_data_dir
))
{
$ilErr
->
raiseError
(
"Questionpool Data Directory ("
.
$xqsp_data_dir
.
") not writeable."
,
$ilErr
->
FATAL
);
}
// create learning module directory (data_dir/lm_data/lm_<id>)
$xqsp_dir
=
$xqsp_data_dir
.
"/xqsp_"
.
$this
->
object
->
getId
();
ilUtil
::
makeDir
(
$xqsp_dir
);
if
(
!@
is_dir
(
$xqsp_dir
))
{
if
(
!@
is_dir
(
$xqsp_dir
))
{
$ilErr
->
raiseError
(
"Creation of QuestionSetPool Directory failed. xqsp_"
,
$ilErr
->
FATAL
);
}
// // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
...
...
@@ -109,11 +101,9 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
// $ilErr->raiseError("Creation of Export Directory failed. xls", $ilErr->FATAL);
// }
ilUtil
::
makeDir
(
$this
->
getExportDirectory
(
'zip'
));
if
(
!@
is_dir
(
$this
->
getExportDirectory
(
'zip'
)))
{
if
(
!@
is_dir
(
$this
->
getExportDirectory
(
'zip'
)))
{
$ilErr
->
raiseError
(
"Creation of Export Directory failed. zip"
,
$ilErr
->
FATAL
);
}
}
/**
...
...
@@ -121,13 +111,10 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
* @param string $type
* @return string
*/
function
getExportDirectory
(
$type
=
""
)
{
include_once
"./Services/Utilities/classes/class.ilUtil.php"
;
switch
(
$type
)
public
function
getExportDirectory
(
$type
=
""
)
{
switch
(
$type
)
{
case
'xml'
:
include_once
(
"./Services/Export/classes/class.ilExport.php"
);
$export_dir
=
ilExport
::
_getExportDirectory
(
$this
->
object
->
getId
(),
$type
,
$this
->
object
->
getType
());
break
;
// case 'xls':
...
...
@@ -181,8 +168,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
$ilBench
->
stop
(
"ContentObjectExport"
,
"exportMediaObjects"
);
$this
->
expLog
->
write
(
date
(
"[y-m-d H:i:s] "
)
.
"Finished Export Media Objects"
);
if
(
is_array
(
$this
->
qpl_obj
->
file_ids
)
&&
count
(
$this
->
qpl_obj
->
file_ids
)
>
0
)
{
if
(
is_array
(
$this
->
qpl_obj
->
file_ids
)
&&
count
(
$this
->
qpl_obj
->
file_ids
)
>
0
)
{
// FileItems
$this
->
expLog
->
write
(
date
(
"[y-m-d H:i:s] "
)
.
"Start Export File Items"
);
$ilBench
->
start
(
"ContentObjectExport"
,
"exportFileItems"
);
...
...
@@ -196,9 +182,8 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
/**
* export content objects meta data to xml (see ilias_co.dtd)
*/
function
exportXMLMetaData
()
public
function
exportXMLMetaData
()
{
include_once
(
"Services/MetaData/classes/class.ilMD2XML.php"
);
$md2xml
=
new
ilMD2XML
(
$this
->
object
->
getId
(),
0
,
$this
->
object
->
getType
());
$md2xml
->
setExportMode
(
true
);
$md2xml
->
startExport
();
...
...
@@ -236,8 +221,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
$sets
=
$setlist
->
loadData
();
$this
->
xml_writer
->
xmlStartTag
(
'QuestionSets'
);
foreach
(
$sets
as
$set_index
=>
$set_data
)
{
foreach
(
$sets
as
$set_index
=>
$set_data
)
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$set_data
[
'id'
]);
$set
->
read
();
...
...
@@ -268,8 +252,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
$questions
=
array
();
$questions
=
$questionList
->
loadData
();
$this
->
xml_writer
->
xmlStartTag
(
'Questions'
);
foreach
(
$questions
as
$question_index
=>
$question
)
{
foreach
(
$questions
as
$question_index
=>
$question
)
{
$this
->
xml_writer
->
xmlStartTag
(
'Question'
);
$this
->
xml_writer
->
xmlElement
(
'QuestionId'
,
null
,
$question
[
'question_id'
]);
$this
->
xml_writer
->
xmlElement
(
'QuestionIndex'
,
null
,
$question
[
'question_index'
]);
...
...
@@ -278,8 +261,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
$this
->
questions
[
$question
[
'question_id'
]]
=
$question
[
'question_id'
];
}
$this
->
xml_writer
->
xmlEndTag
(
'Questions'
);
if
(
is_array
(
$this
->
questions
)
&&
count
(
$this
->
questions
)
>
0
)
{
if
(
is_array
(
$this
->
questions
)
&&
count
(
$this
->
questions
)
>
0
)
{
$this
->
exportQuestions
();
}
}
...
...
@@ -293,8 +275,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
$paths
=
$pathList
->
loadData
();
$this
->
xml_writer
->
xmlStartTag
(
'Paths'
);
foreach
(
$paths
as
$path_index
=>
$path_data
)
{
foreach
(
$paths
as
$path_index
=>
$path_data
)
{
$path
=
new
ilQuestionSetPoolPath
();
$path
->
setId
(
$path_data
[
'id'
]);
$path
->
read
();
...
...
@@ -321,8 +302,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
$nodes
=
$nodeList
->
loadData
();
$this
->
xml_writer
->
xmlStartTag
(
'Nodes'
);
foreach
(
$nodes
as
$node_index
=>
$node_data
)
{
foreach
(
$nodes
as
$node_index
=>
$node_data
)
{
$node
=
new
ilQuestionSetPoolNode
((
int
)
$node_data
[
'id'
]);
$node
->
read
();
$this
->
xml_writer
->
xmlStartTag
(
'Node'
);
...
...
@@ -356,8 +336,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
$this
->
xml_writer
->
xmlStartTag
(
'JumpConditions'
);
foreach
(
$jumpConditions
as
$jmp_con_index
=>
$jumpCondition_data
)
{
foreach
(
$jumpConditions
as
$jmp_con_index
=>
$jumpCondition_data
)
{
$jumpCondition
=
new
ilQuestionSetPoolJumpCondition
();
$jumpCondition
->
setId
(
$jumpCondition_data
[
'id'
]);
$jumpCondition
->
read
();
...
...
@@ -396,18 +375,14 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
/**
* @param $a_export_dir
*/
function
exportXHTMLMediaObjects
(
$a_export_dir
)
public
function
exportXHTMLMediaObjects
(
$a_export_dir
)
{
include_once
(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php"
);
ilUtil
::
makeDirParents
(
$a_export_dir
.
"/objects/"
);
foreach
(
$this
->
questions
as
$question_id
)
{
foreach
(
$this
->
questions
as
$question_id
)
{
$mobs
=
ilObjMediaObject
::
_getMobsOfObject
(
"qpl:html"
,
$question_id
);
foreach
(
$mobs
as
$mob
)
{
if
(
ilObjMediaObject
::
_exists
(
$mob
))
{
foreach
(
$mobs
as
$mob
)
{
if
(
ilObjMediaObject
::
_exists
(
$mob
))
{
$mob_obj
=
new
ilObjMediaObject
(
$mob
);
$mob_obj
->
exportFiles
(
$a_export_dir
);
unset
(
$mob_obj
);
...
...
@@ -472,8 +447,7 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
*/
public
function
getXmlExportHeadDependencies
(
$a_entity
,
$a_target_release
,
$a_ids
)
{
if
(
"xqsp"
==
$a_entity
)
{
if
(
"xqsp"
==
$a_entity
)
{
// Array von QSP obj_ids
$qpl_obj_ids
=
array
();
...
...
@@ -487,27 +461,20 @@ class ilQuestionSetPoolExporter extends ilXmlExporter
WHERE '
.
$ilDB
->
in
(
'qs.questionsetpool_fi'
,
$a_ids
,
false
,
'integer'
));
$org_qst_ids
=
array
();
while
(
$row
=
$ilDB
->
fetchAssoc
(
$res
))
{
while
(
$row
=
$ilDB
->
fetchAssoc
(
$res
))
{
$ids
[]
=
$row
;
if
(
$row
[
'original_id'
]
!==
NULL
)
{
if
(
$row
[
'original_id'
]
!==
null
)
{
$org_qst_ids
[]
=
$row
[
'original_id'
];
}
else
{
}
else
{
$org_qst_ids
[]
=
$row
[
'question_id'
];
}
}
if
(
is_array
(
$org_qst_ids
)
&&
count
(
$org_qst_ids
)
>
0
)
{
if
(
is_array
(
$org_qst_ids
)
&&
count
(
$org_qst_ids
)
>
0
)
{
$res_2
=
$ilDB
->
query
(
'SELECT obj_fi FROM qpl_questions WHERE '
.
$ilDB
->
in
(
'question_id'
,
$org_qst_ids
,
false
,
'integer'
));
while
(
$row
=
$ilDB
->
fetchAssoc
(
$res_2
))
{
if
(
$ilObjDataCache
->
lookupType
(
$row
[
'obj_fi'
])
==
'qpl'
)
{
while
(
$row
=
$ilDB
->
fetchAssoc
(
$res_2
))
{
if
(
$ilObjDataCache
->
lookupType
(
$row
[
'obj_fi'
])
==
'qpl'
)
{
$qpl_obj_ids
[
$row
[
'obj_fi'
]]
=
$row
[
'obj_fi'
];
}
}
...
...
classes/class.ilQuestionSetPoolImporter.php
View file @
381d5850
<?php
/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
include_once
(
"./Services/Export/classes/class.ilXmlImporter.php"
);
include_once
(
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php"
);
/**
* Class ilQuestionSetPoolImporter
* @author Nadia Matuschek <nmatuschek@databay.de>
...
...
@@ -16,7 +13,7 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
/**
* @var ilObjQuestionPool
*/
protected
$qpl_obj
=
NULL
;
protected
$qpl_obj
=
null
;
protected
$is_single_import
=
true
;
...
...
@@ -30,11 +27,11 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
/**
* @var null
*/
protected
$xml_file
=
NULL
;
protected
$xml_file
=
null
;
/**
* @var null
*/
protected
$qti_file
=
NULL
;
protected
$qti_file
=
null
;
/**
* @var array
...
...
@@ -111,20 +108,17 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
{
global
$ilErr
;
include_once
"./Services/Utilities/classes/class.ilUtil.php"
;
$xqsp_data_dir
=
ilUtil
::
getDataDir
()
.
"/xqsp_data"
;
ilUtil
::
makeDir
(
$xqsp_data_dir
);
if
(
!
is_writable
(
$xqsp_data_dir
))
{
if
(
!
is_writable
(
$xqsp_data_dir
))
{
$ilErr
->
raiseError
(
"QuestionSetPool Data Directory ("
.
$xqsp_data_dir
.
") not writeable."
,
$ilErr
->
error_obj
->
FATAL
);
}
// create QuestionSetPool directory (data_dir/xqsp_data/xqsp_import)
$import_dir
=
$xqsp_data_dir
.
"/xqsp_import"
;
ilUtil
::
makeDir
(
$import_dir
);
if
(
!@
is_dir
(
$import_dir
))
{
if
(
!@
is_dir
(
$import_dir
))
{
$ilErr
->
raiseError
(
"Creation of QuestionSetPool import directory failed."
,
$ilErr
->
error_obj
->
FATAL
);
}
...
...
@@ -133,12 +127,9 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
public
function
initializeQplObject
(
$id
)
{
if
(
$id
<=
0
)
{
if
(
$id
<=
0
)
{
$this
->
qpl_obj
=
$this
->
createQplObject
();
}
else
{
}
else
{
$this
->
qpl_obj
=
new
ilObjQuestionPool
(
$id
,
false
);
$this
->
qpl_obj
->
read
(
true
);
}
...
...
@@ -177,7 +168,6 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
protected
function
parseQtiFile
()
{
//@important do not delete this $_SESSION handling!!
include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php"
;
$tmp_dir
=
ilObjQuestionPool
::
_getImportDirectory
();
ilObjQuestionPool
::
_setImportDirectory
(
$this
->
getImportDirectoryBase
());
...
...
@@ -185,7 +175,6 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
$_SESSION
[
"qpl_import_subdir"
]
=
basename
(
$this
->
getImportDirectory
());
// start parsing of QTI files
include_once
"./Services/QTI/classes/class.ilQTIParser.php"
;
$qtiParser
=
new
ilQTIParser
(
$this
->
getQtiFile
(),
IL_MO_PARSE_QTI
,
$this
->
xqsp_obj
->
getId
());
$result
=
$qtiParser
->
startParsing
();
$this
->
addQuestionMapping
(
$qtiParser
->
getImportMapping
());
...
...
@@ -196,8 +185,7 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
protected
function
addQuestionMapping
(
$qtiParser_import_mapping
)
{
foreach
(
$qtiParser_import_mapping
as
$question_ident
=>
$pool_qst_ident
)
{
foreach
(
$qtiParser_import_mapping
as
$question_ident
=>
$pool_qst_ident
)
{
$exp_ident
=
explode
(
'_qst_'
,
$question_ident
);
$old_qst_id
=
end
(
$exp_ident
);
$new_qst_id
=
$pool_qst_ident
[
'pool'
];
...
...
@@ -222,36 +210,28 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
$this
->
addSetMapping
(
$set_data
[
'SetId'
],
$set
->
getId
());
foreach
(
$set_questions
as
$set_question
)
{
foreach
(
$set_questions
as
$set_question
)
{
$original_question_id
=
$a_mapping
->
getMapping
(
'Modules/TestQuestionPool'
,
'quest'
,
$set_question
[
'QuestionOriginalId'
]);
if
(
$original_question_id
)
{
if
(
!
assQuestion
::
_questionExistsInPool
(
$original_question_id
))
{
$original_question_id
=
NULL
;
if
(
$original_question_id
)
{
if
(
!
assQuestion
::
_questionExistsInPool
(
$original_question_id
))
{
$original_question_id
=
null
;
}
}
$copy_id
=
$set
->
getQuestionList
()
->
import
(
$this
->
qpl_qst_mapping
[
$set_question
[
'QuestionId'
]],
$original_question_id
);
$this
->
qpl_qst_mapping
[
$set_question
[
'QuestionId'
]]
=
$copy_id
;
if
(
$original_question_id
==
0
||
$this
->
is_single_import
)
{
if
(
$original_question_id
==
0
||
$this
->
is_single_import
)
{
$this
->
qpl_qst_mapping
[
'new_qpl'
][
$set_question
[
'QuestionId'
]]
=
$copy_id
;
if
(
$set_question
[
'QuestionOriginalId'
])
{
if
(
$set_question
[
'QuestionOriginalId'
])
{
$a_mapping
->
addMapping
(
'Plugins/xqsp'
,
'org_qst_id'
,
$set_question
[
'QuestionOriginalId'
],
$copy_id
);
}
}
else
{
}
else
{
$this
->
qpl_qst_mapping
[
'new_qpl'
][
$set_question
[
'QuestionId'
]]
=
$original_question_id
;
}
}
foreach
(
$set_paths
as
$set_path
)
{
foreach
(
$set_paths
as
$set_path
)
{
$path
=
new
ilQuestionSetPoolPath
();
$path
->
setSet
(
$set
);
$path
->
setTitle
(
$set_path
[
0
][
'PathTitle'
]);
...
...
@@ -270,14 +250,12 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
*/
protected
function
importNodes
(
$nodes
,
ilQuestionSetPoolPath
$path
)
{
foreach
(
$nodes
as
$node_data
)
{
foreach
(
$nodes
as
$node_data
)
{
$node
=
new
ilQuestionSetPoolNode
();
$node
->
setQuestion
(
assQuestion
::
_instantiateQuestion
(
$this
->
qpl_qst_mapping
[
$node_data
[
0
][
'NodeQuestionId'
]]));
$node
->
setPath
(
$path
);
$node
->
setInitialCondition
(
$node_data
[
0
][
'NodeInitialCondition'
]);
if
(
strlen
(
$node_data
[
0
][
'NodeDominantScoring'
]))
{
if
(
strlen
(
$node_data
[
0
][
'NodeDominantScoring'
]))
{
$node
->
setDominantScoring
(
$node_data
[
0
][
'NodeDominantScoring'
]);
}
$node
->
setTrueFeedback
(
$node_data
[
0
][
'NodeTrueFeedback'
]);
...
...
@@ -288,8 +266,7 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
$this
->
addNodeMapping
(
$node_data
[
0
][
'NodeId'
],
$node
->
getId
());
$jump_conditions
=
$node_data
[
'jump_conditions'
];
if
(
is_array
(
$jump_conditions
)
&&
count
(
$jump_conditions
)
==
0
)
{
if
(
is_array
(
$jump_conditions
)
&&
count
(
$jump_conditions
)
==
0
)
{
continue
1
;
}
$this
->
importJumpConditions
(
$jump_conditions
,
$node
);
...
...
@@ -302,18 +279,16 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
*/
protected
function
importJumpConditions
(
$jump_conditions
,
ilQuestionSetPoolNode
$node
)
{
foreach
(
$jump_conditions
as
$jump_condition_data
)
{
foreach
(
$jump_conditions
as
$jump_condition_data
)
{
$jump_con
=
new
ilQuestionSetPoolJumpCondition
();
$jump_con
->
setNode
(
$node
);
$jump_con
->
setQuestion
(
$this
->
qpl_qst_mapping
[
$jump_condition_data
[
'JumpConditionQuestionId'
]]
?
assQuestion
::
_instantiateQuestion
(
$this
->
qpl_qst_mapping
[
$jump_condition_data
[
'JumpConditionQuestionId'
]])
:
NULL
null
);
$jump_con
->
setJumpCondition
(
$jump_condition_data
[
'JumpConditionText'
]);
if
(
strlen
(
$jump_condition_data
[
'JumpConditionRepetitions'
]))
{
if
(
strlen
(
$jump_condition_data
[
'JumpConditionRepetitions'
]))
{
$jump_con
->
setRepititions
(
$jump_condition_data
[
'JumpConditionRepetitions'
]);
}
...
...
@@ -360,7 +335,7 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
* @param $a_mapping
* @return bool
*/
function
importXmlRepresentation
(
$a_entity
,
$a_id
,
$a_xml
,
$a_mapping
)
public
function
importXmlRepresentation
(
$a_entity
,
$a_id
,
$a_xml
,
$a_mapping
)
{
/**
* @var $tree ilTree
...
...
@@ -372,8 +347,7 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
$parent_ref_id
=
0
;
if
(
$new_id
=
$a_mapping
->
getMapping
(
'Services/Container'
,
'objs'
,
$a_id
))
{
if
(
$new_id
=
$a_mapping
->
getMapping
(
'Services/Container'
,
'objs'
,
$a_id
))
{
$ref_ids
=
ilObject
::
_getAllReferences
(
$new_id
);
$ref_id
=
current
(
$ref_ids
);
...
...
@@ -382,9 +356,7 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
$this
->
xqsp_obj
=
ilObjectFactory
::
getInstanceByObjId
(
$new_id
,
false
);
$this
->
xqsp_obj
->
setRefId
(
$ref_id
);
$this
->
is_single_import
=
false
;
}
else
{
}
else
{
$this
->
xqsp_obj
=
new
ilObjQuestionSetPool
();
$this
->
xqsp_obj
->
create
(
true
);
$this
->
is_single_import
=
true
;
...
...
@@ -404,15 +376,14 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
// create sets
$sets
=
$parser
->
getSetsArray
();
foreach
(
$sets
as
$set_data
)
{
foreach
(
$sets
as
$set_data
)
{
$this
->
importQuestionSet
(
$set_data
[
0
],
$set_data
[
'questions'
],
$set_data
[
'paths'
],
$a_mapping
);
}
$a_mapping
->
addMapping
(
'Plugins/xqsp'
,
'xqsp'
,
$a_id
,
$this
->
xqsp_obj
->
getId
());
}
function
finalProcessing
(
$a_mapping
)
public
function
finalProcessing
(
$a_mapping
)
{
// Container import
...
...
@@ -423,32 +394,23 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
// Einzel-Import mit (ggf. erfolgter Wahl eines bestehenden Fragenpools als Ziel für Originale unserer Fragen)
$new_qpl_id
=
(
int
)
$_POST
[
'qpl'
];
if
(
$_POST
[
'qpl'
]
==
self
::
SINGLE_IMPORT_NO_POOL
)
{
if
(
$_POST
[
'qpl'
]
==
self
::
SINGLE_IMPORT_NO_POOL
)
{
//Die neuen Fragen 'ohne pool' liegen schon im XQSP.
}
else
{
if
(
$new_qpl_id
>
0
)
{
}
else
{
if
(
$new_qpl_id
>
0
)
{
$this
->
initializeQplObject
(
$new_qpl_id
);
}
// Containter-Import (Plugin liegt im Kurs, die Originale unserer Fragen liegen ggf.(!!) in ebenfalls importierten Fragenpools)
else
if
(
$this
->
is_single_import
||
(
is_array
(
$this
->
qpl_qst_mapping
[
'new_qpl'
])
&&
count
(
$this
->
qpl_qst_mapping
[
'new_qpl'
])
>
0
))
{
elseif
(
$this
->
is_single_import
||
(
is_array
(
$this
->
qpl_qst_mapping
[
'new_qpl'
])
&&
count
(
$this
->
qpl_qst_mapping
[
'new_qpl'
])
>
0
))
{
$parent_ref_id
=
$a_mapping
->
getTargetId
();
if
(
!
$this
->
is_single_import
&&
$this
->
current_parent_ref_id
>
0
)
{
if
(
!
$this
->
is_single_import
&&
$this
->
current_parent_ref_id
>
0
)
{
$parent_ref_id
=
$this
->
current_parent_ref_id
;
}
if
(
isset
(
self
::
$pool_by_parent_id
[
$parent_ref_id
]))
{
if
(
isset
(
self
::
$pool_by_parent_id
[
$parent_ref_id
]))
{
$pool_obj_id
=
self
::
$pool_by_parent_id
[
$parent_ref_id
];
$this
->
initializeQplObject
(
$pool_obj_id
);
}
else
{
}
else
{
// es handelt sich um einen dummy pool
$this
->
initializeQplObject
(
0
);
// put the questionpool object in the administration tree
...
...
@@ -460,15 +422,13 @@ class ilQuestionSetPoolImporter extends ilXmlImporter
}
}
foreach
(
$this
->
qpl_qst_mapping
[
'new_qpl'
]
as
$new_id
)
{
foreach
(
$this
->
qpl_qst_mapping
[
'new_qpl'
]
as
$new_id
)
{
//Die neuen Fragen 'ohne pool' liegen schon im XQSP.
// jetzt müssen sie in den neu angelegten dummy pool (QPL) kopiert werden und die org_id im xqsp-pool angepasst werden.
$source_qst
=
assQuestion
::
_instantiateQuestion
(
$new_id
);
$is_xqsp_pool
=
(
ilObject
::
_lookupType
(
$source_qst
->
getObjId
())
==
'xqsp'
?
true
:
false
);
// This is the intended behaviour, see http://www.ilias.de/mantis/view.php?id=18325
if
((
$source_qst
->
getOriginalId
()
==
NULL
||
$this
->
is_single_import
)
&&
$is_xqsp_pool
)
{
if
((
$source_qst
->
getOriginalId
()
==
null
||
$this
->
is_single_import
)
&&
$is_xqsp_pool
)
{
// Dies ist nur für Fragen "ohne pool" relevant!!!!
$clone_id
=
$source_qst
->
copyObject
(
$this
->
qpl_obj
->
getId
());
$source_qst
=
assQuestion
::
_instantiateQuestion
(
$new_id
);
...
...
Prev
1
2
3
4
5
6
7
Next