Commit 11f56886 authored by Alexis Lebis's avatar Alexis Lebis

Started course def

parent 1265d8f1
......@@ -6,6 +6,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
ADD_EXECUTABLE(ceao main.cpp)
ADD_EXECUTABLE(ceao_competency ceao_competency.cpp)
ADD_EXECUTABLE(ceao_course ceao_course.cpp)
ADD_EXECUTABLE(tryInit tryInit.cpp)
ADD_EXECUTABLE(tryMutation tryMutation.cpp)
......@@ -14,6 +15,7 @@ ADD_EXECUTABLE(tryEval tryEval.cpp)
ADD_DEPENDENCIES(ceao lQueen lModel)
ADD_DEPENDENCIES(ceao_competency lQueen lModel)
ADD_DEPENDENCIES(ceao_course lQueen lModel)
ADD_DEPENDENCIES(tryInit lQueen)
ADD_DEPENDENCIES(tryMutation lQueen)
......@@ -24,6 +26,7 @@ ADD_DEPENDENCIES(tryEval lQueen)
TARGET_LINK_LIBRARIES(ceao ${PARADISEO_LIBRARIES} lQueen lModel)
TARGET_LINK_LIBRARIES(ceao_competency ${PARADISEO_LIBRARIES} lQueen lModel)
TARGET_LINK_LIBRARIES(ceao_course ${PARADISEO_LIBRARIES} lQueen lModel)
TARGET_LINK_LIBRARIES(tryInit ${PARADISEO_LIBRARIES} lQueen)
TARGET_LINK_LIBRARIES(tryMutation ${PARADISEO_LIBRARIES} lQueen)
......
#include <eo>
#include <iostream>
#include <string>
#include "model/course.h"
int main(int argc, char* argv[])
{
Course c = Course::build();
std::cout << c << std::endl;
std::cout << "Length of prereq: " << c.prerequisites().size() << std::endl;
c = Course::build();
std::cout << c << std::endl;
std::cout << "Length of prereq: " << c.prerequisites().size() << std::endl;
c = Course::build(5);
std::cout << c << std::endl;
c = Course::build(7,"Testdel'oeuf");
std::cout << c << std::endl;
c = Course::build(-1, "lol");
std::cout << c << std::endl;
return EXIT_SUCCESS;
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
SET (EXERCICE_SOURCES
magnitude.cpp
competency.cpp
course.cpp
)
ADD_LIBRARY(lModel STATIC ${EXERCICE_SOURCES})
......
#include <iostream>
#include <utility>
#include "course.h"
#include "competency.h"
#include "exception/courseECTSException.h"
int Course::COURSE_COUNTER = 0;
// === FACTORY
Course Course::build(int ects, std::string name)
{
int id = Course::assignID();
if(name.empty())
name = "Course#"+std::to_string(id);
if(ects < 0)
throw CourseECTSException(new Course(id, ects, name));
else
return Course(id, ects, name);
}
// === END FACTORY
// === CONSTRUCTOR
Course::Course(int id, int ects, std::string name)
: _id(id), _ects(ects), _name(name)
{}
// === END CONSTRUCTOR
// === GETTER
//cf. course.h
// === END GETTER
// === MUTATOR
// SETTER
void Course::setECTS(int ects)
{
this->_ects = ects;
if(this->_ects < 0)
throw CourseECTSException(this);
}
void Course::setName(std::string name)
{
if(name.empty())
name = "Course#"+std::to_string(this->_id);
this->_name = name;
}
void Course::setAvailabilities(std::vector<int> times)
{}
void Course::setPrerequisites(std::vector<Competency> prereqs)
{}
void Course::setTeachedComps(std::vector<std::pair<Competency,double>> wComps)
{}
// ADDER
void Course::addTeachedComp(std::pair<Competency,double> wComp)
{}
void Course::addPrerequisite(Competency prereq)
{}
void Course::addTemporalFrame(int time)
{}
// DELETER
Competency * Course::rmPrerequisite(Competency prereq)
{return NULL;}
std::pair<Competency,double> * Course::rmTeachedComp(Competency teached)
{return NULL;}
int * Course::rmTemporalFrameIndex(int index)
{
return NULL;
}
int * Course::rmTemporalFrameValue(int value)
{
return NULL;
}
// === END MUTATOR
// === OPERATOR
std::ostream& operator<<(std::ostream& Stream, const Course & c)
{
std::string s = "Competency\n\tid:"+std::to_string(c.id())+"\n\tname:"+c.name()+"\n\tECTS: "+std::to_string(c.ects());
Stream << s;
return Stream;
}
// === END OPERATOR
// === STATIC
/// Course counter
int Course::assignID()
{
return ++Course::COURSE_COUNTER;
}
// === END STATIC
\ No newline at end of file
......@@ -2,6 +2,7 @@
#define SRC_COURSE_H_
#include <vector>
#include <utility>
#include "competency.h"
......@@ -11,28 +12,78 @@
* Based on a non exhaustive WiP standard from APACHES project. It includes several element of a french course teached in universities.
* This representation is subject to change.
*
* @param diffusionWeight The weight each {@link teached} competencies are transfered to the student (presumably from a teacher).
* @author alexis.lebis
* @version 1
*/
class Course
{
private:
// Competencies related
std::vector<Competency> prerequisites;
std::vector<Competency> teached;
std::vector<double> diffusionWeight;
// === COMPETENCIES RELATED
// Other
int ects;
std::vector<int> temporalAvailability;
std::vector<Competency> _prerequisites;
/** weightTeached represents how a compentency i is teached. This means that a competency i is transfered to a student with a weight w (a double). A course has a vector of competency, each one with a specific weight.
*/
std::vector<std::pair<Competency,double>> _weightedTeached;
// std::vector<Competency> teached;
// std::vector<double> diffusionWeight;
// === OTHER
/// European Credit Transfer and Accumulation System
int _ects;
/** Timeframe availablity of a course.
* @note For now, it discretiez time into semester
* @version 1.0
*/
std::vector<int> _temporalAvailability;
std::string _name;
int _id;
// Static
static int COURSE_COUNTER;
static int assignID();
// Constructor
//Course();
Course(int id, int ects, std::string name);
public:
Course();
static Course build(int ects = 0, std::string name = "");
// === GETTER
const int id() const{return this->_id;};
const std::string name() const{return this->_name;};
const int ects() const{return this->_ects;}
const std::vector<Competency> prerequisites() const {return this->_prerequisites;}
// === MUTATOR
// SETTER
void setECTS(int ects);
void setName(std::string);
void setAvailabilities(std::vector<int>);
void setPrerequisites(std::vector<Competency>);
void setTeachedComps(std::vector<std::pair<Competency,double>>);
// ADDER
void addTeachedComp(std::pair<Competency,double>);
void addPrerequisite(Competency);
void addTemporalFrame(int);
// DELETER
/// rmPrerequisite return a pointer to the removed competency from the _prerequisite, or NULL if not found.
Competency * rmPrerequisite(Competency);
/// rmTeachedComp removes the given Competency. It returns a pointer to the std::pair<Competency,double> removed in _weightedTeached, or NULL.
std::pair<Competency,double> * rmTeachedComp(Competency);
/// rmTemporalFrame removes the temporal frame stored at the index. It returns the value or NULL;
int* rmTemporalFrameIndex(int index);
int* rmTemporalFrameValue(int value);
// === FUNC
void fixECTS();
};
// === OPERATOR
std::ostream & operator<<(std::ostream& Stream, const Course & c);
......
#ifndef SRC_MODEL_EXCEPTION_COURSE_ECTS_EXCEPTION_H_
#define SRC_MODEL_EXCEPTION_COURSE_ECTS_EXCEPTION_H_
#include <exception>
#include <iostream>
#include <string>
#include "../course.h"
class CourseECTSException : public std::exception
{
private:
Course * _course;
std::string _phrase;
public:
CourseECTSException(Course * c) throw()
: _course(c)
{
this->_phrase = "Exception on ECTS: value ("+std::to_string(c->ects())+") uncorrect. Can it be negative?";
}
virtual const char* what() const throw()
{return _phrase.c_str();}
virtual ~CourseECTSException() throw()
{
//this->_course must not be free by ~this!
}
};
#endif // SRC_MODEL_EXCEPTION_COURSE_ECTS_EXCEPTION_H_
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment