Пример #1
0
void
TrackView::getTracks(std::vector<Track::id_type>& trackIds)
{
	LMS_LOG(UI, DEBUG) << "Getting all tracks...";

	Wt::Dbo::Transaction transaction(DboSession());
	Wt::Dbo::Query<Track::UIQueryResult> query = _queryModel.query();
	Wt::Dbo::collection<Track::UIQueryResult> results = query.limit(-1).offset(-1);

	for (auto it = results.begin(); it != results.end(); ++it)
	{
		Track::id_type id = it->get<0>();
		trackIds.push_back(id);
	}

	LMS_LOG(UI, DEBUG) << "Getting all tracks done! " << trackIds.size() << " tracks!";
}
Пример #2
0
Wt::Dbo::collection< Wt::Dbo::ptr<VirtualWorldInstance> > find_virtual_world_elements_request(boost::shared_ptr<AppSession>& app_session, Wt::Dbo::Session& dbo_session)
{
	Wt::Dbo::Transaction transaction(dbo_session);

	std::string last_instance_name = app_session->general_participation()->get_last_instance_name();
	Wt::Dbo::collection< Wt::Dbo::ptr<VirtualWorldInstance> > elements;
	if (!last_instance_name.empty())
	{
		elements = dbo_session.find<VirtualWorldInstance>()
								.where("virtual_world = ?").bind(app_session->virtual_world()->get_denomination())
								.where("denomination = ?").bind(last_instance_name);
	}
	if (elements.size() == 0)
	{
		// either no last instance name or this instance was not found -> find any instance
		elements = dbo_session.find<VirtualWorldInstance>()
								.where("virtual_world = ?").bind(app_session->virtual_world()->get_denomination());
	}
	transaction.commit();
	return elements;
}
Пример #3
0
void AlunoList::setTable(){

	Wt::Dbo::Transaction transaction(_dbSession);
	_table->clear();
	_table->setHeaderCount(1);
	_table->setStyleClass("table table-striped table-hover");
	_table->setWidth(500);

		Wt::Dbo::ptr<SiconfModel::Turma> turma = _disciplina->turma();

		Wt::Dbo::collection<Wt::Dbo::ptr<SiconfModel::Aluno>> alunos = turma->alunos();

		new Wt::WText("Nome", _table->elementAt(0,0));
		new Wt::WText("Frequencia", _table->elementAt(0,1));

		Wt::Dbo::collection<Wt::Dbo::ptr<SiconfModel::Avaliacao>> avaliacoes = _disciplina->avaliacoes();

		for(unsigned i = 1; i < (avaliacoes.size() + 1) ; i++){
			new Wt::WText("Av. " + std::to_string(i), _table->elementAt(0, _table->columnCount()));
		}

		new Wt::WText("Media", _table->elementAt(0, _table->columnCount()));

		for(auto aluno : alunos){
			int row = _table->rowCount();
			new Wt::WText(aluno->usuario()->nome(), _table->elementAt(row, 0));
			float presencas = 0.0;
			float total = 0.0;

			try{

				std::vector<Wt::Dbo::ptr<SiconfModel::Frequencia>> frequencias;

				total = _disciplina->aulas().size();

				Wt::Dbo::collection<Wt::Dbo::ptr<SiconfModel::Frequencia>> collFrequ = _dbSession.find<SiconfModel::Frequencia>("where frequencias_aluno_id = ?").bind(aluno.id());

				for(auto i : collFrequ){

					if(i->aula()->disciplina().id() == _disciplina.id()){
						if(i->presenca()){
							presencas +=1;
						}
					}
				}

				if(total > 0){
					for(auto i : frequencias){
						if(i->presenca()) presencas +=1;
					}
					presencas = ((presencas/total)* 100);
				}

			}catch(Wt::Dbo::Exception& e){
				std::cout << "AlunoList::setTable: " << e.what() << std::endl;
			}

			std::stringstream strPresencas;
			strPresencas << std::fixed << std::setprecision(1) << presencas;

			new Wt::WText(strPresencas.str() + " %", _table->elementAt(row, 1));
			unsigned col = 2;

			int qtdAvaliacoes = avaliacoes.size();
			float media = 0;

			for(auto avaliacao : avaliacoes){
				Wt::Dbo::ptr<SiconfModel::Nota> nota = _dbSession.find<SiconfModel::Nota>("where notas_avaliacao_id = ? and notas_aluno_id = ?").bind(avaliacao.id()).bind(aluno.id());
				if(nota){
					media+=nota->nota();
					std::stringstream strNotas;
					strNotas << std::fixed << std::setprecision(1) << nota->nota();
					Wt::WText* text = new Wt::WText(strNotas.str(), _table->elementAt(row, col));
					if(nota->nota() < 5){
						text->addStyleClass("text-red");
					}
				}
				col++;
			}


			if(qtdAvaliacoes == 0){
				media = 0;
			}else{
				media /= qtdAvaliacoes;
			}


			std::stringstream strMedia;
			strMedia << std::fixed << std::setprecision(1) << media;
			Wt::WText* text = new Wt::WText(strMedia.str(), _table->elementAt(row, _table->columnCount() -1));
			if(media < 5){
				text->addStyleClass("text-red");
			}
		}
}