Commit 58e7cab9 authored by Alexis Lebis's avatar Alexis Lebis

csdvp exported

parent a5aed863
...@@ -125,6 +125,7 @@ int main(int argc, char* argv[]){ ...@@ -125,6 +125,7 @@ int main(int argc, char* argv[]){
CSDVP::generateProblem(pb, CSDVP::GenerationType::RANDOM, SEED); CSDVP::generateProblem(pb, CSDVP::GenerationType::RANDOM, SEED);
assert(pb.checkConfig()); assert(pb.checkConfig());
std::cout << pb.exportMe() << std::endl;
// std::cout << "CSDVP IS : \n" << pb << std::endl; // std::cout << "CSDVP IS : \n" << pb << std::endl;
// for(int i = 0; i < pb.coursesCatalogue().size(); i++) // for(int i = 0; i < pb.coursesCatalogue().size(); i++)
// std::cout << pb.coursesCatalogue().at(i) << std::endl; // std::cout << pb.coursesCatalogue().at(i) << std::endl;
......
...@@ -154,3 +154,10 @@ bool Competency::operator==(const Competency & c) const ...@@ -154,3 +154,10 @@ bool Competency::operator==(const Competency & c) const
{ {
return ( this->_id == c.id() || ( this->_name.compare(c.c_name()) == 0 ) ); return ( this->_id == c.id() || ( this->_name.compare(c.c_name()) == 0 ) );
} }
std::string Competency::exportMe() const
{
std::string res = "\"competency\":{\"name\":\""+this->_name+"\","+this->_m.exportMe()+"}";
return res;
}
\ No newline at end of file
...@@ -93,6 +93,8 @@ class Competency ...@@ -93,6 +93,8 @@ class Competency
/// A competency is equal to another iff their id are the same, or their name /// A competency is equal to another iff their id are the same, or their name
bool operator==(const Competency & c) const; bool operator==(const Competency & c) const;
// === EXPORT
std::string exportMe() const;
}; };
// === OPERATOR // === OPERATOR
std::ostream & operator<<(std::ostream& Stream, const Competency & c); std::ostream & operator<<(std::ostream& Stream, const Competency & c);
......
...@@ -288,6 +288,35 @@ bool Course::operator==(const Course & c) const ...@@ -288,6 +288,35 @@ bool Course::operator==(const Course & c) const
} }
// === END OPERATOR // === END OPERATOR
// === EXPORT
std::string Course::exportMe() const
{
std::string res = "\"course\":{\"name\":\""+this->_name+"\",\"ects\":"+std::to_string(this->_ects);
std::string tmp = "";
res +=",\"prerequisites\":[";
for(unsigned int i = 0; i < this->_prerequisites.size(); i++)
{
tmp = this->_prerequisites.at(i).exportMe();
res+="{"+tmp+"}";
if(i < this->_prerequisites.size()-1)
res+=",";
}
res += "]";
res +=",\"competencies\":[";
for(unsigned int i = 0; i < this->_weightedTeached.size();i++)
{
tmp = this->_weightedTeached.at(i).first.exportMe();
res+="{"+tmp+"}";
if(i < this->_weightedTeached.size()-1)
res+=",";
}
res+="]";
res += "}";
return res;
}
// === STATIC // === STATIC
/// Course counter /// Course counter
......
...@@ -116,6 +116,9 @@ class Course ...@@ -116,6 +116,9 @@ class Course
// === OPERATOR // === OPERATOR
/// A course is equal to another iff {(lazy_equality) || (full_equality) /// A course is equal to another iff {(lazy_equality) || (full_equality)
bool operator==(const Course & c) const; bool operator==(const Course & c) const;
// === EXPORT
std::string exportMe() const;
}; };
// === OPERATOR // === OPERATOR
......
...@@ -134,3 +134,11 @@ double Magnitude::rebase() ...@@ -134,3 +134,11 @@ double Magnitude::rebase()
} }
return this->_value; return this->_value;
} }
// EXPORT
std::string Magnitude::exportMe() const
{
std::string res = "\"magnitude\":{\"value\":"+std::to_string(this->_value)+"}";
return res;
}
\ No newline at end of file
#ifndef SRC_MAGNITUDE_H_ #ifndef SRC_MAGNITUDE_H_
#define SRC_MAGNITUDE_H_ #define SRC_MAGNITUDE_H_
#include <string>
/** Magnitude represents the mastery of a competency. /** Magnitude represents the mastery of a competency.
* *
* It should be used in accordance with a scale * It should be used in accordance with a scale
...@@ -34,6 +36,9 @@ class Magnitude ...@@ -34,6 +36,9 @@ class Magnitude
//SETTER //SETTER
bool set(double v); bool set(double v);
//EXPORT
std::string exportMe() const;
}; };
Magnitude operator+(const Magnitude & m1, const Magnitude & m2); Magnitude operator+(const Magnitude & m1, const Magnitude & m2);
......
...@@ -595,3 +595,51 @@ std::tuple<int, int, double, double> CSDVP::distributionStats() ...@@ -595,3 +595,51 @@ std::tuple<int, int, double, double> CSDVP::distributionStats()
return Stream; return Stream;
} }
// === END OPERATOR // === END OPERATOR
// === EXPORT
std::string CSDVP::exportMe() const
{
std::string res = "\"problem\":{";
res+="\"cfg_seed\":"+std::to_string(this->_seed)+",";
res+="\"cfg_nbCourses\":"+std::to_string(this->_quantityAvailableCourses)+",";
res+="\"cfg_nbCompetencies\":"+std::to_string(this->_quantityAvailableCompetencies)+",";
res+="\"cfg_minTimeFrame\":"+std::to_string(this->_minimalTimeFrame)+",";
res+="\"cfg_maxTimeFrame\":"+std::to_string(this->_maximalTimeFrame)+",";
res+="\"cfg_minECTS\":"+std::to_string(this->_minimalECTSValue)+",";
res+="\"cfg_maxECTS\":"+std::to_string(this->_maximalECTSValue)+",";
res+="\"cfg_minCoursesByTF\":"+std::to_string(this->_minimalCoursesByTimeFrame)+",";
res+="\"cfg_maxCoursesByTF\":"+std::to_string(this->_maximalCoursesByTimeFrame)+",";
res+="\"cfg_minCompByCourse\":"+std::to_string(this->_minimalCompetencyByCourse)+",";
res+="\"cfg_maxCompByCourse\":"+std::to_string(this->_maximalCompetencyByCourse)+",";
res+="\"cfg_minPrereqByCourse\":"+std::to_string(this->_minimalPrerequisiteByCourse)+",";
res+="\"cfg_maxPrereqByCourse\":"+std::to_string(this->_maximalPrerequisiteByCourse)+",";
res+="\"cfg_minMagnitude\":"+std::to_string(this->_minimalMagnitude.value())+",";
res+="\"cfg_maxMagnitude\":"+std::to_string(this->_maximalMagnitude.value())+",";
res+="\"cfg_pickedCourseByTF\":"+std::to_string(this->_pickedCoursesByTimeFrame)+",";
// res+="\"seed\":"+std::to_string(this->_seed)+",";
std::string tmp = "";
res += "\"coursesCatalogue\":[";
for(unsigned int i = 0 ; i < this->_availableCourses.size(); i++)
{
tmp = this->_availableCourses.at(i).exportMe();
res+="{"+tmp+"}";
if(i < this->_availableCourses.size()-1)
res+=",";
}
res += "],";
res += "\"competenciesCatalogue\":[";
for(unsigned int i = 0; i < this->_availableCompentecies.size(); i++)
{
tmp = this->_availableCompentecies.at(i).exportMe();
res+="{"+tmp+"}";
if(i < this->_availableCompentecies.size()-1)
res+=",";
}
res+= "]";
res += "}";
return res;
}
\ No newline at end of file
...@@ -203,6 +203,9 @@ class CSDVP ...@@ -203,6 +203,9 @@ class CSDVP
// === FUNC // === FUNC
/// Checks all configuration attributes. If they have been all set, then isConfig is set to true /// Checks all configuration attributes. If they have been all set, then isConfig is set to true
bool checkConfig(); bool checkConfig();
// === EXPORT
std::string exportMe() const;
}; };
std::ostream & operator<<(std::ostream & Stream, const CSDVP & c); std::ostream & operator<<(std::ostream & Stream, const CSDVP & c);
......
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