ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 ()
 
 deliverFile ($a_http_post_files, $a_ass_id, $user_id, $unzip=false)
 Save submitted file of user. More...
 
 addUploadedFile ($a_http_post_files, $unzipUploadedFile=false)
 Upload assigment files. More...
 
 deleteFiles ($a_files)
 
 saveData ()
 
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone exercise (no member data) More...
 
 deleteDeliveredFiles ($a_exc_id, $a_ass_id, $file_id_array, $user_id)
 Deletes already delivered files. More...
 
 deliverReturnedFiles ($user_id)
 Delivers the returned files of an user. 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 ($a_exc_id, $a_ass_id, $a_members)
 send exercise per mail to members More...
 
 _lookupStatusTime ($exc_id, $member_id)
 Get time when exercise has been set to solved. More...
 
 __formatBody ($a_ass_id)
 
 __formatSubject ($a_ass_title="")
 
 __formatRecipients ($a_members)
 
 processUploadedFile ($fileTmp, $storageMethod, $persistentErrorMessage, $a_ass_id)
 processes errorhandling etc for uploaded archive 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...
 
 handleSubmission ($ass_id)
 This method is called after an user submitted one or more files. More...
 
 addResourceObject ($a_wsp_id, $a_ass_id, $user_id, $a_text=null)
 Add personal resource to assigment. More...
 
 deleteResourceObject ($a_ass_id, $user_id, $a_returned_id)
 Remove personal resource to assigment. More...
 
 updateTextSubmission ($a_exc_id, $a_ass_id, $a_user_id, $a_text)
 Handle text assignment submissions. More...
 
 deleteAllDeliveredFilesOfUser ($a_user_id)
 Delete all delivered files of user. More...
 
 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...
 

Static Public Member Functions

static _fixFilename ($a_filename)
 This function fixes filenames. More...
 
static _fixFilenameArray ($a_array)
 Iterates an associative array and fixes all fields with the key "filename" using the _fixFilename() method. More...
 
static _lookupFinishedUserExercises ($a_user_id)
 Get all exercises for user. More...
 
static lookupExerciseIdForReturnedId ($a_returned_id)
 
static findUserFiles ($a_user_id, $a_filetitle)
 Check if given file was assigned. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_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 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

◆ __formatBody()

ilObjExercise::__formatBody (   $a_ass_id)

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

533 {
534 global $lng;
535
536 $lng->loadLanguageModule("exc");
537
538 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
539 $ass = new ilExAssignment($a_ass_id);
540
541 $body = $ass->getInstruction();
542 $body .= "\n\n";
543 if ($ass->getDeadline() == 0)
544 {
545 $body .= $lng->txt("exc_edit_until") . ": ".
546 $lng->txt("exc_no_deadline_specified");
547 }
548 else
549 {
550 $body .= $lng->txt("exc_edit_until") . ": ".
551 ilFormat::formatDate(date("Y-m-d H:i:s",$ass->getDeadline()), "datetime", true);
552 }
553 $body .= "\n\n";
554 $body .= ILIAS_HTTP_PATH.
555 "/goto.php?target=".
556 $this->getType().
557 "_".$this->getRefId()."&client_id=".CLIENT_ID;
558
559 return $body;
560 }
Exercise assignment.
formatDate($a_date, $a_mode="datetime", $a_omit_seconds=false, $a_relative=TRUE)
format a date according to the user language shortcut for Format::fmtDateTime @access public
getType()
get object type @access public

References ilObject\$lng, ilFormat\formatDate(), and ilObject\getType().

Referenced by sendAssignment().

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

◆ __formatRecipients()

ilObjExercise::__formatRecipients (   $a_members)

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

575 {
576 foreach($a_members as $member_id => $value)
577 {
578 $tmp_obj = ilObjectFactory::getInstanceByObjId($member_id);
579 $tmp_members[] = $tmp_obj->getLogin();
580
581 unset($tmp_obj);
582 }
583
584 return implode(',',$tmp_members ? $tmp_members : array());
585 }
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References ilObjectFactory\getInstanceByObjId().

Referenced by sendAssignment().

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

◆ __formatSubject()

ilObjExercise::__formatSubject (   $a_ass_title = "")

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

563 {
564 $subject = $this->getTitle();
565
566 if ($a_ass_title != "")
567 {
568 $subject.= ": ".$a_ass_title;
569 }
570
571 return $subject;
572 }
getTitle()
get object title @access public

References ilObject\getTitle().

Referenced by sendAssignment().

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

◆ _fixFilename()

static ilObjExercise::_fixFilename (   $a_filename)
static

This function fixes filenames.

Prior to ILIAS 3.10.0 filenames have been stored with full path in exc_returned.filename, e.g. /opt/ilias/my_client/exercise/547/157/20070813113926_README.doc

Problems occur, if the server is moved from one location to another. We do the following: The filename will be parsed and if it contains the string "/exercise/" we truncate everything before "/exercise/" and replace it with the current CLIENT_DATA_DIR.

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

651 {
652 $ex_pos = strrpos($a_filename, "/exercise/");
653 if ($ex_pos > 0)
654 {
655 $a_filename = CLIENT_DATA_DIR.substr($a_filename, $ex_pos);
656 }
657 return $a_filename;
658 }

Referenced by _fixFilenameArray().

+ Here is the caller graph for this function:

◆ _fixFilenameArray()

static ilObjExercise::_fixFilenameArray (   $a_array)
static

Iterates an associative array and fixes all fields with the key "filename" using the _fixFilename() method.

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

665 {
666 if (is_array($a_array))
667 {
668 foreach ($a_array as $k => $v)
669 {
670 if ($v["filename"] != "")
671 {
672 $a_array[$k]["filename"] = ilObjExercise::_fixFilename($a_array[$k]["filename"]);
673 }
674 }
675 }
676
677 return $a_array;
678 }
static _fixFilename($a_filename)
This function fixes filenames.

References _fixFilename().

+ Here is the call graph for this function:

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

1034 {
1035 global $ilDB;
1036
1037 $set = $ilDB->query("SELECT obj_id, status FROM exc_members".
1038 " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
1039 " AND (status = ".$ilDB->quote("passed", "text").
1040 " OR status = ".$ilDB->quote("failed", "text").")");
1041
1042 $all = array();
1043 while($row = $ilDB->fetchAssoc($set))
1044 {
1045 $all[$row["obj_id"]] = ($row["status"] == "passed");
1046 }
1047 return $all;
1048 }
global $ilDB

References $ilDB, and $row.

Referenced by ilExerciseVerificationTableGUI\getItems().

+ Here is the caller graph for this function:

◆ _lookupStatusTime()

ilObjExercise::_lookupStatusTime (   $exc_id,
  $member_id 
)

Get time when exercise has been set to solved.

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

515 {
516
517 global $ilDB, $lng;
518
519 $q = "SELECT * ".
520 "FROM exc_members ".
521 "WHERE obj_id= ".$ilDB->quote($exc_id, "integer").
522 " AND usr_id= ".$ilDB->quote($member_id, "integer");
523
524 $set = $ilDB->query($q);
525 if ($rec = $ilDB->fetchAssoc($set))
526 {
527 return ilUtil::getMySQLTimestamp($rec["status_time"]);
528 }
529 }
static getMySQLTimestamp($a_ts)
Get MySQL timestamp in 4.1.x or higher format (yyyy-mm-dd hh:mm:ss) This function converts a timestam...

References $ilDB, ilObject\$lng, and ilUtil\getMySQLTimestamp().

+ Here is the call graph for this function:

◆ addResourceObject()

ilObjExercise::addResourceObject (   $a_wsp_id,
  $a_ass_id,
  $user_id,
  $a_text = null 
)

Add personal resource to assigment.

Parameters
int$a_wsp_id
int$a_ass_id
int$user_id
string$a_text

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

1059 {
1060 global $ilDB;
1061
1062 $next_id = $ilDB->nextId("exc_returned");
1063 $query = sprintf("INSERT INTO exc_returned ".
1064 "(returned_id, obj_id, user_id, filetitle, ass_id, ts, atext) ".
1065 "VALUES (%s, %s, %s, %s, %s, %s, %s)",
1066 $ilDB->quote($next_id, "integer"),
1067 $ilDB->quote($this->getId(), "integer"),
1068 $ilDB->quote($user_id, "integer"),
1069 $ilDB->quote($a_wsp_id, "text"),
1070 $ilDB->quote($a_ass_id, "integer"),
1071 $ilDB->quote(ilUtil::now(), "timestamp"),
1072 $ilDB->quote($a_text, "text")
1073 );
1074 $ilDB->manipulate($query);
1075 if (!$this->members_obj->isAssigned($user_id))
1076 {
1077 $this->members_obj->assignMember($user_id);
1078 }
1079 // no submission (of blog/portfolio) yet (unless text assignment)
1080 ilExAssignment::updateStatusReturnedForUser($a_ass_id, $user_id, (bool)$a_text);
1081 ilExerciseMembers::_writeReturned($this->getId(), $user_id, (bool)$a_text);
1082
1083 return $next_id;
1084 }
updateStatusReturnedForUser($a_ass_id, $a_user_id, $a_status)
was: setStatusReturnedForMember($a_member_id,$a_status)
_writeReturned($a_obj_id, $a_user_id, $a_status)
Write returned status.
getId()
get object id @access public
static now()
Return current timestamp in Y-m-d H:i:s format.

References $ilDB, $query, ilExerciseMembers\_writeReturned(), ilObject\getId(), ilUtil\now(), and ilExAssignment\updateStatusReturnedForUser().

Referenced by updateTextSubmission().

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

◆ addUploadedFile()

ilObjExercise::addUploadedFile (   $a_http_post_files,
  $unzipUploadedFile = false 
)

Upload assigment files.

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

218 {
219 global $lng;
220 if ($unzipUploadedFile && preg_match("/zip/", $a_http_post_files["type"]) == 1)
221 {
222
223 $this->processUploadedFile($a_http_post_files["tmp_name"], "storeUploadedFile", true);
224 return true;
225
226
227 }
228 else
229 {
230 $this->file_obj->storeUploadedFile($a_http_post_files, true);
231 return true;
232 }
233 }
processUploadedFile($fileTmp, $storageMethod, $persistentErrorMessage, $a_ass_id)
processes errorhandling etc for uploaded archive

References ilObject\$lng, and processUploadedFile().

+ Here is the call 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 270 of file class.ilObjExercise.php.

271 {
272 global $ilDB;
273
274 // Copy settings
275 $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
276 $new_obj->setInstruction($this->getInstruction());
277 $new_obj->setTimestamp($this->getTimestamp());
278 $new_obj->setPassMode($this->getPassMode());
279 $new_obj->saveData();
280 $new_obj->setPassNr($this->getPassNr());
281 $new_obj->setShowSubmissions($this->getShowSubmissions());
282 $new_obj->setCompletionBySubmission($this->isCompletionBySubmissionEnabled());
283
284
285 $new_obj->update();
286
287 // Copy assignments
288 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
289 ilExAssignment::cloneAssignmentsOfExercise($this->getId(), $new_obj->getId());
290
291 // Copy learning progress settings
292 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
293 $obj_settings = new ilLPObjSettings($this->getId());
294 $obj_settings->cloneSettings($new_obj->getId());
295 unset($obj_settings);
296
297 return $new_obj;
298 }
cloneAssignmentsOfExercise($a_old_exc_id, $a_new_exc_id)
Clone assignments of exercise.
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)

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

344 {
345 global $ilDB, $ilAppEventHandler;
346
347 // always call parent delete function first!!
348 if (!parent::delete())
349 {
350 return false;
351 }
352 // put here course specific stuff
353 $ilDB->manipulate("DELETE FROM exc_data ".
354 "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer"));
355
356 //$this->ilias->db->query($query);
357
358 //$this->file_obj->delete();
359 //$this->members_obj->delete();
360
361 // remove all notifications
362 include_once "./Services/Notification/classes/class.ilNotification.php";
364
365 $ilAppEventHandler->raise('Modules/Exercise',
366 'delete',
367 array('obj_id'=>$this->getId()));
368
369 return true;
370 }
static removeForObject($type, $id)
Remove all notifications for given object.

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

+ Here is the call graph for this function:

◆ deleteAllDeliveredFilesOfUser()

ilObjExercise::deleteAllDeliveredFilesOfUser (   $a_user_id)

Delete all delivered files of user.

Parameters
int$a_user_iduser id

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

1170 {
1171 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1173 }
static deleteAllDeliveredFilesOfUser($a_exc_id, $a_user_id)
Delete all delivered files of user.

References ilExAssignment\deleteAllDeliveredFilesOfUser(), and ilObject\getId().

+ Here is the call graph for this function:

◆ deleteDeliveredFiles()

ilObjExercise::deleteDeliveredFiles (   $a_exc_id,
  $a_ass_id,
  $file_id_array,
  $user_id 
)

Deletes already delivered files.

Parameters
array$file_id_arrayAn array containing database ids of the delivered files
numeric$user_idThe database id of the user @access public

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

307 {
308 ilExAssignment::deleteDeliveredFiles($a_exc_id, $a_ass_id, $file_id_array, $user_id);
309
310 // Finally update status 'returned' of member if no file exists
311 if(!count(ilExAssignment::getDeliveredFiles($a_exc_id, $a_ass_id, $user_id)))
312 {
313 // team upload?
314 $user_ids = ilExAssignment::getTeamMembersByAssignmentId($a_ass_id, $user_id);
315 if(!$user_ids)
316 {
317 $user_ids = array($user_id);
318 }
319
320 foreach($user_ids as $user_id)
321 {
322 ilExAssignment::updateStatusReturnedForUser($a_ass_id, $user_id, 0);
323 }
324 }
325 }
static getTeamMembersByAssignmentId($a_ass_id, $a_user_id)
Find team members by assignment and team member.
getDeliveredFiles($a_exc_id, $a_ass_id, $a_user_id, $a_filter_empty_filename=false)
was: getDeliveredFiles($a_member_id)
deleteDeliveredFiles($a_exc_id, $a_ass_id, $file_id_array, $a_user_id)
was: deleteDeliveredFiles($file_id_array, $a_member_id)

References ilExAssignment\deleteDeliveredFiles(), ilExAssignment\getDeliveredFiles(), ilExAssignment\getTeamMembersByAssignmentId(), and ilExAssignment\updateStatusReturnedForUser().

Referenced by updateTextSubmission().

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

◆ deleteFiles()

ilObjExercise::deleteFiles (   $a_files)

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

235 {
236 $this->file_obj->unlinkFiles($a_files);
237 }

◆ deleteResourceObject()

ilObjExercise::deleteResourceObject (   $a_ass_id,
  $user_id,
  $a_returned_id 
)

Remove personal resource to assigment.

Parameters
int$a_ass_id
int$user_id
int$a_returned_id

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

1094 {
1095 global $ilDB;
1096
1097 $ilDB->manipulate("DELETE FROM exc_returned".
1098 " WHERE obj_id = ".$ilDB->quote($this->getId(), "integer").
1099 " AND user_id = ".$ilDB->quote($user_id, "integer").
1100 " AND ass_id = ".$ilDB->quote($a_ass_id, "integer").
1101 " AND returned_id = ".$ilDB->quote($a_returned_id, "integer"));
1102 }

References $ilDB.

◆ deliverFile()

ilObjExercise::deliverFile (   $a_http_post_files,
  $a_ass_id,
  $user_id,
  $unzip = false 
)

Save submitted file of user.

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

165 {
166 global $ilDB;
167
168 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
169 $storage = new ilFSStorageExercise($this->getId(), $a_ass_id);
170 $deliver_result = $storage->deliverFile($a_http_post_files, $user_id, $unzip);
171//var_dump($deliver_result);
172 if ($deliver_result)
173 {
174 $next_id = $ilDB->nextId("exc_returned");
175 $query = sprintf("INSERT INTO exc_returned ".
176 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id) ".
177 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
178 $ilDB->quote($next_id, "integer"),
179 $ilDB->quote($this->getId(), "integer"),
180 $ilDB->quote($user_id, "integer"),
181 $ilDB->quote($deliver_result["fullname"], "text"),
182 $ilDB->quote($a_http_post_files["name"], "text"),
183 $ilDB->quote($deliver_result["mimetype"], "text"),
184 $ilDB->quote(ilUtil::now(), "timestamp"),
185 $ilDB->quote($a_ass_id, "integer")
186 );
187 $ilDB->manipulate($query);
188
189 // team upload?
190 $user_ids = ilExAssignment::getTeamMembersByAssignmentId($a_ass_id, $user_id);
191 if(!$user_ids)
192 {
193 $user_ids = array($user_id);
194 }
195 else
196 {
197 $team_id = ilExAssignment::getTeamIdByAssignment($a_ass_id, $user_id);
198 ilExAssignment::writeTeamLog($team_id, ilExAssignment::TEAM_LOG_ADD_FILE, $a_http_post_files["name"]);
199 }
200
201 foreach($user_ids as $user_id)
202 {
203 if (!$this->members_obj->isAssigned($user_id))
204 {
205 $this->members_obj->assignMember($user_id);
206 }
207 ilExAssignment::updateStatusReturnedForUser($a_ass_id, $user_id, 1);
208 ilExerciseMembers::_writeReturned($this->getId(), $user_id, 1);
209 }
210 }
211 return true;
212 }
static getTeamIdByAssignment($a_ass_id, $a_user_id)
Find team by assignment.
static writeTeamLog($a_team_id, $a_action, $a_details=null)
Add entry to team log.

References $ilDB, $query, ilExerciseMembers\_writeReturned(), ilObject\getId(), ilExAssignment\getTeamIdByAssignment(), ilExAssignment\getTeamMembersByAssignmentId(), ilUtil\now(), ilExAssignment\TEAM_LOG_ADD_FILE, ilExAssignment\updateStatusReturnedForUser(), and ilExAssignment\writeTeamLog().

+ Here is the call graph for this function:

◆ deliverReturnedFiles()

ilObjExercise::deliverReturnedFiles (   $user_id)

Delivers the returned files of an user.

Parameters
numeric$user_idThe database id of the user @access public

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

333 {
334 require_once "./Services/Utilities/classes/class.ilUtil.php";
335 }

◆ determinStatusOfUser()

ilObjExercise::determinStatusOfUser (   $a_user_id = 0)

Determine status of user.

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

684 {
685 global $ilUser;
686
687 if ($a_user_id == 0)
688 {
689 $a_user_id = $ilUser->getId();
690 }
691
692 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
694
695 $passed_all_mandatory = true;
696 $failed_a_mandatory = false;
697 $cnt_passed = 0;
698 $cnt_notgraded = 0;
699 $passed_at_least_one = false;
700
701 foreach ($ass as $a)
702 {
703 $stat = ilExAssignment::lookupStatusOfUser($a["id"], $a_user_id);
704 if ($a["mandatory"] && ($stat == "failed" || $stat == "notgraded"))
705 {
706 $passed_all_mandatory = false;
707 }
708 if ($a["mandatory"] && ($stat == "failed"))
709 {
710 $failed_a_mandatory = true;
711 }
712 if ($stat == "passed")
713 {
714 $cnt_passed++;
715 }
716 if ($stat == "notgraded")
717 {
718 $cnt_notgraded++;
719 }
720 }
721
722 if (count($ass) == 0)
723 {
724 $passed_all_mandatory = false;
725 }
726
727 if ($this->getPassMode() != "nr")
728 {
729//echo "5";
730 $overall_stat = "notgraded";
731 if ($failed_a_mandatory)
732 {
733//echo "6";
734 $overall_stat = "failed";
735 }
736 else if ($passed_all_mandatory && $cnt_passed > 0)
737 {
738//echo "7";
739 $overall_stat = "passed";
740 }
741 }
742 else
743 {
744//echo "8";
745 $min_nr = $this->getPassNr();
746 $overall_stat = "notgraded";
747//echo "*".$cnt_passed."*".$cnt_notgraded."*".$min_nr."*";
748 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr))
749 {
750//echo "9";
751 $overall_stat = "failed";
752 }
753 else if ($passed_all_mandatory && $cnt_passed >= $min_nr)
754 {
755//echo "A";
756 $overall_stat = "passed";
757 }
758 }
759
760 $ret = array(
761 "overall_status" => $overall_stat,
762 "failed_a_mandatory" => $failed_a_mandatory);
763//echo "<br>p:".$cnt_passed.":ng:".$cnt_notgraded;
764//var_dump($ret);
765 return $ret;
766 }
lookupStatusOfUser($a_ass_id, $a_user_id)
was: getStatusByMember
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
global $ilUser
Definition: imgupload.php:15

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

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

808 {
809 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
811
812 include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
813 $excelfile = ilUtil::ilTempnam();
814 $adapter = new ilExcelWriterAdapter($excelfile, FALSE);
815 $workbook = $adapter->getWorkbook();
816 $workbook->setVersion(8); // Use Excel97/2000 Format
817 include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
818
819 //
820 // status
821 //
822 $mainworksheet = $workbook->addWorksheet();
823
824 // header row
825 $mainworksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("name")));
826 $cnt = 1;
827 foreach ($ass_data as $ass)
828 {
829 $mainworksheet->writeString(0, $cnt, $cnt);
830 $cnt++;
831 }
832 $mainworksheet->writeString(0, $cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_total_exc")));
833
834 // data rows
835 $this->mem_obj = new ilExerciseMembers($this);
836 $getmems = $this->mem_obj->getMembers();
837 $mems = array();
838 foreach ($getmems as $user_id)
839 {
840 $mems[$user_id] = ilObjUser::_lookupName($user_id);
841 }
842 $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
843
844 $data = array();
845 $row_cnt = 1;
846 foreach ($mems as $user_id => $d)
847 {
848 $col_cnt = 1;
849
850 // name
851 $mainworksheet->writeString($row_cnt, 0,
852 ilExcelUtils::_convert_text($d["lastname"].", ".$d["firstname"]." [".$d["login"]."]"));
853
854 reset($ass_data);
855
856 foreach ($ass_data as $ass)
857 {
858 $status = ilExAssignment::lookupStatusOfUser($ass["id"], $user_id);
859 $mainworksheet->writeString($row_cnt, $col_cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_".$status)));
860 $col_cnt++;
861 }
862
863 // total status
864 $status = ilExerciseMembers::_lookupStatus($this->getId(), $user_id);
865 $mainworksheet->writeString($row_cnt, $col_cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_".$status)));
866
867 $row_cnt++;
868 }
869
870 //
871 // mark
872 //
873 $worksheet2 = $workbook->addWorksheet();
874
875 // header row
876 $worksheet2->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("name")));
877 $cnt = 1;
878 foreach ($ass_data as $ass)
879 {
880 $worksheet2->writeString(0, $cnt, $cnt);
881 $cnt++;
882 }
883 $worksheet2->writeString(0, $cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_total_exc")));
884
885 // data rows
886 $data = array();
887 $row_cnt = 1;
888 reset($mems);
889 foreach ($mems as $user_id => $d)
890 {
891 $col_cnt = 1;
892 $d = ilObjUser::_lookupName($user_id);
893
894 // name
895 $worksheet2->writeString($row_cnt, 0,
896 ilExcelUtils::_convert_text($d["lastname"].", ".$d["firstname"]." [".$d["login"]."]"));
897
898 reset($ass_data);
899
900 foreach ($ass_data as $ass)
901 {
902 $worksheet2->writeString($row_cnt, $col_cnt,
904 $col_cnt++;
905 }
906
907 // total mark
908 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
909 $worksheet2->writeString($row_cnt, $col_cnt,
911
912 $row_cnt++;
913 }
914
915
916 $workbook->close();
917 $exc_name = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->getTitle()));
918 ilUtil::deliverFile($excelfile, $exc_name.".xls", "application/vnd.ms-excel");
919 }
lookupMarkOfUser($a_ass_id, $a_user_id)
Lookup user mark.
_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
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static ilTempnam()
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.

References $d, $data, ilExcelUtils\_convert_text(), ilLPMarks\_lookupMark(), ilObjUser\_lookupName(), ilExerciseMembers\_lookupStatus(), ilUtil\deliverFile(), ilUtil\getASCIIFilename(), ilExAssignment\getAssignmentDataOfExercise(), ilObject\getId(), ilObject\getTitle(), ilUtil\ilTempnam(), ilExAssignment\lookupMarkOfUser(), ilExAssignment\lookupStatusOfUser(), and ilUtil\sortArray().

+ Here is the call graph for this function:

◆ findUserFiles()

static ilObjExercise::findUserFiles (   $a_user_id,
  $a_filetitle 
)
static

Check if given file was assigned.

Parameters
int$a_user_id
string$a_filetitle

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

1182 {
1183 global $ilDB;
1184
1185 $set = $ilDB->query("SELECT obj_id, ass_id".
1186 " FROM exc_returned".
1187 " WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
1188 " AND filetitle = ".$ilDB->quote($a_filetitle, "text"));
1189 $res = array();
1190 while($row = $ilDB->fetchAssoc($set))
1191 {
1192 $res[$row["ass_id"]] = $row;
1193 }
1194 return $res;
1195 }

References $ilDB, $res, and $row.

Referenced by ilObjBlogGUI\render(), and ilObjPortfolioBaseGUI\view().

+ Here is the caller 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 1203 of file class.ilObjExercise.php.

1204 {
1205 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
1206 }

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:

◆ handleSubmission()

ilObjExercise::handleSubmission (   $ass_id)

This method is called after an user submitted one or more files.

It should handle the setting "Completion by Submission" and, if enabled, set the status of the current user to either 'passed' or 'notgraded'.

Parameters
integer@access public

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

990 {
991 global $ilUser, $ilDB;
992
994 {
995 include_once 'Modules/Exercise/classes/class.ilExAssignment.php';
996
997 // #17673 - team upload?
998 $user_ids = ilExAssignment::getTeamMembersByAssignmentId($ass_id, $ilUser->getId());
999 if(!$user_ids)
1000 {
1001 $user_ids = array($ilUser->getId());
1002 }
1003
1004 $res = $ilDB->query(
1005 'SELECT returned_id'.
1006 ' FROM exc_returned'.
1007 ' WHERE obj_id = '.$ilDB->quote($this->getId(), 'integer').
1008 ' AND ass_id = '.$ilDB->quote($ass_id, 'integer').
1009 ' AND '.$ilDB->in('user_id', $user_ids, '', 'integer')
1010 );
1011
1012 if($ilDB->numRows($res))
1013 {
1014 $status = 'passed';
1015 }
1016 else
1017 {
1018 $status = 'notgraded';
1019 }
1020 foreach($user_ids as $user_id)
1021 {
1022 ilExAssignment::updateStatusOfUser($ass_id, $user_id, $status);
1023 }
1024 }
1025 }
updateStatusOfUser($a_ass_id, $a_user_id, $a_status)
was: setStatusForMember($a_member_id,$a_status)

References $ilDB, $ilUser, $res, ilExAssignment\getTeamMembersByAssignmentId(), isCompletionBySubmissionEnabled(), and ilExAssignment\updateStatusOfUser().

+ Here is the call graph for this function:

◆ hasAddToDesktop()

ilObjExercise::hasAddToDesktop ( )

Add to desktop after hand-in.

Returns
bool

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

1274 {
1275 $exc_set = new ilSetting("excs");
1276 return (bool)$exc_set->get("add_to_pd", true);
1277 }
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 1241 of file class.ilObjExercise.php.

1242 {
1243 // show certificate?
1244 include_once "Services/Certificate/classes/class.ilCertificate.php";
1246 {
1247 $certificate_visible = $this->getCertificateVisibility();
1248 // if not never
1249 if($certificate_visible != 2)
1250 {
1251 // if passed only
1252 include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php';
1253 $status = ilExerciseMembers::_lookupStatus($this->getId(), $a_user_id);
1254 if($certificate_visible == 1 && $status == "passed")
1255 {
1256 return true;
1257 }
1258 // always (excluding notgraded)
1259 else if($certificate_visible == 0 && $status != "notgraded")
1260 {
1261 return true;
1262 }
1263 }
1264 }
1265 return false;
1266 }
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 958 of file class.ilObjExercise.php.

959 {
961 }

References $completion_by_submission.

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

+ Here is the caller graph for this function:

◆ lookupExerciseIdForReturnedId()

static ilObjExercise::lookupExerciseIdForReturnedId (   $a_returned_id)
static

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

1154 {
1155 global $ilDB;
1156
1157 $set = $ilDB->query("SELECT obj_id".
1158 " FROM exc_returned".
1159 " WHERE returned_id = ".$ilDB->quote($a_returned_id, "integer"));
1160 $row = $ilDB->fetchAssoc($set);
1161 return (int)$row["obj_id"];
1162 }

References $ilDB, and $row.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

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

383 {
384 // object specific event handling
385
386 parent::notify($a_event,$a_ref_id,$a_node_id,$a_params);
387 }

◆ processUploadedFile()

ilObjExercise::processUploadedFile (   $fileTmp,
  $storageMethod,
  $persistentErrorMessage,
  $a_ass_id 
)

processes errorhandling etc for uploaded archive

Parameters
string$tmpFilepath and filename to uploaded file
string$storageMethoddeliverFile or storeUploadedFile
boolean$persistentErrorMessageDefines whether sendInfo will be persistent or not

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

595 {
596 global $lng, $ilUser;
597
598 // Create unzip-directory
599 $newDir = ilUtil::ilTempnam();
600 ilUtil::makeDir($newDir);
601
602 include_once ("Services/Utilities/classes/class.ilFileUtils.php");
603
604 try
605 {
606 $processDone = ilFileUtils::processZipFile($newDir,$fileTmp, false);
607 ilFileUtils::recursive_dirscan($newDir, $filearray);
608
609 foreach ($filearray["file"] as $key => $filename)
610 {
611 $a_http_post_files["name"] = ilFileUtils::utf8_encode($filename);
612 $a_http_post_files["type"] = "other";
613 $a_http_post_files["tmp_name"] = $filearray["path"][$key]."/".$filename;
614 $a_http_post_files["error"] = 0;
615 $a_http_post_files["size"] = filesize($filearray["path"][$key]."/".$filename);
616
617 if ($storageMethod == "deliverFile")
618 {
619 $this->$storageMethod($a_http_post_files, $a_ass_id, $ilUser->id, true);
620 }
621 else if ($storageMethod == "storeUploadedFile")
622 {
623 $this->file_obj->$storageMethod($a_http_post_files, true, true);
624 }
625 }
626 ilExerciseMembers::_writeReturned($this->getId(), $ilUser->id, 1);
627 ilUtil::sendSuccess($this->lng->txt("file_added"),$persistentErrorMessage);
628 }
629 catch (ilFileUtilsException $e)
630 {
631 ilUtil::sendFailure($e->getMessage(), $persistentErrorMessage);
632 }
633
634
635 ilUtil::delDir($newDir);
636 return $processDone;
637
638 }
$filename
Definition: buildRTE.php:89
Class to report exception.
utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
processZipFile($a_directory, $a_file, $structure, $ref_id=null, $containerType=null, $tree=null, $access_handler=null)
unzips in given directory and processes uploaded zip for use as single files
recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References $filename, $ilUser, ilObject\$lng, ilExerciseMembers\_writeReturned(), ilUtil\delDir(), ilObject\getId(), ilUtil\ilTempnam(), ilUtil\makeDir(), ilFileUtils\processZipFile(), ilFileUtils\recursive_dirscan(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and ilFileUtils\utf8_encode().

Referenced by addUploadedFile().

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

◆ read()

ilObjExercise::read ( )

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

390 {
391 global $ilDB;
392
393 parent::read();
394
395 $query = "SELECT * FROM exc_data ".
396 "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
397
398 $res = $ilDB->query($query);
399 while($row = $ilDB->fetchObject($res))
400 {
401 $this->setInstruction($row->instruction);
402 $this->setTimestamp($row->time_stamp);
403 $pm = ($row->pass_mode == "")
404 ? "all"
405 : $row->pass_mode;
406 $this->setPassMode($pm);
407 $this->setShowSubmissions($row->show_submissions);
408 if ($row->pass_mode == "nr")
409 {
410 $this->setPassNr($row->pass_nr);
411 }
412 $this->setCompletionBySubmission($row->compl_by_submission == 1 ? true : false);
413 $this->setCertificateVisibility($row->certificate_visibility);
414 }
415
416 $this->members_obj = new ilExerciseMembers($this);
417
418 return true;
419 }
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 1225 of file class.ilObjExercise.php.

1226 {
1227 global $ilDB;
1228
1229 $affectedRows = $ilDB->manipulateF("UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
1230 array('integer', 'integer'),
1231 array($a_value, $this->getId())
1232 );
1233 }

References $ilDB, and ilObject\getId().

+ Here is the call graph for this function:

◆ saveData()

ilObjExercise::saveData ( )

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

240 {
241 global $ilDB;
242
243 // SAVE ONLY EXERCISE SPECIFIC DATA
244 /*$query = "INSERT INTO exc_data SET ".
245 "obj_id = ".$ilDB->quote($this->getId()).", ".
246 "instruction = ".$ilDB->quote($this->getInstruction()).", ".
247 "time_stamp = ".$ilDB->quote($this->getTimestamp());
248 $this->ilias->db->query($query);*/
249
250 $ilDB->insert("exc_data", array(
251 "obj_id" => array("integer", $this->getId()),
252 "instruction" => array("clob", $this->getInstruction()),
253 "time_stamp" => array("integer", $this->getTimestamp()),
254 "pass_mode" => array("text", $this->getPassMode()),
255 "pass_nr" => array("text", $this->getPassNr()),
256 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
257 'compl_by_submission' => array('integer', (int)$this->isCompletionBySubmissionEnabled()),
258 "certificate_visibility" => array("integer", (int)$this->getCertificateVisibility())
259 ));
260 return true;
261 }

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

+ Here is the call graph for this function:

◆ sendAssignment()

ilObjExercise::sendAssignment (   $a_exc_id,
  $a_ass_id,
  $a_members 
)

send exercise per mail to members

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

465 {
466 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
467 $ass_title = ilExAssignment::lookupTitle($a_ass_id);
468
469 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
470 $storage = new ilFSStorageExercise($a_exc_id, $a_ass_id);
471 $files = $storage->getFiles();
472
473 if(count($files))
474 {
475 include_once "./Services/Mail/classes/class.ilFileDataMail.php";
476
477 $mfile_obj = new ilFileDataMail($_SESSION["AccountId"]);
478 foreach($files as $file)
479 {
480 $mfile_obj->copyAttachmentFile($file["fullpath"], $file["name"]);
481 $file_names[] = $file["name"];
482 }
483 }
484
485 include_once "Services/Mail/classes/class.ilMail.php";
486
487 $tmp_mail_obj = new ilMail($_SESSION["AccountId"]);
488 $message = $tmp_mail_obj->sendMail(
489 $this->__formatRecipients($a_members),"","",
490 $this->__formatSubject($ass_title), $this->__formatBody($a_ass_id),
491 count($file_names) ? $file_names : array(),array("normal"));
492
493 unset($tmp_mail_obj);
494
495 if(count($file_names))
496 {
497 $mfile_obj->unlinkFiles($file_names);
498 unset($mfile_obj);
499 }
500
501
502 // SET STATUS SENT FOR ALL RECIPIENTS
503 foreach($a_members as $member_id => $value)
504 {
505 ilExAssignment::updateStatusSentForUser($a_ass_id, $member_id, 1);
506 }
507
508 return true;
509 }
print $file
updateStatusSentForUser($a_ass_id, $a_user_id, $a_status)
was: setStatusSentForMember($a_member_id,$a_status)
static lookupTitle($a_id)
Lookup title.
This class handles all operations on files (attachments) in directory ilias_data/mail.
Class Mail this class handles base functions for mail handling.
__formatSubject($a_ass_title="")
__formatRecipients($a_members)
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

References $_SESSION, $file, $files, __formatBody(), __formatRecipients(), __formatSubject(), ilExAssignment\lookupTitle(), and ilExAssignment\updateStatusSentForUser().

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

925 {
926 $user_ids = $a_user_id;
927 if(!is_array($user_ids))
928 {
929 $user_ids = array($user_ids);
930 }
931
932 include_once("./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
933
934 $type = (bool)$a_is_text_feedback
937
938 $not = new ilExerciseMailNotification();
939 $not->setType($type);
940 $not->setAssignmentId($a_ass_id);
941 $not->setObjId($this->getId());
942 if ($this->getRefId() > 0)
943 {
944 $not->setRefId($this->getRefId());
945 }
946 $not->setRecipients($user_ids);
947 $not->send();
948 }
getRefId()
get reference id @access public

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

1215 {
1216 $this->certificate_visibility = $a_value;
1217 }

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

973 {
974 $this->completion_by_submission = (bool)$bool;
975
976 return $this;
977 }

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

422 {
423 global $ilDB;
424
425 parent::update();
426
427 /*$query = "UPDATE exc_data SET ".
428 "instruction = ".$ilDB->quote($this->getInstruction()).", ".
429 "time_stamp = ".$ilDB->quote($this->getTimestamp())." ".
430 "WHERE obj_id = ".$ilDB->quote($this->getId());
431 */
432
433 if ($this->getPassMode() == "all")
434 {
435 $pass_nr = null;
436 }
437 else
438 {
439 $pass_nr = $this->getPassNr();
440 }
441
442 $ilDB->update("exc_data", array(
443 "instruction" => array("clob", $this->getInstruction()),
444 "time_stamp" => array("integer", $this->getTimestamp()),
445 "pass_mode" => array("text", $this->getPassMode()),
446 "pass_nr" => array("integer", $this->getPassNr()),
447 "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
448 'compl_by_submission' => array('integer', (int)$this->isCompletionBySubmissionEnabled())
449 ), array(
450 "obj_id" => array("integer", $this->getId())
451 ));
452
453 $this->updateAllUsersStatus();
454
455 //$res = $this->ilias->db->query($query);
456
457 #$this->members_obj->update();
458 return true;
459 }
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 790 of file class.ilObjExercise.php.

791 {
792 if (!is_object($this->members_obj));
793 {
794 $this->members_obj = new ilExerciseMembers($this);
795 }
796
797 $mems = $this->members_obj->getMembers();
798 foreach ($mems as $mem)
799 {
800 $this->updateUserStatus($mem);
801 }
802 }
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:

◆ updateTextSubmission()

ilObjExercise::updateTextSubmission (   $a_exc_id,
  $a_ass_id,
  $a_user_id,
  $a_text 
)

Handle text assignment submissions.

Parameters
int$a_exc_id
int$a_ass_id
int$a_user_id
string$a_text
Returns
int

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

1114 {
1115 global $ilDB;
1116
1117 $files = ilExAssignment::getDeliveredFiles($a_exc_id, $a_ass_id, $a_user_id);
1118
1119 // no text = remove submission
1120 if(!trim($a_text))
1121 {
1122 if($files)
1123 {
1124 $files = array_shift($files);
1125 $id = $files["returned_id"];
1126 if($id)
1127 {
1128 $this->deleteDeliveredFiles($a_exc_id, $a_ass_id, array($id), $a_user_id);
1129 return;
1130 }
1131 }
1132 }
1133
1134 if(!$files)
1135 {
1136 return $this->addResourceObject("TEXT", $a_ass_id, $a_user_id, $a_text);
1137 }
1138 else
1139 {
1140 $files = array_shift($files);
1141 $id = $files["returned_id"];
1142 if($id)
1143 {
1144 $ilDB->manipulate("UPDATE exc_returned".
1145 " SET atext = ".$ilDB->quote($a_text, "text").
1146 ", ts = ".$ilDB->quote(ilUtil::now(), "timestamp").
1147 " WHERE returned_id = ".$ilDB->quote($id, "integer"));
1148 return $id;
1149 }
1150 }
1151 }
deleteDeliveredFiles($a_exc_id, $a_ass_id, $file_id_array, $user_id)
Deletes already delivered files.
addResourceObject($a_wsp_id, $a_ass_id, $user_id, $a_text=null)
Add personal resource to assigment.

References $files, ilObject\$id, $ilDB, addResourceObject(), deleteDeliveredFiles(), ilExAssignment\getDeliveredFiles(), and ilUtil\now().

+ Here is the call graph for this function:

◆ updateUserStatus()

ilObjExercise::updateUserStatus (   $a_user_id = 0)

Update exercise status of user.

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

772 {
773 global $ilUser;
774
775 if ($a_user_id == 0)
776 {
777 $a_user_id = $ilUser->getId();
778 }
779
780 $st = $this->determinStatusOfUser($a_user_id);
781
782 include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
783 ilExerciseMembers::_writeStatus($this->getId(), $a_user_id,
784 $st["overall_status"]);
785 }
_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(), and updateTextSubmission().

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