Skip to content

Commit

Permalink
Merge pull request #161 from STEM-C/develop
Browse files Browse the repository at this point in the history
Added functionality to Content Creator views
  • Loading branch information
MeghaNagarmunoli authored Feb 1, 2021
2 parents b9f1010 + d50e7a3 commit 539efac
Show file tree
Hide file tree
Showing 14 changed files with 1,636 additions and 386 deletions.
1,298 changes: 1,200 additions & 98 deletions client/public/lib/arduino_compressed.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions client/src/Utils/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,16 @@ export const deleteLearningStandard = async (id) => (
})
);

export const createLearningStandard = async (description,name,number,unit) =>(
export const createLearningStandard = async (description,name,number,unit, teks) =>(
makeRequest({
method: POST,
path: `${server}/learning-standards`,
data: {
"expectations": description,
"name": name,
"number": number,
"unit": unit
"unit": unit,
"teks": teks
},
auth: true,
error: "Login failed."
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/Classroom/Roster/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function ListView(props) {
)
},
{
title: 'Edit',
title: 'Edit----',
dataIndex: 'edit',
key: 'edit',
width: '10%',
Expand Down
206 changes: 82 additions & 124 deletions client/src/views/ContentCreator/ContentCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { QuestionCircleOutlined } from '@ant-design/icons';
import DayEditor from './LearningStandardDayCreator/DayEditor'
import UnitCreator from './UnitCreator/UnitCreator';
import LearningStandardDayCreator from './LearningStandardCreator/LearningStandardCreator'
import {getLearningStandard, getLearningStandardAll,deleteLearningStandard, getGrades} from '../../Utils/requests'
import {getLearningStandard, getLearningStandardAll,deleteLearningStandard, getGrades, getUnits, getAllUnits} from '../../Utils/requests'
import ViewDayModal from './viewDayModal/viewDayModal';
import UnitEditor from './UnitEditor/UnitEditor'

Expand All @@ -16,32 +16,38 @@ const { TabPane } = Tabs;
export default function ContentCreator(props) {

const [dataSource, setDataSource] = useState([])
const [dataSourceGrade5, setDataSourceGrade5] = useState([])
const [dataSourceMap, setDataSourceMap] = useState([])
const [dataSourceGrade6, setDataSourceGrade6] = useState([])
const [dataSourceGrade5, setDataSourceGrade5] = useState([])
const [gradeMenu, setGradeMenu] = useState([])

useEffect(() => {
//console.log(getLearningStandardcount())
getGrades().then(res => {
if(res.data){
setGradeMenu(res.data)
console.log("this is the grade menu", gradeMenu)
// console.log("this is the grade menu", gradeMenu, res.data)
}else{
message.error(res.err)
}
})
axiosCallAll()
axiosCallgrade(4)
// axiosCallgrade(4)
}, [])



const columns = [
{
title: 'Name',
title: 'Learning Standard',
dataIndex: 'name',
key: 'name',
editable: true,
width: '22.5%',
align: 'left',
render: (_, key) => (
<DayEditor history={props.history} days = {getDays(key)} learningStandardId={key.id} learningStandardName={key.name} linkBtn={true}/>
)
},
{
title: 'Unit',
Expand All @@ -50,17 +56,20 @@ export default function ContentCreator(props) {
editable: true,
width: '22.5%',
align: 'left',
},
{
title: 'Edit',
dataIndex: 'edit',
key: 'edit',
width: '10%',
align: 'right',
render: (_, key) => (
<UnitEditor days={getDays(key)} learningStandard={key.edit} linkBtn={true}/>
<UnitEditor days={getDays(key)} learningStandard={key.id} linkBtn={true}/>
)
},
// {
// title: 'Edit',
// dataIndex: 'edit',
// key: 'edit',
// width: '10%',
// align: 'right',
// render: (_, key) => (
// <UnitEditor days={getDays(key)} learningStandard={key.edit} linkBtn={true}/>
// )
// },
{
title: 'Desciption',
dataIndex: 'description',
Expand All @@ -69,16 +78,16 @@ export default function ContentCreator(props) {
width: '22.5%',
align: 'left',
},
{
title: 'View',
dataIndex: 'view',
key: 'view',
width: '10%',
align: 'right',
render: (_, key) => (
<DayEditor history={props.history} days = {getDays(key)} learningStandard={key.edit} linkBtn={true}/>
)
},
// {
// title: 'View',
// dataIndex: 'view',
// key: 'view',
// width: '10%',
// align: 'right',
// render: (_, key) => (
// <DayEditor history={props.history} days = {getDays(key)} learningStandardId={key.edit} learningStandardName = {getLearningStandardName(key.edit)} linkBtn={true}/>
// )
// },
// {
// title: 'Edit',
// dataIndex: 'edit',
Expand Down Expand Up @@ -133,108 +142,71 @@ export default function ContentCreator(props) {
}

const getDays = (i) => {
//console.log(i.edit)
const day1 = []
//console.log(i)
const request = getLearningStandard(i.edit);
//console.log(request)
var j = 1;
//console.log(request)
// console.log(i)

const request = getLearningStandard(i.id);

request.then(function (result) {
//console.log(result)
//console.log(result.data.days)
result.data.days.forEach(el => {
day1.push({
id: el.id,
day: j,
template: el.template
})
j++;
//console.log(day1)
});
//console.log(day1)

day1.push(...result.data.days)

})
// console.log("Day ",day1)
return day1;
}



const axiosCallAll = async() =>{
const newArr=[]
const newMap={}
const allreq = getLearningStandardAll();
//console.log(allreq)
const allres1 = await allreq
console.log("all Learning Standards", allres1)
allres1.data.forEach(learningStand => {
getTempStandard(learningStand, newArr)
})

}

const axiosCallgrade = async(grade) =>{
setDataSource([])
const newArr=[]
const allreq = getLearningStandardAll();
//console.log(allreq)
const allres1 = await allreq
allres1.data.forEach(learningStand=>{
getTempStandardGrade(learningStand,newArr,grade)
})
}

const getTempStandardGrade = async(learningStand, newArr, grade)=>{

const request = getLearningStandard(learningStand.id);
const result = await request;
console.log(result,result.data.unit.grade ,grade)
if(result.data.unit.grade === grade){
const value = {
name: result.data.name,
unit: result.data.unit.name,
description: result.data.expectations.length > 5 ? result.data.expectations.substring(0,30) + "..." : result.data.expectations,
name: learningStand.name,
unit: learningStand.unit.name,
description: learningStand.expectations.length > 5 ? learningStand.expectations.substring(0, 30) + "..." : learningStand.expectations,
view: learningStand.id,
edit: learningStand.id,
id: learningStand.id,
delete: learningStand.id
}
newArr.push(value)
// console.log(newArr)
// console.log(value)
if(grade === 4){
setDataSourceGrade5(dataSourceGrade5.concat(newArr))
}
else{
setDataSourceGrade6(dataSourceGrade6.concat(newArr))
}
}

}

const getTempStandard = async(learningStand, newArr)=>{

const request = getLearningStandard(learningStand.id);
const result = await request;
console.log(result)

const value = {
name: result.data.name,
unit: result.data.unit.name,
description: result.data.expectations.length > 5 ? result.data.expectations.substring(0, 30) + "..." : result.data.expectations,
view: learningStand.id,
edit: learningStand.id,
delete: learningStand.id
}
newArr.push(value)
// console.log(newArr)
// console.log(value)
newMap[learningStand.unit.grade] = newMap[learningStand.unit.grade] || [];
newMap[learningStand.unit.grade].push(value);

})
setDataSource(dataSource.concat(newArr))

setDataSourceMap(newMap)
}


const addTodataSource = (val) => {
setDataSource(dataSource.concat(val));
}

const setTabs = (grade) => {

return (
<TabPane tab={grade.name} key={grade.name}>
<div id="page-header">
<h1>Learning Standards & Units:</h1>
</div>
<div id='table-container'>
<UnitCreator datasource={dataSource} changeDataSource={addTodataSource} gradeMenu={gradeMenu}></UnitCreator>
<LearningStandardDayCreator dataSource = {dataSourceMap[grade.id]} changeDataSource={addTodataSource}></LearningStandardDayCreator>
<Table columns={columns} dataSource={dataSourceMap[grade.id]} rowClassName="editable-row">
</Table>
</div>
</TabPane>
)
}

return (

<div className="container nav-padding">

<Navbar isContentCreator={true}/>
Expand All @@ -249,40 +221,26 @@ export default function ContentCreator(props) {
<Tabs>
<TabPane tab="Home" key="home">
<div id="page-header">
<h1>Units & Learning Standards:</h1>
<h1>Learning Standards & Units:</h1>
</div>
<div id='table-container'>
<UnitCreator datasource={dataSource} changeDataSource={addTodataSource} gradeMenu={gradeMenu}></UnitCreator>
<LearningStandardDayCreator dataSource = {dataSource} changeDataSource={addTodataSource}></LearningStandardDayCreator>
<LearningStandardDayCreator dataSource = {dataSource} changeDataSource={addTodataSource} ></LearningStandardDayCreator>
<Table columns={columns} dataSource={dataSource} rowClassName="editable-row">
</Table>
</div>
</TabPane>
<TabPane tab="5th" key="5th">
<div id="page-header">
<h1>Units & Learning Standards:</h1>
</div>
<div id='table-container'>
<UnitCreator datasource={dataSource} changeDataSource={addTodataSource} gradeMenu={gradeMenu}></UnitCreator>
<LearningStandardDayCreator dataSource = {dataSourceGrade5} changeDataSource={addTodataSource}></LearningStandardDayCreator>
<Table columns={columns} dataSource={dataSourceGrade5} rowClassName="editable-row">
</Table>
</div>
</TabPane>
<TabPane tab="6th" key="6th">
<div id="page-header">
<h1>Units & Learning Standards:</h1>
</div>
<div id='table-container'>
<UnitCreator datasource={dataSource} changeDataSource={addTodataSource} gradeMenu={gradeMenu}></UnitCreator>
<LearningStandardDayCreator dataSource = {dataSourceGrade6} changeDataSource={addTodataSource}></LearningStandardDayCreator>
<Table columns={columns} dataSource={dataSourceGrade6} rowClassName="editable-row">
</Table>
</div>
</div>
</TabPane>
</Tabs>


{
gradeMenu.map(grade => {
// console.log("logging grades", grade)
return setTabs(grade)

})
}


</Tabs>
</div>
)

Expand Down
Loading

0 comments on commit 539efac

Please sign in to comment.