bos = new BackOfficeService();
if ($id) {
$this->id = $id;
}
}
public function load($loader = NULL) {
if (!$loader) {
$loader = $this->bos->loadAnswer($this->idXML());
}
if ($loader) {
$this->type = "answer";
$this->id = $loader->id[0][0];
$this->title = $loader->title[0][0];
$this->url = $loader->url[0][0];
$this->content = $loader->content[0][0];
$this->created = $loader->created[0][0];
$this->modified = $loader->modified[0][0];
$this->graded = $loader->graded[0][0];
$this->creator = $loader->creator[0][0];
$this->grade = $loader->grade[0][0];
$this->feedback = $loader->feedback[0][0];
$this->assignment = $loader->assignment[0][0];
}
}
public function create() {
$created = $this->bos->createAnswer($this->answerXML());
if ($created) {
$this->id = $created->id[0][0];
return $this->id;
}
return false;
}
public function save_grade() {
return $this->bos->gradeAnswer($this->dataXML());
}
public function getObjectURL($course_id) {
return WWW_ROOT."course/assignments/{$course_id}/answer/{$this->id}/view";
}
public function getURL() {
return $this->url;
}
public function getType() {
return $this->type;
}
public function canEdit() {
// Answer objects are created and edited elsewhere
// This function only exists for compatibility purpose
// TODO Delete if is proven to be unneeded
return false;
}
public function isGraded() {
if ($this->grade) {
return true;
}
return false;
}
public function isFeedback() {
if (!empty($this->feedback)) {
return true;
}
return false;
}
public function getId() {
return $this->id;
}
public function getOwner() {
return $this->creator;
}
public function getOwnerEntity() {
if (!isset($this->owner_entity)) {
$user = new User($this->getOwner());
$user->load();
$this->owner_entity = $user;
return $user;
}
return $this->owner_entity;
}
public function getAssignment() {
return $this->assignment;
}
public function getAssignmentEntity() {
if (!isset($this->assignment_entity)) {
$assignment = new Assignment($this->assignment);
$assignment->load();
$this->assignment_entity = $assignment;
return $assignment;
}
return $this->assignment_entity;
}
public function idXML() {
$data = "";
$data .= "";
$data .= "{$this->id}";
$data .= "";
return $data;
}
/**
* Please note that this will only send grade and feedback as data.
* This is used for grading purposes only.
*/
public function dataXML() {
$data = ""
. ""
. "{$this->id}"
. "grade}]]>"
//. "feedback}]]>"
. "";
return $data;
}
public function answerXML() {
$data = ""
. ""
. "{$this->id}"
. "{$this->assignment}"
. "url}]]>"
. ""
. "{$this->creator}"
. "";
return $data;
}
}