ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 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 ()
 
 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)
 
 _checkCondition ($a_exc_id, $a_operator, $a_value, $a_usr_id=0)
 
 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)
 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...
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor 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 public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title 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 public More...
 
 getLastUpdateDate ()
 get last update date public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 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...
 
 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) public More...
 
 createRoleFolder ()
 creates a local role folder 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 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 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 20 of file class.ilObjExercise.php.

Member Function Documentation

◆ __formatBody()

ilObjExercise::__formatBody (   $a_ass_id)

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

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

Referenced by sendAssignment().

537  {
538  global $lng;
539 
540  $lng->loadLanguageModule("exc");
541 
542  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
543  $ass = new ilExAssignment($a_ass_id);
544 
545  $body = $ass->getInstruction();
546  $body .= "\n\n";
547  if ($ass->getDeadline() == 0)
548  {
549  $body .= $lng->txt("exc_edit_until") . ": ".
550  $lng->txt("exc_no_deadline_specified");
551  }
552  else
553  {
554  $body .= $lng->txt("exc_edit_until") . ": ".
555  ilFormat::formatDate(date("Y-m-d H:i:s",$ass->getDeadline()), "datetime", true);
556  }
557  $body .= "\n\n";
558  $body .= ILIAS_HTTP_PATH.
559  "/goto.php?target=".
560  $this->getType().
561  "_".$this->getRefId()."&client_id=".CLIENT_ID;
562 
563  return $body;
564  }
Exercise assignment.
getType()
get object type public
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 public ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __formatRecipients()

ilObjExercise::__formatRecipients (   $a_members)

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

References ilObjectFactory\getInstanceByObjId().

Referenced by sendAssignment().

579  {
580  foreach($a_members as $member_id => $value)
581  {
582  $tmp_obj = ilObjectFactory::getInstanceByObjId($member_id);
583  $tmp_members[] = $tmp_obj->getLogin();
584 
585  unset($tmp_obj);
586  }
587 
588  return implode(',',$tmp_members ? $tmp_members : array());
589  }
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ 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 566 of file class.ilObjExercise.php.

References ilObject\getTitle().

Referenced by sendAssignment().

567  {
568  $subject = $this->getTitle();
569 
570  if ($a_ass_title != "")
571  {
572  $subject.= ": ".$a_ass_title;
573  }
574 
575  return $subject;
576  }
getTitle()
get object title public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _checkCondition()

ilObjExercise::_checkCondition (   $a_exc_id,
  $a_operator,
  $a_value,
  $a_usr_id = 0 
)

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

References $ilUser, and ilExerciseMembers\_lookupStatus().

Referenced by ilConditionHandler\_checkCondition().

592  {
593  global $ilUser;
594 
595  $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
596 
597  switch($a_operator)
598  {
599  case 'passed':
600  if (ilExerciseMembers::_lookupStatus($a_exc_id, $a_usr_id) == "passed")
601  {
602  return true;
603  }
604  else
605  {
606  return false;
607  }
608  break;
609 
610  default:
611  return true;
612  }
613  return true;
614  }
global $ilUser
Definition: imgupload.php:15
_lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
+ 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 679 of file class.ilObjExercise.php.

Referenced by _fixFilenameArray().

680  {
681  $ex_pos = strrpos($a_filename, "/exercise/");
682  if ($ex_pos > 0)
683  {
684  $a_filename = CLIENT_DATA_DIR.substr($a_filename, $ex_pos);
685  }
686  return $a_filename;
687  }
+ 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 693 of file class.ilObjExercise.php.

References _fixFilename().

694  {
695  if (is_array($a_array))
696  {
697  foreach ($a_array as $k => $v)
698  {
699  if ($v["filename"] != "")
700  {
701  $a_array[$k]["filename"] = ilObjExercise::_fixFilename($a_array[$k]["filename"]);
702  }
703  }
704  }
705 
706  return $a_array;
707  }
static _fixFilename($a_filename)
This function fixes filenames.
+ 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 1057 of file class.ilObjExercise.php.

References $row.

Referenced by ilExerciseVerificationTableGUI\getItems().

1058  {
1059  global $ilDB;
1060 
1061  $set = $ilDB->query("SELECT obj_id, status FROM exc_members".
1062  " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
1063  " AND (status = ".$ilDB->quote("passed", "text").
1064  " OR status = ".$ilDB->quote("failed", "text").")");
1065 
1066  $all = array();
1067  while($row = $ilDB->fetchAssoc($set))
1068  {
1069  $all[$row["obj_id"]] = ($row["status"] == "passed");
1070  }
1071  return $all;
1072  }
+ 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 518 of file class.ilObjExercise.php.

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

519  {
520 
521  global $ilDB, $lng;
522 
523  $q = "SELECT * ".
524  "FROM exc_members ".
525  "WHERE obj_id= ".$ilDB->quote($exc_id, "integer").
526  " AND usr_id= ".$ilDB->quote($member_id, "integer");
527 
528  $set = $ilDB->query($q);
529  if ($rec = $ilDB->fetchAssoc($set))
530  {
531  return ilUtil::getMySQLTimestamp($rec["status_time"]);
532  }
533  }
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...
+ 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 1082 of file class.ilObjExercise.php.

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

Referenced by updateTextSubmission().

1083  {
1084  global $ilDB;
1085 
1086  $next_id = $ilDB->nextId("exc_returned");
1087  $query = sprintf("INSERT INTO exc_returned ".
1088  "(returned_id, obj_id, user_id, filetitle, ass_id, ts, atext) ".
1089  "VALUES (%s, %s, %s, %s, %s, %s, %s)",
1090  $ilDB->quote($next_id, "integer"),
1091  $ilDB->quote($this->getId(), "integer"),
1092  $ilDB->quote($user_id, "integer"),
1093  $ilDB->quote($a_wsp_id, "text"),
1094  $ilDB->quote($a_ass_id, "integer"),
1095  $ilDB->quote(ilUtil::now(), "timestamp"),
1096  $ilDB->quote($a_text, "text")
1097  );
1098  $ilDB->manipulate($query);
1099  if (!$this->members_obj->isAssigned($user_id))
1100  {
1101  $this->members_obj->assignMember($user_id);
1102  }
1103  // no submission (of blog/portfolio) yet (unless text assignment)
1104  ilExAssignment::updateStatusReturnedForUser($a_ass_id, $user_id, (bool)$a_text);
1105  ilExerciseMembers::_writeReturned($this->getId(), $user_id, (bool)$a_text);
1106 
1107  return $next_id;
1108  }
static now()
Return current timestamp in Y-m-d H:i:s format.
getId()
get object id public
_writeReturned($a_obj_id, $a_user_id, $a_status)
Write returned status.
updateStatusReturnedForUser($a_ass_id, $a_user_id, $a_status)
was: setStatusReturnedForMember($a_member_id,$a_status)
+ 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 218 of file class.ilObjExercise.php.

References ilObject\$lng, and processUploadedFile().

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

◆ checkDate()

ilObjExercise::checkDate ( )

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

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

◆ cloneObject()

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

Clone exercise (no member data)

public

Parameters
inttarget ref_id
intcopy id

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

References ilExAssignment\cloneAssignmentsOfExercise(), ilObject\getId(), getInstruction(), getPassMode(), getPassNr(), getShowSubmissions(), getTimestamp(), and isCompletionBySubmissionEnabled().

272  {
273  global $ilDB;
274 
275  // Copy settings
276  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
277  $new_obj->setInstruction($this->getInstruction());
278  $new_obj->setTimestamp($this->getTimestamp());
279  $new_obj->setPassMode($this->getPassMode());
280  $new_obj->saveData();
281  $new_obj->setPassNr($this->getPassNr());
282  $new_obj->setShowSubmissions($this->getShowSubmissions());
283  $new_obj->setCompletionBySubmission($this->isCompletionBySubmissionEnabled());
284 
285 
286  $new_obj->update();
287 
288  // Copy assignments
289  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
290  ilExAssignment::cloneAssignmentsOfExercise($this->getId(), $new_obj->getId());
291  //$tmp_file_obj =& new ilFileDataExercise($this->getId());
292  //$tmp_file_obj->ilClone($new_obj->getId());
293  //unset($tmp_file_obj);
294 
295  // Copy learning progress settings
296  include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
297  $obj_settings = new ilLPObjSettings($this->getId());
298  $obj_settings->cloneSettings($new_obj->getId());
299  unset($obj_settings);
300 
301  return $new_obj;
302  }
getPassMode()
Get pass mode (all | nr)
getShowSubmissions()
Get whether submissions of learners should be shown to other learners after deadline.
cloneAssignmentsOfExercise($a_old_exc_id, $a_new_exc_id)
Clone assignments of exercise.
getId()
get object id public
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
getPassNr()
Get number of assignments that must be passed to pass the exercise.
+ Here is the call graph for this function:

◆ delete()

ilObjExercise::delete ( )

delete course and all related data

public

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

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

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

348  {
349  global $ilDB;
350 
351  // always call parent delete function first!!
352  if (!parent::delete())
353  {
354  return false;
355  }
356  // put here course specific stuff
357  $ilDB->manipulate("DELETE FROM exc_data ".
358  "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer"));
359 
360  //$this->ilias->db->query($query);
361 
362  //$this->file_obj->delete();
363  //$this->members_obj->delete();
364 
365  // remove all notifications
366  include_once "./Services/Notification/classes/class.ilNotification.php";
368 
369  return true;
370  }
static removeForObject($type, $id)
Remove all notifications for given object.
getId()
get object id public
+ 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 1193 of file class.ilObjExercise.php.

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

1194  {
1195  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1197  }
static deleteAllDeliveredFilesOfUser($a_exc_id, $a_user_id)
Delete all delivered files of user.
getId()
get object id public
+ 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 public

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

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

Referenced by updateTextSubmission().

311  {
312  ilExAssignment::deleteDeliveredFiles($a_exc_id, $a_ass_id, $file_id_array, $user_id);
313 
314  // Finally update status 'returned' of member if no file exists
315  if(!count(ilExAssignment::getDeliveredFiles($a_exc_id, $a_ass_id, $user_id)))
316  {
317  // team upload?
318  $user_ids = ilExAssignment::getTeamMembersByAssignmentId($a_ass_id, $user_id);
319  if(!$user_ids)
320  {
321  $user_ids = array($user_id);
322  }
323 
324  foreach($user_ids as $user_id)
325  {
326  ilExAssignment::updateStatusReturnedForUser($a_ass_id, $user_id, 0);
327  }
328  }
329  }
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)
updateStatusReturnedForUser($a_ass_id, $a_user_id, $a_status)
was: setStatusReturnedForMember($a_member_id,$a_status)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteFiles()

ilObjExercise::deleteFiles (   $a_files)

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

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

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

1118  {
1119  global $ilDB;
1120 
1121  $ilDB->manipulate("DELETE FROM exc_returned".
1122  " WHERE obj_id = ".$ilDB->quote($this->getId(), "integer").
1123  " AND user_id = ".$ilDB->quote($user_id, "integer").
1124  " AND ass_id = ".$ilDB->quote($a_ass_id, "integer").
1125  " AND returned_id = ".$ilDB->quote($a_returned_id, "integer"));
1126  }

◆ deliverFile()

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

Save submitted file of user.

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

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

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

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

337  {
338  require_once "./Services/Utilities/classes/class.ilUtil.php";
339  }

◆ determinStatusOfUser()

ilObjExercise::determinStatusOfUser (   $a_user_id = 0)

Determine status of user.

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

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

Referenced by updateUserStatus().

713  {
714  global $ilUser;
715 
716  if ($a_user_id == 0)
717  {
718  $a_user_id = $ilUser->getId();
719  }
720 
721  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
723 
724  $passed_all_mandatory = true;
725  $failed_a_mandatory = false;
726  $cnt_passed = 0;
727  $cnt_notgraded = 0;
728  $passed_at_least_one = false;
729 
730  foreach ($ass as $a)
731  {
732  $stat = ilExAssignment::lookupStatusOfUser($a["id"], $a_user_id);
733  if ($a["mandatory"] && ($stat == "failed" || $stat == "notgraded"))
734  {
735  $passed_all_mandatory = false;
736  }
737  if ($a["mandatory"] && ($stat == "failed"))
738  {
739  $failed_a_mandatory = true;
740  }
741  if ($stat == "passed")
742  {
743  $cnt_passed++;
744  }
745  if ($stat == "notgraded")
746  {
747  $cnt_notgraded++;
748  }
749  }
750 
751  if (count($ass) == 0)
752  {
753  $passed_all_mandatory = false;
754  }
755 
756  if ($this->getPassMode() != "nr")
757  {
758 //echo "5";
759  $overall_stat = "notgraded";
760  if ($failed_a_mandatory)
761  {
762 //echo "6";
763  $overall_stat = "failed";
764  }
765  else if ($passed_all_mandatory && $cnt_passed > 0)
766  {
767 //echo "7";
768  $overall_stat = "passed";
769  }
770  }
771  else
772  {
773 //echo "8";
774  $min_nr = $this->getPassNr();
775  $overall_stat = "notgraded";
776 //echo "*".$cnt_passed."*".$cnt_notgraded."*".$min_nr."*";
777  if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr))
778  {
779 //echo "9";
780  $overall_stat = "failed";
781  }
782  else if ($passed_all_mandatory && $cnt_passed >= $min_nr)
783  {
784 //echo "A";
785  $overall_stat = "passed";
786  }
787  }
788 
789  $ret = array(
790  "overall_status" => $overall_stat,
791  "failed_a_mandatory" => $failed_a_mandatory);
792 //echo "<br>p:".$cnt_passed.":ng:".$cnt_notgraded;
793 //var_dump($ret);
794  return $ret;
795  }
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
getPassMode()
Get pass mode (all | nr)
lookupStatusOfUser($a_ass_id, $a_user_id)
was: getStatusByMember
getId()
get object id public
global $ilUser
Definition: imgupload.php:15
getPassNr()
Get number of assignments that must be passed to pass the exercise.
+ 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 836 of file class.ilObjExercise.php.

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().

837  {
838  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
840 
841  include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
842  $excelfile = ilUtil::ilTempnam();
843  $adapter = new ilExcelWriterAdapter($excelfile, FALSE);
844  $workbook = $adapter->getWorkbook();
845  $workbook->setVersion(8); // Use Excel97/2000 Format
846  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
847 
848  //
849  // status
850  //
851  $mainworksheet = $workbook->addWorksheet();
852 
853  // header row
854  $mainworksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("name")));
855  $cnt = 1;
856  foreach ($ass_data as $ass)
857  {
858  $mainworksheet->writeString(0, $cnt, $cnt);
859  $cnt++;
860  }
861  $mainworksheet->writeString(0, $cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_total_exc")));
862 
863  // data rows
864  $this->mem_obj = new ilExerciseMembers($this);
865  $getmems = $this->mem_obj->getMembers();
866  $mems = array();
867  foreach ($getmems as $user_id)
868  {
869  $mems[$user_id] = ilObjUser::_lookupName($user_id);
870  }
871  $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
872 
873  $data = array();
874  $row_cnt = 1;
875  foreach ($mems as $user_id => $d)
876  {
877  $col_cnt = 1;
878 
879  // name
880  $mainworksheet->writeString($row_cnt, 0,
881  ilExcelUtils::_convert_text($d["lastname"].", ".$d["firstname"]." [".$d["login"]."]"));
882 
883  reset($ass_data);
884 
885  foreach ($ass_data as $ass)
886  {
887  $status = ilExAssignment::lookupStatusOfUser($ass["id"], $user_id);
888  $mainworksheet->writeString($row_cnt, $col_cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_".$status)));
889  $col_cnt++;
890  }
891 
892  // total status
893  $status = ilExerciseMembers::_lookupStatus($this->getId(), $user_id);
894  $mainworksheet->writeString($row_cnt, $col_cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_".$status)));
895 
896  $row_cnt++;
897  }
898 
899  //
900  // mark
901  //
902  $worksheet2 = $workbook->addWorksheet();
903 
904  // header row
905  $worksheet2->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("name")));
906  $cnt = 1;
907  foreach ($ass_data as $ass)
908  {
909  $worksheet2->writeString(0, $cnt, $cnt);
910  $cnt++;
911  }
912  $worksheet2->writeString(0, $cnt, ilExcelUtils::_convert_text($this->lng->txt("exc_total_exc")));
913 
914  // data rows
915  $data = array();
916  $row_cnt = 1;
917  reset($mems);
918  foreach ($mems as $user_id => $d)
919  {
920  $col_cnt = 1;
921  $d = ilObjUser::_lookupName($user_id);
922 
923  // name
924  $worksheet2->writeString($row_cnt, 0,
925  ilExcelUtils::_convert_text($d["lastname"].", ".$d["firstname"]." [".$d["login"]."]"));
926 
927  reset($ass_data);
928 
929  foreach ($ass_data as $ass)
930  {
931  $worksheet2->writeString($row_cnt, $col_cnt,
933  $col_cnt++;
934  }
935 
936  // total mark
937  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
938  $worksheet2->writeString($row_cnt, $col_cnt,
940 
941  $row_cnt++;
942  }
943 
944 
945  $workbook->close();
946  $exc_name = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->getTitle()));
947  ilUtil::deliverFile($excelfile, $exc_name.".xls", "application/vnd.ms-excel");
948  }
static _lookupName($a_user_id)
lookup user name
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
Class ilExerciseMembers.
lookupStatusOfUser($a_ass_id, $a_user_id)
was: getStatusByMember
_lookupMark($a_usr_id, $a_obj_id)
_convert_text($a_text, $a_target="has been removed")
lookupMarkOfUser($a_ass_id, $a_user_id)
Lookup user mark.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
Class ilExcelWriterAdapter.
getId()
get object id public
getTitle()
get object title public
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
static ilTempnam()
Create a temporary file in an ILIAS writable directory.
_lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
+ 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 1205 of file class.ilObjExercise.php.

References $res, and $row.

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

1206  {
1207  global $ilDB;
1208 
1209  $set = $ilDB->query("SELECT obj_id, ass_id".
1210  " FROM exc_returned".
1211  " WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
1212  " AND filetitle = ".$ilDB->quote($a_filetitle, "text"));
1213  $res = array();
1214  while($row = $ilDB->fetchAssoc($set))
1215  {
1216  $res[$row["ass_id"]] = $row;
1217  }
1218  return $res;
1219  }
+ 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) public

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

Referenced by hasUserCertificate(), and saveData().

1228  {
1229  return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
1230  }
+ Here is the caller graph for this function:

◆ getInstruction()

ilObjExercise::getInstruction ( )

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

References $instruction.

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

82  {
83  return $this->instruction;
84  }
+ Here is the caller graph for this function:

◆ getPassMode()

ilObjExercise::getPassMode ( )

Get pass mode (all | nr)

Returns
string pass mode

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

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

102  {
103  return $this->pass_mode;
104  }
+ 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 121 of file class.ilObjExercise.php.

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

122  {
123  return $this->pass_nr;
124  }
+ 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 141 of file class.ilObjExercise.php.

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

142  {
143  return $this->show_submissions;
144  }
+ Here is the caller graph for this function:

◆ getTimestamp()

ilObjExercise::getTimestamp ( )

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

References $timestamp.

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

70  {
71  return $this->timestamp;
72  }
+ 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
integerpublic

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

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

1014  {
1015  global $ilUser, $ilDB;
1016 
1017  if($this->isCompletionBySubmissionEnabled())
1018  {
1019  include_once 'Modules/Exercise/classes/class.ilExAssignment.php';
1020 
1021  // #17673 - team upload?
1022  $user_ids = ilExAssignment::getTeamMembersByAssignmentId($ass_id, $ilUser->getId());
1023  if(!$user_ids)
1024  {
1025  $user_ids = array($ilUser->getId());
1026  }
1027 
1028  $res = $ilDB->query(
1029  'SELECT returned_id'.
1030  ' FROM exc_returned'.
1031  ' WHERE obj_id = '.$ilDB->quote($this->getId(), 'integer').
1032  ' AND ass_id = '.$ilDB->quote($ass_id, 'integer').
1033  ' AND '.$ilDB->in('user_id', $user_ids, '', 'integer')
1034  );
1035 
1036  if($ilDB->numRows($res))
1037  {
1038  $status = 'passed';
1039  }
1040  else
1041  {
1042  $status = 'notgraded';
1043  }
1044  foreach($user_ids as $user_id)
1045  {
1046  ilExAssignment::updateStatusOfUser($ass_id, $user_id, $status);
1047  }
1048  }
1049  }
static getTeamMembersByAssignmentId($a_ass_id, $a_user_id)
Find team members by assignment and team member.
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
global $ilUser
Definition: imgupload.php:15
updateStatusOfUser($a_ass_id, $a_user_id, $a_status)
was: setStatusForMember($a_member_id,$a_status)
+ Here is the call graph for this function:

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

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

1266  {
1267  // show certificate?
1268  include_once "Services/Certificate/classes/class.ilCertificate.php";
1270  {
1271  $certificate_visible = $this->getCertificateVisibility();
1272  // if not never
1273  if($certificate_visible != 2)
1274  {
1275  // if passed only
1276  include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php';
1277  $status = ilExerciseMembers::_lookupStatus($this->getId(), $a_user_id);
1278  if($certificate_visible == 1 && $status == "passed")
1279  {
1280  return true;
1281  }
1282  // always (excluding notgraded)
1283  else if($certificate_visible == 0 && $status != "notgraded")
1284  {
1285  return true;
1286  }
1287  }
1288  }
1289  return false;
1290  }
getCertificateVisibility()
Returns the visibility settings of the certificate.
getId()
get object id public
static isObjectActive($a_obj_id)
_lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
+ Here is the call graph for this function:

◆ ilObjExercise()

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

Constructor public.

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

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

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

52  {
53  $this->setPassMode("all");
54  $this->type = "exc";
55  $this->ilObject($a_id,$a_call_by_reference);
56  }
ilObject($a_id=0, $a_reference=true)
Constructor public.
setPassMode($a_val)
Set pass mode (all | nr)
+ Here is the call graph for this function:

◆ isCompletionBySubmissionEnabled()

ilObjExercise::isCompletionBySubmissionEnabled ( )

Checks whether completion by submission is enabled or not.

Returns
boolean public

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

References $completion_by_submission.

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

983  {
985  }
+ Here is the caller graph for this function:

◆ lookupExerciseIdForReturnedId()

static ilObjExercise::lookupExerciseIdForReturnedId (   $a_returned_id)
static

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

References $row.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

1178  {
1179  global $ilDB;
1180 
1181  $set = $ilDB->query("SELECT obj_id".
1182  " FROM exc_returned".
1183  " WHERE returned_id = ".$ilDB->quote($a_returned_id, "integer"));
1184  $row = $ilDB->fetchAssoc($set);
1185  return (int)$row["obj_id"];
1186  }
+ 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.

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

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().

624  {
625  global $lng, $ilUser;
626 
627  // Create unzip-directory
628  $newDir = ilUtil::ilTempnam();
629  ilUtil::makeDir($newDir);
630 
631  include_once ("Services/Utilities/classes/class.ilFileUtils.php");
632 
633  try
634  {
635  $processDone = ilFileUtils::processZipFile($newDir,$fileTmp, false);
636  ilFileUtils::recursive_dirscan($newDir, $filearray);
637 
638  foreach ($filearray["file"] as $key => $filename)
639  {
640  $a_http_post_files["name"] = ilFileUtils::utf8_encode($filename);
641  $a_http_post_files["type"] = "other";
642  $a_http_post_files["tmp_name"] = $filearray["path"][$key]."/".$filename;
643  $a_http_post_files["error"] = 0;
644  $a_http_post_files["size"] = filesize($filearray["path"][$key]."/".$filename);
645 
646  if ($storageMethod == "deliverFile")
647  {
648  $this->$storageMethod($a_http_post_files, $a_ass_id, $ilUser->id, true);
649  }
650  else if ($storageMethod == "storeUploadedFile")
651  {
652  $this->file_obj->$storageMethod($a_http_post_files, true, true);
653  }
654  }
655  ilExerciseMembers::_writeReturned($this->getId(), $ilUser->id, 1);
656  ilUtil::sendSuccess($this->lng->txt("file_added"),$persistentErrorMessage);
657  }
658  catch (ilFileUtilsException $e)
659  {
660  ilUtil::sendFailure($e->getMessage(), $persistentErrorMessage);
661  }
662 
663 
664  ilUtil::delDir($newDir);
665  return $processDone;
666 
667  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getId()
get object id public
utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
_writeReturned($a_obj_id, $a_user_id, $a_status)
Write returned status.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$filename
Definition: buildRTE.php:89
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
global $ilUser
Definition: imgupload.php:15
static ilTempnam()
Create a temporary file in an ILIAS writable directory.
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
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
Class to report exception.
+ 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.

References $query, $res, $row, ilObject\getId(), setCertificateVisibility(), setCompletionBySubmission(), setInstruction(), setPassNr(), setShowSubmissions(), and setTimestamp().

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  // GET FILE ASSIGNED TO EXERCISE
419 // $this->file_obj = new ilFileDataExercise($this->getId());
420 // $this->files = $this->file_obj->getFiles();
421 
422  return true;
423  }
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
Class ilExerciseMembers.
setInstruction($a_instruction)
setCertificateVisibility($a_value)
Sets the visibility settings of the certificate.
getId()
get object id public
setTimestamp($a_timestamp)
setShowSubmissions($a_val)
Set whether submissions of learners should be shown to other learners after deadline.
setPassNr($a_val)
Set number of assignments that must be passed to pass the exercise.
+ 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) private

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

References ilObject\getId().

1250  {
1251  global $ilDB;
1252 
1253  $affectedRows = $ilDB->manipulateF("UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
1254  array('integer', 'integer'),
1255  array($a_value, $this->getId())
1256  );
1257  }
getId()
get object id public
+ Here is the call graph for this function:

◆ saveData()

ilObjExercise::saveData ( )

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

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

241  {
242  global $ilDB;
243 
244  // SAVE ONLY EXERCISE SPECIFIC DATA
245  /*$query = "INSERT INTO exc_data SET ".
246  "obj_id = ".$ilDB->quote($this->getId()).", ".
247  "instruction = ".$ilDB->quote($this->getInstruction()).", ".
248  "time_stamp = ".$ilDB->quote($this->getTimestamp());
249  $this->ilias->db->query($query);*/
250 
251  $ilDB->insert("exc_data", array(
252  "obj_id" => array("integer", $this->getId()),
253  "instruction" => array("clob", $this->getInstruction()),
254  "time_stamp" => array("integer", $this->getTimestamp()),
255  "pass_mode" => array("text", $this->getPassMode()),
256  "pass_nr" => array("text", $this->getPassNr()),
257  "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
258  'compl_by_submission' => array('integer', (int)$this->isCompletionBySubmissionEnabled()),
259  "certificate_visibility" => array("integer", (int)$this->getCertificateVisibility())
260  ));
261  return true;
262  }
getPassMode()
Get pass mode (all | nr)
getCertificateVisibility()
Returns the visibility settings of the certificate.
getShowSubmissions()
Get whether submissions of learners should be shown to other learners after deadline.
getId()
get object id public
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
getPassNr()
Get number of assignments that must be passed to pass the exercise.
+ 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 468 of file class.ilObjExercise.php.

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

469  {
470  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
471  $ass_title = ilExAssignment::lookupTitle($a_ass_id);
472 
473  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
474  $storage = new ilFSStorageExercise($a_exc_id, $a_ass_id);
475  $files = $storage->getFiles();
476 
477  if(count($files))
478  {
479  include_once "./Services/Mail/classes/class.ilFileDataMail.php";
480 
481  $mfile_obj = new ilFileDataMail($_SESSION["AccountId"]);
482  foreach($files as $file)
483  {
484  $mfile_obj->copyAttachmentFile($file["fullpath"], $file["name"]);
485  $file_names[] = $file["name"];
486  }
487  }
488 
489  include_once "Services/Mail/classes/class.ilMail.php";
490 
491  $tmp_mail_obj = new ilMail($_SESSION["AccountId"]);
492  $message = $tmp_mail_obj->sendMail(
493  $this->__formatRecipients($a_members),"","",
494  $this->__formatSubject($ass_title), $this->__formatBody($a_ass_id),
495  count($file_names) ? $file_names : array(),array("normal"));
496 
497  unset($tmp_mail_obj);
498 
499  if(count($file_names))
500  {
501  $mfile_obj->unlinkFiles($file_names);
502  unset($mfile_obj);
503  }
504 
505 
506  // SET STATUS SENT FOR ALL RECIPIENTS
507  foreach($a_members as $member_id => $value)
508  {
509  ilExAssignment::updateStatusSentForUser($a_ass_id, $member_id, 1);
510  }
511 
512  return true;
513  }
< 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']
print $file
This class handles all operations on files (attachments) in directory ilias_data/mail.
Class Mail this class handles base functions for mail handling.
__formatRecipients($a_members)
updateStatusSentForUser($a_ass_id, $a_user_id, $a_status)
was: setStatusSentForMember($a_member_id,$a_status)
__formatSubject($a_ass_title="")
static lookupTitle($a_id)
Lookup title.
+ Here is the call graph for this function:

◆ sendFeedbackFileNotification()

ilObjExercise::sendFeedbackFileNotification (   $a_feedback_file,
  $a_user_id,
  $a_ass_id 
)

Send feedback file notification to user.

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

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

954  {
955  $user_ids = $a_user_id;
956  if(!is_array($user_ids))
957  {
958  $user_ids = array($user_ids);
959  }
960 
961  include_once("./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
962  $not = new ilExerciseMailNotification();
964  $not->setAssignmentId($a_ass_id);
965  $not->setObjId($this->getId());
966  if ($this->getRefId() > 0)
967  {
968  $not->setRefId($this->getRefId());
969  }
970  $not->setRecipients($user_ids);
971  $not->send();
972  }
getId()
get object id public
getRefId()
get reference id public
+ Here is the call 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) public

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

Referenced by read().

1239  {
1240  $this->certificate_visibility = $a_value;
1241  }
+ Here is the caller graph for this function:

◆ setCompletionBySubmission()

ilObjExercise::setCompletionBySubmission (   $bool)

Enabled/Disable completion by submission.

Parameters
boolean
Returns
ilObjExercise public

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

Referenced by read().

997  {
998  $this->completion_by_submission = (bool)$bool;
999 
1000  return $this;
1001  }
+ Here is the caller graph for this function:

◆ setDate()

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

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

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

◆ setInstruction()

ilObjExercise::setInstruction (   $a_instruction)

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

Referenced by read().

78  {
79  $this->instruction = $a_instruction;
80  }
+ Here is the caller graph for this function:

◆ setPassMode()

ilObjExercise::setPassMode (   $a_val)

Set pass mode (all | nr)

Parameters
stringpass mode

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

Referenced by ilObjExercise().

92  {
93  $this->pass_mode = $a_val;
94  }
+ 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 111 of file class.ilObjExercise.php.

Referenced by read().

112  {
113  $this->pass_nr = $a_val;
114  }
+ 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 131 of file class.ilObjExercise.php.

Referenced by read().

132  {
133  $this->show_submissions = $a_val;
134  }
+ Here is the caller graph for this function:

◆ setTimestamp()

ilObjExercise::setTimestamp (   $a_timestamp)

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

Referenced by read().

74  {
75  $this->timestamp = $a_timestamp;
76  }
+ Here is the caller graph for this function:

◆ update()

ilObjExercise::update ( )

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

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

426  {
427  global $ilDB;
428 
429  parent::update();
430 
431  /*$query = "UPDATE exc_data SET ".
432  "instruction = ".$ilDB->quote($this->getInstruction()).", ".
433  "time_stamp = ".$ilDB->quote($this->getTimestamp())." ".
434  "WHERE obj_id = ".$ilDB->quote($this->getId());
435  */
436 
437  if ($this->getPassMode() == "all")
438  {
439  $pass_nr = null;
440  }
441  else
442  {
443  $pass_nr = $this->getPassNr();
444  }
445 
446  $ilDB->update("exc_data", array(
447  "instruction" => array("clob", $this->getInstruction()),
448  "time_stamp" => array("integer", $this->getTimestamp()),
449  "pass_mode" => array("text", $this->getPassMode()),
450  "pass_nr" => array("integer", $this->getPassNr()),
451  "show_submissions" => array("integer", (int) $this->getShowSubmissions()),
452  'compl_by_submission' => array('integer', (int)$this->isCompletionBySubmissionEnabled())
453  ), array(
454  "obj_id" => array("integer", $this->getId())
455  ));
456 
457  $this->updateAllUsersStatus();
458 
459  //$res = $this->ilias->db->query($query);
460 
461  #$this->members_obj->update();
462  return true;
463  }
getPassMode()
Get pass mode (all | nr)
getShowSubmissions()
Get whether submissions of learners should be shown to other learners after deadline.
updateAllUsersStatus()
Update status of all users.
getId()
get object id public
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
getPassNr()
Get number of assignments that must be passed to pass the exercise.
+ Here is the call graph for this function:

◆ updateAllUsersStatus()

ilObjExercise::updateAllUsersStatus ( )

Update status of all users.

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

References updateUserStatus().

Referenced by update().

820  {
821  if (!is_object($this->members_obj));
822  {
823  $this->members_obj = new ilExerciseMembers($this);
824  }
825 
826  $mems = $this->members_obj->getMembers();
827  foreach ($mems as $mem)
828  {
829  $this->updateUserStatus($mem);
830  }
831  }
Class ilExerciseMembers.
updateUserStatus($a_user_id=0)
Update exercise status of user.
+ 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 1137 of file class.ilObjExercise.php.

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

1138  {
1139  global $ilDB;
1140 
1141  $files = ilExAssignment::getDeliveredFiles($a_exc_id, $a_ass_id, $a_user_id);
1142 
1143  // no text = remove submission
1144  if(!trim($a_text))
1145  {
1146  if($files)
1147  {
1148  $files = array_shift($files);
1149  $id = $files["returned_id"];
1150  if($id)
1151  {
1152  $this->deleteDeliveredFiles($a_exc_id, $a_ass_id, array($id), $a_user_id);
1153  return;
1154  }
1155  }
1156  }
1157 
1158  if(!$files)
1159  {
1160  return $this->addResourceObject("TEXT", $a_ass_id, $a_user_id, $a_text);
1161  }
1162  else
1163  {
1164  $files = array_shift($files);
1165  $id = $files["returned_id"];
1166  if($id)
1167  {
1168  $ilDB->manipulate("UPDATE exc_returned".
1169  " SET atext = ".$ilDB->quote($a_text, "text").
1170  ", ts = ".$ilDB->quote(ilUtil::now(), "timestamp").
1171  " WHERE returned_id = ".$ilDB->quote($id, "integer"));
1172  return $id;
1173  }
1174  }
1175  }
addResourceObject($a_wsp_id, $a_ass_id, $user_id, $a_text=null)
Add personal resource to assigment.
static now()
Return current timestamp in Y-m-d H:i:s format.
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, $user_id)
Deletes already delivered files.
+ Here is the call graph for this function:

◆ updateUserStatus()

ilObjExercise::updateUserStatus (   $a_user_id = 0)

Update exercise status of user.

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

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

Referenced by updateAllUsersStatus(), and ilExAssignment\updateStatusOfUser().

801  {
802  global $ilUser;
803 
804  if ($a_user_id == 0)
805  {
806  $a_user_id = $ilUser->getId();
807  }
808 
809  $st = $this->determinStatusOfUser($a_user_id);
810 
811  include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
812  ilExerciseMembers::_writeStatus($this->getId(), $a_user_id,
813  $st["overall_status"]);
814  }
determinStatusOfUser($a_user_id=0)
Determine status of user.
getId()
get object id public
global $ilUser
Definition: imgupload.php:15
_writeStatus($a_obj_id, $a_user_id, $a_status)
Write user status.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $certificate_visibility

ilObjExercise::$certificate_visibility

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

◆ $completion_by_submission

ilObjExercise::$completion_by_submission = false
protected

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

Referenced by isCompletionBySubmissionEnabled().

◆ $day

ilObjExercise::$day

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

◆ $file_obj

ilObjExercise::$file_obj

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

◆ $files

ilObjExercise::$files

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

◆ $hour

ilObjExercise::$hour

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

◆ $instruction

ilObjExercise::$instruction

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

Referenced by getInstruction().

◆ $members_obj

ilObjExercise::$members_obj

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

◆ $minutes

ilObjExercise::$minutes

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

◆ $month

ilObjExercise::$month

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

◆ $timestamp

ilObjExercise::$timestamp

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

Referenced by getTimestamp().

◆ $year

ilObjExercise::$year

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


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