/**
  * Evaluate all parameters and store as instance variables, then execute
  * the operator as defined in simpleExecute()
  *
  * @param Assignment $assignment object used to evaluate parameters
  * @return mixed the evaluated expression
  */
 public function execute($assignment)
 {
     $this->assignment = $assignment;
     $this->parameters = [];
     // evaluated parameters
     foreach ($this->args as $key => $val) {
         $this->parameters[$key] = $assignment->evaluate($val);
     }
     return $this->_simpleExecute();
 }
Example #2
0
 /**
  * Retourne tous les assignment enregistrés.
  * 
  * @return array[Assignment] Tous les objets dans un tableau.
  */
 public static function findAll()
 {
     $mesAssignments = array();
     $data = BaseSingleton::select('SELECT id, module_id, label, description, ' . 'date_creation, date_passage, affiche, prixRattrapage, rattrapage ' . 'FROM assignment ');
     foreach ($data as $row) {
         $assignment = new Assignment();
         $assignment->hydrate($row);
         $mesAssignments[] = $assignment;
     }
     return $mesAssignments;
 }
Example #3
0
 public static function get_NumAssignments($cid = "")
 {
     if (empty($cid)) {
         $cid = Auth::consoleuser()->get()->cid;
     }
     $assignmentscount = Assignment::where('auditors', 'like', '%' . $cid . ',%')->count();
     return $assignmentscount;
 }
Example #4
0
 public static function getDataGantt($groups)
 {
     $arrayData = array();
     $arrayLink = array();
     $count = count($groups) + 1;
     foreach ($groups as $item => $group) {
         $dataGroup = array();
         $dataGroup['id'] = $item + 1;
         $dataGroup['text'] = $group->name;
         $dataGroup['type'] = 'gantt.config.types.project';
         $dataGroup['open'] = true;
         $dataLink = array();
         $dataLink['id'] = $item + 1;
         $dataLink['source'] = $item + 1;
         $dataLink['target'] = $count;
         $assignments = Assignment::where('group_id', new MongoId($group->_id))->orderBy('date_assigned', 'asc')->get();
         $progress = array();
         foreach ($assignments as $index => $assignment) {
             if ($index == 0) {
                 $dataLink['type'] = 1;
                 array_push($arrayLink, json_encode($dataLink));
             }
             $dataAssignment = array();
             $dataAssignment['id'] = $count;
             $dataAssignment['text'] = $assignment->description;
             $dataAssignment['start_date'] = date('d-m-Y', $assignment->date_assigned->sec);
             $dataAssignment['parent'] = $item + 1;
             $dataAssignment['open'] = true;
             $dataLink = array();
             $dataLink['id'] = $count;
             $dataLink['source'] = $count;
             $dataLink['target'] = $count + 1;
             $dataLink['type'] = 0;
             array_push($arrayLink, json_encode($dataLink));
             $pg = strcasecmp($assignment->state, 'c') === 0 ? 1 : 0;
             $dataAssignment['progress'] = $pg;
             if ($pg === 1) {
                 $dataAssignment['type'] = 'gantt.config.types.milestone';
             }
             array_push($progress, $pg);
             $date_assigned = new DateTime(date('Y-m-d', $assignment->date_assigned->sec));
             $deadline = new DateTime(date('Y-m-d', $assignment->deadline->sec));
             $date_assigned = $date_assigned->diff($deadline);
             $dataAssignment['duration'] = $date_assigned->days;
             array_push($arrayData, json_encode($dataAssignment));
             $count += 1;
         }
         $dataGroup['progress'] = count($progress) > 0 ? array_sum($progress) / count($progress) : 0;
         array_push($arrayData, json_encode($dataGroup));
     }
     return array('data' => $arrayData, 'link' => $arrayLink);
 }
Example #5
0
 public function actionIndex()
 {
     $uid = Ibos::app()->user->uid;
     if (EnvUtil::getRequest("param") == "search") {
         $this->search();
     }
     $this->_condition = AssignmentUtil::joinCondition($this->_condition, "(`status` = 2 OR `status` = 3) AND (`designeeuid` = {$uid} OR `chargeuid` = {$uid} OR FIND_IN_SET({$uid}, `participantuid`))");
     $data = Assignment::model()->fetchAllAndPage($this->_condition);
     $data["datas"] = AssignmentUtil::handleListData($data["datas"]);
     $data["datas"] = $this->groupByFinishtime($data["datas"]);
     $this->setPageTitle(Ibos::lang("Assignment"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Assignment"), "url" => $this->createUrl("unfinished/index")), array("name" => Ibos::lang("Unfinished list"))));
     $this->render("list", $data);
 }
Example #6
0
 /**
  * Returns options for the related model multiple select
  * @param string $model
  * @return  string options for relate model  multiple select
  * @since 1.0
  */
 public function related_opts($model)
 {
     $relatedPKs = Assignment::extractPkValue($model->assignments);
     $options = '';
     $categories = GxHtml::listDataEx(Assignment::model()->findAllAttributes(null, true));
     foreach ($categories as $value => $text) {
         if (!$model->isNewRecord) {
             in_array($value, $relatedPKs) ? $options .= '<option selected="selected" value=' . $value . '>' . $text . '</option>\\n' : ($options .= '<option  value=' . $value . '>' . $text . '</option>\\n');
         } else {
             $options .= '<option  value=' . $value . '>' . $text . '</option>\\n';
         }
     }
     echo $options;
 }
Example #7
0
 /**
  * Teacher can publish notification for the assignment which will be sent
  * to all the students of the classroom
  * @before _secure, _teacher
  */
 public function assignment($assignment_id)
 {
     $redirect = $_SERVER['HTTP_REFERER'];
     $assignment = Assignment::first(array("id = ?" => $assignment_id));
     if (!$assignment) {
         self::redirect($redirect);
     }
     $this->JSONView();
     $view = $this->getActionView();
     $template = new Framework\View(array("file" => APP_PATH . "/application/views/notification/templates/newAssignment.html"));
     $template->set("title", $assignment->title);
     $content = $template->render();
     $classroom = TeacherService::$_classes[$assignment->classroom_id];
     $service = new Shared\Services\Classroom();
     $users = $service->enrollments($classroom, array('only_user' => true));
     $this->_save(array('type' => 'assignment', 'type_id' => $assignment->id, 'url' => '/student/assignments/' . $assignment->course_id), $content, $users);
     Registry::get("session")->set('$redirectMessage', "Notification sent to students");
     self::redirect($_SERVER['HTTP_REFERER']);
 }
$total_count = Assignment::count_all();
//4. to limit pagination number
// 3 means abc[page]efg -> 3 right, 3 left
$stages = 2;
$pagination = new Pagination($page, $per_page, $total_count);
// Instead of finding all records, just find the records
// for this page
$sql = "SELECT * FROM assignments  ";
if (isset($_POST['sort'])) {
    $batch = strtolower($_POST['batch']);
    $sql .= "WHERE batch={$batch}";
}
$sql .= "ORDER BY created DESC ";
$sql .= " LIMIT {$per_page} ";
$sql .= "OFFSET {$pagination->offset()} ";
$assignments = Assignment::find_by_sql($sql);
if (empty($assignments)) {
    $session->message("There are no Assignments in Assignment vault.");
    redirect_to('index.php');
}
// Need to add ?page=$page to all links we want to
// maintain the current page (or store $page in $session)
?>


<?php 
include_layout_template('admin_header.php');
?>

<a class="ui teal basic button" href="index.php">&laquo; Back</a>
<br/>
Example #9
0
 /**
  * @before _secure, _student
  */
 public function courses()
 {
     $this->setSEO(array("title" => "Result | Student"));
     $view = $this->getActionView();
     $session = Registry::get("session");
     $courses = StudentService::$_courses;
     $result = array();
     $sub = Registry::get("MongoDB")->submission;
     foreach ($courses as $c) {
         $a = Assignment::count(array("course_id = ?" => $c->id));
         $s = $sub->count(array("course_id" => (int) $c->id, "user_id" => (int) $this->user->id));
         $data = array("_title" => $c->title, "_description" => $c->description, "_grade_id" => $c->grade_id, "_id" => $c->id, "_assignments" => $a, "_assignment_submitted" => $s);
         $data = ArrayMethods::toObject($data);
         $result[] = $data;
     }
     $view->set("courses", $result);
 }
Example #10
0
 /**
  * Find all the courses to which the teacher is assigned
  * @before _secure, _teacher
  */
 public function courses()
 {
     $this->setSEO(array("title" => "Manage Your Courses | Teacher"));
     $view = $this->getActionView();
     $teaches = \Teach::all(array("user_id = ?" => $this->user->id, "live = ?" => true));
     $grades = \Grade::all(array("organization_id = ?" => $this->organization->id), array("id", "title"));
     $storedGrades = array();
     foreach ($grades as $g) {
         $storedGrades[$g->id] = $g;
     }
     $courses = TeacherService::$_courses;
     $classes = TeacherService::$_classes;
     $result = array();
     foreach ($teaches as $t) {
         $grade = $storedGrades[$t->grade_id];
         $class = $classes[$t->classroom_id];
         $course = $courses[$t->course_id];
         $asgmnt = \Assignment::count(array("course_id = ?" => $t->course_id));
         $data = array("grade" => $grade->title, "grade_id" => $g->id, "section" => $class->section, "course" => $course->title, "course_id" => $course->id, "classroom_id" => $class->id, "assignments" => $asgmnt);
         $data = ArrayMethods::toObject($data);
         $result[] = $data;
     }
     $session = Registry::get("session");
     if ($session->get('Notification\\Students:$sent')) {
         $view->set("success", "Notification sent to students");
         $session->erase('Notification\\Students:$sent');
     }
     $view->set("courses", $result);
 }
Example #11
0
 $assignmentPath = get_path('coursesRepositorySys') . claro_get_course_path(claro_get_current_course_id()) . '/work/assig_' . (int) $result['assignment_id'] . '/';
 //  count author's submissions for the name of directory
 if ($result['authors'] != $previousAuthors) {
     $i = 1;
     $previousAuthors = $result['authors'];
 } else {
     $i++;
 }
 $authorsDir = replace_dangerous_char($result['authors']) . '/';
 if (!is_dir($zipPath . $assigDir . '/' . $authorsDir)) {
     mkdir($zipPath . $assigDir . '/' . $authorsDir, CLARO_FILE_PERMISSIONS, true);
 }
 if ($downloadScore && !(isset($currAssigId) && $currAssigId == $result['assignment_id'])) {
     $course = new Claro_Course(claro_get_current_course_id());
     $course->load();
     $assignment = new Assignment();
     $assignment->load($result['assignment_id']);
     $currAssigId = $result['assignment_id'];
     $scoreList = new CLWRK_AssignementScoreList($assignment);
     if (!$downloadOnlyCurrentMembersSubmissions) {
         $scoreList->setOptAllUsers();
     }
     $scoreListIterator = $scoreList->getScoreList();
     $scoreListRenderer = new CLWRK_ScoreListRenderer($course, $assignment, $scoreListIterator);
     file_put_contents($zipPath . $assigDir . '/scores.html', $scoreListRenderer->render());
 }
 $submissionPrefix = $assigDir . $authorsDir . replace_dangerous_char(get_lang('Submission')) . '_' . $i . '_';
 // attached file
 if (!empty($result['submitted_doc_path'])) {
     if (file_exists($assignmentPath . $result['submitted_doc_path'])) {
         copy($assignmentPath . $result['submitted_doc_path'], $zipPath . '/' . $submissionPrefix . $result['submitted_doc_path']);
Example #12
0
<?php

if ($_SERVER['REQUEST_TYPE'] == 'POST') {
    $cid = $_POST['cid'];
    $duedate = $_POST['duedate'];
    $title = $_POST['title'];
    $description = $POST['description'];
    $assignment = Assignment::create($aid, $cid, $duedate, $title, $description);
    if ($assignment == null) {
        header("HTTP/1.0 500 Server Error");
        print "No account with that login exists.";
        exit;
    } else {
        header("Content-type: application/json");
        print $assignment->getJSON();
        exit;
    }
}
Example #13
0
 public function info($assignment_id = null)
 {
     global $db;
     if (is_null($assignment_id)) {
         $assignment_id = $this->assignment_id;
     }
     $user_id = user::authService()['user_id'];
     if (!isset($assignment_id) && !isset($user_id)) {
         return -1;
     }
     $db->where("assignment_id", $assignment_id);
     $result = $db->get("assignment")[0];
     $db->where("type_id", $assignment_id);
     $db->where("type", "question");
     $resultFile = $db->get("file");
     $files = array();
     foreach ($resultFile as $rowFile) {
         $filepath = file::getFilename($rowFile['file_id'], $rowFile['extension']);
         $rowFile['filepath'] = $filepath;
         $files[] = $rowFile;
     }
     $result['files'] = $files;
     if (user::isStudent()) {
         $result['group_id'] = Assignment::groupID($assignment_id);
         $result['editor'] = Assignment::getEditor($result['group_id']);
     } elseif (user::isTeacher()) {
         $db->where("assignment_id", $assignment_id);
         $result2 = $db->get("assignment_group", "COUNT(*) as group_count")[0];
         $result['group_count'] = $result2['group_count'];
         $deadline = explode(" ", $result['deadline']);
         $result['due_date'] = $deadline[0];
         $result['due_time'] = $deadline[1];
         $db->where("assignment_id", $assignment_id);
         $sample_codes = $db->get("assignment_sample_code");
         $result['sample_code'] = $sample_codes;
     }
     $result['deadline_time'] = strtotime($result['deadline']);
     if (time() > $result['deadline_time']) {
         $result['overdue'] = true;
     } else {
         $result['overdue'] = false;
         $diff = $result['deadline_time'] - time();
         $result['deadline_day'] = ceil($diff / 60 / 60 / 24);
     }
     return $result;
 }
Example #14
0
                   class="client-val-form button">
        </div>

        <!--The tree will be rendered in this div-->

        <div id="<?php 
echo Assignment::ADMIN_TREE_CONTAINER_ID;
?>
"  class="admintree" >
        </div>

       <div id='category_info'>
            <div id='pic'></div>
            <div id='title'>
                                <h3><?php 
echo Assignment::model()->findByPK($category_id)->name;
?>
</h3>
                            </div>
        </div>


         <div id="listview-wrapper" class="left">
            <?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $prod_dataProvider, 'itemView' => 'application.views.student._frontend_view', 'id' => 'student-listview', 'afterAjaxUpdate' => 'js:function(id,data){$.bind_crud()}', 'pagerCssClass' => 'pager_wrapper clearfix'));
?>
        </div>

    
    </div>
    <!--   Content-->
<?php

require_once "includes/initialize.php";
if (!$session->is_logged_in()) {
    redirect_to("login.php");
}
// must have an ID
if (empty($_GET['id'])) {
    $session->message("Assignment ID was not provided.");
    redirect_to('index.php');
}
$assignment = Assignment::find_by_id($_GET['id']);
if ($assignment && $assignment->delete()) {
    $session->message("The assignemnt was deleted.");
    redirect_to('list_assignments.php');
} else {
    $session->message("The assignemnt could not be deleted.");
    redirect_to('list_assignments.php');
}
if (isset($database)) {
    $database->close_connection();
}
Example #16
0
 public function loadNew()
 {
     $uid = Ibos::app()->user->uid;
     return Assignment::model()->getUnfinishCountByUid($uid);
 }
Example #17
0
 /**
  * Compute the automatic assignment of papers
  *
  */
 function computeassignmentAction()
 {
     $paperTbl = new Paper();
     $userTbl = new User();
     $ratingTbl = new Rating();
     $assignmentTbl = new Assignment();
     // Form has been posted? Store the new assignment
     if (isset($_POST['commitAssignment'])) {
         if (isset($_POST['idMin'])) {
             // Commit for a group
             $idMin = $_POST['idMin'];
             $idMax = $_POST['idMax'];
         } else {
             $idMin = $idMax = -1;
         }
         $this->commitAssignment($idMin, $idMax, $this->db_v1);
         $this->view->set_file("content", "index.xml");
         $this->view->initial_message = "Assignment committed!";
         // SummaryPapersAssignment (&$this->view, $this->db_v1);
     } else {
         if ($this->config->assignment_mode == Config::TOPIC_BASED) {
             // Assignment based on topics
             $this->view->setFile("content", "topicbased.xml");
             $this->view->setBlock("content", "MEMBER", "MEMBERS");
             $this->view->setBlock("MEMBER", "PAPER", "PAPERS");
             $this->zmax_context->db->query("DELETE FROM Assignment");
             // Loop on PC members
             $members = $userTbl->fetchAll("roles LIKE '%R%'");
             $i = 0;
             foreach ($members as $member) {
                 $member->putInView($this->view);
                 $this->view->PAPERS = "";
                 $nbPapers = 0;
                 // Loop on papers that match the reviewer's topics
                 $qPapers = "SELECT p.* FROM Paper p, UserTopic s " . " WHERE p.topic=s.id_topic  AND s.id_user='******' ";
                 $rPapers = $this->zmax_context->db->query($qPapers);
                 while ($p = $rPapers->fetch(Zend_Db::FETCH_OBJ)) {
                     // instantiate a PaperRow object. Ok, not elegant, but easier
                     $paper = $paperTbl->find($p->id)->current();
                     // Check whether there is a conflict
                     $comments = "";
                     $conflict = $paper->checkConflictWithuser($member, $comments);
                     if ($conflict) {
                         $this->view->PAPERS .= "<li>{$comments}</li>";
                     } else {
                         $paper->putInView($this->view);
                         $nbPapers++;
                         // OK, now save the rating
                         $assignment = $assignmentTbl->createRow();
                         $assignment->idPaper = $paper->id;
                         $assignment->id_user = $member->id;
                         $assignment->weight = 5;
                         $assignment->save();
                         $this->view->append("PAPERS", "PAPER");
                     }
                     if ($nbPapers >= 4) {
                         break;
                     }
                 }
                 // Loop on papers
                 $this->view->nb_papers = $nbPapers;
                 $this->view->append("MEMBERS", "MEMBER");
             }
             // End of loop on users
         } else {
             // Assignment based on reviewers preferences
             $this->view->set_file("content", "computeassignment.xml");
             $this->view->set_file("assigngroup", "assigngroup.xml");
             // Compute and propose the assignment
             if (isset($_GET['nbRev'])) {
                 $maxReviewers = $_GET['nbRev'];
             } else {
                 $maxReviewers = $this->config->nbReviewersPerItem;
             }
             ComputeAssignment($this->view, $this->db_v1, $maxReviewers);
         }
     }
     echo $this->view->render("layout");
 }
Example #18
0
if (isset($_REQUEST['assigId'])) {
    $assigId = (int) $_REQUEST['assigId'];
} else {
    $assigId = null;
}
if (isset($_REQUEST['downloadMode'])) {
    $downloadMode = $_REQUEST['downloadMode'];
} else {
    $downloadMode = 'all';
}
/*============================================================================
                HANDLING FORM DATA : CREATE/EDIT ASSIGNMENT
  =============================================================================*/
if (!is_null($cmd)) {
    // instanciate assignment object
    $assignment = new Assignment();
    if (!is_null($assigId)) {
        // we handle a particular assignment, no form has been posted (delete, change visibility , ask for edition)
        // read assignment
        if (!$assignment->load($assigId)) {
            // could not read assignment
            $cmd = null;
            $assigId = null;
        }
    }
    if (isset($_REQUEST['submitAssignment']) && !is_null($cmd)) {
        // form submitted
        if (isset($_REQUEST['title'])) {
            $assignment->setTitle(strip_tags(trim($_REQUEST['title'])));
        }
        if (!isset($_REQUEST['description']) || trim(strip_tags($_REQUEST['description'], $allowedTags)) == '') {
 public static function getLatestAssignments()
 {
     $sectionCodes = SectionCode::where('teacher_id', new MongoId(Auth::id()))->where('status', true)->get();
     $arraySectionCodes = array();
     $arrayGroups = array();
     foreach ($sectionCodes as $sectionCode) {
         array_push($arraySectionCodes, new MongoId($sectionCode->_id));
     }
     $groups = Group::whereIn('section_code_id', $arraySectionCodes)->get();
     foreach ($groups as $group) {
         array_push($arrayGroups, new MongoId($group->_id));
     }
     $assignments = Assignment::whereIn('group_id', $arrayGroups)->get();
     $arrayAssignments = array();
     foreach ($assignments as $assignment) {
         if ($assignment->date_assigned->sec >= Auth::user()->last_activity->sec) {
             array_push($arrayAssignments, $assignment);
         }
     }
     return $arrayAssignments;
 }
Example #20
0
<?php

require_once 'includes/initialize.php';
if (!$session->is_logged_in()) {
    redirect_to("login.php");
}
if (isset($_POST['submit'])) {
    //creating a new Assignment
    $assignment = new Assignment();
    $assignment->subject = $_POST['subject'];
    $assignment->description = $_POST['description'];
    $assignment->teacher = $_POST['teacher'];
    $assignment->batch = $_POST['batch'];
    $deadline = strtotime($_POST['deadline']);
    $assignment->deadline = strftime("%Y-%m-%d %H:%M:%S", $deadline);
    $assignment->created = strftime("%Y-%m-%d %H:%M:%S", time());
    if ($assignment->save()) {
        $session->message("Assignment created successfully.");
        redirect_to('index.php');
    } else {
        // Failure
        $session->message("Assignment failed.");
        redirect_to('index.php');
    }
}
?>

<?php 
include_layout_template('admin_header.php');
?>
<!-- datepicker javascript -->
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Assignment::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
<?php

$assignmentAPI = new Assignment($assignment_id);
$assignment = $assignmentAPI->info();
$course_id = $assignment['course_id'];
$courseAPI = new course($course_id);
$course = $courseAPI->info();
$group_id = $param2;
?>
<style>
#code_hierarchy
{
	position:relative;
	width:600px;
	margin:0 auto;
}

#code_hierarchy_legend
{
	height:100px;
	font-size:1.4em;
	text-align:center;
}

.bg-success:hover {
	background-color: #626c75;
	border-color: #626c75;
	cursor: pointer;
}
</style>
<script type="text/javascript" src="/js/data/visualization.js"></script>
<?php

$assignmentAPI = new Assignment($assignment_id);
$assignment = $assignmentAPI->info();
$course_id = $assignment['course_id'];
$courseAPI = new course($course_id);
$course = $courseAPI->info();
?>

<!-- START PAGE CONTENT WRAPPER -->
<div class="page-content-wrapper">
    <!-- START PAGE CONTENT -->
    <div class="content">
        <!-- START JUMBOTRON -->
        <div class="jumbotron" data-pages="parallax">
            <div class="container-fluid container-fixed-lg sm-p-l-20 sm-p-r-20">
                <div class="inner">
                    <!-- START BREADCRUMB -->
                    <ul class="breadcrumb">
                        <li>
                            <a href="<?php 
echo $router->generate('course');
?>
" class="">Course</a>
                        </li>
                        <li>
                        	<a href="<?php 
echo $router->generate('course_detail', array('course_id' => $course['course_id']));
?>
" class=""><?php 
echo $course['name'];
 protected function body()
 {
     // Validate input.
     $inputs = array('group' => 'isIndex', 'problem' => 'isIndex', 'deadline' => 'isDate', 'reward' => 'isNonNegativeInt');
     if (!$this->isInputValid($inputs)) {
         return false;
     }
     // Load input
     $id = $this->getParams('id');
     $group = $this->getParams('group');
     $problem = $this->getParams('problem');
     $deadline = $this->getParams('deadline');
     $reward = $this->getParams('reward');
     // Adjust input
     $deadline = $deadline . ' 23:59:59';
     // Load from database
     /**
      * @var $groupEntity \Group
      * @var $assignmentEntity \Assignment
      * @var $problemEntity \Problem
      */
     $groupEntity = Repositories::getEntityManager()->find('Group', $group);
     $problemEntity = Repositories::getEntityManager()->find('Problem', $problem);
     if ($groupEntity === null || $problemEntity === null) {
         return $this->stop('Group or problem does not exist.', 'Assignment cannot be edited.');
     }
     // Authenticate
     $user = User::instance();
     if (!$user->hasPrivileges(User::groupsManageAll) && (!$user->hasPrivileges(User::groupsManageOwn) || $groupEntity->getOwner()->getId() !== $user->getId())) {
         return $this->stop(Language::get(StringID::InsufficientPrivileges));
     }
     // Already exists?
     if ($id !== null && $id !== '') {
         $assignmentEntity = Repositories::getEntityManager()->find('Assignment', $id);
         $assignmentEntity->setDeadline(\DateTime::createFromFormat("Y-m-d H:i:s", $deadline));
         $assignmentEntity->setReward($reward);
         Repositories::getEntityManager()->persist($assignmentEntity);
         Repositories::getEntityManager()->flush($assignmentEntity);
     } else {
         // Verify integrity
         if ($problemEntity->getLecture()->getId() !== $groupEntity->getLecture()->getId()) {
             return $this->stop('You are adding an assignment for problem belonging to lecture X to a group that belongs to lecture Y. This is not possible.');
         }
         // Create new
         $assignmentEntity = new \Assignment();
         $assignmentEntity->setGroup($groupEntity);
         $assignmentEntity->setProblem($problemEntity);
         $assignmentEntity->setDeadline(\DateTime::createFromFormat("Y-m-d H:i:s", $deadline));
         $assignmentEntity->setReward($reward);
         Repositories::getEntityManager()->persist($assignmentEntity);
         Repositories::getEntityManager()->flush($assignmentEntity);
         // Send e-mail
         /**
          * @var $subscription \Subscription
          */
         $query = Repositories::getEntityManager()->createQuery('SELECT s, u FROM Subscription s JOIN s.user u  WHERE s.group = :group');
         $query->setParameter('group', $groupEntity);
         $subscriptions = $query->getResult();
         foreach ($subscriptions as $subscription) {
             if (!$subscription->getUser()->getSendEmailOnNewAssignment()) {
                 continue;
             }
             $to = $subscription->getUser()->getEmail();
             $email = file_get_contents(Config::get("paths", "newAssignmentEmail"));
             $email = str_replace("%{Problem}", $problemEntity->getName(), $email);
             $email = str_replace("%{Deadline}", $deadline, $email);
             $email = str_replace("%{Group}", $groupEntity->getName(), $email);
             $email = str_replace("%{Link}", Config::getHttpRoot() . "#studentAssignments#" . $assignmentEntity->getId(), $email);
             $email = str_replace("%{Date}", date("Y-m-d H:i:s"), $email);
             $lines = explode("\n", $email);
             $subject = $lines[0];
             // The first line is subject.
             $text = preg_replace('/^.*\\n/', '', $email);
             // Everything except the first line.
             if (!Core::sendEmail($to, trim($subject), $text)) {
                 Core::logError(Error::create(Error::levelWarning, "E-mail could not be sent to {$to}."));
             }
         }
     }
     return true;
 }
Example #25
0
        $assignment->uploadVideo($conn, $_POST['textVideo']);
    }
    if (isset($_FILES['uploadedFiles'])) {
        $fileCount = count($_FILES['uploadedFiles']["name"]);
        if ($fileCount != 0 && $_FILES['uploadedFiles']["name"][0] != "") {
            $assignment->uploadFiles($conn, $_FILES['uploadedFiles']);
        }
    }
    $assignment->setAttachments($conn);
    if (isset($_GET['action'])) {
        $action = (int) $_GET['action'];
        if ($action == 1) {
            ?>
 <meta http-equiv="refresh" content="0;url=assignment.php?id=<?php 
            echo $assignment->getId();
            ?>
"><?php 
        } else {
            if ($action == 2) {
                ?>
 <meta http-equiv="refresh" content="0;url=prehladZadani.php"><?php 
            }
        }
    }
    $assignment->getEditingHtml($flag);
} else {
    $assignment = new Assignment($conn, 0);
    $assignment->getEditingHtml(true);
}
mysqli_close($conn);
page_footer();
Example #26
0
 /**
  * Retourne tous les assign avec rattrapage à .
  *
  * @return Assignment Tous les objets dans un tableau.
  */
 public static function findAllRattrapageAssign($moduleId)
 {
     $data = BaseSingleton::select('SELECT assignment.id, assignment.module_id, ' . 'assignment.label, ' . 'assignment.description, assignment.date_creation, ' . 'assignment.date_passage, assignment.affiche, ' . 'assignment.prixRattrapage, assignment.rattrapage ' . 'FROM module, assignment, exam ' . 'WHERE module.id = assignment.module_id AND module.id = exam.module_id ' . ' AND assignment.rattrapage = 1' . ' AND module.id = ? ' . 'GROUP BY module.id', array('i', &$moduleId));
     $rattrapageAssign = new Assignment();
     if (sizeof($data) <= 0) {
         return false;
     } else {
         $rattrapageAssign->hydrate($data[0]);
     }
     return $rattrapageAssign;
 }
Example #27
0
} else {
    $cmd = null;
}
if (isset($_REQUEST['downloadMode'])) {
    $downloadMode = $_REQUEST['downloadMode'];
} else {
    $downloadMode = 'all';
}
$req['assignmentId'] = isset($_REQUEST['assigId']) && !empty($_REQUEST['assigId']) && ctype_digit($_REQUEST['assigId']) ? (int) $_REQUEST['assigId'] : false;
/*============================================================================
    Prerequisites
  ============================================================================*/
/*--------------------------------------------------------------------
ASSIGNMENT INFORMATIONS
--------------------------------------------------------------------*/
$assignment = new Assignment();
if (!$req['assignmentId'] || !$assignment->load($req['assignmentId'])) {
    // we NEED to know in which assignment we are, so if assigId is not set
    // relocate the user to the previous page
    claro_redirect(Url::Contextualize('work.php'));
    exit;
}
/*============================================================================
    Group Publish Option
  ============================================================================*/
// redirect to the submission form prefilled with a .url document targetting the published document
/**
 * @todo $_REQUEST['submitGroupWorkUrl'] must be treated in  filter process
 */
if (isset($_REQUEST['submitGroupWorkUrl']) && !empty($_REQUEST['submitGroupWorkUrl']) && claro_is_in_a_group()) {
    claro_redirect(Url::Contextualize('user_work.php?authId=' . claro_get_current_group_id() . '&cmd=rqSubWrk' . '&assigId=' . $req['assignmentId'] . '&submitGroupWorkUrl=' . urlencode($_REQUEST['submitGroupWorkUrl'])));
Example #28
0
<?php

require_once dirname(__FILE__) . "/includes/functions.php";
page_head("Pridanie zadania");
page_nav();
get_topright_form();
if (!isset($_SESSION["loggedUser"]) || $_SESSION["loggedUser"] == null) {
    dieWithError("err-not-logged-in");
}
if (get_class($_SESSION["loggedUser"]) == "Team") {
    dieWithError("err-add-assignment-rights");
}
if ($conn = db_connect()) {
    $id = new_assignment($conn, $_SESSION["loggedUser"]->getId());
    $assignment = new Assignment($conn, $id);
    if (isset($_POST['skName']) && $_POST['skName'] != $assignment->getSkName()) {
        $assignment->setSkName($conn, $_POST['skName']);
    }
    if (isset($_POST['engName']) && $_POST['engName'] != $assignment->getEngName()) {
        $assignment->setEngName($conn, $_POST['engName']);
    }
    if (isset($_POST['skTextPopis']) && $_POST['skTextPopis'] != $assignment->getSkTxt()) {
        $assignment->setSkTxt($conn, $_POST['skTextPopis']);
    }
    if (isset($_POST['engTextPopis']) && $_POST['engTextPopis'] != $assignment->getEngTxt()) {
        $assignment->setEngTxt($conn, $_POST['engTextPopis']);
    }
    if (isset($_POST['textVideo']) && $_POST['textVideo'] != "") {
        $assignment->uploadVideo($conn, $_POST['textVideo']);
    }
    if (isset($_FILES['uploadedFiles'])) {
Example #29
0
 private function handleCancel($assignmentId)
 {
     Assignment::model()->modify($assignmentId, array("status" => 4));
     AssignmentApply::model()->deleteAll("assignmentid = {$assignmentId}");
     $this->addStepComment($assignmentId, Ibos::lang("Cancel the assignment"));
     AssignmentLog::model()->addLog($assignmentId, "cancel", Ibos::lang("Cancel the assignment"));
     return true;
 }
Example #30
0
<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once '../../model/class/Exam.php';
require_once '../../model/DAL/ExamDAL.php';
require_once '../../model/class/Assignment.php';
require_once '../../model/DAL/AssignmentDAL.php';
require_once '../../model/class/Module.php';
require_once '../../model/DAL/ModuleDAL.php';
//===Création du module====
$newModule = new Module();
$newAssignment = new Assignment();
$newExam = new Exam();
//regex opur les date format YYYY/MM/DD
$myregex = "~^[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}\$~";
//********CREATION MODULE *******
//Vérifie ce qui est renvoyer par le POST de /view/phtml/module_create.php
//et set de l'objet newModule au fur et à mesure
$validModuleLabel = filter_input(INPUT_POST, 'label', FILTER_SANITIZE_STRING);
$newModule->setLabel($validModuleLabel);
$validModuleNumber = filter_input(INPUT_POST, 'moduleNumber', FILTER_SANITIZE_NUMBER_INT);
$newModule->setNumber($validModuleNumber);
$validModuleDescription = filter_input(INPUT_POST, 'descriptionModule', FILTER_SANITIZE_STRING);
$newModule->setDescription($validModuleDescription);
$newModule->setBareme(1);
//barème par defaut
$newModule->setAffiche(1);