ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjExercise Class Reference

Class ilObjExercise. More...

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

Public Member Functions

 ilObjExercise ($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 ()
 
 saveData ()
 
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone exercise (no member data) More...
 
 delete ()
 delete course and all related data More...
 
 notify ($a_event, $a_ref_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event happend, each object may decide how it reacts. More...
 
 read ()
 
 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
 ilObject ($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 ($a_force_db=false)
 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 ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) 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...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type 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...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts. 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...
 
 _lookupCreationDate ($a_id)
 Lookup creation date. 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 _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupObjId ($a_id)
 
static setDeletedDates ($a_ref_ids)
 Set deleted date @global type $ilDB. More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id 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 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
 
- 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
 
 $obj_data_record
 object_data record More...
 

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.

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

798 {
799 global $ilDB;
800
801 $set = $ilDB->query("SELECT obj_id, status FROM exc_members".
802 " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
803 " AND (status = ".$ilDB->quote("passed", "text").
804 " OR status = ".$ilDB->quote("failed", "text").")");
805
806 $all = array();
807 while($row = $ilDB->fetchAssoc($set))
808 {
809 $all[$row["obj_id"]] = ($row["status"] == "passed");
810 }
811 return $all;
812 }
global $ilDB

References $ilDB, and $row.

Referenced by ilExerciseVerificationTableGUI\getItems().

+ Here is the caller graph for this function:

◆ checkDate()

ilObjExercise::checkDate ( )

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

152 {
153 return $this->hour == (int) date("H",$this->timestamp) and
154 $this->minutes == (int) date("i",$this->timestamp) and
155 $this->day == (int) date("d",$this->timestamp) and
156 $this->month == (int) date("m",$this->timestamp) and
157 $this->year == (int) date("Y",$this->timestamp);
158
159 }

◆ cloneObject()

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

Clone exercise (no member data)

@access public

Parameters
inttarget ref_id
intcopy id

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

194 {
195 global $ilDB;
196
197 // Copy settings
198 $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
199 $new_obj->setInstruction($this->getInstruction());
200 $new_obj->setTimestamp($this->getTimestamp());
201 $new_obj->setPassMode($this->getPassMode());
202 $new_obj->saveData();
203 $new_obj->setPassNr($this->getPassNr());
204 $new_obj->setShowSubmissions($this->getShowSubmissions());
205 $new_obj->setCompletionBySubmission($this->isCompletionBySubmissionEnabled());
206 $new_obj->update();
207
208 // Copy criteria catalogues
209 $crit_cat_map = array();
210 include_once("./Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php");
211 foreach(ilExcCriteriaCatalogue::getInstancesByParentId($this->getId()) as $crit_cat)
212 {
213 $new_id = $crit_cat->cloneObject($new_obj->getId());
214 $crit_cat_map[$crit_cat->getId()] = $new_id;
215 }
216
217 // Copy assignments
218 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
219 ilExAssignment::cloneAssignmentsOfExercise($this->getId(), $new_obj->getId(), $crit_cat_map);
220
221 // Copy learning progress settings
222 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
223 $obj_settings = new ilLPObjSettings($this->getId());
224 $obj_settings->cloneSettings($new_obj->getId());
225 unset($obj_settings);
226
227 return $new_obj;
228 }
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(), 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 236 of file class.ilObjExercise.php.

237 {
238 global $ilDB, $ilAppEventHandler;
239
240 // always call parent delete function first!!
241 if (!parent::delete())
242 {
243 return false;
244 }
245 // put here course specific stuff
246 $ilDB->manipulate("DELETE FROM exc_data ".
247 "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer"));
248
249 //$this->ilias->db->query($query);
250
251 //$this->file_obj->delete();
252 //$this->members_obj->delete();
253
254 include_once "Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php";
256
257 // remove all notifications
258 include_once "./Services/Notification/classes/class.ilNotification.php";
260
261 $ilAppEventHandler->raise('Modules/Exercise',
262 'delete',
263 array('obj_id'=>$this->getId()));
264
265 return true;
266 }
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 450 of file class.ilObjExercise.php.

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

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

575 {
576 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
577 $ass_data = ilExAssignment::getInstancesByExercise($this->getId());
578
579 include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
580 $excelfile = ilUtil::ilTempnam();
581 $adapter = new ilExcelWriterAdapter($excelfile, FALSE);
582 $workbook = $adapter->getWorkbook();
583 $workbook->setVersion(8); // Use Excel97/2000 Format
584 include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
585
586 //
587 // status
588 //
589 $mainworksheet = $workbook->addWorksheet();
590
591 // header row
592 $mainworksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("name")));
593 $cnt = 1;
594 foreach ($ass_data as $ass)
595 {
596 $mainworksheet->writeString(0, $cnt, $cnt);
597 $cnt++;
598 }
599 $mainworksheet->writeString(0, $cnt++, ilExcelUtils::_convert_text($this->lng->txt("exc_total_exc")));
600 $mainworksheet->writeString(0, $cnt++, ilExcelUtils::_convert_text($this->lng->txt("exc_mark")));
601 $mainworksheet->writeString(0, $cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_comment_for_learner")));
602
603 // data rows
604 $this->mem_obj = new ilExerciseMembers($this);
605 $getmems = $this->mem_obj->getMembers();
606 $mems = array();
607 foreach ($getmems as $user_id)
608 {
609 $mems[$user_id] = ilObjUser::_lookupName($user_id);
610 }
611 $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
612
613 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
614
615 $data = array();
616 $row_cnt = 1;
617 foreach ($mems as $user_id => $d)
618 {
619 $col_cnt = 1;
620
621 // name
622 $mainworksheet->writeString($row_cnt, 0,
623 ilExcelUtils::_convert_text($d["lastname"].", ".$d["firstname"]." [".$d["login"]."]"));
624
625 reset($ass_data);
626
627 foreach ($ass_data as $ass)
628 {
629 $status = $ass->getMemberStatus($user_id)->getStatus();
630 $mainworksheet->writeString($row_cnt, $col_cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_".$status)));
631 $col_cnt++;
632 }
633
634 // total status
635 $status = ilExerciseMembers::_lookupStatus($this->getId(), $user_id);
636 $mainworksheet->writeString($row_cnt, $col_cnt++, ilExcelUtils::_convert_text($this->lng->txt("exc_".$status)));
637
638 // #18096
639 $marks_obj = new ilLPMarks($this->getId(), $user_id);
640 $mainworksheet->writeString($row_cnt, $col_cnt++, ilExcelUtils::_convert_text($marks_obj->getMark()));
641 $mainworksheet->writeString($row_cnt, $col_cnt, ilExcelUtils::_convert_text($marks_obj->getComment()));
642
643 $row_cnt++;
644 }
645
646 //
647 // mark
648 //
649 $worksheet2 = $workbook->addWorksheet();
650
651 // header row
652 $worksheet2->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("name")));
653 $cnt = 1;
654 foreach ($ass_data as $ass)
655 {
656 $worksheet2->writeString(0, $cnt, $cnt);
657 $cnt++;
658 }
659 $worksheet2->writeString(0, $cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_total_exc")));
660
661 // data rows
662 $data = array();
663 $row_cnt = 1;
664 reset($mems);
665 foreach ($mems as $user_id => $d)
666 {
667 $col_cnt = 1;
668 $d = ilObjUser::_lookupName($user_id);
669
670 // name
671 $worksheet2->writeString($row_cnt, 0,
672 ilExcelUtils::_convert_text($d["lastname"].", ".$d["firstname"]." [".$d["login"]."]"));
673
674 reset($ass_data);
675
676 foreach ($ass_data as $ass)
677 {
678 $mark = $ass->getMemberStatus($user_id)->getMark();
679 $worksheet2->writeString($row_cnt, $col_cnt, ilExcelUtils::_convert_text($mark));
680 $col_cnt++;
681 }
682
683 // total mark
684 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
685 $worksheet2->writeString($row_cnt, $col_cnt,
687
688 $row_cnt++;
689 }
690
691
692 $workbook->close();
693 $exc_name = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->getTitle()));
694 ilUtil::deliverFile($excelfile, $exc_name.".xls", "application/vnd.ms-excel");
695 }
_convert_text($a_text, $a_target="has been removed")
Class ilExcelWriterAdapter.
Class ilExerciseMembers.
_lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
_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 ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$data

References $d, $data, ilExcelUtils\_convert_text(), ilLPMarks\_lookupMark(), ilObjUser\_lookupName(), ilExerciseMembers\_lookupStatus(), ilUtil\deliverFile(), ilUtil\getASCIIFilename(), ilObject\getId(), ilExAssignment\getInstancesByExercise(), ilObject\getTitle(), ilUtil\ilTempnam(), 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 821 of file class.ilObjExercise.php.

822 {
823 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
824 }

Referenced by hasUserCertificate(), and saveData().

+ Here is the caller graph for this function:

◆ getInstruction()

ilObjExercise::getInstruction ( )

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

81 {
82 return $this->instruction;
83 }

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

101 {
102 return $this->pass_mode;
103 }

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

121 {
122 return $this->pass_nr;
123 }

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

141 {
142 return $this->show_submissions;
143 }

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

+ Here is the caller graph for this function:

◆ getTimestamp()

ilObjExercise::getTimestamp ( )

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

69 {
70 return $this->timestamp;
71 }

References $timestamp.

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

892 {
893 $exc_set = new ilSetting("excs");
894 return (bool)$exc_set->get("add_to_pd", true);
895 }
ILIAS Setting Class.

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

860 {
861 // show certificate?
862 include_once "Services/Certificate/classes/class.ilCertificate.php";
864 {
865 $certificate_visible = $this->getCertificateVisibility();
866 // if not never
867 if($certificate_visible != 2)
868 {
869 // if passed only
870 include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php';
871 $status = ilExerciseMembers::_lookupStatus($this->getId(), $a_user_id);
872 if($certificate_visible == 1 && $status == "passed")
873 {
874 return true;
875 }
876 // always (excluding notgraded)
877 else if($certificate_visible == 0 && $status != "notgraded")
878 {
879 return true;
880 }
881 }
882 }
883 return false;
884 }
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:

◆ ilObjExercise()

ilObjExercise::ilObjExercise (   $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)

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

51 {
52 $this->setPassMode("all");
53 $this->type = "exc";
54 $this->ilObject($a_id,$a_call_by_reference);
55 }
setPassMode($a_val)
Set pass mode (all | nr)
ilObject($a_id=0, $a_reference=true)
Constructor @access public.

References ilObject\ilObject(), and setPassMode().

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

735 {
737 }

References $completion_by_submission.

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

+ Here is the caller graph for this function:

◆ notify()

ilObjExercise::notify (   $a_event,
  $a_ref_id,
  $a_node_id,
  $a_params = 0 
)

notifys an object about an event occured Based on the event happend, each object may decide how it reacts.

@access public

Parameters
stringevent
integerreference id of object where the event occured
arraypasses optional paramters if required
Returns
boolean

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

279 {
280 // object specific event handling
281
282 parent::notify($a_event,$a_ref_id,$a_node_id,$a_params);
283 }

◆ processExerciseStatus()

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

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

756 {
757 $a_has_submitted = (bool)$a_has_submitted;
758
759 include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
760 foreach($a_user_ids as $user_id)
761 {
762 $member_status = $a_ass->getMemberStatus($user_id);
763 $member_status->setReturned($a_has_submitted);
764 $member_status->update();
765
766 ilExerciseMembers::_writeReturned($this->getId(), $user_id, $a_has_submitted);
767 }
768
769 // re-evaluate exercise status
771 {
772 foreach($a_user_ids as $user_id)
773 {
774 $status = 'notgraded';
775 if($a_has_submitted)
776 {
777 if(!is_array($a_valid_submissions) ||
778 $a_valid_submissions[$user_id])
779 {
780 $status = 'passed';
781 }
782 }
783
784 $member_status = $a_ass->getMemberStatus($user_id);
785 $member_status->setStatus($status);
786 $member_status->update();
787 }
788 }
789 }
getMemberStatus($a_user_id=null)
_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 ( )

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

286 {
287 global $ilDB;
288
289 parent::read();
290
291 $query = "SELECT * FROM exc_data ".
292 "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
293
294 $res = $ilDB->query($query);
295 while($row = $ilDB->fetchObject($res))
296 {
297 $this->setInstruction($row->instruction);
298 $this->setTimestamp($row->time_stamp);
299 $pm = ($row->pass_mode == "")
300 ? "all"
301 : $row->pass_mode;
302 $this->setPassMode($pm);
303 $this->setShowSubmissions($row->show_submissions);
304 if ($row->pass_mode == "nr")
305 {
306 $this->setPassNr($row->pass_nr);
307 }
308 $this->setCompletionBySubmission($row->compl_by_submission == 1 ? true : false);
309 $this->setCertificateVisibility($row->certificate_visibility);
310 }
311
312 $this->members_obj = new ilExerciseMembers($this);
313
314 return true;
315 }
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.
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(), and setTimestamp().

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

844 {
845 global $ilDB;
846
847 $affectedRows = $ilDB->manipulateF("UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
848 array('integer', 'integer'),
849 array($a_value, $this->getId())
850 );
851 }

References $ilDB, and ilObject\getId().

+ Here is the call graph for this function:

◆ saveData()

ilObjExercise::saveData ( )

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

163 {
164 global $ilDB;
165
166 // SAVE ONLY EXERCISE SPECIFIC DATA
167 /*$query = "INSERT INTO exc_data SET ".
168 "obj_id = ".$ilDB->quote($this->getId()).", ".
169 "instruction = ".$ilDB->quote($this->getInstruction()).", ".
170 "time_stamp = ".$ilDB->quote($this->getTimestamp());
171 $this->ilias->db->query($query);*/
172
173 $ilDB->insert("exc_data", array(
174 "obj_id" => array("integer", $this->getId()),
175 "instruction" => array("clob", $this->getInstruction()),
176 "time_stamp" => array("integer", $this->getTimestamp()),
177 "pass_mode" => array("text", $this->getPassMode()),
178 "pass_nr" => array("text", $this->getPassNr()),
179 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
180 'compl_by_submission' => array('integer', (int)$this->isCompletionBySubmissionEnabled()),
181 "certificate_visibility" => array("integer", (int)$this->getCertificateVisibility())
182 ));
183 return true;
184 }

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

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

References $_SESSION, $file, $files, $ilUser, ilObject\$lng, ilLink\_getLink(), ilDatePresentation\formatDate(), ilExAssignment\getDeadline(), ilExAssignment\getExerciseId(), ilExAssignment\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 700 of file class.ilObjExercise.php.

701 {
702 $user_ids = $a_user_id;
703 if(!is_array($user_ids))
704 {
705 $user_ids = array($user_ids);
706 }
707
708 include_once("./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
709
710 $type = (bool)$a_is_text_feedback
713
714 $not = new ilExerciseMailNotification();
715 $not->setType($type);
716 $not->setAssignmentId($a_ass_id);
717 $not->setObjId($this->getId());
718 if ($this->getRefId() > 0)
719 {
720 $not->setRefId($this->getRefId());
721 }
722 $not->setRecipients($user_ids);
723 $not->send();
724 }

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

833 {
834 $this->certificate_visibility = $a_value;
835 }

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

749 {
750 $this->completion_by_submission = (bool)$bool;
751
752 return $this;
753 }

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

59 {
60 $this->hour = (int) $a_hour;
61 $this->minutes = (int) $a_minutes;
62 $this->day = (int) $a_day;
63 $this->month = (int) $a_month;
64 $this->year = (int) $a_year;
65 $this->timestamp = mktime($this->hour,$this->minutes,0,$this->month,$this->day,$this->year);
66 return true;
67 }

◆ setInstruction()

ilObjExercise::setInstruction (   $a_instruction)

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

77 {
78 $this->instruction = $a_instruction;
79 }

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

91 {
92 $this->pass_mode = $a_val;
93 }

Referenced by ilObjExercise().

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

111 {
112 $this->pass_nr = $a_val;
113 }

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

131 {
132 $this->show_submissions = $a_val;
133 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTimestamp()

ilObjExercise::setTimestamp (   $a_timestamp)

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

73 {
74 $this->timestamp = $a_timestamp;
75 }

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

318 {
319 global $ilDB;
320
321 parent::update();
322
323 /*$query = "UPDATE exc_data SET ".
324 "instruction = ".$ilDB->quote($this->getInstruction()).", ".
325 "time_stamp = ".$ilDB->quote($this->getTimestamp())." ".
326 "WHERE obj_id = ".$ilDB->quote($this->getId());
327 */
328
329 if ($this->getPassMode() == "all")
330 {
331 $pass_nr = null;
332 }
333 else
334 {
335 $pass_nr = $this->getPassNr();
336 }
337
338 $ilDB->update("exc_data", array(
339 "instruction" => array("clob", $this->getInstruction()),
340 "time_stamp" => array("integer", $this->getTimestamp()),
341 "pass_mode" => array("text", $this->getPassMode()),
342 "pass_nr" => array("integer", $this->getPassNr()),
343 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
344 'compl_by_submission' => array('integer', (int)$this->isCompletionBySubmissionEnabled())
345 ), array(
346 "obj_id" => array("integer", $this->getId())
347 ));
348
349 $this->updateAllUsersStatus();
350
351 //$res = $this->ilias->db->query($query);
352
353 #$this->members_obj->update();
354 return true;
355 }
updateAllUsersStatus()
Update status of all users.

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

+ Here is the call graph for this function:

◆ updateAllUsersStatus()

ilObjExercise::updateAllUsersStatus ( )

Update status of all users.

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

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

539 {
540 global $ilUser;
541
542 if ($a_user_id == 0)
543 {
544 $a_user_id = $ilUser->getId();
545 }
546
547 $st = $this->determinStatusOfUser($a_user_id);
548
549 include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
550 ilExerciseMembers::_writeStatus($this->getId(), $a_user_id,
551 $st["overall_status"]);
552 }
_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 42 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().

◆ $year

ilObjExercise::$year

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


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