Merge pull request 'update-existing-code' (#3) from update-existing-code into development
Reviewed-on: WizdomWaves/TedQuMobileApp#3
This commit is contained in:
commit
2a1f8e3f01
|
@ -578,34 +578,37 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
||||||
tableRow.alignment = .center // Centers the buttons vertically
|
tableRow.alignment = .center // Centers the buttons vertically
|
||||||
tableRow.distribution = .equalSpacing // Ensures equal spacing between buttons
|
tableRow.distribution = .equalSpacing // Ensures equal spacing between buttons
|
||||||
tableRow.translatesAutoresizingMaskIntoConstraints = false
|
tableRow.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
tableRow.isLayoutMarginsRelativeArrangement = false
|
||||||
tableLayout.addArrangedSubview(tableRow)
|
tableLayout.addArrangedSubview(tableRow)
|
||||||
}
|
}
|
||||||
|
|
||||||
let cardButton = UIButton(type: .system)
|
let cardButton = UIButton(type: .system)
|
||||||
|
cardButton.backgroundColor = UIColor.darkGray
|
||||||
if let cardId = cardDict["card_id"] as? Int {
|
if let cardId = cardDict["card_id"] as? Int {
|
||||||
cardButton.setTitle("\(cardId)", for: .normal)
|
cardButton.setTitle("\(cardId)", for: .normal)
|
||||||
cardButton.tag = cardId
|
cardButton.tag = cardId
|
||||||
} else if let cardId = cardDict["card_id"] as? String, let cardIdInt = Int(cardId) {
|
} else if let cardId = cardDict["card_id"] as? String, let cardIdInt = Int(cardId) {
|
||||||
cardButton.setTitle(cardId, for: .normal)
|
cardButton.setTitle(cardId, for: .normal)
|
||||||
cardButton.tag = cardIdInt
|
cardButton.tag = cardIdInt
|
||||||
|
|
||||||
|
if let is_attendance_taken = self.classData?["is_attendance_taken"], is_attendance_taken as! Bool {
|
||||||
|
if let is_present = cardDict["is_present"] as? Bool, !is_present {
|
||||||
|
cardButton.backgroundColor = .red
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print("Could not cast card_id to Int for card: \(cardDict)")
|
print("Could not cast card_id to Int for card: \(cardDict)")
|
||||||
}
|
}
|
||||||
|
|
||||||
cardButton.setTitleColor(.white, for: .normal)
|
cardButton.setTitleColor(.white, for: .normal)
|
||||||
cardButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 12)
|
cardButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 12)
|
||||||
cardButton.backgroundColor = UIColor.darkGray
|
cardButton.layer.cornerRadius = 12
|
||||||
cardButton.layer.cornerRadius = 15
|
cardButton.contentEdgeInsets = .zero
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
tableRow.addArrangedSubview(cardButton)
|
cardButton.heightAnchor.constraint(equalToConstant: 24),
|
||||||
NSLayoutConstraint.activate([
|
cardButton.widthAnchor.constraint(equalToConstant: 24)
|
||||||
|
])
|
||||||
cardButton.heightAnchor.constraint(equalToConstant: 30),
|
tableRow.addArrangedSubview(cardButton)
|
||||||
cardButton.widthAnchor.constraint(equalToConstant: 30)
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +633,7 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
||||||
func createCardsDesignTableLayout(context: UIView) -> UIStackView {
|
func createCardsDesignTableLayout(context: UIView) -> UIStackView {
|
||||||
let cardDesign = UIStackView()
|
let cardDesign = UIStackView()
|
||||||
cardDesign.axis = .vertical
|
cardDesign.axis = .vertical
|
||||||
cardDesign.spacing = 10
|
cardDesign.spacing = 2
|
||||||
cardDesign.alignment = .leading
|
cardDesign.alignment = .leading
|
||||||
cardDesign.translatesAutoresizingMaskIntoConstraints = false
|
cardDesign.translatesAutoresizingMaskIntoConstraints = false
|
||||||
context.addSubview(cardDesign)
|
context.addSubview(cardDesign)
|
||||||
|
@ -686,6 +689,23 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hasStudentPresent(cardlists: [Any], key: String, value: Int) -> Bool {
|
||||||
|
|
||||||
|
if let is_attendance_taken = self.classData?["is_attendance_taken"], is_attendance_taken as! Bool {
|
||||||
|
for cardD in cardData {
|
||||||
|
guard let cardDict = cardD as? [String: Any] else { continue }
|
||||||
|
if let cardIdString = cardDict[key] as? String, let cardIdInt = Int(cardIdString) {
|
||||||
|
if cardIdInt == value {
|
||||||
|
if let is_present = cardDict["is_present"] as? Bool, !is_present {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
private func storeCardResult(_ resultsArray : [[String: Any]]){
|
private func storeCardResult(_ resultsArray : [[String: Any]]){
|
||||||
|
|
||||||
for marker in resultsArray {
|
for marker in resultsArray {
|
||||||
|
@ -701,10 +721,13 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
||||||
self.cardResult.append(["answer": answer, "attendance": 1, "card_id": id])
|
self.cardResult.append(["answer": answer, "attendance": 1, "card_id": id])
|
||||||
}
|
}
|
||||||
}else if(CARD_SCANNING_TYPE == 1){
|
}else if(CARD_SCANNING_TYPE == 1){
|
||||||
if let index = self.cardResult.firstIndex(where: { $0["card_id"] as! Int == id }) {
|
let studentPresent = hasStudentPresent(cardlists: cardData as! [Any], key: "card_id", value: id)
|
||||||
self.cardResult[index]["answer"] = answer
|
if(studentPresent){
|
||||||
} else {
|
if let index = self.cardResult.firstIndex(where: { $0["card_id"] as! Int == id }) {
|
||||||
self.cardResult.append(["answer": answer, "attendance": 1, "card_id": id])
|
self.cardResult[index]["answer"] = answer
|
||||||
|
} else {
|
||||||
|
self.cardResult.append(["answer": answer, "attendance": 1, "card_id": id])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else if(CARD_SCANNING_TYPE == 2){
|
}else if(CARD_SCANNING_TYPE == 2){
|
||||||
var serial = 0
|
var serial = 0
|
||||||
|
@ -764,7 +787,10 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
||||||
|
|
||||||
for markerId in markerIds {
|
for markerId in markerIds {
|
||||||
if let cardButton = self.viewWithTag(markerId) as? UIButton {
|
if let cardButton = self.viewWithTag(markerId) as? UIButton {
|
||||||
cardButton.backgroundColor = .green
|
|
||||||
|
if cardButton.backgroundColor != UIColor.red {
|
||||||
|
cardButton.backgroundColor = .green
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.storeCardResult(resultsArray)
|
self.storeCardResult(resultsArray)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState } from 'react'
|
import React from 'react'
|
||||||
import { View, Text, Button, Animated, StyleSheet, TouchableOpacity, ActivityIndicator } from 'react-native'
|
import { View, Text, Button, Animated, StyleSheet, TouchableOpacity, ActivityIndicator } from 'react-native'
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage"
|
import AsyncStorage from "@react-native-async-storage/async-storage"
|
||||||
|
|
||||||
|
@ -42,8 +42,6 @@ class QuestionScreen extends React.Component<any, any>{
|
||||||
if(casheAnswer && questionnaire_details){
|
if(casheAnswer && questionnaire_details){
|
||||||
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[this.state.currentQuestion]?.id)
|
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[this.state.currentQuestion]?.id)
|
||||||
if(answer){
|
if(answer){
|
||||||
console.log('hi')
|
|
||||||
console.log(answer)
|
|
||||||
this.setState({ starCount: answer.answer })
|
this.setState({ starCount: answer.answer })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,14 +137,9 @@ class QuestionScreen extends React.Component<any, any>{
|
||||||
questionsStarRating: [...prevState.questionsStarRating, newItem],
|
questionsStarRating: [...prevState.questionsStarRating, newItem],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
const answer = questionsStarRating.length > 0 && questionsStarRating.find((item:any) => item.id === questionnaire_details[this.state.currentQuestion]?.id)
|
||||||
if(questionsStarRating){
|
if(answer){
|
||||||
const answer = questionsStarRating.find((item:any) => item.id === questionnaire_details[this.state.currentQuestion]?.id)
|
|
||||||
if(answer){
|
|
||||||
this.setState({ starCount: answer.value })
|
this.setState({ starCount: answer.value })
|
||||||
}else{
|
|
||||||
this.setState({ starCount: 0 })
|
|
||||||
}
|
|
||||||
}else if(casheAnswer){
|
}else if(casheAnswer){
|
||||||
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[this.state.currentQuestion]?.id)
|
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[this.state.currentQuestion]?.id)
|
||||||
if(answer){
|
if(answer){
|
||||||
|
@ -200,13 +193,10 @@ class QuestionScreen extends React.Component<any, any>{
|
||||||
const { casheAnswer } = this.props
|
const { casheAnswer } = this.props
|
||||||
const { currentQuestion, starCount,questionsStarRating } = this.state
|
const { currentQuestion, starCount,questionsStarRating } = this.state
|
||||||
const { unique_id, class_id, student_id, questionnaire_details } = this.props.questionDetails
|
const { unique_id, class_id, student_id, questionnaire_details } = this.props.questionDetails
|
||||||
if(questionsStarRating){
|
|
||||||
const answer = questionsStarRating.find((item:any) => item.id === questionnaire_details[currentQuestionId]?.id)
|
const answer = questionsStarRating.length > 0 && questionsStarRating.find((item:any) => item.id === questionnaire_details[currentQuestionId]?.id)
|
||||||
if(answer){
|
if(answer){
|
||||||
this.setState({ starCount: answer.value })
|
this.setState({ starCount: answer.value })
|
||||||
}else{
|
|
||||||
this.setState({ starCount: 0 })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(casheAnswer){
|
else if(casheAnswer){
|
||||||
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[currentQuestionId]?.id)
|
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[currentQuestionId]?.id)
|
||||||
|
|
|
@ -345,7 +345,8 @@ class StudentProfile extends React.Component<any, any>{
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{studentPerfomanceInfo && studentPerfomanceInfo.map((subjectItem: any, subjectIndex: any) => (
|
{studentPerfomanceInfo && studentPerfomanceInfo.map((subjectItem: any, subjectIndex: any) => (
|
||||||
|
subjectItem.percentage && subjectItem.percentage.length > 0 &&
|
||||||
<View key={subjectIndex} style={[BaseStyles.padding10, AppStyles.diaryCard, BaseStyles.marTop5,{ flex: 1, flexDirection: "column", width: "100%", justifyContent: "center", alignContent: "center" }]}>
|
<View key={subjectIndex} style={[BaseStyles.padding10, AppStyles.diaryCard, BaseStyles.marTop5,{ flex: 1, flexDirection: "column", width: "100%", justifyContent: "center", alignContent: "center" }]}>
|
||||||
<Text style={[AppStyles.studentHeader, BaseStyles.marBottom10]}>{subjectItem?.subject_name}</Text>
|
<Text style={[AppStyles.studentHeader, BaseStyles.marBottom10]}>{subjectItem?.subject_name}</Text>
|
||||||
<Text style={[AppStyles.nameLabel, BaseStyles.marBottom10]}>No of Questions : {subjectItem?.total_count}</Text>
|
<Text style={[AppStyles.nameLabel, BaseStyles.marBottom10]}>No of Questions : {subjectItem?.total_count}</Text>
|
||||||
|
|
|
@ -198,7 +198,7 @@ class StudentReport extends React.Component<any, any>{
|
||||||
</View>}
|
</View>}
|
||||||
<ScrollView style={{ marginVertical: 12, marginHorizontal: 15 }}>
|
<ScrollView style={{ marginVertical: 12, marginHorizontal: 15 }}>
|
||||||
<View style={{ flex: 1, flexDirection: "column", }}>
|
<View style={{ flex: 1, flexDirection: "column", }}>
|
||||||
{this.props.studentsList.data && this.props.classes.data.status !== false &&
|
{this.props.studentsList.data && this.props.classes?.data?.status !== false &&
|
||||||
<Formik
|
<Formik
|
||||||
validationSchema={perfomanceReportValidationSchema}
|
validationSchema={perfomanceReportValidationSchema}
|
||||||
enableReinitialize={true}
|
enableReinitialize={true}
|
||||||
|
|
|
@ -209,7 +209,7 @@ class MapClassUpdate extends React.Component<any, any>{
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.btnItem}>
|
<View style={styles.btnItem}>
|
||||||
<TouchableOpacity disabled={!isValid || !dirty || this.props.loading}
|
<TouchableOpacity disabled={!isValid || !dirty || this.props.loading}
|
||||||
style={[AppStyles.primaryBtn, { alignSelf: 'center' }]} onPress={handleSubmit} activeOpacity={0.8}>
|
style={[AppStyles.primaryBtn, { alignSelf: 'center' }, (!isValid || !dirty || this.props.loading) && AppStyles.primaryDisabledButton]} onPress={handleSubmit} activeOpacity={0.8}>
|
||||||
<Text style={AppStyles.btnText} >Update</Text>
|
<Text style={AppStyles.btnText} >Update</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -262,7 +262,7 @@ class MapSubject extends React.Component<any, any>{
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.btnItem}>
|
<View style={styles.btnItem}>
|
||||||
<TouchableOpacity disabled={!isValid || !dirty || this.props.loading}
|
<TouchableOpacity disabled={!isValid || !dirty || this.props.loading}
|
||||||
style={[AppStyles.primaryBtn, { alignSelf: 'center' }]} onPress={handleSubmit} activeOpacity={0.8}>
|
style={[AppStyles.primaryBtn, { alignSelf: 'center' }, (!isValid || !dirty || this.props.loading) && AppStyles.primaryDisabledButton]} onPress={handleSubmit} activeOpacity={0.8}>
|
||||||
<Text style={AppStyles.btnText} >Add</Text>
|
<Text style={AppStyles.btnText} >Add</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -278,7 +278,7 @@ class MapSubjectUpdate extends React.Component<any, any>{
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.btnItem}>
|
<View style={styles.btnItem}>
|
||||||
<TouchableOpacity disabled={!isValid || this.props.loading} style={[AppStyles.primaryBtn, { alignSelf: 'center' }]}
|
<TouchableOpacity disabled={!isValid || this.props.loading} style={[AppStyles.primaryBtn, { alignSelf: 'center' }, (!isValid || this.props.loading) && AppStyles.primaryDisabledButton]}
|
||||||
onPress={handleSubmit} activeOpacity={0.8}>
|
onPress={handleSubmit} activeOpacity={0.8}>
|
||||||
<Text style={AppStyles.btnText} >Update</Text>
|
<Text style={AppStyles.btnText} >Update</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
|
@ -180,19 +180,17 @@ class TeacherInfo extends React.Component<any, any>{
|
||||||
color: BaseColors.mainColor, alignSelf: 'center'
|
color: BaseColors.mainColor, alignSelf: 'center'
|
||||||
}]}>{subjectItem?.subject_name} </Text>
|
}]}>{subjectItem?.subject_name} </Text>
|
||||||
<Sepator />
|
<Sepator />
|
||||||
{subjectItem?.class_list && subjectItem?.class_list.map((classBasedTopic: any, classBasedIndex: any) => (
|
<View key={subjectIndex}>
|
||||||
<View key={classBasedIndex}>
|
<Text style={[AppStyles.stdLabel, BaseStyles.marBottom10, { alignSelf: 'center' }]}>{subjectItem?.class_name} </Text>
|
||||||
<Text style={[AppStyles.stdLabel, BaseStyles.marBottom10, { alignSelf: 'center' }]}>{classBasedTopic?.class_name} </Text>
|
|
||||||
<View style={{ flex: 1, flexDirection: "row", width: '100%', flexWrap: "wrap", alignContent: 'center', justifyContent: 'center' }}>
|
<View style={{ flex: 1, flexDirection: "row", width: '100%', flexWrap: "wrap", alignContent: 'center', justifyContent: 'center' }}>
|
||||||
{classBasedTopic?.graph_data && classBasedTopic?.graph_data.map((topicItem: any, topicIndex: any) => (
|
{subjectItem?.graph_data && subjectItem?.graph_data.map((topicItem: any, topicIndex: any) => (
|
||||||
<TouchableOpacity key={topicIndex} style={[BaseStyles.marHorizontal5, BaseStyles.marVertical5]} activeOpacity={0.8}
|
<TouchableOpacity key={topicIndex} style={[BaseStyles.marHorizontal5, BaseStyles.marVertical5]} activeOpacity={0.8}
|
||||||
onPress={this.onTopicBasedResults.bind(this, topicItem, classBasedTopic)}>
|
onPress={this.onTopicBasedResults.bind(this, topicItem, subjectItem)}>
|
||||||
<Text style={[{ backgroundColor: topicItem?.color_code }, AppStyles.performanceTile,]}>{topicItem?.topics} {topicItem?.question_performance}%</Text>
|
<Text style={[{ backgroundColor: topicItem?.color_code }, AppStyles.performanceTile,]}>{topicItem?.topics} {topicItem?.question_performance}%</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
))}
|
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -556,6 +556,9 @@ export const AppStyles = StyleSheet.create({
|
||||||
marginTop: 40,
|
marginTop: 40,
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
},
|
},
|
||||||
|
primaryDisabledButton: {
|
||||||
|
backgroundColor: "#d3cffa",
|
||||||
|
},
|
||||||
primaryDisabledBtn: {
|
primaryDisabledBtn: {
|
||||||
width: "64%",
|
width: "64%",
|
||||||
backgroundColor: "#d3cffa",
|
backgroundColor: "#d3cffa",
|
||||||
|
|
Loading…
Reference in New Issue