/** * Updates an existing Grades model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate() { $username = Yii::$app->user->identity->username; $users = User::find()->all(); $grades = Grades::find()->all(); $model = new Grades(); $tuitions = Tuitionfees::find()->all(); foreach ($users as $user) { foreach ($tuitions as $tuition) { if ($user->username == $username && $user->id == $tuition->tuitionfee_id) { $id = $tuition->tuitionfee_id; $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { $fileName = $model->tuitionfee_id . "regform"; $model->file = UploadedFile::getInstance($model, 'file'); if ($model->file != null) { $model->file->saveAs('uploads/' . $fileName . '.' . $model->file->extension); $model->tuitionfee_registrationForm = 'uploads/' . $fileName . '.' . $model->file->extension; } $model->save(); return $this->redirect(['view', 'id' => $model->tuitionfee_id]); return $this->redirect(['view', 'id' => $model->tuitionfee_id]); } else { return $this->render('update', ['model' => $model]); } } } } }
/** * Handle request * * This is the main method for handling a request. Note that * most preparation should be done in the prepare() method; * by the time handle() is called the action should be * more or less ready to go. * * @param array $args $_REQUEST args; handled in prepare() * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } if (!$this->user->hasRole('grader')) { $this->clientError(_('Usted no tiene privilegios para visitar esta página.')); return; } $groupid = $this->trimmed('groupid'); $delimiter = $this->trimmed('grade-export-delimiter'); $separator = $this->trimmed('grade-export-separator'); $arrayReport = Grades::getGradedNoticesAndUsersWithinGroup($groupid); $nicksMembers = Grades::getMembersNicksExcludeGradersAndAdmin($groupid); foreach ($nicksMembers as $nick) { if (!array_key_exists($nick, $arrayReport)) { $arrayReport[$nick] = 0; } } $arrayFinal = array(); foreach ($arrayReport as $alumno => $puntuacion) { $arrayFinal[] = array($alumno, number_format($puntuacion, 2)); } $this->generarInformeCSV($arrayFinal, 'report_group_' . $groupid . '.csv', $separator, $delimiter); }
function reportGroupGrades($groupnick) { $groupgrades = Grades::getGradedNoticesAndUsersWithinGroup($groupnick); print PHP_EOL; print PHP_EOL; print sprintf(_m('Group %s report' . PHP_EOL), $groupnick); foreach ($groupgrades as $login => $sumnoticegrades) { print sprintf(_m('+ %s : %s' . PHP_EOL), $login, $sumnoticegrades); } }
function savegrade() { if (isset($_POST['savegrades'])) { if ($_POST['finalave'] >= 75 and $_POST['finalave'] <= 100) { $remarks = "Passed"; } else { $remarks = "Failed"; } $instClass = new InstructorClasses(); $cur = $instClass->single_class($_GET['classId']); $grade = new Grades(); $grade->INST_ID = $cur->INST_ID; $grade->FIRST = $_POST['first']; $grade->SECOND = $_POST['second']; $grade->THIRD = $_POST['third']; $grade->FOURTH = $_POST['fourth']; $grade->AVE = $_POST['finalave']; $grade->REMARKS = $remarks; $grade->update($_GET['gradeId']); message("Grade successfully updated!"); redirect("index.php?view=class&id=" . $_GET['classId'] . "&instructorId=" . $_GET['instructorId'] . ""); } }
function showContent() { if (empty($this->user)) { $this->element('p', array('class' => 'notespdf-generate-error'), _m('Login first!')); } else { $this->element('h2', null, 'Grupos Disponibles'); // Obtenemos los grupos a los que pertenece el usuario. $groupsUser = $this->user->getGroups()->fetchAll(); // Si no pertenece a ninguno, le animamos a que se una a alguno de los existentes. if (empty($groupsUser)) { $this->elementStart('p', array('class' => 'notes-empty-groups')); $this->raw("Todavía no perteneces a ningún grupo."); $this->element('br'); $this->raw("Prueba uniéndote a alguno de los "); $this->element('a', array('href' => common_root_url() . 'groups/'), "Grupos Disponibles"); $this->elementEnd('p'); } else { // Obtenemos los grupos que contienen tweets puntuados. $groupsGraded = Grades::getIDsGroupsWithGrades(); $this->elementStart('ul'); foreach ($groupsUser as $group) { $this->elementStart('li', array('class' => 'notespdf-group-item')); $avatar = $group->getAvatar(); $this->element('img', array('src' => $avatar, 'width' => '48', 'height' => '48')); $this->elementStart('p'); $name = $group->getBestName(); $this->raw($name); $this->elementEnd('p'); // Si el grupo no tiene puntuaciones no se pueden generar apuntes if (!in_array($group->id, $groupsGraded)) { $butGenerate = new Notesgroupsform($this, $group->id, 'true'); $butGenerate->show(); $this->elementStart('div'); $this->elementStart('p', array('class' => 'notes-error-group-text')); $this->raw("No es posible generar apuntes. Grupo sin puntuaciones."); $this->elementEnd('p'); $path = common_path('local/plugins/NotesPDF/css/x.gif'); $this->element('img', array('class' => 'notes-error-group', 'src' => $path)); $this->elementEnd('div'); } else { $butGenerate = new Notesgroupsform($this, $group->id); $butGenerate->show(); } $this->elementEnd('li'); } $this->elementEnd('ul'); } } }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('all', array('nickname' => $user->nickname))); return; } $noticeid = $this->trimmed('notice'); $notice = Notice::staticGet($noticeid); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $gradevalue = $this->trimmed('value'); $nickname = $user->nickname; $exist = Grades::getNoticeGrade($noticeid, $nickname); if ($exist != '?') { Grades::updateNotice(array('noticeid' => $noticeid, 'grade' => $gradevalue, 'userid' => $nickname)); } else { Grades::register(array('userid' => $nickname, 'noticeid' => $noticeid, 'grade' => $gradevalue)); } if ($this->boolean('ajax')) { $this->startHTML('application/xml,text/xml;charset=utf-8'); $this->elementStart('head'); $this->element('title', null, _('Disfavor favorite')); $this->elementEnd('head'); $this->elementStart('body'); $this->element('p'); $this->elementEnd('body'); $this->elementEnd('html'); } }
* @author Alvaro Ortego <*****@*****.**> * */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'n'; $longoptions = array('noticeid='); $helptext = <<<END_OF_REGISTERUSER_HELP grade.php [options] read grades associated to a notice -n --noticeid id of the notice to grade END_OF_REGISTERUSER_HELP; require_once INSTALLDIR . '/scripts/commandline.inc'; require_once INSTALLDIR . '/local/plugins/Grades/classes/Grades.php'; $noticeid = get_option_value('n', 'noticeid'); if (empty($noticeid)) { print "Must provide a notice id.\n"; exit(1); } try { $notice = Notice::staticGet('notice', $noticeid); if (empty($notice)) { throw new Exception("A notice with id '{$noticeid}' must exists."); } print 'Current grade is :' . Grades::getNoticeGrade($noticeid) . ' '; } catch (Exception $e) { print $e->getMessage() . "\n"; print $e->getTraceAsString(); exit(1); }
<div class="form-group"> <div class="col-md-8"> <label class="col-md-4 control-label" for= "subjdesc">Subject Description</label> <div class="col-md-8"> <input class="form-control input-sm" id="subjdesc" name="subjdesc" readonly placeholder= "Subject Description" type="text" value="<?php echo isset($cur) ? $cur->SUBJ_DESCRIPTION : 'Description'; ?> "> </div> </div> </div> <?php $grade = new Grades(); $cur = $grade->single_grades($gradeId); ?> <div class="form-group"> <div class="col-md-8"> <label class="col-md-4 control-label" for= "prelim">Prelim</label> <div class="col-md-8"> <input class="form-control input-sm" id="prelim" name="prelim" onkeyup="calculate()" type="text" value="<?php echo isset($cur) ? $cur->PRE : 'prelim'; ?> "> </div> </div> </div>
static function getNotaMediaYTotalofUserinGroup($userid, $groupid) { $grade = new Grades(); $qry = 'select avg(tmp.gradeAvg) as media, sum(tmp.gradeAvg) as total ' . 'from (select avg(g.grade) as gradeAvg ' . 'from grades g, group_inbox gr, notice n ' . 'where g.noticeid = gr.notice_id ' . 'and gr.group_id = ' . $groupid . ' and g.noticeid = n.id ' . 'and n.profile_id = ' . $userid . ' group by g.noticeid) as tmp'; $grade->query($qry); $notas = array(); if ($grade->fetch()) { $notas[$grade->total] = $grade->media; } $grade->free(); return $notas; }
function initTask($groupid, $tag, $status, $taskid) { $result = array(); if ($status == -1) { // Registramos la tarea en la tabla task_grader $id = Task_Grader::register(array('graderid' => $this->user->id, 'groupid' => $groupid, 'tag' => $tag)); $idsUsers = Grades::getMembersExcludeGradersAndAdmin($groupid); // Creamos una tarea asociada para cada alumno del grupo. if (count($idsUsers) > 0) { Task::register(array('id' => $id, 'idsUsers' => $idsUsers)); } $result[0] = 1; $result[1] = $id; } else { Task_Grader::updateTask($taskid, $tag); Task::reopenTask($taskid); $result[0] = 1; $result[1] = $taskid; } if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title. $this->element('title', null, _m('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); $form = new InitForm($this, $groupid, $result); $form->show(); $this->elementEnd('body'); $this->elementEnd('html'); } }
/** * Finds the Grades model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Grades the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Grades::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
function doDelsubj() { $bureauId = $_GET['bureauId']; $cid = $_GET['cid']; $sy = $_GET['sy']; @($id = $_POST['selector']); $key = count($id); if (!$id == '') { //multi delete using checkbox as a selector for ($i = 0; $i < $key; $i++) { //echo $id[$i]; $studSubjects = new Grades(); $studSubjects->delete($id[$i]); } message("bureau subject(s) already Deleted!", "info"); redirect('index.php?view=subject&bureauId=' . $bureauId . '&cid=' . $cid . '&sy=' . $sy . ''); } else { message("Select your subject(s) first, if you want to delete it!", "error"); redirect('index.php?view=subject&bureauId=' . $bureauId . '&cid=' . $cid . '&sy=' . $sy . ''); } }
Create a grade in the name of a user for a notice -u --user nickname of the user who creates the notice -n --noticeid id of the notice to grade -g --grade grade assigned to the notice END_OF_REGISTERUSER_HELP; require_once INSTALLDIR . '/scripts/commandline.inc'; require_once INSTALLDIR . '/local/plugins/Grades/classes/Grades.php'; $nickname = get_option_value('u', 'user'); $noticeid = get_option_value('n', 'noticeid'); $gradeval = get_option_value('g', 'grade'); if (empty($nickname) || empty($noticeid) || empty($gradeval)) { print "Must provide a username, a notice id, and a grade.\n"; exit(1); } try { $user = User::staticGet('nickname', $nickname); if (empty($user)) { throw new Exception("A user named '{$nickname}' must exists."); } $notice = Notice::staticGet('notice', $noticeid); if (empty($notice)) { throw new Exception("A notice with id '{$noticeid}' must exists."); } $grade = Grades::register(array('userid' => $nickname, 'noticeid' => $noticeid, 'grade' => $gradeval)); } catch (Exception $e) { print $e->getMessage() . "\n"; print $e->getTraceAsString(); exit(1); }
?> <h2>It should create a valid Grades object when all input is provided</h2> <?php $validTest = array('listFile' => 'c:\\xampp\\htdocs\\classList.csv'); $s1 = new Grades($validTest); echo "The object is: {$s1}<br>"; $test1 = is_object($s1) ? '' : 'Failed:It should create a valid object when valid input is provided<br>'; echo $test1; $test2 = empty($s1->getErrors()) ? '' : 'Failed:It not have errors when valid input is provided<br>'; echo $test2; ?> <h2>It should extract the parameters that went in</h2> <?php $props = $s1->getParameters(); print_r($props); ?> <h2>It should have an error when the class list file doesn't exist</h2> <?php $invalidTest = array('listFile' => 'c:\\xampp\\htdocs\\classListNone.csv'); $s1 = new Grades($invalidTest); $test2 = empty($s1->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>'; echo $test2; echo "The error for listFile is: " . $s1->getError('listFile') . "<br>"; echo "The object is: {$s1}<br>"; ?> </body> </html>
function showReportGrader() { $groupsUser = $this->user->getGroups()->fetchAll(); if (empty($groupsUser)) { $this->element('p', null, 'Todavía no perteneces a ningún grupo.'); } foreach ($groupsUser as $group) { $gradespergroup = Grades::getGradedNoticesAndUsersWithinGroup($group->id); $nicksMembers = Grades::getMembersNicksExcludeGradersAndAdmin($group->id); foreach ($nicksMembers as $nick) { if (!array_key_exists($nick, $gradespergroup)) { $gradespergroup[$nick] = '0'; } } $this->elementStart('div', array('id' => 'grade-report-group-' . $group->id, 'class' => 'div-group-report')); $this->elementStart('h3', array('class' => 'grade-report-group', 'title' => $group->getBestName())); $this->element('a', array('class' => 'grade-report-group-link', 'href' => common_root_url() . 'group/' . $group->nickname), $group->getBestName()); $this->elementEnd('h3'); $this->element('a', array('class' => 'grade-show-report', 'href' => 'javascript:mostrarReport(' . $group->id . ');'), 'Expandir'); $this->element('a', array('class' => 'grade-export-report', 'href' => common_local_url('gradeoptionscsv') . '?group=' . $group->id), 'Exportar CSV'); $this->element('p', array('class' => 'grade-reports-group-underline'), ''); $this->elementStart('div', array('class' => 'report-group-hidden')); if (empty($gradespergroup)) { $this->element('p', null, 'Todavía no hay puntuaciones.'); } else { $this->elementStart('ol', array('class' => 'grade-report-groupmembers')); foreach ($gradespergroup as $alumno => $puntuacion) { $this->elementStart('li', array('class' => 'grade-report-groupmembers-item')); $profile = Profile::staticGet('nickname', $alumno); $avatar = $profile->getAvatar(AVATAR_MINI_SIZE); if ($avatar) { $avatar = $avatar->displayUrl(); } else { $avatar = Avatar::defaultImage(AVATAR_MINI_SIZE); } $this->element('img', array('src' => $avatar)); $this->elementStart('a', array('class' => 'user-link-report', 'href' => common_local_url('gradeshowuser', array('nickgroup' => $group->nickname, 'nickname' => $profile->nickname)))); $this->raw($profile->getBestName() . ', ' . number_format($puntuacion, 2)); $this->elementEnd('a'); $this->elementEnd('li'); } $this->elementEnd('ol'); } $this->elementEnd('div'); $this->elementEnd('div'); } }
function generarEstadisticas($ids) { $this->numeroTweetsPuntuados = count($ids); $this->numeroTweets = Grades::getNumberTweetsOfUserInGroup($this->alumno->id, $this->group->id); $notas = Grades::getNotaMediaYTotalofUserinGroup($this->alumno->id, $this->group->id); $this->notaMedia = number_format(reset($notas), 2); $this->notaTotal = number_format(key($notas), 2); if (empty($this->notaTotal)) { $this->notaTotal = number_format(0, 2); } }
function onEndShowNoticeItem($args) { $user = common_current_user(); if (!empty($user)) { if ($user->hasRole('grader')) { // Si la noticia NO es de un profesor, entonces se puede puntuar. if (!$args->notice->getProfile()->getUser()->hasRole('grader')) { $noticeid = $args->notice->id; $nickname = $user->nickname; $userid = $user->id; // Si puede puntuar (porque es grader en el grupo del tweet) if (Grades::getValidGrader($noticeid, $userid)) { $gradevalue = Grades::getNoticeGrade($noticeid, $nickname); if ($gradevalue == '?') { $args->out->elementStart('div', array('class' => 'notice-grades')); } else { if ($gradevalue != '?') { $args->out->elementStart('div', array('id' => 'div-grades-hidden-' . $noticeid, 'class' => 'notice-grades-hidden')); } } $this->showNumbers($args, 0); $this->showNumbers($args, 1); $this->showNumbers($args, 2); $this->showNumbers($args, 3); $args->out->elementEnd('div'); } } } } return true; }