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.distribution = .equalSpacing // Ensures equal spacing between buttons
|
||||
tableRow.translatesAutoresizingMaskIntoConstraints = false
|
||||
tableRow.isLayoutMarginsRelativeArrangement = false
|
||||
tableLayout.addArrangedSubview(tableRow)
|
||||
}
|
||||
|
||||
let cardButton = UIButton(type: .system)
|
||||
|
||||
if let cardId = cardDict["card_id"] as? Int {
|
||||
cardButton.backgroundColor = UIColor.darkGray
|
||||
if let cardId = cardDict["card_id"] as? Int {
|
||||
cardButton.setTitle("\(cardId)", for: .normal)
|
||||
cardButton.tag = cardId
|
||||
} else if let cardId = cardDict["card_id"] as? String, let cardIdInt = Int(cardId) {
|
||||
cardButton.setTitle(cardId, for: .normal)
|
||||
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 {
|
||||
print("Could not cast card_id to Int for card: \(cardDict)")
|
||||
}
|
||||
|
||||
cardButton.setTitleColor(.white, for: .normal)
|
||||
cardButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 12)
|
||||
cardButton.backgroundColor = UIColor.darkGray
|
||||
cardButton.layer.cornerRadius = 15
|
||||
|
||||
tableRow.addArrangedSubview(cardButton)
|
||||
NSLayoutConstraint.activate([
|
||||
|
||||
cardButton.heightAnchor.constraint(equalToConstant: 30),
|
||||
cardButton.widthAnchor.constraint(equalToConstant: 30)
|
||||
])
|
||||
|
||||
|
||||
cardButton.layer.cornerRadius = 12
|
||||
cardButton.contentEdgeInsets = .zero
|
||||
NSLayoutConstraint.activate([
|
||||
cardButton.heightAnchor.constraint(equalToConstant: 24),
|
||||
cardButton.widthAnchor.constraint(equalToConstant: 24)
|
||||
])
|
||||
tableRow.addArrangedSubview(cardButton)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -630,7 +633,7 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
|||
func createCardsDesignTableLayout(context: UIView) -> UIStackView {
|
||||
let cardDesign = UIStackView()
|
||||
cardDesign.axis = .vertical
|
||||
cardDesign.spacing = 10
|
||||
cardDesign.spacing = 2
|
||||
cardDesign.alignment = .leading
|
||||
cardDesign.translatesAutoresizingMaskIntoConstraints = false
|
||||
context.addSubview(cardDesign)
|
||||
|
@ -686,6 +689,23 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
|||
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]]){
|
||||
|
||||
for marker in resultsArray {
|
||||
|
@ -701,10 +721,13 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
|||
self.cardResult.append(["answer": answer, "attendance": 1, "card_id": id])
|
||||
}
|
||||
}else if(CARD_SCANNING_TYPE == 1){
|
||||
if let index = self.cardResult.firstIndex(where: { $0["card_id"] as! Int == id }) {
|
||||
self.cardResult[index]["answer"] = answer
|
||||
} else {
|
||||
self.cardResult.append(["answer": answer, "attendance": 1, "card_id": id])
|
||||
let studentPresent = hasStudentPresent(cardlists: cardData as! [Any], key: "card_id", value: id)
|
||||
if(studentPresent){
|
||||
if let index = self.cardResult.firstIndex(where: { $0["card_id"] as! Int == id }) {
|
||||
self.cardResult[index]["answer"] = answer
|
||||
} else {
|
||||
self.cardResult.append(["answer": answer, "attendance": 1, "card_id": id])
|
||||
}
|
||||
}
|
||||
}else if(CARD_SCANNING_TYPE == 2){
|
||||
var serial = 0
|
||||
|
@ -764,7 +787,10 @@ class CameraView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
|
|||
|
||||
for markerId in markerIds {
|
||||
if let cardButton = self.viewWithTag(markerId) as? UIButton {
|
||||
cardButton.backgroundColor = .green
|
||||
|
||||
if cardButton.backgroundColor != UIColor.red {
|
||||
cardButton.backgroundColor = .green
|
||||
}
|
||||
}
|
||||
}
|
||||
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 AsyncStorage from "@react-native-async-storage/async-storage"
|
||||
|
||||
|
@ -42,8 +42,6 @@ class QuestionScreen extends React.Component<any, any>{
|
|||
if(casheAnswer && questionnaire_details){
|
||||
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[this.state.currentQuestion]?.id)
|
||||
if(answer){
|
||||
console.log('hi')
|
||||
console.log(answer)
|
||||
this.setState({ starCount: answer.answer })
|
||||
}
|
||||
}
|
||||
|
@ -139,14 +137,9 @@ class QuestionScreen extends React.Component<any, any>{
|
|||
questionsStarRating: [...prevState.questionsStarRating, newItem],
|
||||
}))
|
||||
}
|
||||
|
||||
if(questionsStarRating){
|
||||
const answer = questionsStarRating.find((item:any) => item.id === questionnaire_details[this.state.currentQuestion]?.id)
|
||||
if(answer){
|
||||
const answer = questionsStarRating.length > 0 && questionsStarRating.find((item:any) => item.id === questionnaire_details[this.state.currentQuestion]?.id)
|
||||
if(answer){
|
||||
this.setState({ starCount: answer.value })
|
||||
}else{
|
||||
this.setState({ starCount: 0 })
|
||||
}
|
||||
}else if(casheAnswer){
|
||||
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[this.state.currentQuestion]?.id)
|
||||
if(answer){
|
||||
|
@ -200,13 +193,10 @@ class QuestionScreen extends React.Component<any, any>{
|
|||
const { casheAnswer } = this.props
|
||||
const { currentQuestion, starCount,questionsStarRating } = this.state
|
||||
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)
|
||||
if(answer){
|
||||
this.setState({ starCount: answer.value })
|
||||
}else{
|
||||
this.setState({ starCount: 0 })
|
||||
}
|
||||
|
||||
const answer = questionsStarRating.length > 0 && questionsStarRating.find((item:any) => item.id === questionnaire_details[currentQuestionId]?.id)
|
||||
if(answer){
|
||||
this.setState({ starCount: answer.value })
|
||||
}
|
||||
else if(casheAnswer){
|
||||
const answer = casheAnswer.answer_data.find((item:any) => item.question_id === questionnaire_details[currentQuestionId]?.id)
|
||||
|
|
|
@ -346,6 +346,7 @@ class StudentProfile extends React.Component<any, 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" }]}>
|
||||
<Text style={[AppStyles.studentHeader, BaseStyles.marBottom10]}>{subjectItem?.subject_name}</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>}
|
||||
<ScrollView style={{ marginVertical: 12, marginHorizontal: 15 }}>
|
||||
<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
|
||||
validationSchema={perfomanceReportValidationSchema}
|
||||
enableReinitialize={true}
|
||||
|
|
|
@ -209,7 +209,7 @@ class MapClassUpdate extends React.Component<any, any>{
|
|||
</View>
|
||||
<View style={styles.btnItem}>
|
||||
<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>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
|
|
@ -262,7 +262,7 @@ class MapSubject extends React.Component<any, any>{
|
|||
</View>
|
||||
<View style={styles.btnItem}>
|
||||
<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>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
|
|
@ -278,7 +278,7 @@ class MapSubjectUpdate extends React.Component<any, any>{
|
|||
</TouchableOpacity>
|
||||
</View>
|
||||
<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}>
|
||||
<Text style={AppStyles.btnText} >Update</Text>
|
||||
</TouchableOpacity>
|
||||
|
|
|
@ -180,19 +180,17 @@ class TeacherInfo extends React.Component<any, any>{
|
|||
color: BaseColors.mainColor, alignSelf: 'center'
|
||||
}]}>{subjectItem?.subject_name} </Text>
|
||||
<Sepator />
|
||||
{subjectItem?.class_list && subjectItem?.class_list.map((classBasedTopic: any, classBasedIndex: any) => (
|
||||
<View key={classBasedIndex}>
|
||||
<Text style={[AppStyles.stdLabel, BaseStyles.marBottom10, { alignSelf: 'center' }]}>{classBasedTopic?.class_name} </Text>
|
||||
<View key={subjectIndex}>
|
||||
<Text style={[AppStyles.stdLabel, BaseStyles.marBottom10, { alignSelf: 'center' }]}>{subjectItem?.class_name} </Text>
|
||||
<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}
|
||||
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>
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
|
|
|
@ -556,6 +556,9 @@ export const AppStyles = StyleSheet.create({
|
|||
marginTop: 40,
|
||||
marginBottom: 10,
|
||||
},
|
||||
primaryDisabledButton: {
|
||||
backgroundColor: "#d3cffa",
|
||||
},
|
||||
primaryDisabledBtn: {
|
||||
width: "64%",
|
||||
backgroundColor: "#d3cffa",
|
||||
|
|
Loading…
Reference in New Issue