ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
 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...
 
 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...
 
 determinStatusOfUser ($a_user_id=0)
 Determine status of user. 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...
 
 hasUserCertificate ($a_user_id)
 Check if given user has certificate to show/download. 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...
 
 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 ()
 
 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...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! 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 ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 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 _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)
 only called in ilTree::saveSubTree More...
 
static setDeletedDates ($a_ref_ids)
 Set deleted date @global type $ilDB. 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 _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. 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
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $ilias
 
 $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

 $completion_by_submission = false
 

Detailed Description

Class ilObjExercise.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

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

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 56 of file class.ilObjExercise.php.

57 {
58 $this->setPassMode("all");
59 $this->type = "exc";
60 parent::__construct($a_id,$a_call_by_reference);
61 }
setPassMode($a_val)
Set pass mode (all | nr)

References setPassMode().

+ 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 776 of file class.ilObjExercise.php.

777 {
778 global $ilDB;
779
780 $set = $ilDB->query("SELECT obj_id, status FROM exc_members".
781 " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
782 " AND (status = ".$ilDB->quote("passed", "text").
783 " OR status = ".$ilDB->quote("failed", "text").")");
784
785 $all = array();
786 while($row = $ilDB->fetchAssoc($set))
787 {
788 $all[$row["obj_id"]] = ($row["status"] == "passed");
789 }
790 return $all;
791 }
global $ilDB

References $ilDB, and $row.

Referenced by ilExerciseVerificationTableGUI\getItems().

+ Here is the caller graph for this function:

◆ checkDate()

ilObjExercise::checkDate ( )

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

158 {
159 return $this->hour == (int) date("H",$this->timestamp) and
160 $this->minutes == (int) date("i",$this->timestamp) and
161 $this->day == (int) date("d",$this->timestamp) and
162 $this->month == (int) date("m",$this->timestamp) and
163 $this->year == (int) date("Y",$this->timestamp);
164
165 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())

References date.

◆ 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

Reimplemented from ilObject.

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

218 {
219 global $ilDB;
220
221 // Copy settings
222 $new_obj = parent::cloneObject($a_target_id,$a_copy_id, $a_omit_tree);
223 $new_obj->setInstruction($this->getInstruction());
224 $new_obj->setTimestamp($this->getTimestamp());
225 $new_obj->setPassMode($this->getPassMode());
226 $new_obj->saveData();
227 $new_obj->setPassNr($this->getPassNr());
228 $new_obj->setShowSubmissions($this->getShowSubmissions());
229 $new_obj->setCompletionBySubmission($this->isCompletionBySubmissionEnabled());
230 $new_obj->setTutorFeedback($this->getTutorFeedback());
231 $new_obj->update();
232
233 // Copy criteria catalogues
234 $crit_cat_map = array();
235 include_once("./Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php");
236 foreach(ilExcCriteriaCatalogue::getInstancesByParentId($this->getId()) as $crit_cat)
237 {
238 $new_id = $crit_cat->cloneObject($new_obj->getId());
239 $crit_cat_map[$crit_cat->getId()] = $new_id;
240 }
241
242 // Copy assignments
243 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
244 ilExAssignment::cloneAssignmentsOfExercise($this->getId(), $new_obj->getId(), $crit_cat_map);
245
246 // Copy learning progress settings
247 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
248 $obj_settings = new ilLPObjSettings($this->getId());
249 $obj_settings->cloneSettings($new_obj->getId());
250 unset($obj_settings);
251
252 // #18945
253 include_once "./Services/Certificate/classes/class.ilCertificate.php";
254 include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
255 $cert = new ilCertificate(new ilExerciseCertificateAdapter($this));
256 $newcert = new ilCertificate(new ilExerciseCertificateAdapter($new_obj));
257 $cert->cloneCertificate($newcert);
258
259 return $new_obj;
260 }
Create PDF certificates.
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.
getPassNr()
Get number of assignments that must be passed to pass the exercise.
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
getPassMode()
Get pass mode (all | nr)
getId()
get object id @access public

References $ilDB, ilExAssignment\cloneAssignmentsOfExercise(), ilObject\getId(), ilExcCriteriaCatalogue\getInstancesByParentId(), getInstruction(), 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

Reimplemented from ilObject.

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

269 {
270 global $ilDB, $ilAppEventHandler;
271
272 // always call parent delete function first!!
273 if (!parent::delete())
274 {
275 return false;
276 }
277 // put here course specific stuff
278 $ilDB->manipulate("DELETE FROM exc_data ".
279 "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer"));
280
281 include_once "Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php";
283
284 // remove all notifications
285 include_once "./Services/Notification/classes/class.ilNotification.php";
287
288 $ilAppEventHandler->raise('Modules/Exercise',
289 'delete',
290 array('obj_id'=>$this->getId()));
291
292 return true;
293 }
static removeForObject($type, $id)
Remove all notifications for given object.

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

+ Here is the call graph for this function:

◆ determinStatusOfUser()

ilObjExercise::determinStatusOfUser (   $a_user_id = 0)

Determine status of user.

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

452 {
453 global $ilUser;
454
455 if ($a_user_id == 0)
456 {
457 $a_user_id = $ilUser->getId();
458 }
459
460 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
462
463 $passed_all_mandatory = true;
464 $failed_a_mandatory = false;
465 $cnt_passed = 0;
466 $cnt_notgraded = 0;
467 $passed_at_least_one = false;
468
469 foreach ($ass as $a)
470 {
471 $stat = $a->getMemberStatus($a_user_id)->getStatus();
472 if ($a->getMandatory() && ($stat == "failed" || $stat == "notgraded"))
473 {
474 $passed_all_mandatory = false;
475 }
476 if ($a->getMandatory() && ($stat == "failed"))
477 {
478 $failed_a_mandatory = true;
479 }
480 if ($stat == "passed")
481 {
482 $cnt_passed++;
483 }
484 if ($stat == "notgraded")
485 {
486 $cnt_notgraded++;
487 }
488 }
489
490 if (count($ass) == 0)
491 {
492 $passed_all_mandatory = false;
493 }
494
495 if ($this->getPassMode() != "nr")
496 {
497//echo "5";
498 $overall_stat = "notgraded";
499 if ($failed_a_mandatory)
500 {
501//echo "6";
502 $overall_stat = "failed";
503 }
504 else if ($passed_all_mandatory && $cnt_passed > 0)
505 {
506//echo "7";
507 $overall_stat = "passed";
508 }
509 }
510 else
511 {
512//echo "8";
513 $min_nr = $this->getPassNr();
514 $overall_stat = "notgraded";
515//echo "*".$cnt_passed."*".$cnt_notgraded."*".$min_nr."*";
516 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr))
517 {
518//echo "9";
519 $overall_stat = "failed";
520 }
521 else if ($passed_all_mandatory && $cnt_passed >= $min_nr)
522 {
523//echo "A";
524 $overall_stat = "passed";
525 }
526 }
527
528 $ret = array(
529 "overall_status" => $overall_stat,
530 "failed_a_mandatory" => $failed_a_mandatory);
531//echo "<br>p:".$cnt_passed.":ng:".$cnt_notgraded;
532//var_dump($ret);
533 return $ret;
534 }
static getInstancesByExercise($a_exc_id)
$ret
Definition: parser.php:6
$ilUser
Definition: imgupload.php:18

References $ilUser, $ret, ilObject\getId(), ilExAssignment\getInstancesByExercise(), getPassMode(), and getPassNr().

Referenced by updateUserStatus().

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

◆ exportGradesExcel()

ilObjExercise::exportGradesExcel ( )

Exports grades as excel.

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

576 {
577 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
578 $ass_data = ilExAssignment::getInstancesByExercise($this->getId());
579
580 include_once "./Services/Excel/classes/class.ilExcel.php";
581 $excel = new ilExcel();
582 $excel->addSheet($this->lng->txt("exc_status"));
583
584
585 //
586 // status
587 //
588
589 // header row
590 $row = $cnt = 1;
591 $excel->setCell($row, 0, $this->lng->txt("name"));
592 foreach ($ass_data as $ass)
593 {
594 $excel->setCell($row, $cnt++, $cnt-1);
595 }
596 $excel->setCell($row, $cnt++, $this->lng->txt("exc_total_exc"));
597 $excel->setCell($row, $cnt++, $this->lng->txt("exc_mark"));
598 $excel->setCell($row++, $cnt, $this->lng->txt("exc_comment_for_learner"));
599 $excel->setBold("A1:".$excel->getColumnCoord($cnt)."1");
600
601 // data rows
602 $mem_obj = new ilExerciseMembers($this);
603 $mems = array();
604 foreach($mem_obj->getMembers() as $user_id)
605 {
606 $mems[$user_id] = ilObjUser::_lookupName($user_id);
607 }
608 $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
609
610 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
611 foreach ($mems as $user_id => $d)
612 {
613 $col = 0;
614
615 // name
616 $excel->setCell($row, $col++, $d["lastname"].", ".$d["firstname"]." [".$d["login"]."]");
617
618 reset($ass_data);
619 foreach ($ass_data as $ass)
620 {
621 $status = $ass->getMemberStatus($user_id)->getStatus();
622 $excel->setCell($row, $col++, $this->lng->txt("exc_".$status));
623 }
624
625 // total status
626 $status = ilExerciseMembers::_lookupStatus($this->getId(), $user_id);
627 $excel->setCell($row, $col++, $this->lng->txt("exc_".$status));
628
629 // #18096
630 $marks_obj = new ilLPMarks($this->getId(), $user_id);
631 $excel->setCell($row, $col++, $marks_obj->getMark());
632 $excel->setCell($row++, $col, $marks_obj->getComment());
633 }
634
635
636 //
637 // mark
638 //
639
640 $excel->addSheet($this->lng->txt("exc_mark"));
641
642 // header row
643 $row = $cnt = 1;
644 $excel->setCell($row, 0, $this->lng->txt("name"));
645 foreach ($ass_data as $ass)
646 {
647 $excel->setCell($row, $cnt++, $cnt-1);
648 }
649 $excel->setCell($row++, $cnt++, $this->lng->txt("exc_total_exc"));
650 $excel->setBold("A1:".$excel->getColumnCoord($cnt)."1");
651
652 // data rows
653 reset($mems);
654 foreach ($mems as $user_id => $d)
655 {
656 $col = 0;
657
658 // name
659 $d = ilObjUser::_lookupName($user_id);
660 $excel->setCell($row, $col++, $d["lastname"].", ".$d["firstname"]." [".$d["login"]."]");
661
662 reset($ass_data);
663 foreach ($ass_data as $ass)
664 {
665 $excel->setCell($row, $col++, $ass->getMemberStatus($user_id)->getMark());
666 }
667
668 // total mark
669 $excel->setCell($row++, $col, ilLPMarks::_lookupMark($user_id, $this->getId()));
670 }
671
672 $exc_name = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->getTitle()));
673 $excel->sendToClient($exc_name);
674 }
for($col=0; $col< 50; $col++) $d
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
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

References $d, $row, ilLPMarks\_lookupMark(), ilObjUser\_lookupName(), ilExerciseMembers\_lookupStatus(), ilUtil\getASCIIFilename(), ilObject\getId(), ilExAssignment\getInstancesByExercise(), 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 800 of file class.ilObjExercise.php.

801 {
802 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
803 }

Referenced by hasUserCertificate(), and saveData().

+ Here is the caller graph for this function:

◆ getInstruction()

ilObjExercise::getInstruction ( )

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

87 {
88 return $this->instruction;
89 }

References $instruction.

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 106 of file class.ilObjExercise.php.

107 {
108 return $this->pass_mode;
109 }

Referenced by cloneObject(), determinStatusOfUser(), 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 126 of file class.ilObjExercise.php.

127 {
128 return $this->pass_nr;
129 }

Referenced by cloneObject(), determinStatusOfUser(), 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 146 of file class.ilObjExercise.php.

147 {
148 return $this->show_submissions;
149 }

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

+ Here is the caller graph for this function:

◆ getTimestamp()

ilObjExercise::getTimestamp ( )

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

75 {
76 return $this->timestamp;
77 }

References $timestamp.

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

+ Here is the caller graph for this function:

◆ getTutorFeedback()

ilObjExercise::getTutorFeedback ( )
protected

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

183 {
185 }

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 870 of file class.ilObjExercise.php.

871 {
872 $exc_set = new ilSetting("excs");
873 return (bool)$exc_set->get("add_to_pd", true);
874 }
ILIAS Setting Class.

◆ hasTutorFeedbackFile()

ilObjExercise::hasTutorFeedbackFile ( )

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

178 {
179 return $this->tutor_feedback & self::TUTOR_FEEDBACK_FILE;
180 }

References TUTOR_FEEDBACK_FILE.

◆ hasTutorFeedbackMail()

ilObjExercise::hasTutorFeedbackMail ( )

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

173 {
174 return $this->tutor_feedback & self::TUTOR_FEEDBACK_MAIL;
175 }

References TUTOR_FEEDBACK_MAIL.

◆ hasTutorFeedbackText()

ilObjExercise::hasTutorFeedbackText ( )

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

168 {
169 return $this->tutor_feedback & self::TUTOR_FEEDBACK_TEXT;
170 }

References TUTOR_FEEDBACK_TEXT.

◆ hasUserCertificate()

ilObjExercise::hasUserCertificate (   $a_user_id)

Check if given user has certificate to show/download.

Parameters
int$a_user_id
Returns
bool

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

839 {
840 // show certificate?
841 include_once "Services/Certificate/classes/class.ilCertificate.php";
843 {
844 $certificate_visible = $this->getCertificateVisibility();
845 // if not never
846 if($certificate_visible != 2)
847 {
848 // if passed only
849 include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php';
850 $status = ilExerciseMembers::_lookupStatus($this->getId(), $a_user_id);
851 if($certificate_visible == 1 && $status == "passed")
852 {
853 return true;
854 }
855 // always (excluding notgraded)
856 else if($certificate_visible == 0 && $status != "notgraded")
857 {
858 return true;
859 }
860 }
861 }
862 return false;
863 }
static isObjectActive($a_obj_id)
getCertificateVisibility()
Returns the visibility settings of the certificate.

References ilExerciseMembers\_lookupStatus(), getCertificateVisibility(), ilObject\getId(), ilCertificate\isActive(), and ilCertificate\isObjectActive().

+ Here is the call graph for this function:

◆ isCompletionBySubmissionEnabled()

ilObjExercise::isCompletionBySubmissionEnabled ( )

Checks whether completion by submission is enabled or not.

Returns
boolean @access public

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

714 {
716 }

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 734 of file class.ilObjExercise.php.

735 {
736 $a_has_submitted = (bool)$a_has_submitted;
737
738 include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
739 foreach($a_user_ids as $user_id)
740 {
741 $member_status = $a_ass->getMemberStatus($user_id);
742 $member_status->setReturned($a_has_submitted);
743 $member_status->update();
744
745 ilExerciseMembers::_writeReturned($this->getId(), $user_id, $a_has_submitted);
746 }
747
748 // re-evaluate exercise status
750 {
751 foreach($a_user_ids as $user_id)
752 {
753 $status = 'notgraded';
754 if($a_has_submitted)
755 {
756 if(!is_array($a_valid_submissions) ||
757 $a_valid_submissions[$user_id])
758 {
759 $status = 'passed';
760 }
761 }
762
763 $member_status = $a_ass->getMemberStatus($user_id);
764 $member_status->setStatus($status);
765 $member_status->update();
766 }
767 }
768 }
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 295 of file class.ilObjExercise.php.

296 {
297 global $ilDB;
298
299 parent::read();
300
301 $query = "SELECT * FROM exc_data ".
302 "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
303
304 $res = $ilDB->query($query);
305 while($row = $ilDB->fetchObject($res))
306 {
307 $this->setInstruction($row->instruction);
308 $this->setTimestamp($row->time_stamp);
309 $pm = ($row->pass_mode == "")
310 ? "all"
311 : $row->pass_mode;
312 $this->setPassMode($pm);
313 $this->setShowSubmissions($row->show_submissions);
314 if ($row->pass_mode == "nr")
315 {
316 $this->setPassNr($row->pass_nr);
317 }
318 $this->setCompletionBySubmission($row->compl_by_submission == 1 ? true : false);
319 $this->setCertificateVisibility($row->certificate_visibility);
320 $this->setTutorFeedback($row->tfeedback);
321 }
322
323 $this->members_obj = new ilExerciseMembers($this);
324
325 return true;
326 }
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.
setTutorFeedback($a_value)
setCertificateVisibility($a_value)
Sets the visibility settings of the certificate.
setInstruction($a_instruction)
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.

References $ilDB, $query, $res, $row, ilObject\getId(), setCertificateVisibility(), setCompletionBySubmission(), setInstruction(), 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 822 of file class.ilObjExercise.php.

823 {
824 global $ilDB;
825
826 $affectedRows = $ilDB->manipulateF("UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
827 array('integer', 'integer'),
828 array($a_value, $this->getId())
829 );
830 }

References $ilDB, and ilObject\getId().

+ Here is the call graph for this function:

◆ saveData()

ilObjExercise::saveData ( )

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

193 {
194 global $ilDB;
195
196 $ilDB->insert("exc_data", array(
197 "obj_id" => array("integer", $this->getId()),
198 "instruction" => array("clob", $this->getInstruction()),
199 "time_stamp" => array("integer", $this->getTimestamp()),
200 "pass_mode" => array("text", $this->getPassMode()),
201 "pass_nr" => array("text", $this->getPassNr()),
202 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
203 'compl_by_submission' => array('integer', (int)$this->isCompletionBySubmissionEnabled()),
204 "certificate_visibility" => array("integer", (int)$this->getCertificateVisibility()),
205 "tfeedback" => array("integer", (int)$this->getTutorFeedback())
206 ));
207 return true;
208 }

References $ilDB, getCertificateVisibility(), ilObject\getId(), getInstruction(), 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 363 of file class.ilObjExercise.php.

364 {
365 global $lng, $ilUser;
366
367 $lng->loadLanguageModule("exc");
368
369 // subject
370 $subject = $a_ass->getTitle()
371 ? $this->getTitle().": ".$a_ass->getTitle()
372 : $this->getTitle();
373
374
375 // body
376
377 $body = $a_ass->getInstruction();
378 $body .= "\n\n";
379
380 $body .= $lng->txt("exc_edit_until").": ";
381 $body .= (!$a_ass->getDeadline())
382 ? $lng->txt("exc_no_deadline_specified")
384 $body .= "\n\n";
385
386 include_once "Services/Link/classes/class.ilLink.php";
387 $body .= ilLink::_getLink($this->getRefId(), "exc");
388
389
390 // files
391 $file_names = array();
392 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
393 $storage = new ilFSStorageExercise($a_ass->getExerciseId(), $a_ass->getId());
394 $files = $storage->getFiles();
395 if(count($files))
396 {
397 include_once "./Services/Mail/classes/class.ilFileDataMail.php";
398 $mfile_obj = new ilFileDataMail($GLOBALS['DIC']['ilUser']->getId());
399 foreach($files as $file)
400 {
401 $mfile_obj->copyAttachmentFile($file["fullpath"], $file["name"]);
402 $file_names[] = $file["name"];
403 }
404 }
405
406 // recipients
407 $recipients = array();
408 foreach($a_members as $member_id)
409 {
410 $tmp_obj = ilObjectFactory::getInstanceByObjId($member_id);
411 $recipients[] = $tmp_obj->getLogin();
412 unset($tmp_obj);
413 }
414 $recipients = implode("," ,$recipients);
415
416 // send mail
417 include_once "Services/Mail/classes/class.ilMail.php";
418 $tmp_mail_obj = new ilMail($ilUser->getId());
419 $message = $tmp_mail_obj->sendMail(
420 $recipients,
421 "",
422 "",
423 $subject,
424 $body,
425 $file_names,
426 array("normal")
427 );
428 unset($tmp_mail_obj);
429
430 // remove tmp files
431 if(sizeof($file_names))
432 {
433 $mfile_obj->unlinkFiles($file_names);
434 unset($mfile_obj);
435 }
436
437 // set recipients mail status
438 foreach($a_members as $member_id)
439 {
440 $member_status = $a_ass->getMemberStatus($member_id);
441 $member_status->setSent(true);
442 $member_status->update();
443 }
444
445 return true;
446 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date)
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)
This class handles all operations on files (attachments) in directory ilias_data/mail.
This class handles base functions for mail handling.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getRefId()
get reference id @access public
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, $files, $GLOBALS, $ilUser, ilObject\$lng, 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 679 of file class.ilObjExercise.php.

680 {
681 $user_ids = $a_user_id;
682 if(!is_array($user_ids))
683 {
684 $user_ids = array($user_ids);
685 }
686
687 include_once("./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
688
689 $type = (bool)$a_is_text_feedback
692
693 $not = new ilExerciseMailNotification();
694 $not->setType($type);
695 $not->setAssignmentId($a_ass_id);
696 $not->setObjId($this->getId());
697 if ($this->getRefId() > 0)
698 {
699 $not->setRefId($this->getRefId());
700 }
701 $not->setRecipients($user_ids);
702 $not->send();
703 }

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 811 of file class.ilObjExercise.php.

812 {
813 $this->certificate_visibility = $a_value;
814 }

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 727 of file class.ilObjExercise.php.

728 {
729 $this->completion_by_submission = (bool)$bool;
730
731 return $this;
732 }

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 64 of file class.ilObjExercise.php.

65 {
66 $this->hour = (int) $a_hour;
67 $this->minutes = (int) $a_minutes;
68 $this->day = (int) $a_day;
69 $this->month = (int) $a_month;
70 $this->year = (int) $a_year;
71 $this->timestamp = mktime($this->hour,$this->minutes,0,$this->month,$this->day,$this->year);
72 return true;
73 }

◆ setInstruction()

ilObjExercise::setInstruction (   $a_instruction)

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

83 {
84 $this->instruction = $a_instruction;
85 }

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 96 of file class.ilObjExercise.php.

97 {
98 $this->pass_mode = $a_val;
99 }

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 116 of file class.ilObjExercise.php.

117 {
118 $this->pass_nr = $a_val;
119 }

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 136 of file class.ilObjExercise.php.

137 {
138 $this->show_submissions = $a_val;
139 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTimestamp()

ilObjExercise::setTimestamp (   $a_timestamp)

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

79 {
80 $this->timestamp = $a_timestamp;
81 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTutorFeedback()

ilObjExercise::setTutorFeedback (   $a_value)

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

188 {
189 $this->tutor_feedback = $a_value;
190 }

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 328 of file class.ilObjExercise.php.

329 {
330 global $ilDB;
331
332 parent::update();
333
334 if ($this->getPassMode() == "all")
335 {
336 $pass_nr = null;
337 }
338 else
339 {
340 $pass_nr = $this->getPassNr();
341 }
342
343 $ilDB->update("exc_data", array(
344 "instruction" => array("clob", $this->getInstruction()),
345 "time_stamp" => array("integer", $this->getTimestamp()),
346 "pass_mode" => array("text", $this->getPassMode()),
347 "pass_nr" => array("integer", $this->getPassNr()),
348 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
349 'compl_by_submission' => array('integer', (int)$this->isCompletionBySubmissionEnabled()),
350 'tfeedback' => array('integer', (int)$this->getTutorFeedback()),
351 ), array(
352 "obj_id" => array("integer", $this->getId())
353 ));
354
355 $this->updateAllUsersStatus();
356
357 return true;
358 }
updateAllUsersStatus()
Update status of all users.

References $ilDB, ilObject\getId(), getInstruction(), 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 558 of file class.ilObjExercise.php.

559 {
560 if (!is_object($this->members_obj))
561 {
562 $this->members_obj = new ilExerciseMembers($this);
563 }
564
565 $mems = $this->members_obj->getMembers();
566 foreach ($mems as $mem)
567 {
568 $this->updateUserStatus($mem);
569 }
570 }
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 539 of file class.ilObjExercise.php.

540 {
541 global $ilUser;
542
543 if ($a_user_id == 0)
544 {
545 $a_user_id = $ilUser->getId();
546 }
547
548 $st = $this->determinStatusOfUser($a_user_id);
549
550 include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
551 ilExerciseMembers::_writeStatus($this->getId(), $a_user_id,
552 $st["overall_status"]);
553 }
static _writeStatus($a_obj_id, $a_user_id, $a_status)
Write user status.
determinStatusOfUser($a_user_id=0)
Determine status of user.

References $ilUser, ilExerciseMembers\_writeStatus(), determinStatusOfUser(), 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 32 of file class.ilObjExercise.php.

◆ $completion_by_submission

ilObjExercise::$completion_by_submission = false
protected

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

Referenced by isCompletionBySubmissionEnabled().

◆ $day

ilObjExercise::$day

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

◆ $file_obj

ilObjExercise::$file_obj

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

◆ $files

ilObjExercise::$files

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

Referenced by sendAssignment().

◆ $hour

ilObjExercise::$hour

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

◆ $instruction

ilObjExercise::$instruction

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

Referenced by getInstruction().

◆ $members_obj

ilObjExercise::$members_obj

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

◆ $minutes

ilObjExercise::$minutes

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

◆ $month

ilObjExercise::$month

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

◆ $timestamp

ilObjExercise::$timestamp

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

Referenced by getTimestamp().

◆ $tutor_feedback

ilObjExercise::$tutor_feedback = 7

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

Referenced by getTutorFeedback().

◆ $year

ilObjExercise::$year

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

◆ 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: