ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 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)
 only called in ilTree::saveSubTree More...
 
static setDeletedDates ($a_ref_ids)
 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
 
- 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
 
 $completion_by_submission = false
 
- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

Private Attributes

 $webFilesystem
 

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

67 {
68 global $DIC;
69
70 $this->db = $DIC->database();
71 $this->app_event_handler = $DIC["ilAppEventHandler"];
72 $this->lng = $DIC->language();
73 $this->user = $DIC->user();
74 $this->setPassMode("all");
75 $this->type = "exc";
76 $this->webFilesystem = $DIC->filesystem()->web();
77
78 parent::__construct($a_id, $a_call_by_reference);
79 }
user()
Definition: user.php:4
setPassMode($a_val)
Set pass mode (all | nr)
global $DIC
Definition: saml.php:7

References $DIC, 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 775 of file class.ilObjExercise.php.

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

References $DIC, $ilDB, and $row.

Referenced by ilCertificateMigrationJob\getExerciseCertificates().

+ Here is the caller graph for this function:

◆ checkDate()

ilObjExercise::checkDate ( )

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

176 {
177 return $this->hour == (int) date("H", $this->timestamp) and
178 $this->minutes == (int) date("i", $this->timestamp) and
179 $this->day == (int) date("d", $this->timestamp) and
180 $this->month == (int) date("m", $this->timestamp) and
181 $this->year == (int) date("Y", $this->timestamp);
182 }

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

235 {
237
238 // Copy settings
239 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
240 $new_obj->setInstruction($this->getInstruction());
241 $new_obj->setTimestamp($this->getTimestamp());
242 $new_obj->setPassMode($this->getPassMode());
243 $new_obj->saveData();
244 $new_obj->setPassNr($this->getPassNr());
245 $new_obj->setShowSubmissions($this->getShowSubmissions());
246 $new_obj->setCompletionBySubmission($this->isCompletionBySubmissionEnabled());
247 $new_obj->setTutorFeedback($this->getTutorFeedback());
248 $new_obj->setCertificateVisibility($this->getCertificateVisibility());
249 $new_obj->update();
250
251 $new_obj->saveCertificateVisibility($this->getCertificateVisibility());
252
253 // Copy criteria catalogues
254 $crit_cat_map = array();
255 include_once("./Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php");
256 foreach (ilExcCriteriaCatalogue::getInstancesByParentId($this->getId()) as $crit_cat) {
257 $new_id = $crit_cat->cloneObject($new_obj->getId());
258 $crit_cat_map[$crit_cat->getId()] = $new_id;
259 }
260
261 // Copy assignments
262 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
263 ilExAssignment::cloneAssignmentsOfExercise($this->getId(), $new_obj->getId(), $crit_cat_map);
264
265 // Copy learning progress settings
266 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
267 $obj_settings = new ilLPObjSettings($this->getId());
268 $obj_settings->cloneSettings($new_obj->getId());
269 unset($obj_settings);
270
272 $templateRepository = new ilCertificateTemplateRepository($ilDB);
273
274 $cloneAction = new ilCertificateCloneAction(
275 $ilDB,
276 $factory,
277 $templateRepository,
278 $this->webFilesystem,
279 $this->log,
281 );
282
283 $cloneAction->cloneCertificate($this, $new_obj);
284
285 return $new_obj;
286 }
$factory
Definition: metadata.php:43
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.
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

References ilObject\$db, $factory, $ilDB, ilExAssignment\cloneAssignmentsOfExercise(), getCertificateVisibility(), 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

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

295 {
297 $ilAppEventHandler = $this->app_event_handler;
298
299 // always call parent delete function first!!
300 if (!parent::delete()) {
301 return false;
302 }
303 // put here course specific stuff
304 $ilDB->manipulate("DELETE FROM exc_data " .
305 "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer"));
306
307 include_once "Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php";
309
310 // remove all notifications
311 include_once "./Services/Notification/classes/class.ilNotification.php";
313
314 $ilAppEventHandler->raise(
315 'Modules/Exercise',
316 'delete',
317 array('obj_id' => $this->getId())
318 );
319
320 return true;
321 }
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:

◆ determinStatusOfUser()

ilObjExercise::determinStatusOfUser (   $a_user_id = 0)

Determine status of user.

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

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

References $ilUser, $ret, $user, 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 578 of file class.ilObjExercise.php.

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

References $d, $GLOBALS, $row, 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 800 of file class.ilObjExercise.php.

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

Referenced by cloneObject(), and saveData().

+ Here is the caller graph for this function:

◆ getInstruction()

ilObjExercise::getInstruction ( )

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

105 {
106 return $this->instruction;
107 }

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

125 {
126 return $this->pass_mode;
127 }

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

145 {
146 return $this->pass_nr;
147 }

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

165 {
166 return $this->show_submissions;
167 }

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

+ Here is the caller graph for this function:

◆ getTimestamp()

ilObjExercise::getTimestamp ( )

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

93 {
94 return $this->timestamp;
95 }

References $timestamp.

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

+ Here is the caller graph for this function:

◆ getTutorFeedback()

ilObjExercise::getTutorFeedback ( )
protected

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

200 {
202 }

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

839 {
840 $exc_set = new ilSetting("excs");
841 return (bool) $exc_set->get("add_to_pd", true);
842 }
ILIAS Setting Class.

◆ hasTutorFeedbackFile()

ilObjExercise::hasTutorFeedbackFile ( )

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

195 {
196 return $this->tutor_feedback & self::TUTOR_FEEDBACK_FILE;
197 }

References TUTOR_FEEDBACK_FILE.

◆ hasTutorFeedbackMail()

ilObjExercise::hasTutorFeedbackMail ( )

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

190 {
191 return $this->tutor_feedback & self::TUTOR_FEEDBACK_MAIL;
192 }

References TUTOR_FEEDBACK_MAIL.

◆ hasTutorFeedbackText()

ilObjExercise::hasTutorFeedbackText ( )

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

185 {
186 return $this->tutor_feedback & self::TUTOR_FEEDBACK_TEXT;
187 }

References TUTOR_FEEDBACK_TEXT.

◆ isCompletionBySubmissionEnabled()

ilObjExercise::isCompletionBySubmissionEnabled ( )

Checks whether completion by submission is enabled or not.

Returns
boolean @access public

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

718 {
720 }

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

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

324 {
326
327 parent::read();
328
329 $query = "SELECT * FROM exc_data " .
330 "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
331
332 $res = $ilDB->query($query);
333 while ($row = $ilDB->fetchObject($res)) {
334 $this->setInstruction($row->instruction);
335 $this->setTimestamp($row->time_stamp);
336 $pm = ($row->pass_mode == "")
337 ? "all"
338 : $row->pass_mode;
339 $this->setPassMode($pm);
340 $this->setShowSubmissions($row->show_submissions);
341 if ($row->pass_mode == "nr") {
342 $this->setPassNr($row->pass_nr);
343 }
344 $this->setCompletionBySubmission($row->compl_by_submission == 1 ? true : false);
345 $this->setCertificateVisibility($row->certificate_visibility);
346 $this->setTutorFeedback($row->tfeedback);
347 }
348
349 $this->members_obj = new ilExerciseMembers($this);
350
351 return true;
352 }
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.
$query
foreach($_POST as $key=> $value) $res

References ilObject\$db, $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 {
825
826 $affectedRows = $ilDB->manipulateF(
827 "UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
828 array('integer', 'integer'),
829 array($a_value, $this->getId())
830 );
831 }

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

+ Here is the call graph for this function:

◆ saveData()

ilObjExercise::saveData ( )

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

210 {
212
213 $ilDB->insert("exc_data", array(
214 "obj_id" => array("integer", $this->getId()),
215 "instruction" => array("clob", $this->getInstruction()),
216 "time_stamp" => array("integer", $this->getTimestamp()),
217 "pass_mode" => array("text", $this->getPassMode()),
218 "pass_nr" => array("text", $this->getPassNr()),
219 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
220 'compl_by_submission' => array('integer', (int) $this->isCompletionBySubmissionEnabled()),
221 "certificate_visibility" => array("integer", (int) $this->getCertificateVisibility()),
222 "tfeedback" => array("integer", (int) $this->getTutorFeedback())
223 ));
224 return true;
225 }

References ilObject\$db, $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 386 of file class.ilObjExercise.php.

387 {
390
391 $lng->loadLanguageModule("exc");
392
393 // subject
394 $subject = $a_ass->getTitle()
395 ? $this->getTitle() . ": " . $a_ass->getTitle()
396 : $this->getTitle();
397
398
399 // body
400
401 $body = $a_ass->getInstruction();
402 $body .= "\n\n";
403
404 $body .= $lng->txt("exc_edit_until") . ": ";
405 $body .= (!$a_ass->getDeadline())
406 ? $lng->txt("exc_no_deadline_specified")
408 $body .= "\n\n";
409
410 include_once "Services/Link/classes/class.ilLink.php";
411 $body .= ilLink::_getLink($this->getRefId(), "exc");
412
413
414 // files
415 $file_names = array();
416 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
417 $storage = new ilFSStorageExercise($a_ass->getExerciseId(), $a_ass->getId());
418 $files = $storage->getFiles();
419 if (count($files)) {
420 include_once "./Services/Mail/classes/class.ilFileDataMail.php";
421 $mfile_obj = new ilFileDataMail($GLOBALS['DIC']['ilUser']->getId());
422 foreach ($files as $file) {
423 $mfile_obj->copyAttachmentFile($file["fullpath"], $file["name"]);
424 $file_names[] = $file["name"];
425 }
426 }
427
428 // recipients
429 $recipients = array();
430 foreach ($a_members as $member_id) {
431 $tmp_obj = ilObjectFactory::getInstanceByObjId($member_id);
432 $recipients[] = $tmp_obj->getLogin();
433 unset($tmp_obj);
434 }
435 $recipients = implode(",", $recipients);
436
437 // send mail
438 include_once "Services/Mail/classes/class.ilMail.php";
439 $tmp_mail_obj = new ilMail($ilUser->getId());
440 $errors = $tmp_mail_obj->sendMail(
441 $recipients,
442 "",
443 "",
444 $subject,
445 $body,
446 $file_names,
447 array("normal")
448 );
449 unset($tmp_mail_obj);
450
451 // remove tmp files
452 if (sizeof($file_names)) {
453 $mfile_obj->unlinkFiles($file_names);
454 unset($mfile_obj);
455 }
456
457 // set recipients mail status
458 foreach ($a_members as $member_id) {
459 $member_status = $a_ass->getMemberStatus($member_id);
460 $member_status->setSent(true);
461 $member_status->update();
462 }
463
464 return true;
465 }
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
Definition: index.php:6

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

686 {
687 $user_ids = $a_user_id;
688 if (!is_array($user_ids)) {
689 $user_ids = array($user_ids);
690 }
691
692 include_once("./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
693
694 $type = (bool) $a_is_text_feedback
697
698 $not = new ilExerciseMailNotification();
699 $not->setType($type);
700 $not->setAssignmentId($a_ass_id);
701 $not->setObjId($this->getId());
702 if ($this->getRefId() > 0) {
703 $not->setRefId($this->getRefId());
704 }
705 $not->setRecipients($user_ids);
706 $not->send();
707 }

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

732 {
733 $this->completion_by_submission = (bool) $bool;
734
735 return $this;
736 }

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

83 {
84 $this->hour = (int) $a_hour;
85 $this->minutes = (int) $a_minutes;
86 $this->day = (int) $a_day;
87 $this->month = (int) $a_month;
88 $this->year = (int) $a_year;
89 $this->timestamp = mktime($this->hour, $this->minutes, 0, $this->month, $this->day, $this->year);
90 return true;
91 }

◆ setInstruction()

ilObjExercise::setInstruction (   $a_instruction)

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

101 {
102 $this->instruction = $a_instruction;
103 }

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

115 {
116 $this->pass_mode = $a_val;
117 }

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

135 {
136 $this->pass_nr = $a_val;
137 }

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

155 {
156 $this->show_submissions = $a_val;
157 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTimestamp()

ilObjExercise::setTimestamp (   $a_timestamp)

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

97 {
98 $this->timestamp = $a_timestamp;
99 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTutorFeedback()

ilObjExercise::setTutorFeedback (   $a_value)

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

205 {
206 $this->tutor_feedback = $a_value;
207 }

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

355 {
357
359
360 if ($this->getPassMode() == "all") {
361 $pass_nr = null;
362 } else {
363 $pass_nr = $this->getPassNr();
364 }
365
366 $ilDB->update("exc_data", array(
367 "instruction" => array("clob", $this->getInstruction()),
368 "time_stamp" => array("integer", $this->getTimestamp()),
369 "pass_mode" => array("text", $this->getPassMode()),
370 "pass_nr" => array("integer", $this->getPassNr()),
371 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
372 'compl_by_submission' => array('integer', (int) $this->isCompletionBySubmissionEnabled()),
373 'tfeedback' => array('integer', (int) $this->getTutorFeedback()),
374 ), array(
375 "obj_id" => array("integer", $this->getId())
376 ));
377
378 $this->updateAllUsersStatus();
379
380 return true;
381 }
updateAllUsersStatus()
Update status of all users.
update($pash, $contents, Config $config)

References ilObject\$db, $ilDB, ilObject\getId(), getInstruction(), getPassMode(), getPassNr(), getShowSubmissions(), getTimestamp(), getTutorFeedback(), isCompletionBySubmissionEnabled(), League\Flysystem\Adapter\Polyfill\update(), and updateAllUsersStatus().

+ Here is the call graph for this function:

◆ updateAllUsersStatus()

ilObjExercise::updateAllUsersStatus ( )

Update status of all users.

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

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

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

References $ilUser, $user, 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 37 of file class.ilObjExercise.php.

◆ $completion_by_submission

ilObjExercise::$completion_by_submission = false
protected

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

Referenced by isCompletionBySubmissionEnabled().

◆ $day

ilObjExercise::$day

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

◆ $file_obj

ilObjExercise::$file_obj

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

◆ $files

ilObjExercise::$files

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

Referenced by sendAssignment().

◆ $hour

ilObjExercise::$hour

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

◆ $instruction

ilObjExercise::$instruction

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

Referenced by getInstruction().

◆ $members_obj

ilObjExercise::$members_obj

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

◆ $minutes

ilObjExercise::$minutes

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

◆ $month

ilObjExercise::$month

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

◆ $timestamp

ilObjExercise::$timestamp

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

Referenced by getTimestamp().

◆ $tutor_feedback

ilObjExercise::$tutor_feedback = 7

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

Referenced by getTutorFeedback().

◆ $user

ilObjExercise::$user
protected

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

Referenced by determinStatusOfUser(), sendAssignment(), and updateUserStatus().

◆ $webFilesystem

ilObjExercise::$webFilesystem
private

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

◆ $year

ilObjExercise::$year

Definition at line 35 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: