ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilObjExercise Class Reference

Class ilObjExercise. More...

+ Inheritance diagram for ilObjExercise:
+ Collaboration diagram for ilObjExercise:

Public Member Functions

 __construct ($a_id=0, $a_call_by_reference=true)
 Constructor @access public. More...
 
 setId ($id)
 Set id. More...
 
 setDate ($a_hour, $a_minutes, $a_day, $a_month, $a_year)
 
 getTimestamp ()
 
 setTimestamp ($a_timestamp)
 
 setInstruction ($a_instruction)
 
 getInstruction ()
 
 setPassMode ($a_val)
 Set pass mode (all | nr) More...
 
 getPassMode ()
 Get pass mode (all | nr) More...
 
 setPassNr ($a_val)
 Set number of assignments that must be passed to pass the exercise. More...
 
 getPassNr ()
 Get number of assignments that must be passed to pass the exercise. More...
 
 setShowSubmissions ($a_val)
 Set whether submissions of learners should be shown to other learners after deadline. More...
 
 getShowSubmissions ()
 Get whether submissions of learners should be shown to other learners after deadline. More...
 
 setNrMandatoryRandom ($a_val)
 Set number of mandatory assignments in random pass mode. More...
 
 getNrMandatoryRandom ()
 Get number of mandatory assignments in random pass mode. More...
 
 checkDate ()
 
 hasTutorFeedbackText ()
 
 hasTutorFeedbackMail ()
 
 hasTutorFeedbackFile ()
 
 setTutorFeedback ($a_value)
 
 saveData ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone exercise (no member data) More...
 
 delete ()
 delete course and all related data More...
 
 read ()
 read object data from db into object More...
 
 update ()
 update object in db More...
 
 sendAssignment (ilExAssignment $a_ass, $a_members)
 send exercise per mail to members More...
 
 updateUserStatus ($a_user_id=0)
 Update exercise status of user. More...
 
 updateAllUsersStatus ()
 Update status of all users. More...
 
 exportGradesExcel ()
 Exports grades as excel. More...
 
 sendFeedbackFileNotification ($a_feedback_file, $a_user_id, $a_ass_id, $a_is_text_feedback=false)
 Send feedback file notification to user. More...
 
 isCompletionBySubmissionEnabled ()
 Checks whether completion by submission is enabled or not. More...
 
 setCompletionBySubmission ($bool)
 Enabled/Disable completion by submission. More...
 
 processExerciseStatus (ilExAssignment $a_ass, array $a_user_ids, $a_has_submitted, array $a_valid_submissions=null)
 
 getCertificateVisibility ()
 Returns the visibility settings of the certificate. More...
 
 setCertificateVisibility ($a_value)
 Sets the visibility settings of the certificate. More...
 
 saveCertificateVisibility ($a_value)
 Saves the visibility settings of the certificate. More...
 
 hasAddToDesktop ()
 Add to desktop after hand-in. More...
 
- Public Member Functions inherited from ilObject
 __construct ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ()
 read object data from db into object More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) @access public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _lookupFinishedUserExercises ($a_user_id)
 Get all exercises for user. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id, $a_deleted_by)
 
static setDeletedDates ($a_ref_ids, $a_user_id)
 Set deleted date. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data@access public More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

 $file_obj
 
 $members_obj
 
 $files
 
 $timestamp
 
 $hour
 
 $minutes
 
 $day
 
 $month
 
 $year
 
 $instruction
 
 $certificate_visibility
 
 $tutor_feedback = 7
 
const TUTOR_FEEDBACK_MAIL = 1
 
const TUTOR_FEEDBACK_TEXT = 2
 
const TUTOR_FEEDBACK_FILE = 4
 
const PASS_MODE_NR = "nr"
 
const PASS_MODE_ALL = "all"
 
const PASS_MODE_RANDOM = "random"
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 

Protected Member Functions

 getTutorFeedback ()
 

Protected Attributes

 $user
 
 $nr_random_mand
 
 $completion_by_submission = false
 
 $mandatory_manager
 
- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

Private Attributes

 $webFilesystem
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjExercise::__construct (   $a_id = 0,
  $a_call_by_reference = true 
)

Constructor @access public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Reimplemented from ilObject.

Definition at line 76 of file class.ilObjExercise.php.

77 {
78 global $DIC;
79
80 $this->db = $DIC->database();
81 $this->app_event_handler = $DIC["ilAppEventHandler"];
82 $this->lng = $DIC->language();
83 $this->user = $DIC->user();
84 $this->setPassMode("all");
85 $this->type = "exc";
86 $this->webFilesystem = $DIC->filesystem()->web();
87
88 parent::__construct($a_id, $a_call_by_reference);
89 $this->mandatory_manager = $DIC->exercise()->internal()->service()->getMandatoryAssignmentManager($this);
90 }
user()
Definition: user.php:4
setPassMode($a_val)
Set pass mode (all | nr)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), setPassMode(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _lookupFinishedUserExercises()

static ilObjExercise::_lookupFinishedUserExercises (   $a_user_id)
static

Get all exercises for user.

Parameters
<type>$a_user_id
Returns
array (exercise id => passed)

Definition at line 819 of file class.ilObjExercise.php.

820 {
821 global $DIC;
822
823 $ilDB = $DIC->database();
824
825 $set = $ilDB->query("SELECT obj_id, status FROM exc_members" .
826 " WHERE usr_id = " . $ilDB->quote($a_user_id, "integer") .
827 " AND (status = " . $ilDB->quote("passed", "text") .
828 " OR status = " . $ilDB->quote("failed", "text") . ")");
829
830 $all = array();
831 while ($row = $ilDB->fetchAssoc($set)) {
832 $all[$row["obj_id"]] = ($row["status"] == "passed");
833 }
834 return $all;
835 }
global $ilDB

References $DIC, and $ilDB.

◆ checkDate()

ilObjExercise::checkDate ( )

Definition at line 218 of file class.ilObjExercise.php.

219 {
220 return $this->hour == (int) date("H", $this->timestamp) and
221 $this->minutes == (int) date("i", $this->timestamp) and
222 $this->day == (int) date("d", $this->timestamp) and
223 $this->month == (int) date("m", $this->timestamp) and
224 $this->year == (int) date("Y", $this->timestamp);
225 }

◆ cloneObject()

ilObjExercise::cloneObject (   $a_target_id,
  $a_copy_id = 0,
  $a_omit_tree = false 
)

Clone exercise (no member data)

@access public

Parameters
inttarget ref_id
intcopy id

Definition at line 278 of file class.ilObjExercise.php.

279 {
281
282 // Copy settings
283 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
284 $new_obj->setInstruction($this->getInstruction());
285 $new_obj->setTimestamp($this->getTimestamp());
286 $new_obj->setPassMode($this->getPassMode());
287 $new_obj->setNrMandatoryRandom($this->getNrMandatoryRandom());
288 $new_obj->saveData();
289 $new_obj->setPassNr($this->getPassNr());
290 $new_obj->setShowSubmissions($this->getShowSubmissions());
291 $new_obj->setCompletionBySubmission($this->isCompletionBySubmissionEnabled());
292 $new_obj->setTutorFeedback($this->getTutorFeedback());
293 $new_obj->setCertificateVisibility($this->getCertificateVisibility());
294 $new_obj->update();
295
296 $new_obj->saveCertificateVisibility($this->getCertificateVisibility());
297
298 // Copy criteria catalogues
299 $crit_cat_map = array();
300 foreach (ilExcCriteriaCatalogue::getInstancesByParentId($this->getId()) as $crit_cat) {
301 $new_id = $crit_cat->cloneObject($new_obj->getId());
302 $crit_cat_map[$crit_cat->getId()] = $new_id;
303 }
304
305 // Copy assignments
306 ilExAssignment::cloneAssignmentsOfExercise($this->getId(), $new_obj->getId(), $crit_cat_map);
307
308 // Copy learning progress settings
309 $obj_settings = new ilLPObjSettings($this->getId());
310 $obj_settings->cloneSettings($new_obj->getId());
311 unset($obj_settings);
312
313 $pathFactory = new ilCertificatePathFactory();
314 $templateRepository = new ilCertificateTemplateRepository($ilDB);
315
316 $cloneAction = new ilCertificateCloneAction(
317 $ilDB,
318 $pathFactory,
319 $templateRepository,
320 $this->webFilesystem,
321 $this->log,
323 );
324
325 $cloneAction->cloneCertificate($this, $new_obj);
326
327 // additional features
328 foreach (ilContainer::_getContainerSettings($this->getId()) as $keyword => $value) {
329 ilContainer::_writeContainerSetting($new_obj->getId(), $keyword, $value);
330 }
331
332 // org unit setting
333 $orgu_object_settings = new ilOrgUnitObjectPositionSetting($new_obj->getId());
334 $orgu_object_settings->setActive(
335 (int) ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($this->getId())
336 );
337 $orgu_object_settings->update();
338
339 return $new_obj;
340 }
static _getContainerSettings($a_id)
static _writeContainerSetting($a_id, $a_keyword, $a_value)
static cloneAssignmentsOfExercise($a_old_exc_id, $a_new_exc_id, array $a_crit_cat_map)
Clone assignments of exercise.
static getInstancesByParentId($a_parent_id)
getShowSubmissions()
Get whether submissions of learners should be shown to other learners after deadline.
getNrMandatoryRandom()
Get number of mandatory assignments in random pass mode.
getPassNr()
Get number of assignments that must be passed to pass the exercise.
getCertificateVisibility()
Returns the visibility settings of the certificate.
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
getPassMode()
Get pass mode (all | nr)
getId()
get object id @access public
Stores object activation status of orgunit position settings.

References ilObject\$db, $ilDB, ilContainer\_getContainerSettings(), ilContainer\_writeContainerSetting(), ilExAssignment\cloneAssignmentsOfExercise(), getCertificateVisibility(), ilObject\getId(), ilOrgUnitGlobalSettings\getInstance(), ilExcCriteriaCatalogue\getInstancesByParentId(), getInstruction(), getNrMandatoryRandom(), getPassMode(), getPassNr(), getShowSubmissions(), getTimestamp(), getTutorFeedback(), and isCompletionBySubmissionEnabled().

+ Here is the call graph for this function:

◆ delete()

ilObjExercise::delete ( )

delete course and all related data

@access public

Returns
boolean true if all object data were removed; false if only a references were removed

Definition at line 348 of file class.ilObjExercise.php.

349 {
351 $ilAppEventHandler = $this->app_event_handler;
352
353 // always call parent delete function first!!
354 if (!parent::delete()) {
355 return false;
356 }
357 // put here course specific stuff
358 $ilDB->manipulate("DELETE FROM exc_data " .
359 "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer"));
360
362
363 // remove all notifications
365
366 $ilAppEventHandler->raise(
367 'Modules/Exercise',
368 'delete',
369 array('obj_id' => $this->getId())
370 );
371
372 return true;
373 }
static removeForObject($type, $id)
Remove all notifications for given object.

References ilObject\$app_event_handler, ilObject\$db, $ilDB, ilExcCriteriaCatalogue\deleteByParent(), ilObject\getId(), ilNotification\removeForObject(), and ilNotification\TYPE_EXERCISE_SUBMISSION.

+ Here is the call graph for this function:

◆ exportGradesExcel()

ilObjExercise::exportGradesExcel ( )

Exports grades as excel.

Definition at line 628 of file class.ilObjExercise.php.

629 {
630 $ass_data = ilExAssignment::getInstancesByExercise($this->getId());
631
632 $excel = new ilExcel();
633 $excel->addSheet($this->lng->txt("exc_status"));
634
635
636 //
637 // status
638 //
639
640 // header row
641 $row = $cnt = 1;
642 $excel->setCell($row, 0, $this->lng->txt("name"));
643 foreach ($ass_data as $ass) {
644 $excel->setCell($row, $cnt++, ($cnt / 2) . " - ". $this->lng->txt("exc_tbl_status"));
645 $excel->setCell($row, $cnt++, (($cnt - 1) / 2) . " - ". $this->lng->txt("exc_tbl_mark"));
646 }
647 $excel->setCell($row, $cnt++, $this->lng->txt("exc_total_exc"));
648 $excel->setCell($row, $cnt++, $this->lng->txt("exc_mark"));
649 $excel->setCell($row++, $cnt, $this->lng->txt("exc_comment_for_learner"));
650 $excel->setBold("A1:" . $excel->getColumnCoord($cnt) . "1");
651
652 // data rows
653 $mem_obj = new ilExerciseMembers($this);
654
655 $filtered_members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
656 'edit_submissions_grades',
657 'edit_submissions_grades',
658 $this->getRefId(),
659 (array) $mem_obj->getMembers()
660 );
661
662 foreach ((array) $filtered_members as $user_id) {
663 $mems[$user_id] = ilObjUser::_lookupName($user_id);
664 }
665 $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
666
667 foreach ($mems as $user_id => $d) {
668 $col = 0;
669
670 // name
671 $excel->setCell($row, $col++, $d["lastname"] . ", " . $d["firstname"] . " [" . $d["login"] . "]");
672
673 reset($ass_data);
674 foreach ($ass_data as $ass) {
675 $status = $ass->getMemberStatus($user_id)->getStatus();
676 $mark = $ass->getMemberStatus($user_id)->getMark();
677 $excel->setCell($row, $col++, $this->lng->txt("exc_" . $status));
678 $excel->setCell($row, $col++, $mark);
679 }
680
681 // total status
682 $status = ilExerciseMembers::_lookupStatus($this->getId(), $user_id);
683 $excel->setCell($row, $col++, $this->lng->txt("exc_" . $status));
684
685 // #18096
686 $marks_obj = new ilLPMarks($this->getId(), $user_id);
687 $excel->setCell($row, $col++, $marks_obj->getMark());
688 $excel->setCell($row++, $col, $marks_obj->getComment());
689 }
690
691
692 //
693 // mark
694 //
695
696 $excel->addSheet($this->lng->txt("exc_mark"));
697
698 // header row
699 $row = $cnt = 1;
700 $excel->setCell($row, 0, $this->lng->txt("name"));
701 foreach ($ass_data as $ass) {
702 $excel->setCell($row, $cnt++, $cnt - 1);
703 }
704 $excel->setCell($row++, $cnt++, $this->lng->txt("exc_total_exc"));
705 $excel->setBold("A1:" . $excel->getColumnCoord($cnt) . "1");
706
707 // data rows
708 reset($mems);
709 foreach ($mems as $user_id => $d) {
710 $col = 0;
711
712 // name
713 $d = ilObjUser::_lookupName($user_id);
714 $excel->setCell($row, $col++, $d["lastname"] . ", " . $d["firstname"] . " [" . $d["login"] . "]");
715
716 reset($ass_data);
717 foreach ($ass_data as $ass) {
718 $excel->setCell($row, $col++, $ass->getMemberStatus($user_id)->getMark());
719 }
720
721 // total mark
722 $excel->setCell($row++, $col, ilLPMarks::_lookupMark($user_id, $this->getId()));
723 }
724
725 $exc_name = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->getTitle()));
726 $excel->sendToClient($exc_name);
727 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static getInstancesByExercise($a_exc_id)
Class ilExerciseMembers.
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
static _lookupMark($a_usr_id, $a_obj_id)
static _lookupName($a_user_id)
lookup user name
getRefId()
get reference id @access public
getTitle()
get object title @access public
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296

References $d, $GLOBALS, ilLPMarks\_lookupMark(), ilObjUser\_lookupName(), ilExerciseMembers\_lookupStatus(), ilUtil\getASCIIFilename(), ilObject\getId(), ilExAssignment\getInstancesByExercise(), ilObject\getRefId(), ilObject\getTitle(), and ilUtil\sortArray().

+ Here is the call graph for this function:

◆ getCertificateVisibility()

ilObjExercise::getCertificateVisibility ( )

Returns the visibility settings of the certificate.

Returns
integer The value for the visibility settings (0 = always, 1 = only passed, 2 = never) @access public

Definition at line 844 of file class.ilObjExercise.php.

845 {
846 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
847 }

Referenced by cloneObject(), and saveData().

+ Here is the caller graph for this function:

◆ getInstruction()

ilObjExercise::getInstruction ( )

Definition at line 127 of file class.ilObjExercise.php.

128 {
129 return $this->instruction;
130 }

References $instruction.

Referenced by cloneObject(), saveData(), and update().

+ Here is the caller graph for this function:

◆ getNrMandatoryRandom()

ilObjExercise::getNrMandatoryRandom ( )

Get number of mandatory assignments in random pass mode.

Returns
int

Definition at line 207 of file class.ilObjExercise.php.

208 {
210 }

References $nr_random_mand.

Referenced by cloneObject(), saveData(), and update().

+ Here is the caller graph for this function:

◆ getPassMode()

ilObjExercise::getPassMode ( )

Get pass mode (all | nr)

Returns
string pass mode

Definition at line 147 of file class.ilObjExercise.php.

148 {
149 return $this->pass_mode;
150 }

Referenced by cloneObject(), saveData(), and update().

+ Here is the caller graph for this function:

◆ getPassNr()

ilObjExercise::getPassNr ( )

Get number of assignments that must be passed to pass the exercise.

Returns
integer pass nr

Definition at line 167 of file class.ilObjExercise.php.

168 {
169 return $this->pass_nr;
170 }

Referenced by cloneObject(), saveData(), and update().

+ Here is the caller graph for this function:

◆ getShowSubmissions()

ilObjExercise::getShowSubmissions ( )

Get whether submissions of learners should be shown to other learners after deadline.

Returns
integer show submissions

Definition at line 187 of file class.ilObjExercise.php.

188 {
189 return $this->show_submissions;
190 }

Referenced by cloneObject(), saveData(), and update().

+ Here is the caller graph for this function:

◆ getTimestamp()

ilObjExercise::getTimestamp ( )

Definition at line 115 of file class.ilObjExercise.php.

116 {
117 return $this->timestamp;
118 }

References $timestamp.

Referenced by cloneObject(), saveData(), and update().

+ Here is the caller graph for this function:

◆ getTutorFeedback()

ilObjExercise::getTutorFeedback ( )
protected

Definition at line 242 of file class.ilObjExercise.php.

243 {
245 }

References $tutor_feedback.

Referenced by cloneObject(), saveData(), and update().

+ Here is the caller graph for this function:

◆ hasAddToDesktop()

ilObjExercise::hasAddToDesktop ( )

Add to desktop after hand-in.

Returns
bool

Definition at line 882 of file class.ilObjExercise.php.

883 {
884 $exc_set = new ilSetting("excs");
885 return (bool) $exc_set->get("add_to_pd", true);
886 }
ILIAS Setting Class.

◆ hasTutorFeedbackFile()

ilObjExercise::hasTutorFeedbackFile ( )

Definition at line 237 of file class.ilObjExercise.php.

238 {
239 return $this->tutor_feedback & self::TUTOR_FEEDBACK_FILE;
240 }

References TUTOR_FEEDBACK_FILE.

◆ hasTutorFeedbackMail()

ilObjExercise::hasTutorFeedbackMail ( )

Definition at line 232 of file class.ilObjExercise.php.

233 {
234 return $this->tutor_feedback & self::TUTOR_FEEDBACK_MAIL;
235 }

References TUTOR_FEEDBACK_MAIL.

◆ hasTutorFeedbackText()

ilObjExercise::hasTutorFeedbackText ( )

Definition at line 227 of file class.ilObjExercise.php.

228 {
229 return $this->tutor_feedback & self::TUTOR_FEEDBACK_TEXT;
230 }

References TUTOR_FEEDBACK_TEXT.

◆ isCompletionBySubmissionEnabled()

ilObjExercise::isCompletionBySubmissionEnabled ( )

Checks whether completion by submission is enabled or not.

Returns
boolean @access public

Definition at line 762 of file class.ilObjExercise.php.

763 {
765 }

References $completion_by_submission.

Referenced by cloneObject(), processExerciseStatus(), saveData(), and update().

+ Here is the caller graph for this function:

◆ processExerciseStatus()

ilObjExercise::processExerciseStatus ( ilExAssignment  $a_ass,
array  $a_user_ids,
  $a_has_submitted,
array  $a_valid_submissions = null 
)

Definition at line 783 of file class.ilObjExercise.php.

784 {
785 $a_has_submitted = (bool) $a_has_submitted;
786
787 foreach ($a_user_ids as $user_id) {
788 $member_status = $a_ass->getMemberStatus($user_id);
789 $member_status->setReturned($a_has_submitted);
790 $member_status->update();
791
792 ilExerciseMembers::_writeReturned($this->getId(), $user_id, $a_has_submitted);
793 }
794
795 // re-evaluate exercise status
796 if ($this->isCompletionBySubmissionEnabled()) {
797 foreach ($a_user_ids as $user_id) {
798 $status = 'notgraded';
799 if ($a_has_submitted) {
800 if (!is_array($a_valid_submissions) ||
801 $a_valid_submissions[$user_id]) {
802 $status = 'passed';
803 }
804 }
805
806 $member_status = $a_ass->getMemberStatus($user_id);
807 $member_status->setStatus($status);
808 $member_status->update();
809 }
810 }
811 }
getMemberStatus($a_user_id=null)
static _writeReturned($a_obj_id, $a_user_id, $a_status)
Write returned status.

References ilExerciseMembers\_writeReturned(), ilObject\getId(), ilExAssignment\getMemberStatus(), and isCompletionBySubmissionEnabled().

+ Here is the call graph for this function:

◆ read()

ilObjExercise::read ( )

read object data from db into object

Parameters
boolean@access public

Reimplemented from ilObject.

Definition at line 375 of file class.ilObjExercise.php.

376 {
378
379 parent::read();
380
381 $query = "SELECT * FROM exc_data " .
382 "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
383
384 $res = $ilDB->query($query);
385 while ($row = $ilDB->fetchObject($res)) {
386 $this->setInstruction($row->instruction);
387 $this->setTimestamp($row->time_stamp);
388 $pm = ($row->pass_mode == "")
389 ? "all"
390 : $row->pass_mode;
391 $this->setPassMode($pm);
392 $this->setShowSubmissions($row->show_submissions);
393 if ($row->pass_mode == "nr") {
394 $this->setPassNr($row->pass_nr);
395 }
396 $this->setNrMandatoryRandom($row->nr_mandatory_random);
397 $this->setCompletionBySubmission($row->compl_by_submission == 1 ? true : false);
398 $this->setCertificateVisibility($row->certificate_visibility);
399 $this->setTutorFeedback($row->tfeedback);
400 }
401
402 $this->members_obj = new ilExerciseMembers($this);
403
404 return true;
405 }
setTimestamp($a_timestamp)
setPassNr($a_val)
Set number of assignments that must be passed to pass the exercise.
setShowSubmissions($a_val)
Set whether submissions of learners should be shown to other learners after deadline.
setNrMandatoryRandom($a_val)
Set number of mandatory assignments in random pass mode.
setTutorFeedback($a_value)
setCertificateVisibility($a_value)
Sets the visibility settings of the certificate.
setInstruction($a_instruction)
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
$query
foreach($_POST as $key=> $value) $res

References ilObject\$db, $ilDB, $query, $res, ilObject\getId(), setCertificateVisibility(), setCompletionBySubmission(), setInstruction(), setNrMandatoryRandom(), setPassNr(), setShowSubmissions(), setTimestamp(), and setTutorFeedback().

+ Here is the call graph for this function:

◆ saveCertificateVisibility()

ilObjExercise::saveCertificateVisibility (   $a_value)

Saves the visibility settings of the certificate.

Parameters
integer$a_valueThe value for the visibility settings (0 = always, 1 = only passed, 2 = never) @access private

Definition at line 866 of file class.ilObjExercise.php.

867 {
869
870 $affectedRows = $ilDB->manipulateF(
871 "UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
872 array('integer', 'integer'),
873 array($a_value, $this->getId())
874 );
875 }

References ilObject\$db, $ilDB, and ilObject\getId().

+ Here is the call graph for this function:

◆ saveData()

ilObjExercise::saveData ( )

Definition at line 252 of file class.ilObjExercise.php.

253 {
255
256 $ilDB->insert("exc_data", array(
257 "obj_id" => array("integer", $this->getId()),
258 "instruction" => array("clob", $this->getInstruction()),
259 "time_stamp" => array("integer", $this->getTimestamp()),
260 "pass_mode" => array("text", $this->getPassMode()),
261 "nr_mandatory_random" => array("integer", (int) $this->getNrMandatoryRandom()),
262 "pass_nr" => array("text", $this->getPassNr()),
263 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
264 'compl_by_submission' => array('integer', (int) $this->isCompletionBySubmissionEnabled()),
265 "certificate_visibility" => array("integer", (int) $this->getCertificateVisibility()),
266 "tfeedback" => array("integer", (int) $this->getTutorFeedback())
267 ));
268 return true;
269 }

References ilObject\$db, $ilDB, getCertificateVisibility(), ilObject\getId(), getInstruction(), getNrMandatoryRandom(), getPassMode(), getPassNr(), getShowSubmissions(), getTimestamp(), getTutorFeedback(), and isCompletionBySubmissionEnabled().

+ Here is the call graph for this function:

◆ sendAssignment()

ilObjExercise::sendAssignment ( ilExAssignment  $a_ass,
  $a_members 
)

send exercise per mail to members

Definition at line 440 of file class.ilObjExercise.php.

441 {
444
445 $lng->loadLanguageModule("exc");
446
447 // subject
448 $subject = $a_ass->getTitle()
449 ? $this->getTitle() . ": " . $a_ass->getTitle()
450 : $this->getTitle();
451
452
453 // body
454
455 $body = $a_ass->getInstruction();
456 $body .= "\n\n";
457
458 $body .= $lng->txt("exc_edit_until") . ": ";
459 $body .= (!$a_ass->getDeadline())
460 ? $lng->txt("exc_no_deadline_specified")
462 $body .= "\n\n";
463
464 $body .= ilLink::_getLink($this->getRefId(), "exc");
465
466
467 // files
468 $file_names = array();
469 $storage = new ilFSStorageExercise($a_ass->getExerciseId(), $a_ass->getId());
470 $files = $storage->getFiles();
471 if (count($files)) {
472 $mfile_obj = new ilFileDataMail($GLOBALS['DIC']['ilUser']->getId());
473 foreach ($files as $file) {
474 $mfile_obj->copyAttachmentFile($file["fullpath"], $file["name"]);
475 $file_names[] = $file["name"];
476 }
477 }
478
479 // recipients
480 $recipients = array();
481 foreach ($a_members as $member_id) {
482 $tmp_obj = ilObjectFactory::getInstanceByObjId($member_id);
483 $recipients[] = $tmp_obj->getLogin();
484 unset($tmp_obj);
485 }
486 $recipients = implode(",", $recipients);
487
488 // send mail
489 $tmp_mail_obj = new ilMail($ilUser->getId());
490 $errors = $tmp_mail_obj->enqueue(
491 $recipients,
492 "",
493 "",
494 $subject,
495 $body,
496 $file_names
497 );
498 unset($tmp_mail_obj);
499
500 // remove tmp files
501 if (sizeof($file_names)) {
502 $mfile_obj->unlinkFiles($file_names);
503 unset($mfile_obj);
504 }
505
506 // set recipients mail status
507 foreach ($a_members as $member_id) {
508 $member_status = $a_ass->getMemberStatus($member_id);
509 $member_status->setSent(true);
510 $member_status->update();
511 }
512
513 return true;
514 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
getExerciseId()
Get exercise id.
getId()
Get assignment id.
getInstruction()
Get instruction.
getDeadline()
Get deadline (timestamp)
Class ilFileDataMail.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$errors
$ilUser
Definition: imgupload.php:18

References $errors, $files, $GLOBALS, $ilUser, ilObject\$lng, $user, ilLink\_getLink(), ilDatePresentation\formatDate(), ilExAssignment\getDeadline(), ilExAssignment\getExerciseId(), ilExAssignment\getId(), ilObject\getId(), ilObjectFactory\getInstanceByObjId(), ilExAssignment\getInstruction(), ilExAssignment\getMemberStatus(), ilObject\getRefId(), ilExAssignment\getTitle(), ilObject\getTitle(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ sendFeedbackFileNotification()

ilObjExercise::sendFeedbackFileNotification (   $a_feedback_file,
  $a_user_id,
  $a_ass_id,
  $a_is_text_feedback = false 
)

Send feedback file notification to user.

Definition at line 732 of file class.ilObjExercise.php.

733 {
734 $user_ids = $a_user_id;
735 if (!is_array($user_ids)) {
736 $user_ids = array($user_ids);
737 }
738
739 $type = (bool) $a_is_text_feedback
742
743 $not = new ilExerciseMailNotification();
744 $not->setType($type);
745 $not->setAssignmentId($a_ass_id);
746 $not->setObjId($this->getId());
747 if ($this->getRefId() > 0) {
748 $not->setRefId($this->getRefId());
749 }
750 $not->setRecipients($user_ids);
751 $not->send();
752 }

References ilObject\$type, ilObject\getId(), ilObject\getRefId(), ilExerciseMailNotification\TYPE_FEEDBACK_FILE_ADDED, and ilExerciseMailNotification\TYPE_FEEDBACK_TEXT_ADDED.

Referenced by ilExAssignment\saveMultiFeedbackFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCertificateVisibility()

ilObjExercise::setCertificateVisibility (   $a_value)

Sets the visibility settings of the certificate.

Parameters
integer$a_valueThe value for the visibility settings (0 = always, 1 = only passed, 2 = never) @access public

Definition at line 855 of file class.ilObjExercise.php.

856 {
857 $this->certificate_visibility = $a_value;
858 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setCompletionBySubmission()

ilObjExercise::setCompletionBySubmission (   $bool)

Enabled/Disable completion by submission.

Parameters
boolean
Returns
ilObjExercise @access public

Definition at line 776 of file class.ilObjExercise.php.

777 {
778 $this->completion_by_submission = (bool) $bool;
779
780 return $this;
781 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setDate()

ilObjExercise::setDate (   $a_hour,
  $a_minutes,
  $a_day,
  $a_month,
  $a_year 
)

Definition at line 105 of file class.ilObjExercise.php.

106 {
107 $this->hour = (int) $a_hour;
108 $this->minutes = (int) $a_minutes;
109 $this->day = (int) $a_day;
110 $this->month = (int) $a_month;
111 $this->year = (int) $a_year;
112 $this->timestamp = mktime($this->hour, $this->minutes, 0, $this->month, $this->day, $this->year);
113 return true;
114 }

◆ setId()

ilObjExercise::setId (   $id)

Set id.

Parameters
int$id

Reimplemented from ilObject.

Definition at line 96 of file class.ilObjExercise.php.

97 {
98 global $DIC;
99 parent::setId($id);
100 // this is needed, since e.g. ilObjectFactory initialises the object with id 0 and later sets the id
101 $this->mandatory_manager = $DIC->exercise()->internal()->service()->getMandatoryAssignmentManager($this);
102 }

References $DIC, and ilObject\$id.

◆ setInstruction()

ilObjExercise::setInstruction (   $a_instruction)

Definition at line 123 of file class.ilObjExercise.php.

124 {
125 $this->instruction = $a_instruction;
126 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setNrMandatoryRandom()

ilObjExercise::setNrMandatoryRandom (   $a_val)

Set number of mandatory assignments in random pass mode.

Parameters
int$a_val

Definition at line 197 of file class.ilObjExercise.php.

198 {
199 $this->nr_random_mand = $a_val;
200 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPassMode()

ilObjExercise::setPassMode (   $a_val)

Set pass mode (all | nr)

Parameters
stringpass mode

Definition at line 137 of file class.ilObjExercise.php.

138 {
139 $this->pass_mode = $a_val;
140 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setPassNr()

ilObjExercise::setPassNr (   $a_val)

Set number of assignments that must be passed to pass the exercise.

Parameters
integerpass nr

Definition at line 157 of file class.ilObjExercise.php.

158 {
159 $this->pass_nr = $a_val;
160 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setShowSubmissions()

ilObjExercise::setShowSubmissions (   $a_val)

Set whether submissions of learners should be shown to other learners after deadline.

Parameters
booleanshow submissions

Definition at line 177 of file class.ilObjExercise.php.

178 {
179 $this->show_submissions = $a_val;
180 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTimestamp()

ilObjExercise::setTimestamp (   $a_timestamp)

Definition at line 119 of file class.ilObjExercise.php.

120 {
121 $this->timestamp = $a_timestamp;
122 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTutorFeedback()

ilObjExercise::setTutorFeedback (   $a_value)

Definition at line 247 of file class.ilObjExercise.php.

248 {
249 $this->tutor_feedback = $a_value;
250 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilObjExercise::update ( )

update object in db

@access public

Returns
boolean true on success

Reimplemented from ilObject.

Definition at line 407 of file class.ilObjExercise.php.

408 {
410
411 parent::update();
412
413 if ($this->getPassMode() == "all") {
414 $pass_nr = null;
415 } else {
416 $pass_nr = $this->getPassNr();
417 }
418
419 $ilDB->update("exc_data", array(
420 "instruction" => array("clob", $this->getInstruction()),
421 "time_stamp" => array("integer", $this->getTimestamp()),
422 "pass_mode" => array("text", $this->getPassMode()),
423 "pass_nr" => array("integer", $this->getPassNr()),
424 "nr_mandatory_random" => array("integer", (int) $this->getNrMandatoryRandom()),
425 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
426 'compl_by_submission' => array('integer', (int) $this->isCompletionBySubmissionEnabled()),
427 'tfeedback' => array('integer', (int) $this->getTutorFeedback()),
428 ), array(
429 "obj_id" => array("integer", $this->getId())
430 ));
431
432 $this->updateAllUsersStatus();
433
434 return true;
435 }
updateAllUsersStatus()
Update status of all users.

References ilObject\$db, $ilDB, ilObject\getId(), getInstruction(), getNrMandatoryRandom(), getPassMode(), getPassNr(), getShowSubmissions(), getTimestamp(), getTutorFeedback(), isCompletionBySubmissionEnabled(), and updateAllUsersStatus().

+ Here is the call graph for this function:

◆ updateAllUsersStatus()

ilObjExercise::updateAllUsersStatus ( )

Update status of all users.

Definition at line 613 of file class.ilObjExercise.php.

614 {
615 if (!is_object($this->members_obj)) {
616 $this->members_obj = new ilExerciseMembers($this);
617 }
618
619 $mems = $this->members_obj->getMembers();
620 foreach ($mems as $mem) {
621 $this->updateUserStatus($mem);
622 }
623 }
updateUserStatus($a_user_id=0)
Update exercise status of user.

References updateUserStatus().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateUserStatus()

ilObjExercise::updateUserStatus (   $a_user_id = 0)

Update exercise status of user.

Definition at line 593 of file class.ilObjExercise.php.

594 {
596
597 if ($a_user_id == 0) {
598 $a_user_id = $ilUser->getId();
599 }
600
601 $st = $this->determinStatusOfUser($a_user_id);
602
604 $this->getId(),
605 $a_user_id,
606 $st["overall_status"]
607 );
608 }
static _writeStatus($a_obj_id, $a_user_id, $a_status)
Write user status.

References $ilUser, $user, ilExerciseMembers\_writeStatus(), and ilObject\getId().

Referenced by updateAllUsersStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $certificate_visibility

ilObjExercise::$certificate_visibility

Definition at line 33 of file class.ilObjExercise.php.

◆ $completion_by_submission

ilObjExercise::$completion_by_submission = false
protected

Definition at line 58 of file class.ilObjExercise.php.

Referenced by isCompletionBySubmissionEnabled().

◆ $day

ilObjExercise::$day

Definition at line 29 of file class.ilObjExercise.php.

◆ $file_obj

ilObjExercise::$file_obj

Definition at line 22 of file class.ilObjExercise.php.

◆ $files

ilObjExercise::$files

Definition at line 24 of file class.ilObjExercise.php.

Referenced by sendAssignment().

◆ $hour

ilObjExercise::$hour

Definition at line 27 of file class.ilObjExercise.php.

◆ $instruction

ilObjExercise::$instruction

Definition at line 32 of file class.ilObjExercise.php.

Referenced by getInstruction().

◆ $mandatory_manager

ilObjExercise::$mandatory_manager
protected

Definition at line 68 of file class.ilObjExercise.php.

◆ $members_obj

ilObjExercise::$members_obj

Definition at line 23 of file class.ilObjExercise.php.

◆ $minutes

ilObjExercise::$minutes

Definition at line 28 of file class.ilObjExercise.php.

◆ $month

ilObjExercise::$month

Definition at line 30 of file class.ilObjExercise.php.

◆ $nr_random_mand

ilObjExercise::$nr_random_mand
protected

Definition at line 40 of file class.ilObjExercise.php.

Referenced by getNrMandatoryRandom().

◆ $timestamp

ilObjExercise::$timestamp

Definition at line 26 of file class.ilObjExercise.php.

Referenced by getTimestamp().

◆ $tutor_feedback

ilObjExercise::$tutor_feedback = 7

Definition at line 35 of file class.ilObjExercise.php.

Referenced by getTutorFeedback().

◆ $user

ilObjExercise::$user
protected

Definition at line 20 of file class.ilObjExercise.php.

Referenced by sendAssignment(), and updateUserStatus().

◆ $webFilesystem

ilObjExercise::$webFilesystem
private

Definition at line 63 of file class.ilObjExercise.php.

◆ $year

ilObjExercise::$year

Definition at line 31 of file class.ilObjExercise.php.

◆ PASS_MODE_ALL

const ilObjExercise::PASS_MODE_ALL = "all"

Definition at line 47 of file class.ilObjExercise.php.

Referenced by ilObjExerciseGUI\initEditCustomForm().

◆ PASS_MODE_NR

const ilObjExercise::PASS_MODE_NR = "nr"

Definition at line 46 of file class.ilObjExercise.php.

Referenced by ilObjExerciseGUI\initEditCustomForm().

◆ PASS_MODE_RANDOM

const ilObjExercise::PASS_MODE_RANDOM = "random"

◆ TUTOR_FEEDBACK_FILE

const ilObjExercise::TUTOR_FEEDBACK_FILE = 4

◆ TUTOR_FEEDBACK_MAIL

const ilObjExercise::TUTOR_FEEDBACK_MAIL = 1

◆ TUTOR_FEEDBACK_TEXT

const ilObjExercise::TUTOR_FEEDBACK_TEXT = 2

The documentation for this class was generated from the following file: